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
@@ -58,7 +58,7 @@ public class TileCraftingMonitorTile extends TileCraftingTile implements IColora
if( hasItem )
{
this.dspPlay = AEItemStack.loadItemStackFromPacket( data );
this.dspPlay = AEItemStack.fromPacket( data );
}
else
{
@@ -40,6 +40,7 @@ import appeng.api.networking.events.MENetworkChannelsChanged;
import appeng.api.networking.events.MENetworkEventSubscribe;
import appeng.api.networking.events.MENetworkPowerStatusChange;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.util.AEPartLocation;
import appeng.api.util.WorldCoord;
@@ -314,7 +315,7 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP
throw new IllegalStateException( this.cluster + " does not contain any kind of blocks, which were destroyed." );
}
for( IAEItemStack ais : inv.getAvailableItems( AEApi.instance().storage().createItemList() ) )
for( IAEItemStack ais : inv.getAvailableItems( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList() ) )
{
ais = ais.copy();
ais.setStackSize( ais.getDefinition().getMaxStackSize() );
@@ -479,7 +479,7 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade
try
{
final TargetPoint where = new TargetPoint( this.world.provider.getDimension(), this.pos.getX(), this.pos.getY(), this.pos.getZ(), 32 );
final IAEItemStack item = AEItemStack.create( output );
final IAEItemStack item = AEItemStack.fromItemStack( output );
NetworkHandler.instance().sendToAllAround( new PacketAssemblerAnimation( this.pos, (byte) speed, item ), where );
}
catch( final IOException e )
@@ -28,6 +28,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.items.ItemHandlerHelper;
import appeng.api.AEApi;
import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.core.AELog;
import appeng.util.Platform;
@@ -111,7 +112,7 @@ public class AppEngInternalAEInventory implements IInternalItemHandler, Iterable
if( c != null )
{
this.inv[x] = AEItemStack.loadItemStackFromNBT( c );
this.inv[x] = AEItemStack.fromNBT( c );
}
}
catch( final Exception e )
@@ -175,7 +176,8 @@ public class AppEngInternalAEInventory implements IInternalItemHandler, Iterable
{
if( existing.isEmpty() )
{
this.inv[slot] = AEApi.instance().storage().createItemStack( reachedLimit ? ItemHandlerHelper.copyStackWithSize( stack, limit ) : stack );
this.inv[slot] = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createStack(
reachedLimit ? ItemHandlerHelper.copyStackWithSize( stack, limit ) : stack );
}
else
{
@@ -220,7 +222,7 @@ public class AppEngInternalAEInventory implements IInternalItemHandler, Iterable
public void setStackInSlot( final int slot, final ItemStack newItemStack )
{
ItemStack oldStack = this.getStackInSlot( slot ).copy();
this.inv[slot] = AEApi.instance().storage().createItemStack( newItemStack );
this.inv[slot] = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createStack( newItemStack );
if( this.te != null && Platform.isServer() )
{
@@ -19,12 +19,14 @@
package appeng.tile.misc;
import appeng.api.AEApi;
import appeng.api.config.AccessRestriction;
import appeng.api.config.Actionable;
import appeng.api.networking.security.IActionSource;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.IMEMonitorHandlerReceiver;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.IStorageChannel;
import appeng.api.storage.channels.IFluidStorageChannel;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IItemList;
import appeng.util.item.FluidList;
@@ -74,9 +76,9 @@ class CondenserFluidInventory implements IMEMonitor<IAEFluidStack>
}
@Override
public StorageChannel getChannel()
public IStorageChannel<IAEFluidStack> getChannel()
{
return StorageChannel.FLUIDS;
return AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class );
}
@Override
@@ -19,12 +19,14 @@
package appeng.tile.misc;
import appeng.api.AEApi;
import appeng.api.config.AccessRestriction;
import appeng.api.config.Actionable;
import appeng.api.networking.security.IActionSource;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.IMEMonitorHandlerReceiver;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.IStorageChannel;
import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import appeng.util.item.ItemList;
@@ -70,9 +72,9 @@ class CondenserItemInventory implements IMEMonitor<IAEItemStack>
}
@Override
public StorageChannel getChannel()
public IStorageChannel getChannel()
{
return StorageChannel.ITEMS;
return AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class );
}
@Override
@@ -85,7 +85,7 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable, IGrid
final boolean c = super.readFromStream( data );
try
{
final IAEItemStack item = AEItemStack.loadItemStackFromPacket( data );
final IAEItemStack item = AEItemStack.fromPacket( data );
final ItemStack is = item.createItemStack();
this.inv.setStackInSlot( 0, is );
}
@@ -100,7 +100,7 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable, IGrid
protected void writeToStream( final ByteBuf data ) throws IOException
{
super.writeToStream( data );
final AEItemStack is = AEItemStack.create( this.inv.getStackInSlot( 0 ) );
final AEItemStack is = AEItemStack.fromItemStack( this.inv.getStackInSlot( 0 ) );
if( is != null )
{
is.writeToPacket( data );
@@ -40,10 +40,12 @@ import appeng.api.definitions.IMaterials;
import appeng.api.implementations.items.IStorageComponent;
import appeng.api.networking.security.IActionSource;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.IStorageChannel;
import appeng.api.storage.IStorageMonitorable;
import appeng.api.storage.IStorageMonitorableAccessor;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.channels.IFluidStorageChannel;
import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEStack;
import appeng.api.util.IConfigManager;
import appeng.api.util.IConfigurableObject;
import appeng.capabilities.Capabilities;
@@ -342,15 +344,17 @@ public class TileCondenser extends AEBaseInvTile implements IConfigManagerHost,
}
@Override
public IMEMonitor<IAEItemStack> getItemInventory()
public <T extends IAEStack<T>> IMEMonitor<T> getInventory( IStorageChannel<T> channel )
{
return this.itemInventory;
}
@Override
public IMEMonitor<IAEFluidStack> getFluidInventory()
{
return this.fluidInventory;
if( channel == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) )
{
return (IMEMonitor<T>) this.itemInventory;
}
else if( channel == AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) )
{
return (IMEMonitor<T>) this.fluidInventory;
}
return null;
}
}
}
@@ -165,7 +165,7 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
{
if( ( slot & ( 1 << num ) ) > 0 )
{
this.inv.setStackInSlot( num, AEItemStack.loadItemStackFromPacket( data ).createItemStack() );
this.inv.setStackInSlot( num, AEItemStack.fromPacket( data ).createItemStack() );
}
else
{
@@ -195,7 +195,7 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
{
if( ( slot & ( 1 << num ) ) > 0 )
{
final AEItemStack st = AEItemStack.create( this.inv.getStackInSlot( num ) );
final AEItemStack st = AEItemStack.fromItemStack( this.inv.getStackInSlot( num ) );
st.writeToPacket( data );
}
}
@@ -57,10 +57,12 @@ import appeng.api.networking.events.MENetworkSecurityChange;
import appeng.api.networking.security.ISecurityProvider;
import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.IStorageChannel;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.MEMonitorHandler;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IAEStack;
import appeng.api.util.AECableType;
import appeng.api.util.AEColor;
import appeng.api.util.AEPartLocation;
@@ -199,7 +201,7 @@ public class TileSecurityStation extends AENetworkTile implements ITerminalHost,
final NBTBase obj = storedItems.getTag( (String) key );
if( obj instanceof NBTTagCompound )
{
this.inventory.getStoredItems().add( AEItemStack.create( new ItemStack( (NBTTagCompound) obj ) ) );
this.inventory.getStoredItems().add( AEItemStack.fromItemStack( new ItemStack( (NBTTagCompound) obj ) ) );
}
}
}
@@ -274,15 +276,14 @@ public class TileSecurityStation extends AENetworkTile implements ITerminalHost,
}
@Override
public IMEMonitor<IAEItemStack> getItemInventory()
{
return this.securityMonitor;
}
@Override
public IMEMonitor<IAEFluidStack> getFluidInventory()
public <T extends IAEStack<T>> IMEMonitor<T> getInventory( IStorageChannel<T> channel )
{
if( channel == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) )
{
return (IMEMonitor<T>) this.securityMonitor;
}
return null;
}
@Override
@@ -74,11 +74,13 @@ import appeng.api.storage.IMEInventory;
import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.IMEMonitorHandlerReceiver;
import appeng.api.storage.IStorageChannel;
import appeng.api.storage.IStorageMonitorable;
import appeng.api.storage.IStorageMonitorableAccessor;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.MEMonitorHandler;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.channels.IFluidStorageChannel;
import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IAEStack;
@@ -209,7 +211,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
return 1;
}
private IMEInventoryHandler getHandler( final StorageChannel channel ) throws ChestNoHandler
private IMEInventoryHandler getHandler( final IStorageChannel channel ) throws ChestNoHandler
{
if( !this.isCached )
{
@@ -228,8 +230,10 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
{
double power = 1.0;
final IMEInventoryHandler<IAEItemStack> itemCell = this.cellHandler.getCellInventory( is, this, StorageChannel.ITEMS );
final IMEInventoryHandler<IAEFluidStack> fluidCell = this.cellHandler.getCellInventory( is, this, StorageChannel.FLUIDS );
final IMEInventoryHandler<IAEItemStack> itemCell = this.cellHandler.getCellInventory( is, this,
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
final IMEInventoryHandler<IAEFluidStack> fluidCell = this.cellHandler.getCellInventory( is, this,
AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) );
if( itemCell != null )
{
@@ -259,37 +263,38 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
}
}
switch( channel )
if( channel == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) )
{
case FLUIDS:
if( this.fluidCell == null )
{
throw NO_HANDLER;
}
return this.fluidCell;
case ITEMS:
if( this.itemCell == null )
{
throw NO_HANDLER;
}
return this.itemCell;
default:
if( this.itemCell == null )
{
throw NO_HANDLER;
}
return this.itemCell;
}
else if( channel == AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) && this.fluidCell != null )
{
if( this.fluidCell == null )
{
throw NO_HANDLER;
}
return this.fluidCell;
}
return null;
}
private <StackType extends IAEStack> MEMonitorHandler<StackType> wrap( final IMEInventoryHandler h )
private <T extends IAEStack<T>> MEMonitorHandler<T> wrap( final IMEInventoryHandler<T> h )
{
if( h == null )
{
return null;
}
final MEInventoryHandler ih = new MEInventoryHandler( h, h.getChannel() );
final MEInventoryHandler<T> ih = new MEInventoryHandler( h, h.getChannel() );
ih.setPriority( this.priority );
final MEMonitorHandler<StackType> g = new ChestMonitorHandler<StackType>( ih );
final MEMonitorHandler<T> g = new ChestMonitorHandler<T>( ih );
g.addListener( new ChestNetNotifier( h.getChannel() ), g );
return g;
@@ -310,7 +315,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
{
try
{
final IMEInventoryHandler handler = this.getHandler( StorageChannel.ITEMS );
final IMEInventoryHandler handler = this.getHandler( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
if( handler instanceof ChestMonitorHandler )
{
return ch.getStatusForCell( cell, ( (ChestMonitorHandler) handler ).getInternalHandler() );
@@ -322,7 +327,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
try
{
final IMEInventoryHandler handler = this.getHandler( StorageChannel.FLUIDS );
final IMEInventoryHandler handler = this.getHandler( AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) );
if( handler instanceof ChestMonitorHandler )
{
return ch.getStatusForCell( cell, ( (ChestMonitorHandler) handler ).getInternalHandler() );
@@ -538,15 +543,17 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
}
@Override
public IMEMonitor getItemInventory()
public <T extends IAEStack<T>> IMEMonitor<T> getInventory( IStorageChannel<T> channel )
{
return this.itemCell;
}
@Override
public IMEMonitor getFluidInventory()
{
return this.fluidCell;
if( channel == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) )
{
return this.itemCell;
}
else if( channel == AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) )
{
return this.fluidCell;
}
return null;
}
@Override
@@ -608,10 +615,10 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
{
if( !ItemHandlerUtil.isEmpty( this.inputInventory ) )
{
final IMEInventory<IAEItemStack> cell = this.getHandler( StorageChannel.ITEMS );
final IMEInventory<IAEItemStack> cell = this.getHandler( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
final IAEItemStack returns = Platform.poweredInsert( this, cell,
AEApi.instance().storage().createItemStack( this.inputInventory.getStackInSlot( 0 ) ),
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createStack( this.inputInventory.getStackInSlot( 0 ) ),
this.mySrc );
if( returns == null )
@@ -630,7 +637,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
}
@Override
public List<IMEInventoryHandler> getCellArray( final StorageChannel channel )
public List<IMEInventoryHandler> getCellArray( final IStorageChannel channel )
{
if( this.getProxy().isActive() )
{
@@ -711,10 +718,10 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
{
try
{
final IMEInventoryHandler invHandler = this.getHandler( StorageChannel.ITEMS );
final IMEInventoryHandler invHandler = this.getHandler( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
if( ch != null && invHandler != null )
{
ch.openChestGui( p, this, ch, invHandler, cell, StorageChannel.ITEMS );
ch.openChestGui( p, this, ch, invHandler, cell, AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
return true;
}
}
@@ -725,10 +732,10 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
try
{
final IMEInventoryHandler invHandler = this.getHandler( StorageChannel.FLUIDS );
final IMEInventoryHandler invHandler = this.getHandler( AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) );
if( ch != null && invHandler != null )
{
ch.openChestGui( p, this, ch, invHandler, cell, StorageChannel.FLUIDS );
ch.openChestGui( p, this, ch, invHandler, cell, AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) );
return true;
}
}
@@ -774,9 +781,9 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
private class ChestNetNotifier<T extends IAEStack<T>> implements IMEMonitorHandlerReceiver<T>
{
private final StorageChannel chan;
private final IStorageChannel chan;
public ChestNetNotifier( final StorageChannel chan )
public ChestNetNotifier( final IStorageChannel chan )
{
this.chan = chan;
}
@@ -784,11 +791,11 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
@Override
public boolean isValid( final Object verificationToken )
{
if( this.chan == StorageChannel.ITEMS )
if( this.chan == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) )
{
return verificationToken == TileChest.this.itemCell;
}
if( this.chan == StorageChannel.FLUIDS )
if( this.chan == AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) )
{
return verificationToken == TileChest.this.fluidCell;
}
@@ -823,7 +830,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
}
}
private class ChestMonitorHandler<T extends IAEStack> extends MEMonitorHandler<T>
private class ChestMonitorHandler<T extends IAEStack<T>> extends MEMonitorHandler<T>
{
public ChestMonitorHandler( final IMEInventoryHandler<T> t )
@@ -951,11 +958,11 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
{
try
{
final IMEInventoryHandler h = TileChest.this.getHandler( StorageChannel.FLUIDS );
final IMEInventoryHandler h = TileChest.this.getHandler( AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) );
TileChest.this.extractAEPower( req, Actionable.MODULATE, PowerMultiplier.CONFIG );
final IAEStack results = h.injectItems( AEFluidStack.create( resource ), doFill ? Actionable.MODULATE : Actionable.SIMULATE,
final IAEStack results = h.injectItems( AEFluidStack.fromFluidStack( resource ), doFill ? Actionable.MODULATE : Actionable.SIMULATE,
TileChest.this.mySrc );
if( results == null )
@@ -989,9 +996,9 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
{
try
{
final IMEInventoryHandler h = TileChest.this.getHandler( StorageChannel.FLUIDS );
final IMEInventoryHandler h = TileChest.this.getHandler( AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) );
if( h.getChannel() == StorageChannel.FLUIDS )
if( h.getChannel() == AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) )
{
return new IFluidTankProperties[] { new FluidTankProperties( null, 1 ) }; // eh?
}
@@ -1019,10 +1026,12 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
{
try
{
final IMEInventory<IAEItemStack> cell = TileChest.this.getHandler( StorageChannel.ITEMS );
final IMEInventory<IAEItemStack> cell = TileChest.this
.getHandler( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
if( cell != null )
{
final IAEItemStack returns = cell.injectItems( AEApi.instance().storage().createItemStack( stack ), Actionable.SIMULATE,
final IAEItemStack returns = cell.injectItems(
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createStack( stack ), Actionable.SIMULATE,
TileChest.this.mySrc );
return returns == null || returns.getStackSize() != stack.getCount();
}
@@ -1048,8 +1057,11 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
public boolean allowInsert( IItemHandler inv, int slot, ItemStack stack )
{
return AEApi.instance().registries().cell().getCellInventory( stack, TileChest.this,
StorageChannel.ITEMS ) != null || AEApi.instance().registries().cell().getCellInventory( stack, TileChest.this,
StorageChannel.FLUIDS ) != null;
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ) != null || AEApi.instance()
.registries()
.cell()
.getCellInventory( stack, TileChest.this,
AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) ) != null;
}
}
@@ -42,7 +42,9 @@ 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.IStorageChannel;
import appeng.api.storage.channels.IFluidStorageChannel;
import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.util.AECableType;
import appeng.api.util.AEPartLocation;
@@ -149,7 +151,7 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior
return 0;
}
if( handler.getChannel() == StorageChannel.ITEMS )
if( handler.getChannel() == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) )
{
if( ch != null )
{
@@ -157,7 +159,7 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior
}
}
if( handler.getChannel() == StorageChannel.FLUIDS )
if( handler.getChannel() == AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) )
{
if( ch != null )
{
@@ -310,7 +312,8 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior
if( this.handlersBySlot[x] != null )
{
IMEInventoryHandler cell = this.handlersBySlot[x].getCellInventory( is, this, StorageChannel.ITEMS );
IMEInventoryHandler cell = this.handlersBySlot[x].getCellInventory( is, this,
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
if( cell != null )
{
@@ -323,7 +326,8 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior
}
else
{
cell = this.handlersBySlot[x].getCellInventory( is, this, StorageChannel.FLUIDS );
cell = this.handlersBySlot[x].getCellInventory( is, this,
AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) );
if( cell != null )
{
@@ -353,12 +357,12 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior
}
@Override
public List<IMEInventoryHandler> getCellArray( final StorageChannel channel )
public List<IMEInventoryHandler> getCellArray( final IStorageChannel channel )
{
if( this.getProxy().isActive() )
{
this.updateState();
return (List) ( channel == StorageChannel.ITEMS ? this.items : this.fluids );
return (List) ( channel == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ? this.items : this.fluids );
}
return new ArrayList();
}
@@ -47,7 +47,9 @@ import appeng.api.networking.ticking.TickRateModulation;
import appeng.api.networking.ticking.TickingRequest;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.IStorageChannel;
import appeng.api.storage.channels.IFluidStorageChannel;
import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IAEStack;
@@ -292,8 +294,10 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
try
{
final IMEInventory<IAEItemStack> itemNet = this.getProxy().getStorage().getItemInventory();
final IMEInventory<IAEFluidStack> fluidNet = this.getProxy().getStorage().getFluidInventory();
final IMEInventory<IAEItemStack> itemNet = this.getProxy().getStorage().getInventory(
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
final IMEInventory<IAEFluidStack> fluidNet = this.getProxy().getStorage().getInventory(
AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) );
final IEnergySource energy = this.getProxy().getEnergy();
for( int x = 0; x < 6; x++ )
{
@@ -302,29 +306,34 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
{
if( ItemsToMove > 0 )
{
final IMEInventory<IAEItemStack> itemInv = this.getInv( is, StorageChannel.ITEMS );
final IMEInventory<IAEFluidStack> fluidInv = this.getInv( is, StorageChannel.FLUIDS );
final IMEInventory<IAEItemStack> itemInv = this.getInv( is, AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
final IMEInventory<IAEFluidStack> fluidInv = this.getInv( is,
AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) );
if( this.manager.getSetting( Settings.OPERATION_MODE ) == OperationMode.EMPTY )
{
if( itemInv != null )
{
ItemsToMove = this.transferContents( energy, itemInv, itemNet, ItemsToMove, StorageChannel.ITEMS );
ItemsToMove = this.transferContents( energy, itemInv, itemNet, ItemsToMove,
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
}
if( fluidInv != null )
{
ItemsToMove = this.transferContents( energy, fluidInv, fluidNet, ItemsToMove, StorageChannel.FLUIDS );
ItemsToMove = this.transferContents( energy, fluidInv, fluidNet, ItemsToMove,
AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) );
}
}
else
{
if( itemInv != null )
{
ItemsToMove = this.transferContents( energy, itemNet, itemInv, ItemsToMove, StorageChannel.ITEMS );
ItemsToMove = this.transferContents( energy, itemNet, itemInv, ItemsToMove,
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
}
if( fluidInv != null )
{
ItemsToMove = this.transferContents( energy, fluidNet, fluidInv, ItemsToMove, StorageChannel.FLUIDS );
ItemsToMove = this.transferContents( energy, fluidNet, fluidInv, ItemsToMove,
AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) );
}
}
@@ -357,16 +366,18 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
return this.upgrades.getInstalledUpgrades( u );
}
private IMEInventory getInv( final ItemStack is, final StorageChannel chan )
private IMEInventory getInv( final ItemStack is, final IStorageChannel chan )
{
if( this.currentCell != is )
{
this.currentCell = is;
this.cachedFluid = AEApi.instance().registries().cell().getCellInventory( is, null, StorageChannel.FLUIDS );
this.cachedItem = AEApi.instance().registries().cell().getCellInventory( is, null, StorageChannel.ITEMS );
this.cachedFluid = AEApi.instance().registries().cell().getCellInventory( is, null,
AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) );
this.cachedItem = AEApi.instance().registries().cell().getCellInventory( is, null,
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
}
if( StorageChannel.ITEMS == chan )
if( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) == chan )
{
return this.cachedItem;
}
@@ -374,7 +385,7 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
return this.cachedFluid;
}
private long transferContents( final IEnergySource energy, final IMEInventory src, final IMEInventory destination, long itemsToMove, final StorageChannel chan )
private long transferContents( final IEnergySource energy, final IMEInventory src, final IMEInventory destination, long itemsToMove, final IStorageChannel chan )
{
final IItemList<? extends IAEStack> myList;
if( src instanceof IMEMonitor )