diff --git a/container/implementations/ContainerCellWorkbench.java b/container/implementations/ContainerCellWorkbench.java index fc764e3ae..1c45e2e1d 100644 --- a/container/implementations/ContainerCellWorkbench.java +++ b/container/implementations/ContainerCellWorkbench.java @@ -283,7 +283,7 @@ public class ContainerCellWorkbench extends ContainerUpgradeable IInventory inv = myte.getInventoryByName( "config" ); IMEInventory cellInv = AEApi.instance().registries().cell() - .getCellInventory( myte.getInventoryByName( "cell" ).getStackInSlot( 0 ), StorageChannel.ITEMS ); + .getCellInventory( myte.getInventoryByName( "cell" ).getStackInSlot( 0 ), null, StorageChannel.ITEMS ); Iterator i = new NullIterator(); if ( cellInv != null ) diff --git a/core/features/registries/CellRegistry.java b/core/features/registries/CellRegistry.java index 24e848b1b..b934bb5df 100644 --- a/core/features/registries/CellRegistry.java +++ b/core/features/registries/CellRegistry.java @@ -7,6 +7,7 @@ import net.minecraft.item.ItemStack; import appeng.api.storage.ICellHandler; import appeng.api.storage.ICellRegistry; import appeng.api.storage.IMEInventoryHandler; +import appeng.api.storage.ISaveProvider; import appeng.api.storage.StorageChannel; public class CellRegistry implements ICellRegistry @@ -52,7 +53,7 @@ public class CellRegistry implements ICellRegistry } @Override - public IMEInventoryHandler getCellInventory(ItemStack is, StorageChannel chan) + public IMEInventoryHandler getCellInventory(ItemStack is, ISaveProvider container, StorageChannel chan) { if ( is == null ) return null; @@ -60,7 +61,7 @@ public class CellRegistry implements ICellRegistry { if ( ch.isCell( is ) ) { - return ch.getCellInventory( is, chan ); + return ch.getCellInventory( is, container, chan ); } } return null; diff --git a/core/features/registries/entries/BasicCellHandler.java b/core/features/registries/entries/BasicCellHandler.java index 9aba535ef..2ff656fbc 100644 --- a/core/features/registries/entries/BasicCellHandler.java +++ b/core/features/registries/entries/BasicCellHandler.java @@ -9,6 +9,7 @@ import appeng.api.storage.ICellInventory; import appeng.api.storage.ICellInventoryHandler; import appeng.api.storage.IMEInventory; import appeng.api.storage.IMEInventoryHandler; +import appeng.api.storage.ISaveProvider; import appeng.api.storage.StorageChannel; import appeng.client.texture.ExtraBlockTextures; import appeng.core.sync.GuiBridge; @@ -27,10 +28,10 @@ public class BasicCellHandler implements ICellHandler } @Override - public IMEInventoryHandler getCellInventory(ItemStack is, StorageChannel channel) + public IMEInventoryHandler getCellInventory(ItemStack is, ISaveProvider container, StorageChannel channel) { if ( channel == StorageChannel.ITEMS ) - return CellInventory.getCell( is ); + return CellInventory.getCell( is, container ); return null; } diff --git a/core/features/registries/entries/CreativeCellHandler.java b/core/features/registries/entries/CreativeCellHandler.java index 5d89d88f3..fb497d978 100644 --- a/core/features/registries/entries/CreativeCellHandler.java +++ b/core/features/registries/entries/CreativeCellHandler.java @@ -7,6 +7,7 @@ import appeng.api.implementations.tiles.IChestOrDrive; import appeng.api.storage.ICellHandler; import appeng.api.storage.IMEInventory; import appeng.api.storage.IMEInventoryHandler; +import appeng.api.storage.ISaveProvider; import appeng.api.storage.StorageChannel; import appeng.client.texture.ExtraBlockTextures; import appeng.core.sync.GuiBridge; @@ -25,7 +26,7 @@ public class CreativeCellHandler implements ICellHandler } @Override - public IMEInventoryHandler getCellInventory(ItemStack is, StorageChannel channel) + public IMEInventoryHandler getCellInventory(ItemStack is, ISaveProvider container, StorageChannel channel) { if ( channel == StorageChannel.ITEMS && is != null && is.getItem() instanceof ItemCreativeStorageCell ) return CreativeCellInventory.getCell( is ); diff --git a/items/contents/PortableCellViewer.java b/items/contents/PortableCellViewer.java index 280d95e3e..17928cea8 100644 --- a/items/contents/PortableCellViewer.java +++ b/items/contents/PortableCellViewer.java @@ -27,7 +27,7 @@ public class PortableCellViewer extends MEMonitorHandler implement private IAEItemPowerStorage ips; public PortableCellViewer(ItemStack is) { - super( CellInventory.getCell( is ) ); + super( CellInventory.getCell( is, null ) ); ips = (IAEItemPowerStorage) is.getItem(); target = is; } diff --git a/items/storage/ItemBasicStorageCell.java b/items/storage/ItemBasicStorageCell.java index 36f62b197..b613fc6da 100644 --- a/items/storage/ItemBasicStorageCell.java +++ b/items/storage/ItemBasicStorageCell.java @@ -72,7 +72,7 @@ public class ItemBasicStorageCell extends AEBaseItem implements IStorageCell, II @Override public void addInformation(ItemStack i, EntityPlayer p, List l, boolean b) { - IMEInventory cdi = AEApi.instance().registries().cell().getCellInventory( i, StorageChannel.ITEMS ); + IMEInventory cdi = AEApi.instance().registries().cell().getCellInventory( i, null, StorageChannel.ITEMS ); if ( cdi instanceof CellInventoryHandler ) { @@ -187,7 +187,7 @@ public class ItemBasicStorageCell extends AEBaseItem implements IStorageCell, II return false; InventoryPlayer pinv = player.inventory; - IMEInventory inv = AEApi.instance().registries().cell().getCellInventory( stack, StorageChannel.ITEMS ); + IMEInventory inv = AEApi.instance().registries().cell().getCellInventory( stack, null, StorageChannel.ITEMS ); if ( inv != null && pinv.getCurrentItem() == stack ) { InventoryAdaptor ia = InventoryAdaptor.getAdaptor( player, ForgeDirection.UNKNOWN ); diff --git a/items/tools/powered/ToolColorApplicator.java b/items/tools/powered/ToolColorApplicator.java index 338fed8a4..7811e2b5c 100644 --- a/items/tools/powered/ToolColorApplicator.java +++ b/items/tools/powered/ToolColorApplicator.java @@ -87,7 +87,7 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe { ItemStack newColor = null; - IMEInventory inv = AEApi.instance().registries().cell().getCellInventory( is, StorageChannel.ITEMS ); + IMEInventory inv = AEApi.instance().registries().cell().getCellInventory( is, null, StorageChannel.ITEMS ); if ( inv != null ) { IItemList itemList = inv.getAvailableItems( AEApi.instance().storage().createItemList() ); @@ -163,7 +163,7 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe ItemStack paintBall = getColor( is ); - IMEInventory inv = AEApi.instance().registries().cell().getCellInventory( is, StorageChannel.ITEMS ); + IMEInventory inv = AEApi.instance().registries().cell().getCellInventory( is, null, StorageChannel.ITEMS ); if ( inv != null ) { IAEItemStack option = inv.extractItems( AEItemStack.create( paintBall ), Actionable.SIMULATE, new BaseActionSource() ); @@ -317,7 +317,7 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe { super.addInformation( is, player, lines, advancedItemTooltips ); - IMEInventory cdi = AEApi.instance().registries().cell().getCellInventory( is, StorageChannel.ITEMS ); + IMEInventory cdi = AEApi.instance().registries().cell().getCellInventory( is, null, StorageChannel.ITEMS ); if ( cdi instanceof CellInventoryHandler ) { diff --git a/items/tools/powered/ToolMassCannon.java b/items/tools/powered/ToolMassCannon.java index b0bf17c66..1564bcd1c 100644 --- a/items/tools/powered/ToolMassCannon.java +++ b/items/tools/powered/ToolMassCannon.java @@ -75,7 +75,7 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell { super.addInformation( is, player, lines, advancedItemTooltips ); - IMEInventory cdi = AEApi.instance().registries().cell().getCellInventory( is, StorageChannel.ITEMS ); + IMEInventory cdi = AEApi.instance().registries().cell().getCellInventory( is, null, StorageChannel.ITEMS ); if ( cdi instanceof CellInventoryHandler ) { @@ -99,7 +99,7 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell if ( cu != null ) shots += cu.getInstalledUpgrades( Upgrades.SPEED ); - IMEInventory inv = AEApi.instance().registries().cell().getCellInventory( item, StorageChannel.ITEMS ); + IMEInventory inv = AEApi.instance().registries().cell().getCellInventory( item, null, StorageChannel.ITEMS ); if ( inv != null ) { IItemList itemList = inv.getAvailableItems( AEApi.instance().storage().createItemList() ); diff --git a/items/tools/powered/ToolPortableCell.java b/items/tools/powered/ToolPortableCell.java index 920bd61a9..3b059aeba 100644 --- a/items/tools/powered/ToolPortableCell.java +++ b/items/tools/powered/ToolPortableCell.java @@ -52,7 +52,7 @@ public class ToolPortableCell extends AEBasePoweredItem implements IStorageCell, { super.addInformation( is, player, lines, advancedItemTooltips ); - IMEInventory cdi = AEApi.instance().registries().cell().getCellInventory( is, StorageChannel.ITEMS ); + IMEInventory cdi = AEApi.instance().registries().cell().getCellInventory( is, null, StorageChannel.ITEMS ); if ( cdi instanceof CellInventoryHandler ) { diff --git a/me/storage/CellInventory.java b/me/storage/CellInventory.java index c11edd8b0..5c9b821e1 100644 --- a/me/storage/CellInventory.java +++ b/me/storage/CellInventory.java @@ -18,6 +18,7 @@ import appeng.api.networking.security.BaseActionSource; import appeng.api.storage.ICellInventory; import appeng.api.storage.IMEInventory; import appeng.api.storage.IMEInventoryHandler; +import appeng.api.storage.ISaveProvider; import appeng.api.storage.StorageChannel; import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IItemList; @@ -48,8 +49,11 @@ public class CellInventory implements ICellInventory protected ItemStack i; protected IStorageCell CellType; - protected CellInventory(NBTTagCompound data) { + final protected ISaveProvider container; + + protected CellInventory(NBTTagCompound data, ISaveProvider container) { tagCompound = data; + this.container = container; } protected void loadCellItems() @@ -131,9 +135,12 @@ public class CellInventory implements ICellInventory tagCompound.removeTag( ITEM_SLOT_ARR[x] ); tagCompound.removeTag( ITEM_SLOTCOUNT_ARR[x] ); } + + if ( container != null ) + container.saveChanges( this ); } - protected CellInventory(ItemStack o) throws AppEngException { + protected CellInventory(ItemStack o, ISaveProvider container) throws AppEngException { if ( ITEM_SLOT_ARR == null ) { ITEM_SLOT_ARR = new String[MAX_ITEM_TYPES]; @@ -176,6 +183,7 @@ public class CellInventory implements ICellInventory if ( MAX_ITEM_TYPES < 1 ) MAX_ITEM_TYPES = 1; + this.container = container; tagCompound = Platform.openNbtData( o ); storedItems = tagCompound.getShort( ITEM_TYPE_TAG ); storedItemCount = tagCompound.getInteger( ITEM_COUNT_TAG ); @@ -206,11 +214,11 @@ public class CellInventory implements ICellInventory return (bytesFree > getBytesPerType() || (bytesFree == getBytesPerType() && getUnusedItemCount() > 0)) && getRemainingItemTypes() > 0; } - public static IMEInventoryHandler getCell(ItemStack o) + public static IMEInventoryHandler getCell(ItemStack o, ISaveProvider container2) { try { - return new CellInventoryHandler( new CellInventory( o ) ); + return new CellInventoryHandler( new CellInventory( o, container2 ) ); } catch (AppEngException e) { @@ -361,7 +369,7 @@ public class CellInventory implements ICellInventory if ( CellInventory.isStorageCell( sharedItemStack ) ) { - IMEInventory meinv = getCell( sharedItemStack ); + IMEInventory meinv = getCell( sharedItemStack, null ); if ( meinv != null && !isEmpty( meinv ) ) return input; } diff --git a/parts/automation/PartFormationPlane.java b/parts/automation/PartFormationPlane.java index 46f899880..2986ca008 100644 --- a/parts/automation/PartFormationPlane.java +++ b/parts/automation/PartFormationPlane.java @@ -495,4 +495,10 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine return input; } + + @Override + public void saveChanges(IMEInventory cellInventory) + { + // nope! + } } diff --git a/parts/misc/PartStorageBus.java b/parts/misc/PartStorageBus.java index bea1317e2..167778bd3 100644 --- a/parts/misc/PartStorageBus.java +++ b/parts/misc/PartStorageBus.java @@ -445,4 +445,10 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC // not used here. } + @Override + public void saveChanges(IMEInventory cellInventory) + { + // nope! + } + } diff --git a/tile/storage/TileChest.java b/tile/storage/TileChest.java index f65e8926e..92e93fa63 100644 --- a/tile/storage/TileChest.java +++ b/tile/storage/TileChest.java @@ -387,8 +387,8 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan { double power = 1.0; - IMEInventoryHandler itemCell = cellHandler.getCellInventory( is, StorageChannel.ITEMS ); - IMEInventoryHandler fluidCell = cellHandler.getCellInventory( is, StorageChannel.FLUIDS ); + IMEInventoryHandler itemCell = cellHandler.getCellInventory( is, this, StorageChannel.ITEMS ); + IMEInventoryHandler fluidCell = cellHandler.getCellInventory( is, this, StorageChannel.FLUIDS ); if ( itemCell != null ) power += cellHandler.cellIdleDrain( is, itemCell ); @@ -494,9 +494,9 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan { if ( i == 1 ) { - if ( AEApi.instance().registries().cell().getCellInventory( itemstack, StorageChannel.ITEMS ) != null ) + if ( AEApi.instance().registries().cell().getCellInventory( itemstack, this, StorageChannel.ITEMS ) != null ) return true; - if ( AEApi.instance().registries().cell().getCellInventory( itemstack, StorageChannel.FLUIDS ) != null ) + if ( AEApi.instance().registries().cell().getCellInventory( itemstack, this, StorageChannel.FLUIDS ) != null ) return true; } else @@ -838,4 +838,10 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan markForUpdate(); return true; } + + @Override + public void saveChanges(IMEInventory cellInventory) + { + worldObj.markTileEntityChunkModified( this.xCoord, this.yCoord, this.zCoord, this ); + } } diff --git a/tile/storage/TileDrive.java b/tile/storage/TileDrive.java index b35f376e7..2e95e6b52 100644 --- a/tile/storage/TileDrive.java +++ b/tile/storage/TileDrive.java @@ -22,6 +22,7 @@ import appeng.api.networking.security.BaseActionSource; import appeng.api.networking.security.MachineSource; import appeng.api.networking.storage.IStorageGrid; import appeng.api.storage.ICellHandler; +import appeng.api.storage.IMEInventory; import appeng.api.storage.IMEInventoryHandler; import appeng.api.storage.StorageChannel; import appeng.api.storage.data.IAEItemStack; @@ -218,7 +219,7 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior if ( handlersBySlot[x] != null ) { - IMEInventoryHandler cell = handlersBySlot[x].getCellInventory( is, StorageChannel.ITEMS ); + IMEInventoryHandler cell = handlersBySlot[x].getCellInventory( is, this, StorageChannel.ITEMS ); if ( cell != null ) { @@ -231,7 +232,7 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior } else { - cell = handlersBySlot[x].getCellInventory( is, StorageChannel.FLUIDS ); + cell = handlersBySlot[x].getCellInventory( is, this, StorageChannel.FLUIDS ); if ( cell != null ) { @@ -359,4 +360,10 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior { return itemstack != null && AEApi.instance().registries().cell().isCellHandled( itemstack ); } + + @Override + public void saveChanges(IMEInventory cellInventory) + { + worldObj.markTileEntityChunkModified( this.xCoord, this.yCoord, this.zCoord, this ); + } } diff --git a/tile/storage/TileIOPort.java b/tile/storage/TileIOPort.java index 4f75dbbc7..61ea20969 100644 --- a/tile/storage/TileIOPort.java +++ b/tile/storage/TileIOPort.java @@ -326,8 +326,8 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC if ( currentCell != is ) { currentCell = is; - cachedFluid = AEApi.instance().registries().cell().getCellInventory( is, StorageChannel.FLUIDS ); - cachedItem = AEApi.instance().registries().cell().getCellInventory( is, StorageChannel.ITEMS ); + cachedFluid = AEApi.instance().registries().cell().getCellInventory( is, null, StorageChannel.FLUIDS ); + cachedItem = AEApi.instance().registries().cell().getCellInventory( is, null, StorageChannel.ITEMS ); } if ( StorageChannel.ITEMS == chan ) diff --git a/util/Platform.java b/util/Platform.java index cd934d47d..a451060e5 100644 --- a/util/Platform.java +++ b/util/Platform.java @@ -1374,7 +1374,7 @@ public class Platform { if ( removed != null ) { - IMEInventory myItems = AEApi.instance().registries().cell().getCellInventory( removed, StorageChannel.ITEMS ); + IMEInventory myItems = AEApi.instance().registries().cell().getCellInventory( removed, null, StorageChannel.ITEMS ); if ( myItems != null ) { @@ -1385,7 +1385,7 @@ public class Platform } } - IMEInventory myFluids = AEApi.instance().registries().cell().getCellInventory( removed, StorageChannel.FLUIDS ); + IMEInventory myFluids = AEApi.instance().registries().cell().getCellInventory( removed, null, StorageChannel.FLUIDS ); if ( myFluids != null ) { @@ -1399,7 +1399,7 @@ public class Platform if ( added != null ) { - IMEInventory myItems = AEApi.instance().registries().cell().getCellInventory( added, StorageChannel.ITEMS ); + IMEInventory myItems = AEApi.instance().registries().cell().getCellInventory( added, null, StorageChannel.ITEMS ); if ( myItems != null ) { @@ -1409,7 +1409,7 @@ public class Platform } } - IMEInventory myFluids = AEApi.instance().registries().cell().getCellInventory( added, StorageChannel.FLUIDS ); + IMEInventory myFluids = AEApi.instance().registries().cell().getCellInventory( added, null, StorageChannel.FLUIDS ); if ( myFluids != null ) {