mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-26 08:48:34 +01:00
Made Reconstructor and Display stand not keep their items on the client when removed
This commit is contained in:
parent
c191761cda
commit
9f36b42d30
1 changed files with 5 additions and 11 deletions
|
@ -42,11 +42,10 @@ public abstract class TileEntityInventoryBase extends TileEntityBase implements
|
||||||
public static void saveSlots(ItemStack[] slots, NBTTagCompound compound){
|
public static void saveSlots(ItemStack[] slots, NBTTagCompound compound){
|
||||||
if(slots != null && slots.length > 0){
|
if(slots != null && slots.length > 0){
|
||||||
NBTTagList tagList = new NBTTagList();
|
NBTTagList tagList = new NBTTagList();
|
||||||
for(int currentIndex = 0; currentIndex < slots.length; currentIndex++){
|
for(ItemStack slot : slots){
|
||||||
NBTTagCompound tagCompound = new NBTTagCompound();
|
NBTTagCompound tagCompound = new NBTTagCompound();
|
||||||
tagCompound.setByte("Slot", (byte)currentIndex);
|
if(slot != null){
|
||||||
if(slots[currentIndex] != null){
|
slot.writeToNBT(tagCompound);
|
||||||
slots[currentIndex].writeToNBT(tagCompound);
|
|
||||||
}
|
}
|
||||||
tagList.appendTag(tagCompound);
|
tagList.appendTag(tagCompound);
|
||||||
}
|
}
|
||||||
|
@ -57,14 +56,9 @@ public abstract class TileEntityInventoryBase extends TileEntityBase implements
|
||||||
public static void loadSlots(ItemStack[] slots, NBTTagCompound compound){
|
public static void loadSlots(ItemStack[] slots, NBTTagCompound compound){
|
||||||
if(slots != null && slots.length > 0){
|
if(slots != null && slots.length > 0){
|
||||||
NBTTagList tagList = compound.getTagList("Items", 10);
|
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);
|
NBTTagCompound tagCompound = tagList.getCompoundTagAt(i);
|
||||||
if(tagCompound != null && tagCompound.hasKey("id")){
|
slots[i] = tagCompound != null && tagCompound.hasKey("id") ? ItemStack.loadItemStackFromNBT(tagCompound) : null;
|
||||||
byte slotIndex = tagCompound.getByte("Slot");
|
|
||||||
if(slotIndex >= 0 && slotIndex < slots.length){
|
|
||||||
slots[slotIndex] = ItemStack.loadItemStackFromNBT(tagCompound);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue