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
@@ -632,7 +632,7 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I
{
try
{
AEApi.instance().createGridConnection( cn, sn );
AEApi.instance().grid().createGridConnection( cn, sn );
}
catch( final FailedConnection e )
{
@@ -37,6 +37,7 @@ import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.config.PowerMultiplier;
import appeng.api.networking.IGridNode;
@@ -53,6 +54,7 @@ import appeng.api.parts.IPart;
import appeng.api.parts.IPartCollisionHelper;
import appeng.api.parts.IPartHost;
import appeng.api.parts.IPartModel;
import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.util.AECableType;
import appeng.api.util.AEPartLocation;
@@ -327,12 +329,13 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
*/
private IAEItemStack storeItemStack( final ItemStack item )
{
final IAEItemStack itemToStore = AEItemStack.create( item );
final IAEItemStack itemToStore = AEItemStack.fromItemStack( item );
try
{
final IStorageGrid storage = this.getProxy().getStorage();
final IEnergyGrid energy = this.getProxy().getEnergy();
final IAEItemStack overflow = Platform.poweredInsert( energy, storage.getItemInventory(), itemToStore, this.mySrc );
final IAEItemStack overflow = Platform.poweredInsert( energy,
storage.getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ), itemToStore, this.mySrc );
this.isAccepting = overflow == null;
@@ -552,8 +555,9 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
for( final ItemStack itemStack : itemStacks )
{
final IAEItemStack itemToTest = AEItemStack.create( itemStack );
final IAEItemStack overflow = storage.getItemInventory().injectItems( itemToTest, Actionable.SIMULATE, this.mySrc );
final IAEItemStack itemToTest = AEItemStack.fromItemStack( itemStack );
final IAEItemStack overflow = storage.getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) )
.injectItems( itemToTest, Actionable.SIMULATE, this.mySrc );
if( overflow == null || itemToTest.getStackSize() > overflow.getStackSize() )
{
canStore = true;
@@ -29,6 +29,7 @@ import net.minecraft.util.EnumHand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.Vec3d;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.config.FuzzyMode;
import appeng.api.config.PowerMultiplier;
@@ -49,6 +50,7 @@ import appeng.api.parts.IPartCollisionHelper;
import appeng.api.parts.IPartModel;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.util.AECableType;
import appeng.core.AELog;
@@ -128,7 +130,8 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
try
{
final InventoryAdaptor destination = this.getHandler();
final IMEMonitor<IAEItemStack> inv = this.getProxy().getStorage().getItemInventory();
final IMEMonitor<IAEItemStack> inv = this.getProxy().getStorage().getInventory(
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
final IEnergyGrid energy = this.getProxy().getEnergy();
final ICraftingGrid cg = this.getProxy().getCrafting();
final FuzzyMode fzMode = (FuzzyMode) this.getConfigManager().getSetting( Settings.FUZZY_MODE );
@@ -266,9 +269,9 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
{
if( mode == Actionable.MODULATE )
{
return AEItemStack.create( d.addItems( items.createItemStack() ) );
return AEItemStack.fromItemStack( d.addItems( items.createItemStack() ) );
}
return AEItemStack.create( d.simulateAdd( items.createItemStack() ) );
return AEItemStack.fromItemStack( d.simulateAdd( items.createItemStack() ) );
}
}
}
@@ -66,7 +66,8 @@ import appeng.api.parts.IPartModel;
import appeng.api.storage.ICellContainer;
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.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import appeng.api.util.AECableType;
@@ -96,7 +97,7 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
return MODELS.getModels();
}
private final MEInventoryHandler myHandler = new MEInventoryHandler( this, StorageChannel.ITEMS );
private final MEInventoryHandler myHandler = new MEInventoryHandler( this, AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
private final AppEngInternalAEInventory Config = new AppEngInternalAEInventory( this, 63 );
private int priority = 0;
private boolean wasActive = false;
@@ -117,7 +118,7 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
this.myHandler.setWhitelist( this.getInstalledUpgrades( Upgrades.INVERTER ) > 0 ? IncludeExclude.BLACKLIST : IncludeExclude.WHITELIST );
this.myHandler.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++ )
@@ -395,9 +396,9 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
}
@Override
public List<IMEInventoryHandler> getCellArray( final StorageChannel channel )
public List<IMEInventoryHandler> getCellArray( final IStorageChannel channel )
{
if( this.getProxy().isActive() && channel == StorageChannel.ITEMS )
if( this.getProxy().isActive() && channel == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) )
{
final List<IMEInventoryHandler> Handler = new ArrayList<>( 1 );
Handler.add( this.myHandler );
@@ -611,9 +612,9 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
}
@Override
public StorageChannel getChannel()
public IStorageChannel getChannel()
{
return StorageChannel.ITEMS;
return AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class );
}
@Override
@@ -43,6 +43,7 @@ import appeng.api.parts.IPartCollisionHelper;
import appeng.api.parts.IPartModel;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.util.AECableType;
import appeng.core.AppEng;
@@ -94,7 +95,8 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
return false;
}
final IAEItemStack out = this.destination.injectItems( this.lastItemChecked = AEApi.instance().storage().createItemStack( stack ), Actionable.SIMULATE,
final IAEItemStack out = this.destination.injectItems(
this.lastItemChecked = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createStack( stack ), Actionable.SIMULATE,
this.source );
if( out == null )
{
@@ -167,7 +169,8 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
this.itemToSend = Math.min( this.itemToSend,
(int) ( 0.01 + this.getProxy().getEnergy().extractAEPower( this.itemToSend, Actionable.SIMULATE, PowerMultiplier.CONFIG ) ) );
final IMEMonitor<IAEItemStack> inv = this.getProxy().getStorage().getItemInventory();
final IMEMonitor<IAEItemStack> inv = this.getProxy().getStorage().getInventory(
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
final IEnergyGrid energy = this.getProxy().getEnergy();
boolean Configured = false;
@@ -234,7 +237,7 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
if( this.lastItemChecked == null || !this.lastItemChecked.isSameType( newItems ) )
{
this.lastItemChecked = AEApi.instance().storage().createItemStack( newItems );
this.lastItemChecked = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createStack( newItems );
}
else
{
@@ -280,12 +283,12 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
if( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 )
{
simResult = myAdaptor.simulateSimilarRemove( toSend, itemStackToImport, fzMode, this.configDestination( inv ) );
itemAmountNotStorable = this.destination.injectItems( AEItemStack.create( simResult ), Actionable.SIMULATE, this.source );
itemAmountNotStorable = this.destination.injectItems( AEItemStack.fromItemStack( simResult ), Actionable.SIMULATE, this.source );
}
else
{
simResult = myAdaptor.simulateRemove( toSend, itemStackToImport, this.configDestination( inv ) );
itemAmountNotStorable = this.destination.injectItems( AEItemStack.create( simResult ), Actionable.SIMULATE, this.source );
itemAmountNotStorable = this.destination.injectItems( AEItemStack.fromItemStack( simResult ), Actionable.SIMULATE, this.source );
}
if( itemAmountNotStorable != null )
@@ -35,6 +35,7 @@ import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraftforge.items.IItemHandler;
import appeng.api.AEApi;
import appeng.api.config.FuzzyMode;
import appeng.api.config.LevelType;
import appeng.api.config.RedstoneMode;
@@ -62,7 +63,8 @@ import appeng.api.parts.IPartCollisionHelper;
import appeng.api.parts.IPartModel;
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.IAEStack;
import appeng.api.storage.data.IItemList;
@@ -274,7 +276,7 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH
this.updateState();
// no more item stuff..
this.getProxy().getStorage().getItemInventory().removeListener( this );
this.getProxy().getStorage().getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ).removeListener( this );
}
catch( final GridAccessException e )
{
@@ -288,11 +290,12 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH
{
if( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 || myStack == null )
{
this.getProxy().getStorage().getItemInventory().addListener( this, this.getProxy().getGrid() );
this.getProxy().getStorage().getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ).addListener( this,
this.getProxy().getGrid() );
}
else
{
this.getProxy().getStorage().getItemInventory().removeListener( this );
this.getProxy().getStorage().getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ).removeListener( this );
if( this.myWatcher != null )
{
@@ -300,7 +303,7 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH
}
}
this.updateReportingValue( this.getProxy().getStorage().getItemInventory() );
this.updateReportingValue( this.getProxy().getStorage().getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ) );
}
catch( final GridAccessException e )
{
@@ -354,9 +357,10 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH
}
@Override
public void onStackChange( final IItemList o, final IAEStack fullStack, final IAEStack diffStack, final IActionSource src, final StorageChannel chan )
public void onStackChange( final IItemList o, final IAEStack fullStack, final IAEStack diffStack, final IActionSource src, final IStorageChannel chan )
{
if( chan == StorageChannel.ITEMS && fullStack.equals( this.config.getAEStackInSlot( 0 ) ) && this.getInstalledUpgrades( Upgrades.FUZZY ) == 0 )
if( chan == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) && fullStack.equals( this.config.getAEStackInSlot( 0 ) ) && this
.getInstalledUpgrades( Upgrades.FUZZY ) == 0 )
{
this.lastReportedValue = fullStack.getStackSize();
this.updateState();
@@ -401,7 +405,7 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH
{
try
{
this.updateReportingValue( this.getProxy().getStorage().getItemInventory() );
this.updateReportingValue( this.getProxy().getStorage().getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ) );
}
catch( final GridAccessException e )
{
@@ -29,13 +29,15 @@ import java.util.Map;
import net.minecraft.item.ItemStack;
import net.minecraftforge.items.IItemHandler;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.networking.security.IActionSource;
import appeng.api.networking.storage.IBaseMonitor;
import appeng.api.networking.ticking.TickRateModulation;
import appeng.api.storage.IMEInventory;
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.core.AELog;
@@ -92,7 +94,7 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
this.onTick();
}
return AEItemStack.create( remaining );
return AEItemStack.fromItemStack( remaining );
}
@Override
@@ -168,7 +170,7 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
this.onTick();
}
return AEItemStack.create( gathered );
return AEItemStack.fromItemStack( gathered );
}
return null;
@@ -255,7 +257,7 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
{
// Completely different item
this.cachedStacks[slot] = newIS;
this.cachedAeStacks[slot] = AEItemStack.create( newIS );
this.cachedAeStacks[slot] = AEItemStack.fromItemStack( newIS );
// If we had a stack previously in this slot, notify the newtork about its disappearance
if( oldAeIS != null )
@@ -330,16 +332,16 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
for( int i = 0; i < this.itemHandler.getSlots(); i++ )
{
out.addStorage( AEItemStack.create( this.itemHandler.getStackInSlot( i ) ) );
out.addStorage( AEItemStack.fromItemStack( this.itemHandler.getStackInSlot( i ) ) );
}
return out;
}
@Override
public StorageChannel getChannel()
public IStorageChannel getChannel()
{
return StorageChannel.ITEMS;
return AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class );
}
@Override
@@ -51,9 +51,10 @@ import appeng.api.networking.ticking.TickingRequest;
import appeng.api.parts.IPartCollisionHelper;
import appeng.api.parts.IPartModel;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.IStorageChannel;
import appeng.api.storage.IStorageMonitorable;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IAEStack;
import appeng.api.util.AECableType;
import appeng.api.util.IConfigManager;
import appeng.core.AppEng;
@@ -192,15 +193,9 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISto
}
@Override
public IMEMonitor<IAEItemStack> getItemInventory()
public <T extends IAEStack<T>> IMEMonitor<T> getInventory( IStorageChannel<T> channel )
{
return this.duality.getItemInventory();
}
@Override
public IMEMonitor<IAEFluidStack> getFluidInventory()
{
return this.duality.getFluidInventory();
return this.duality.getInventory( channel );
}
@Override
@@ -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 )
@@ -203,7 +203,7 @@ public class PartToggleBus extends PartBasicState
{
try
{
this.connection = AEApi.instance().createGridConnection( this.getProxy().getNode(), this.getOuterProxy().getNode() );
this.connection = AEApi.instance().grid().createGridConnection( this.getProxy().getNode(), this.getOuterProxy().getNode() );
}
catch( final FailedConnection e )
{
@@ -240,7 +240,8 @@ public class PartP2PTunnelME extends PartP2PTunnel<PartP2PTunnelME> implements I
try
{
connections.getConnections().put( me.getGridNode(),
new TunnelConnection( me, AEApi.instance().createGridConnection( this.outerProxy.getNode(), me.outerProxy.getNode() ) ) );
new TunnelConnection( me, AEApi.instance().grid().createGridConnection( this.outerProxy.getNode(),
me.outerProxy.getNode() ) ) );
}
catch( final FailedConnection e )
{
@@ -35,13 +35,15 @@ import net.minecraft.util.math.Vec3d;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.api.AEApi;
import appeng.api.implementations.parts.IPartStorageMonitor;
import appeng.api.networking.security.IActionSource;
import appeng.api.networking.storage.IStackWatcher;
import appeng.api.networking.storage.IStackWatcherHost;
import appeng.api.parts.IPartModel;
import appeng.api.storage.IMEMonitor;
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.IAEStack;
import appeng.api.storage.data.IItemList;
@@ -88,7 +90,7 @@ public abstract class AbstractPartMonitor extends AbstractPartDisplay implements
this.isLocked = data.getBoolean( "isLocked" );
final NBTTagCompound myItem = data.getCompoundTag( "configuredItem" );
this.configuredItem = AEItemStack.loadItemStackFromNBT( myItem );
this.configuredItem = AEItemStack.fromNBT( myItem );
}
@Override
@@ -133,7 +135,7 @@ public abstract class AbstractPartMonitor extends AbstractPartDisplay implements
final boolean val = data.readBoolean();
if( val )
{
this.configuredItem = AEItemStack.loadItemStackFromPacket( data );
this.configuredItem = AEItemStack.fromPacket( data );
}
else
{
@@ -172,7 +174,7 @@ public abstract class AbstractPartMonitor extends AbstractPartDisplay implements
}
else if( !this.isLocked )
{
this.configuredItem = AEItemStack.create( eq );
this.configuredItem = AEItemStack.fromItemStack( eq );
this.configureWatchers();
this.getHost().markForUpdate();
}
@@ -201,7 +203,8 @@ public abstract class AbstractPartMonitor extends AbstractPartDisplay implements
this.myWatcher.add( this.configuredItem );
}
this.updateReportingValue( this.getProxy().getStorage().getItemInventory() );
this.updateReportingValue(
this.getProxy().getStorage().getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ) );
}
}
catch( final GridAccessException e )
@@ -287,7 +290,7 @@ public abstract class AbstractPartMonitor extends AbstractPartDisplay implements
}
@Override
public void onStackChange( final IItemList o, final IAEStack fullStack, final IAEStack diffStack, final IActionSource src, final StorageChannel chan )
public void onStackChange( final IItemList o, final IAEStack fullStack, final IAEStack diffStack, final IActionSource src, final IStorageChannel chan )
{
if( this.configuredItem != null )
{
@@ -34,9 +34,9 @@ import appeng.api.config.SortOrder;
import appeng.api.config.ViewItems;
import appeng.api.implementations.tiles.IViewCellStorage;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.IStorageChannel;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IAEStack;
import appeng.api.util.IConfigManager;
import appeng.core.sync.GuiBridge;
import appeng.me.GridAccessException;
@@ -136,25 +136,11 @@ public abstract class AbstractPartTerminal extends AbstractPartDisplay implement
}
@Override
public IMEMonitor<IAEItemStack> getItemInventory()
public <T extends IAEStack<T>> IMEMonitor<T> getInventory( IStorageChannel<T> channel )
{
try
{
return this.getProxy().getStorage().getItemInventory();
}
catch( final GridAccessException e )
{
// err nope?
}
return null;
}
@Override
public IMEMonitor<IAEFluidStack> getFluidInventory()
{
try
{
return this.getProxy().getStorage().getFluidInventory();
return this.getProxy().getStorage().getInventory( channel );
}
catch( final GridAccessException e )
{
@@ -29,9 +29,11 @@ import net.minecraft.util.EnumHand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.Vec3d;
import appeng.api.AEApi;
import appeng.api.networking.energy.IEnergySource;
import appeng.api.parts.IPartModel;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.core.AppEng;
import appeng.helpers.Reflected;
@@ -106,8 +108,9 @@ public class PartConversionMonitor extends AbstractPartMonitor
}
final IEnergySource energy = this.getProxy().getEnergy();
final IMEMonitor<IAEItemStack> cell = this.getProxy().getStorage().getItemInventory();
final IAEItemStack input = AEItemStack.create( item );
final IMEMonitor<IAEItemStack> cell = this.getProxy().getStorage().getInventory(
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
final IAEItemStack input = AEItemStack.fromItemStack( item );
if( ModeB )
{
@@ -152,7 +155,8 @@ public class PartConversionMonitor extends AbstractPartMonitor
}
final IEnergySource energy = this.getProxy().getEnergy();
final IMEMonitor<IAEItemStack> cell = this.getProxy().getStorage().getItemInventory();
final IMEMonitor<IAEItemStack> cell = this.getProxy().getStorage().getInventory(
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
final ItemStack is = input.createItemStack();
input.setStackSize( is.getMaxStackSize() );