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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user