public Inventory(int id, BlockEntity blockEntity, short inventorySize, NbtList slots) { Id = id; BlockEntity = blockEntity; Size = inventorySize; Coordinates = BlockEntity.Coordinates; Slots = new ItemStacks(); for (byte i = 0; i < Size; i++) { Slots.Add(new ItemStack()); } for (byte i = 0; i < slots.Count; i++) { NbtCompound item = (NbtCompound) slots[i]; Slots[item["Slot"].ByteValue] = new ItemStack(item["id"].ShortValue, item["Count"].ByteValue, item["Damage"].ByteValue); } }
public Inventory(int id, BlockEntity blockEntity, short inventorySize, NbtList slots) { Id = id; BlockEntity = blockEntity; Size = inventorySize; Coordinates = BlockEntity.Coordinates; Slots = new MetadataSlots(); for (byte i = 0; i < Size; i++) { if (i < slots.Count) { NbtCompound item = (NbtCompound)slots[i]; Slots[i] = new MetadataSlot(new ItemStack(item["id"].ShortValue, item["Count"].ByteValue)); } else { Slots[i] = new MetadataSlot(new ItemStack()); } } }