Search in sources :

Example 16 with NbtMapBuilder

use of com.nukkitx.nbt.NbtMapBuilder in project JukeboxMC by LucGamesYT.

the class BlockEntitySign method toCompound.

@Override
public NbtMapBuilder toCompound() {
    NbtMapBuilder compound = super.toCompound();
    compound.putString("Text", Joiner.on("\n").skipNulls().join(this.lines));
    return compound;
}
Also used : NbtMapBuilder(com.nukkitx.nbt.NbtMapBuilder)

Example 17 with NbtMapBuilder

use of com.nukkitx.nbt.NbtMapBuilder in project JukeboxMC by LucGamesYT.

the class BlockEntitySkull method toCompound.

@Override
public NbtMapBuilder toCompound() {
    NbtMapBuilder nbtMapBuilder = super.toCompound();
    nbtMapBuilder.putByte("SkullType", this.skullMeta);
    nbtMapBuilder.putByte("Rot", this.rotation);
    return nbtMapBuilder;
}
Also used : NbtMapBuilder(com.nukkitx.nbt.NbtMapBuilder)

Example 18 with NbtMapBuilder

use of com.nukkitx.nbt.NbtMapBuilder in project JukeboxMC by LucGamesYT.

the class BlockEntityShulkerBox method toCompound.

@Override
public NbtMapBuilder toCompound() {
    NbtMapBuilder builder = super.toCompound();
    List<NbtMap> itemsCompoundList = new ArrayList<>();
    for (int slot = 0; slot < this.shulkerBoxInventory.getSize(); slot++) {
        NbtMapBuilder itemCompound = NbtMap.builder();
        Item item = this.shulkerBoxInventory.getItem(slot);
        itemCompound.putByte("Slot", (byte) slot);
        this.fromItem(item, itemCompound);
        itemsCompoundList.add(itemCompound.build());
    }
    builder.putList("Items", NbtType.COMPOUND, itemsCompoundList);
    builder.putByte("facing", this.facing);
    builder.putBoolean("isUndyed", this.undyed);
    return builder;
}
Also used : Item(org.jukeboxmc.item.Item) NbtMap(com.nukkitx.nbt.NbtMap) ArrayList(java.util.ArrayList) NbtMapBuilder(com.nukkitx.nbt.NbtMapBuilder)

Example 19 with NbtMapBuilder

use of com.nukkitx.nbt.NbtMapBuilder in project JukeboxMC by LucGamesYT.

the class BlockEntityBanner method toCompound.

@Override
public NbtMapBuilder toCompound() {
    NbtMapBuilder compound = super.toCompound();
    compound.putInt("Base", this.baseColor);
    compound.putInt("Type", this.type);
    if (this.patterns.size() > 0) {
        List<NbtMap> pattern = new ArrayList<>();
        for (Map.Entry<String, Integer> entry : this.patterns.entrySet()) {
            NbtMapBuilder patternBuilder = NbtMap.builder();
            patternBuilder.putString("Pattern", entry.getKey());
            patternBuilder.putInt("Color", entry.getValue());
            pattern.add(patternBuilder.build());
        }
        compound.putList("Patterns", NbtType.COMPOUND, pattern);
    }
    return compound;
}
Also used : NbtMap(com.nukkitx.nbt.NbtMap) ArrayList(java.util.ArrayList) NbtMapBuilder(com.nukkitx.nbt.NbtMapBuilder) NbtMap(com.nukkitx.nbt.NbtMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 20 with NbtMapBuilder

use of com.nukkitx.nbt.NbtMapBuilder in project JukeboxMC by LucGamesYT.

the class BlockEntityBarrel method toCompound.

@Override
public NbtMapBuilder toCompound() {
    NbtMapBuilder builder = super.toCompound();
    List<NbtMap> itemsCompoundList = new ArrayList<>();
    for (int slot = 0; slot < this.barrelInventory.getSize(); slot++) {
        NbtMapBuilder itemCompound = NbtMap.builder();
        Item item = this.barrelInventory.getItem(slot);
        itemCompound.putByte("Slot", (byte) slot);
        this.fromItem(item, itemCompound);
        itemsCompoundList.add(itemCompound.build());
    }
    builder.putList("Items", NbtType.COMPOUND, itemsCompoundList);
    return builder;
}
Also used : Item(org.jukeboxmc.item.Item) NbtMap(com.nukkitx.nbt.NbtMap) ArrayList(java.util.ArrayList) NbtMapBuilder(com.nukkitx.nbt.NbtMapBuilder)

Aggregations

NbtMapBuilder (com.nukkitx.nbt.NbtMapBuilder)30 NbtMap (com.nukkitx.nbt.NbtMap)15 ArrayList (java.util.ArrayList)11 Item (org.jukeboxmc.item.Item)7 Vector3i (com.nukkitx.math.vector.Vector3i)3 ItemData (com.nukkitx.protocol.bedrock.data.inventory.ItemData)3 CompoundTag (com.github.steveice10.opennbt.tag.builtin.CompoundTag)2 BlockEntityDataPacket (com.nukkitx.protocol.bedrock.packet.BlockEntityDataPacket)2 LinkedHashMap (java.util.LinkedHashMap)2 Map (java.util.Map)2 Container (org.geysermc.geyser.inventory.Container)2 ItemMapping (org.geysermc.geyser.registry.type.ItemMapping)2 BlockEntityShulkerBox (org.jukeboxmc.blockentity.BlockEntityShulkerBox)2 ShulkerBoxInventory (org.jukeboxmc.inventory.ShulkerBoxInventory)2 ItemAir (org.jukeboxmc.item.ItemAir)2 TypeReference (com.fasterxml.jackson.core.type.TypeReference)1 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ItemStack (com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack)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