Search in sources :

Example 1 with CraftingData

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);
}
Also used : ObjectArrayList(it.unimi.dsi.fastutil.objects.ObjectArrayList) CraftingData(com.nukkitx.protocol.bedrock.data.inventory.CraftingData) UUID(java.util.UUID) ItemData(com.nukkitx.protocol.bedrock.data.inventory.ItemData)

Example 2 with CraftingData

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);
}
Also used : ObjectArrayList(it.unimi.dsi.fastutil.objects.ObjectArrayList) CraftingData(com.nukkitx.protocol.bedrock.data.inventory.CraftingData) UUID(java.util.UUID) ItemData(com.nukkitx.protocol.bedrock.data.inventory.ItemData)

Example 3 with CraftingData

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);
}
Also used : ObjectArrayList(it.unimi.dsi.fastutil.objects.ObjectArrayList) CraftingData(com.nukkitx.protocol.bedrock.data.inventory.CraftingData) UUID(java.util.UUID) ItemData(com.nukkitx.protocol.bedrock.data.inventory.ItemData)

Example 4 with CraftingData

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);
}
Also used : ObjectArrayList(it.unimi.dsi.fastutil.objects.ObjectArrayList) CraftingData(com.nukkitx.protocol.bedrock.data.inventory.CraftingData) UUID(java.util.UUID) ItemData(com.nukkitx.protocol.bedrock.data.inventory.ItemData)

Example 5 with CraftingData

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);
}
Also used : ObjectArrayList(it.unimi.dsi.fastutil.objects.ObjectArrayList) ArrayList(java.util.ArrayList) CraftingData(com.nukkitx.protocol.bedrock.data.inventory.CraftingData) ItemAir(org.jukeboxmc.item.ItemAir) ItemData(com.nukkitx.protocol.bedrock.data.inventory.ItemData)

Aggregations

CraftingData (com.nukkitx.protocol.bedrock.data.inventory.CraftingData)10 ItemData (com.nukkitx.protocol.bedrock.data.inventory.ItemData)10 ObjectArrayList (it.unimi.dsi.fastutil.objects.ObjectArrayList)10 UUID (java.util.UUID)8 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ItemStack (com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack)1 Ingredient (com.github.steveice10.mc.protocol.data.game.recipe.Ingredient)1 RecipeType (com.github.steveice10.mc.protocol.data.game.recipe.RecipeType)1 NbtMap (com.nukkitx.nbt.NbtMap)1 NbtUtils (com.nukkitx.nbt.NbtUtils)1 Int2ObjectMap (it.unimi.dsi.fastutil.ints.Int2ObjectMap)1 Int2ObjectOpenHashMap (it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 java.util (java.util)1 ArrayList (java.util.ArrayList)1 GeyserImpl (org.geysermc.geyser.GeyserImpl)1 GeyserRecipe (org.geysermc.geyser.inventory.recipe.GeyserRecipe)1 GeyserShapedRecipe (org.geysermc.geyser.inventory.recipe.GeyserShapedRecipe)1