diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/recipe/data/SmithingRecipeData.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/recipe/data/SmithingRecipeData.java new file mode 100644 index 00000000..56ddcff5 --- /dev/null +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/recipe/data/SmithingRecipeData.java @@ -0,0 +1,15 @@ +package com.github.steveice10.mc.protocol.data.game.recipe.data; + +import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack; +import com.github.steveice10.mc.protocol.data.game.recipe.Ingredient; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NonNull; + +@Data +@AllArgsConstructor +public class SmithingRecipeData implements RecipeData { + private final @NonNull Ingredient base; + private final @NonNull Ingredient addition; + private final @NonNull ItemStack result; +} diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/ServerDeclareRecipesPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/ServerDeclareRecipesPacket.java index b2463537..5b8141c4 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/ServerDeclareRecipesPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/ServerDeclareRecipesPacket.java @@ -6,11 +6,7 @@ import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack; import com.github.steveice10.mc.protocol.data.game.recipe.Ingredient; import com.github.steveice10.mc.protocol.data.game.recipe.Recipe; import com.github.steveice10.mc.protocol.data.game.recipe.RecipeType; -import com.github.steveice10.mc.protocol.data.game.recipe.data.CookedRecipeData; -import com.github.steveice10.mc.protocol.data.game.recipe.data.RecipeData; -import com.github.steveice10.mc.protocol.data.game.recipe.data.ShapedRecipeData; -import com.github.steveice10.mc.protocol.data.game.recipe.data.ShapelessRecipeData; -import com.github.steveice10.mc.protocol.data.game.recipe.data.StoneCuttingRecipeData; +import com.github.steveice10.mc.protocol.data.game.recipe.data.*; import com.github.steveice10.packetlib.io.NetInput; import com.github.steveice10.packetlib.io.NetOutput; import com.github.steveice10.packetlib.packet.Packet; @@ -85,6 +81,14 @@ public class ServerDeclareRecipesPacket implements Packet { data = new StoneCuttingRecipeData(group, ingredient, result); break; } + case SMITHING: { + Ingredient base = this.readIngredient(in); + Ingredient addition = this.readIngredient(in); + ItemStack result = ItemStack.read(in); + + data = new SmithingRecipeData(base, addition, result); + break; + } default: break; } @@ -158,6 +162,14 @@ public class ServerDeclareRecipesPacket implements Packet { ItemStack.write(out, data.getResult()); break; } + case SMITHING: { + SmithingRecipeData data = (SmithingRecipeData) recipe.getData(); + + this.writeIngredient(out, data.getBase()); + this.writeIngredient(out, data.getAddition()); + ItemStack.write(out, data.getResult()); + break; + } default: break; } diff --git a/src/test/java/com/github/steveice10/mc/protocol/packet/ingame/server/ServerDeclareRecipesTest.java b/src/test/java/com/github/steveice10/mc/protocol/packet/ingame/server/ServerDeclareRecipesTest.java index 47d0ff90..287a0263 100644 --- a/src/test/java/com/github/steveice10/mc/protocol/packet/ingame/server/ServerDeclareRecipesTest.java +++ b/src/test/java/com/github/steveice10/mc/protocol/packet/ingame/server/ServerDeclareRecipesTest.java @@ -4,10 +4,7 @@ import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack; import com.github.steveice10.mc.protocol.data.game.recipe.Ingredient; import com.github.steveice10.mc.protocol.data.game.recipe.Recipe; import com.github.steveice10.mc.protocol.data.game.recipe.RecipeType; -import com.github.steveice10.mc.protocol.data.game.recipe.data.CookedRecipeData; -import com.github.steveice10.mc.protocol.data.game.recipe.data.ShapedRecipeData; -import com.github.steveice10.mc.protocol.data.game.recipe.data.ShapelessRecipeData; -import com.github.steveice10.mc.protocol.data.game.recipe.data.StoneCuttingRecipeData; +import com.github.steveice10.mc.protocol.data.game.recipe.data.*; import com.github.steveice10.mc.protocol.packet.PacketTest; import org.junit.Before; @@ -84,6 +81,19 @@ public class ServerDeclareRecipesTest extends PacketTest { }), new ItemStack(40) ) + ), + new Recipe( + RecipeType.SMITHING, + "Recipe5", + new SmithingRecipeData( + new Ingredient(new ItemStack[] { + new ItemStack(10) + }), + new Ingredient(new ItemStack[] { + new ItemStack(11) + }), + new ItemStack(12) + ) ) } )