From ca01e25f383f5c68c52ea7d54bbbee158f8d6af3 Mon Sep 17 00:00:00 2001 From: thatsIch Date: Wed, 3 Dec 2014 11:46:44 +0100 Subject: [PATCH] Remove tags in tag compound in inventories of cells if they are not needed anymore, should fix #535 --- .../java/appeng/me/storage/CellInventory.java | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/main/java/appeng/me/storage/CellInventory.java b/src/main/java/appeng/me/storage/CellInventory.java index 7c25491d..e738571a 100644 --- a/src/main/java/appeng/me/storage/CellInventory.java +++ b/src/main/java/appeng/me/storage/CellInventory.java @@ -139,12 +139,28 @@ public class CellInventory implements ICellInventory * if ( tagType instanceof NBTTagShort ) ((NBTTagShort) tagType).data = storedItems = (short) cellItems.size(); * else */ - tagCompound.setShort( ITEM_TYPE_TAG, storedItems = (short) cellItems.size() ); + if ( this.cellItems.isEmpty() ) + { + this.tagCompound.removeTag( ITEM_TYPE_TAG ); + } + else + { + this.storedItems = ( short ) this.cellItems.size(); + this.tagCompound.setShort( ITEM_TYPE_TAG, this.storedItems ); + } /* * if ( tagCount instanceof NBTTagInt ) ((NBTTagInt) tagCount).data = storedItemCount = itemCount; else */ - tagCompound.setInteger( ITEM_COUNT_TAG, storedItemCount = itemCount ); + if ( itemCount == 0 ) + { + this.tagCompound.removeTag( ITEM_COUNT_TAG ); + } + else + { + this.storedItemCount = itemCount; + this.tagCompound.setInteger( ITEM_COUNT_TAG, itemCount ); + } // clean any old crusty stuff... for (; x < oldStoredItems && x < MAX_ITEM_TYPES; x++)