Refactored StorageChannel enum into an interface (#3138)

This replaces the static enum with a more dynamic interface providing
factory methods for handling network storage.
This commit is contained in:
yueh
2017-10-08 17:59:30 +02:00
committed by GitHub
parent 8ad8ce68b5
commit 6e81f698c0
115 changed files with 1255 additions and 943 deletions
@@ -62,9 +62,10 @@ import appeng.api.storage.ICellContainer;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.IMEMonitorHandlerReceiver;
import appeng.api.storage.IStorageChannel;
import appeng.api.storage.IStorageMonitorable;
import appeng.api.storage.IStorageMonitorableAccessor;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IAEStack;
import appeng.api.storage.data.IItemList;
@@ -257,7 +258,8 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
{
if( this.getProxy().isActive() )
{
this.getProxy().getStorage().postAlterationOfStoredItems( StorageChannel.ITEMS, change, this.mySrc );
this.getProxy().getStorage().postAlterationOfStoredItems( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ), change,
this.mySrc );
}
}
catch( final GridAccessException e )
@@ -340,7 +342,7 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
this.resetCacheLogic = 0;
final IMEInventory<IAEItemStack> in = this.getInternalHandler();
IItemList<IAEItemStack> before = AEApi.instance().storage().createItemList();
IItemList<IAEItemStack> before = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList();
if( in != null )
{
before = in.getAvailableItems( before );
@@ -359,7 +361,7 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
this.monitor.onTick();
}
IItemList<IAEItemStack> after = AEApi.instance().storage().createItemList();
IItemList<IAEItemStack> after = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList();
if( out != null )
{
after = out.getAvailableItems( after );
@@ -382,7 +384,7 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
IStorageMonitorable inventory = accessor.getInventory( this.mySrc );
if( inventory != null )
{
return inventory.getItemInventory();
return inventory.getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
}
// So this could / can be a design decision. If the tile does support our custom capability,
@@ -469,13 +471,13 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
{
this.checkInterfaceVsStorageBus( target, this.getSide().getOpposite() );
this.handler = new MEInventoryHandler<>( inv, StorageChannel.ITEMS );
this.handler = new MEInventoryHandler( inv, AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
this.handler.setBaseAccess( (AccessRestriction) this.getConfigManager().getSetting( Settings.ACCESS ) );
this.handler.setWhitelist( this.getInstalledUpgrades( Upgrades.INVERTER ) > 0 ? IncludeExclude.BLACKLIST : IncludeExclude.WHITELIST );
this.handler.setPriority( this.priority );
final IItemList<IAEItemStack> priorityList = AEApi.instance().storage().createItemList();
final IItemList<IAEItemStack> priorityList = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList();
final int slotsToUse = 18 + this.getInstalledUpgrades( Upgrades.CAPACITY ) * 9;
for( int x = 0; x < this.Config.getSlots() && x < slotsToUse; x++ )
@@ -565,9 +567,9 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
}
@Override
public List<IMEInventoryHandler> getCellArray( final StorageChannel channel )
public List<IMEInventoryHandler> getCellArray( final IStorageChannel channel )
{
if( channel == StorageChannel.ITEMS )
if( channel == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) )
{
final IMEInventoryHandler out = this.getProxy().isActive() ? this.getInternalHandler() : null;
if( out != null )