mirror of
https://github.com/GeyserMC/MCProtocolLib.git
synced 2024-12-04 21:01:02 -05:00
Read smithing crafting data
This commit is contained in:
parent
48a42d3e58
commit
369120ac47
3 changed files with 46 additions and 9 deletions
|
@ -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;
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
)
|
||||
)
|
||||
}
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue