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();
}
Aggregations