diff --git a/src/main/java/appeng/me/storage/AbstractCellInventory.java b/src/main/java/appeng/me/storage/AbstractCellInventory.java index 2cf41b6a1..27ca71d3f 100644 --- a/src/main/java/appeng/me/storage/AbstractCellInventory.java +++ b/src/main/java/appeng/me/storage/AbstractCellInventory.java @@ -192,16 +192,29 @@ public abstract class AbstractCellInventory> implements IC this.cellItems.resetStatus(); // clears totals and stuff. final int types = (int) this.getStoredItemTypes(); + boolean needsUpdate = false; for( int slot = 0; slot < types; slot++ ) { NBTTagCompound compoundTag = this.tagCompound.getCompoundTag( ITEM_SLOT_KEYS[slot] ); int stackSize = this.tagCompound.getInteger( ITEM_SLOT_COUNT_KEYS[slot] ); - this.loadCellItem( compoundTag, stackSize ); + needsUpdate |= !this.loadCellItem( compoundTag, stackSize ); + } + + if( needsUpdate ) + { + this.saveChanges(); } } - protected abstract void loadCellItem( NBTTagCompound compoundTag, int stackSize ); + /** + * Load a single item. + * + * @param compoundTag + * @param stackSize + * @return true when successfully loaded + */ + protected abstract boolean loadCellItem( NBTTagCompound compoundTag, int stackSize ); @Override public IItemList getAvailableItems( final IItemList out ) diff --git a/src/main/java/appeng/me/storage/BasicCellInventory.java b/src/main/java/appeng/me/storage/BasicCellInventory.java index e7ed348e6..15cdff2d4 100644 --- a/src/main/java/appeng/me/storage/BasicCellInventory.java +++ b/src/main/java/appeng/me/storage/BasicCellInventory.java @@ -253,7 +253,7 @@ public class BasicCellInventory> extends AbstractCellInven } @Override - protected void loadCellItem( NBTTagCompound compoundTag, int stackSize ) + protected boolean loadCellItem( NBTTagCompound compoundTag, int stackSize ) { // Now load the item stack final T t; @@ -263,7 +263,7 @@ public class BasicCellInventory> extends AbstractCellInven if( t == null ) { AELog.warn( "Removing item " + compoundTag + " from storage cell because the associated item type couldn't be found." ); - return; + return false; } } catch( Throwable ex ) @@ -271,7 +271,7 @@ public class BasicCellInventory> extends AbstractCellInven if( AEConfig.instance().isRemoveCrashingItemsOnLoad() ) { AELog.warn( ex, "Removing item " + compoundTag + " from storage cell because loading the ItemStack crashed." ); - return; + return false; } throw ex; } @@ -282,5 +282,7 @@ public class BasicCellInventory> extends AbstractCellInven { this.cellItems.add( t ); } + + return true; } }