use of cn.nukkit.inventory.PlayerEnderChestInventory in project Nukkit by Nukkit.
the class EntityHumanType method initEntity.
@Override
protected void initEntity() {
this.inventory = new PlayerInventory(this);
if (this.namedTag.contains("Inventory") && this.namedTag.get("Inventory") instanceof ListTag) {
ListTag<CompoundTag> inventoryList = this.namedTag.getList("Inventory", CompoundTag.class);
for (CompoundTag item : inventoryList.getAll()) {
int slot = item.getByte("Slot");
if (slot >= 0 && slot < 9) {
// hotbar
// Old hotbar saving stuff, remove it (useless now)
inventoryList.remove(item);
} else if (slot >= 100 && slot < 104) {
this.inventory.setItem(this.inventory.getSize() + slot - 100, NBTIO.getItemHelper(item));
} else {
this.inventory.setItem(slot - 9, NBTIO.getItemHelper(item));
}
}
}
this.enderChestInventory = new PlayerEnderChestInventory(this);
if (this.namedTag.contains("EnderItems") && this.namedTag.get("EnderItems") instanceof ListTag) {
ListTag<CompoundTag> inventoryList = this.namedTag.getList("EnderItems", CompoundTag.class);
for (CompoundTag item : inventoryList.getAll()) {
this.enderChestInventory.setItem(item.getByte("Slot"), NBTIO.getItemHelper(item));
}
}
super.initEntity();
}
Aggregations