Search in sources :

Example 11 with ItemData

use of com.nukkitx.protocol.bedrock.data.inventory.ItemData in project JukeboxMC by LucGamesYT.

the class ContainerInventory method sendContents.

@Override
public void sendContents(Player player) {
    InventoryContentPacket inventoryContentPacket = new InventoryContentPacket();
    inventoryContentPacket.setContainerId(WindowId.OPEN_CONTAINER.getId());
    List<ItemData> itemDataList = new ArrayList<>();
    for (Item content : this.getContents()) {
        itemDataList.add(content.toNetwork());
    }
    inventoryContentPacket.setContents(itemDataList);
    player.sendPacket(inventoryContentPacket);
}
Also used : Item(org.jukeboxmc.item.Item) ArrayList(java.util.ArrayList) InventoryContentPacket(com.nukkitx.protocol.bedrock.packet.InventoryContentPacket) ItemData(com.nukkitx.protocol.bedrock.data.inventory.ItemData)

Example 12 with ItemData

use of com.nukkitx.protocol.bedrock.data.inventory.ItemData in project JukeboxMC by LucGamesYT.

the class ShapedRecipe method addOutput.

public ShapedRecipe addOutput(Item... items) {
    List<ItemData> itemDataList = new ArrayList<>();
    for (Item item : items) {
        itemDataList.add(item.toNetwork());
    }
    this.outputs.addAll(itemDataList);
    return this;
}
Also used : Item(org.jukeboxmc.item.Item) ObjectArrayList(it.unimi.dsi.fastutil.objects.ObjectArrayList) ArrayList(java.util.ArrayList) ItemData(com.nukkitx.protocol.bedrock.data.inventory.ItemData)

Example 13 with ItemData

use of com.nukkitx.protocol.bedrock.data.inventory.ItemData 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)

Example 14 with ItemData

use of com.nukkitx.protocol.bedrock.data.inventory.ItemData in project JukeboxMC by LucGamesYT.

the class ShapelessRecipe method addOutput.

public ShapelessRecipe addOutput(Item... items) {
    List<ItemData> itemDataList = new ArrayList<>();
    for (Item item : items) {
        itemDataList.add(item.toNetwork());
    }
    this.outputs.addAll(itemDataList);
    return this;
}
Also used : Item(org.jukeboxmc.item.Item) ObjectArrayList(it.unimi.dsi.fastutil.objects.ObjectArrayList) ArrayList(java.util.ArrayList) ItemData(com.nukkitx.protocol.bedrock.data.inventory.ItemData)

Example 15 with ItemData

use of com.nukkitx.protocol.bedrock.data.inventory.ItemData in project JukeboxMC by LucGamesYT.

the class ShapelessRecipe method addIngredient.

public ShapelessRecipe addIngredient(Item... items) {
    List<ItemData> itemDataList = new ArrayList<>();
    for (Item item : items) {
        itemDataList.add(item.toNetwork());
    }
    this.ingredients.addAll(itemDataList);
    return this;
}
Also used : Item(org.jukeboxmc.item.Item) ObjectArrayList(it.unimi.dsi.fastutil.objects.ObjectArrayList) ArrayList(java.util.ArrayList) ItemData(com.nukkitx.protocol.bedrock.data.inventory.ItemData)

Aggregations

ItemData (com.nukkitx.protocol.bedrock.data.inventory.ItemData)30 ObjectArrayList (it.unimi.dsi.fastutil.objects.ObjectArrayList)13 CraftingData (com.nukkitx.protocol.bedrock.data.inventory.CraftingData)9 UUID (java.util.UUID)8 NbtMap (com.nukkitx.nbt.NbtMap)6 InventoryContentPacket (com.nukkitx.protocol.bedrock.packet.InventoryContentPacket)6 ArrayList (java.util.ArrayList)6 Item (org.jukeboxmc.item.Item)4 NbtMapBuilder (com.nukkitx.nbt.NbtMapBuilder)3 ItemMapping (org.geysermc.geyser.registry.type.ItemMapping)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 ItemStack (com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack)2 Map (java.util.Map)2 TypeReference (com.fasterxml.jackson.core.type.TypeReference)1 Ingredient (com.github.steveice10.mc.protocol.data.game.recipe.Ingredient)1 ServerboundContainerButtonClickPacket (com.github.steveice10.mc.protocol.packet.ingame.serverbound.inventory.ServerboundContainerButtonClickPacket)1 ServerboundContainerClosePacket (com.github.steveice10.mc.protocol.packet.ingame.serverbound.inventory.ServerboundContainerClosePacket)1 CompoundTag (com.github.steveice10.opennbt.tag.builtin.CompoundTag)1 Vector3i (com.nukkitx.math.vector.Vector3i)1 EntityData (com.nukkitx.protocol.bedrock.data.entity.EntityData)1