use of com.nukkitx.protocol.bedrock.data.inventory.CraftingData in project Protocol by CloudburstMC.
the class CraftingDataSerializer_v361 method readShapelessRecipe.
@Override
protected CraftingData readShapelessRecipe(ByteBuf buffer, BedrockPacketHelper helper, CraftingDataType type, BedrockSession session) {
String recipeId = helper.readString(buffer);
List<ItemData> inputs = new ObjectArrayList<>();
helper.readArray(buffer, inputs, this::readIngredient);
List<ItemData> outputs = new ObjectArrayList<>();
helper.readArray(buffer, outputs, buf -> helper.readItem(buf, session));
UUID uuid = helper.readUuid(buffer);
String craftingTag = helper.readString(buffer);
int priority = VarInts.readInt(buffer);
return new CraftingData(type, recipeId, -1, -1, -1, -1, inputs, outputs, uuid, craftingTag, priority);
}
use of com.nukkitx.protocol.bedrock.data.inventory.CraftingData in project Protocol by CloudburstMC.
the class CraftingDataSerializer_v291 method readShapelessRecipe.
protected CraftingData readShapelessRecipe(ByteBuf buffer, BedrockPacketHelper helper, CraftingDataType type, BedrockSession session) {
List<ItemData> inputs = new ObjectArrayList<>();
helper.readArray(buffer, inputs, buf -> helper.readItem(buf, session));
List<ItemData> outputs = new ObjectArrayList<>();
helper.readArray(buffer, outputs, buf -> helper.readItem(buf, session));
UUID uuid = helper.readUuid(buffer);
return new CraftingData(type, -1, -1, -1, -1, inputs, outputs, uuid, null);
}
use of com.nukkitx.protocol.bedrock.data.inventory.CraftingData in project Protocol by CloudburstMC.
the class CraftingDataSerializer_v291 method readShapedRecipe.
protected CraftingData readShapedRecipe(ByteBuf buffer, BedrockPacketHelper helper, CraftingDataType type, BedrockSession session) {
int width = VarInts.readInt(buffer);
int height = VarInts.readInt(buffer);
int inputCount = width * height;
List<ItemData> inputs = new ObjectArrayList<>(inputCount);
for (int i = 0; i < inputCount; i++) {
inputs.add(helper.readItem(buffer, session));
}
List<ItemData> outputs = new ObjectArrayList<>();
helper.readArray(buffer, outputs, buf -> helper.readItem(buf, session));
UUID uuid = helper.readUuid(buffer);
return new CraftingData(type, width, height, -1, -1, inputs, outputs, uuid, null);
}
use of com.nukkitx.protocol.bedrock.data.inventory.CraftingData in project Protocol by CloudburstMC.
the class CraftingDataSerializer_v407 method readShapelessRecipe.
protected CraftingData readShapelessRecipe(ByteBuf buffer, BedrockPacketHelper helper, CraftingDataType type, BedrockSession session) {
String recipeId = helper.readString(buffer);
List<ItemData> inputs = new ObjectArrayList<>();
helper.readArray(buffer, inputs, helper::readRecipeIngredient);
List<ItemData> outputs = new ObjectArrayList<>();
helper.readArray(buffer, outputs, buf -> helper.readItemInstance(buf, session));
UUID uuid = helper.readUuid(buffer);
String craftingTag = helper.readString(buffer);
int priority = VarInts.readInt(buffer);
int networkId = VarInts.readUnsignedInt(buffer);
return new CraftingData(type, recipeId, -1, -1, -1, -1, inputs, outputs, uuid, craftingTag, priority, networkId);
}
use of com.nukkitx.protocol.bedrock.data.inventory.CraftingData in project JukeboxMC by LucGamesYT.
the class ShapedRecipe method doRegister.
@Override
public CraftingData doRegister(CraftingManager craftingManager, String recipeId) {
final List<ItemData> ingredients = new ArrayList<>();
for (String s : this.pattern) {
char[] chars = s.toCharArray();
for (char c : chars) {
ItemData ingredient = this.ingredients.get(c);
if (c == ' ') {
ingredients.add(new ItemAir().toNetwork());
continue;
}
if (ingredient == null) {
return null;
}
ingredients.add(ingredient);
}
}
return new CraftingData(CraftingDataType.SHAPED, recipeId, this.pattern[0].length(), this.pattern.length, -1, -1, ingredients, this.outputs, UUID.randomUUID(), "crafting_table", 1, 0xDEADBEEF);
}
Aggregations