From 9f36b42d30307639827fa1ce5e502f8f675a5866 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Fri, 17 Jun 2016 19:14:59 +0200 Subject: [PATCH] Made Reconstructor and Display stand not keep their items on the client when removed --- .../mod/tile/TileEntityInventoryBase.java | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInventoryBase.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInventoryBase.java index 51fdcc0c8..5832c1dfe 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInventoryBase.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInventoryBase.java @@ -42,11 +42,10 @@ public abstract class TileEntityInventoryBase extends TileEntityBase implements public static void saveSlots(ItemStack[] slots, NBTTagCompound compound){ if(slots != null && slots.length > 0){ NBTTagList tagList = new NBTTagList(); - for(int currentIndex = 0; currentIndex < slots.length; currentIndex++){ + for(ItemStack slot : slots){ NBTTagCompound tagCompound = new NBTTagCompound(); - tagCompound.setByte("Slot", (byte)currentIndex); - if(slots[currentIndex] != null){ - slots[currentIndex].writeToNBT(tagCompound); + if(slot != null){ + slot.writeToNBT(tagCompound); } tagList.appendTag(tagCompound); } @@ -57,14 +56,9 @@ public abstract class TileEntityInventoryBase extends TileEntityBase implements public static void loadSlots(ItemStack[] slots, NBTTagCompound compound){ if(slots != null && slots.length > 0){ NBTTagList tagList = compound.getTagList("Items", 10); - for(int i = 0; i < tagList.tagCount(); i++){ + for(int i = 0; i < slots.length; i++){ NBTTagCompound tagCompound = tagList.getCompoundTagAt(i); - if(tagCompound != null && tagCompound.hasKey("id")){ - byte slotIndex = tagCompound.getByte("Slot"); - if(slotIndex >= 0 && slotIndex < slots.length){ - slots[slotIndex] = ItemStack.loadItemStackFromNBT(tagCompound); - } - } + slots[i] = tagCompound != null && tagCompound.hasKey("id") ? ItemStack.loadItemStackFromNBT(tagCompound) : null; } } }