Search in sources :

Example 1 with ChestInventory

use of cn.nukkit.inventory.ChestInventory in project Nukkit by Nukkit.

the class BlockEntityChest method initBlockEntity.

@Override
protected void initBlockEntity() {
    this.inventory = new ChestInventory(this);
    if (!this.namedTag.contains("Items") || !(this.namedTag.get("Items") instanceof ListTag)) {
        this.namedTag.putList(new ListTag<CompoundTag>("Items"));
    }
    /* for (int i = 0; i < this.getSize(); i++) {
            this.inventory.setItem(i, this.getItem(i));
        } */
    ListTag<CompoundTag> list = (ListTag<CompoundTag>) this.namedTag.getList("Items");
    for (CompoundTag compound : list.getAll()) {
        Item item = NBTIO.getItemHelper(compound);
        this.inventory.slots.put(compound.getByte("Slot"), item);
    }
    super.initBlockEntity();
}
Also used : Item(cn.nukkit.item.Item) ChestInventory(cn.nukkit.inventory.ChestInventory) DoubleChestInventory(cn.nukkit.inventory.DoubleChestInventory) ListTag(cn.nukkit.nbt.tag.ListTag) CompoundTag(cn.nukkit.nbt.tag.CompoundTag)

Aggregations

ChestInventory (cn.nukkit.inventory.ChestInventory)1 DoubleChestInventory (cn.nukkit.inventory.DoubleChestInventory)1 Item (cn.nukkit.item.Item)1 CompoundTag (cn.nukkit.nbt.tag.CompoundTag)1 ListTag (cn.nukkit.nbt.tag.ListTag)1