Refactor Some Class stuff out in favor of StorageChannel.

This commit is contained in:
AlgorithmX2
2014-07-23 14:11:12 -05:00
parent e1fe66adf9
commit 298ae41198
13 changed files with 24 additions and 26 deletions
+3 -2
View File
@@ -47,6 +47,7 @@ import appeng.api.parts.IPart;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.IStorageMonitorable;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.util.AECableType;
@@ -509,8 +510,8 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt
return patterns;
}
MEMonitorPassthu<IAEItemStack> items = new MEMonitorPassthu<IAEItemStack>( new NullInventory(), IAEItemStack.class );
MEMonitorPassthu<IAEFluidStack> fluids = new MEMonitorPassthu<IAEFluidStack>( new NullInventory(), IAEFluidStack.class );
MEMonitorPassthu<IAEItemStack> items = new MEMonitorPassthu<IAEItemStack>( new NullInventory(), StorageChannel.ITEMS );
MEMonitorPassthu<IAEFluidStack> fluids = new MEMonitorPassthu<IAEFluidStack>( new NullInventory(), StorageChannel.FLUIDS );
public void gridChanged()
{
+2 -1
View File
@@ -11,6 +11,7 @@ import appeng.api.implementations.items.IUpgradeModule;
import appeng.api.storage.ICellInventory;
import appeng.api.storage.ICellInventoryHandler;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import appeng.util.Platform;
@@ -38,7 +39,7 @@ public class CellInventoryHandler extends MEInventoryHandler<IAEItemStack> imple
}
CellInventoryHandler(IMEInventory c) {
super( c, IAEItemStack.class );
super( c, StorageChannel.ITEMS );
ICellInventory ci = getCellInv();
if ( ci != null )
+1 -1
View File
@@ -17,7 +17,7 @@ public class DriveWatcher<T extends IAEStack<T>> extends MEInventoryHandler<T>
final IChestOrDrive cord;
public DriveWatcher(IMEInventory<T> i, ItemStack is, ICellHandler han, IChestOrDrive cod) {
super( i, i.getChannel().type );
super( i, i.getChannel() );
this.is = is;
handler = han;
cord = cod;
+4 -4
View File
@@ -16,7 +16,7 @@ import appeng.util.prioitylist.IPartitionList;
public class MEInventoryHandler<T extends IAEStack<T>> implements IMEInventoryHandler<T>
{
Class<? extends IAEStack> clz;
final StorageChannel channel;
final protected IMEMonitor<T> monitor;
final protected IMEInventoryHandler<T> internal;
@@ -25,13 +25,13 @@ public class MEInventoryHandler<T extends IAEStack<T>> implements IMEInventoryHa
public AccessRestriction myAccess = AccessRestriction.READ_WRITE;
public IPartitionList<T> myPartitionList = new DefaultPriorityList<T>();
public MEInventoryHandler(IMEInventory<T> i, Class<? extends IAEStack> cla) {
clz = cla;
public MEInventoryHandler(IMEInventory<T> i, StorageChannel channel ) {
this.channel = channel;
if ( i instanceof IMEInventoryHandler )
internal = (IMEInventoryHandler<T>) i;
else
internal = new MEPassthru<T>( i, clz );
internal = new MEPassthru<T>( i );
monitor = internal instanceof IMEMonitor ? (IMEMonitor<T>) internal : null;
}
+8 -6
View File
@@ -9,22 +9,24 @@ import appeng.api.networking.storage.IBaseMonitor;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.IMEMonitorHandlerReceiver;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEStack;
import appeng.api.storage.data.IItemList;
import appeng.util.Platform;
import appeng.util.inv.ItemListIgnoreCrafting;
import appeng.util.item.ItemList;
public class MEMonitorPassthu<T extends IAEStack<T>> extends MEPassthru<T> implements IMEMonitor<T>, IMEMonitorHandlerReceiver<T>
{
HashMap<IMEMonitorHandlerReceiver<T>, Object> listeners = new HashMap();
IMEMonitor<T> monitor;
StorageChannel channel;
public BaseActionSource changeSource;
public MEMonitorPassthu(IMEInventory<T> i, Class<? extends IAEStack> cla) {
super( i, cla );
public MEMonitorPassthu(IMEInventory<T> i, StorageChannel channel ) {
super( i );
this.channel = channel;
if ( i instanceof IMEMonitor )
monitor = (IMEMonitor<T>) i;
}
@@ -36,13 +38,13 @@ public class MEMonitorPassthu<T extends IAEStack<T>> extends MEPassthru<T> imple
monitor.removeListener( this );
monitor = null;
IItemList<T> before = getInternal() == null ? new ItemList( clz ) : getInternal().getAvailableItems( new ItemListIgnoreCrafting( new ItemList( clz ) ) );
IItemList<T> before = getInternal() == null ? channel.createList() : getInternal().getAvailableItems( new ItemListIgnoreCrafting( channel.createList() ) );
super.setInternal( i );
if ( i instanceof IMEMonitor )
monitor = (IMEMonitor<T>) i;
IItemList<T> after = getInternal() == null ? new ItemList( clz ) : getInternal().getAvailableItems( new ItemListIgnoreCrafting( new ItemList( clz ) ) );
IItemList<T> after = getInternal() == null ? channel.createList() : getInternal().getAvailableItems( new ItemListIgnoreCrafting( channel.createList() ) );
if ( monitor != null )
monitor.addListener( this, monitor );
@@ -74,7 +76,7 @@ public class MEMonitorPassthu<T extends IAEStack<T>> extends MEPassthru<T> imple
{
if ( monitor == null )
{
IItemList<T> out = new ItemList( clz );
IItemList<T> out = channel.createList();
getInternal().getAvailableItems( new ItemListIgnoreCrafting( out ) );
return out;
}
+1 -3
View File
@@ -12,7 +12,6 @@ import appeng.api.storage.data.IItemList;
public class MEPassthru<T extends IAEStack<T>> implements IMEInventoryHandler<T>
{
Class<? extends IAEStack> clz;
private IMEInventory<T> internal;
protected IMEInventory<T> getInternal()
@@ -20,9 +19,8 @@ public class MEPassthru<T extends IAEStack<T>> implements IMEInventoryHandler<T>
return internal;
}
public MEPassthru(IMEInventory<T> i, Class<? extends IAEStack> cla) {
public MEPassthru( IMEInventory<T> i ) {
setInternal( i );
clz = cla;
}
public void setInternal(IMEInventory<T> i)
-1
View File
@@ -15,7 +15,6 @@ import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import appeng.me.GridAccessException;
import appeng.tile.misc.TileSecurity;
import appeng.util.item.ItemList;
public class SecurityInventory implements IMEInventoryHandler<IAEItemStack>
{
+1 -1
View File
@@ -64,7 +64,7 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
int priority = 0;
boolean wasActive = false;
boolean blocked = false;
MEInventoryHandler myHandler = new MEInventoryHandler( this, IAEItemStack.class );
MEInventoryHandler myHandler = new MEInventoryHandler( this, StorageChannel.ITEMS );
AppEngInternalAEInventory Config = new AppEngInternalAEInventory( this, 63 );
public PartFormationPlane(ItemStack is) {
+1 -1
View File
@@ -256,7 +256,7 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
if ( inv != null )
{
handler = new MEInventoryHandler( inv, IAEItemStack.class );
handler = new MEInventoryHandler( inv, StorageChannel.ITEMS );
handler.myAccess = (AccessRestriction) this.getConfigManager().getSetting( Settings.ACCESS );
handler.myWhitelist = getInstalledUpgrades( Upgrades.INVERTER ) > 0 ? IncludeExclude.BLACKLIST : IncludeExclude.WHITELIST;
-1
View File
@@ -32,7 +32,6 @@ import appeng.tile.events.AETileEventHandler;
import appeng.tile.events.TileEventType;
import appeng.tile.grid.AENetworkTile;
import appeng.util.Platform;
import appeng.util.item.ItemList;
public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IPowerChannelState
{
+1 -1
View File
@@ -362,7 +362,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
if ( h == null )
return null;
MEInventoryHandler ih = new MEInventoryHandler( h, h.getChannel().type );
MEInventoryHandler ih = new MEInventoryHandler( h, h.getChannel() );
ih.myPriority = priority;
MEMonitorHandler<StackType> g = new ChestMonitorHandler<StackType>( ih );
+2 -3
View File
@@ -42,7 +42,6 @@ import appeng.util.IConfigManagerHost;
import appeng.util.InventoryAdaptor;
import appeng.util.Platform;
import appeng.util.inv.WrapperInventoryRange;
import appeng.util.item.ItemList;
public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IConfigManagerHost, IGridTickable
{
@@ -302,7 +301,7 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
if ( src instanceof IMEMonitor )
myList = ((IMEMonitor) src).getStorageList();
else
myList = src.getAvailableItems( new ItemList( src.getChannel().type ) );
myList = src.getAvailableItems( src.getChannel().createList() );
if ( fm == FullnessMode.EMPTY )
return myList.isEmpty();
@@ -341,7 +340,7 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
if ( src instanceof IMEMonitor )
myList = ((IMEMonitor) src).getStorageList();
else
myList = src.getAvailableItems( new ItemList( src.getChannel().type ) );
myList = src.getAvailableItems( src.getChannel().createList() );
boolean didStuff;
-1
View File
@@ -93,7 +93,6 @@ import appeng.me.helpers.AENetworkProxy;
import appeng.server.AccessType;
import appeng.util.item.AEItemStack;
import appeng.util.item.AESharedNBT;
import appeng.util.item.ItemList;
import appeng.util.item.OreHelper;
import appeng.util.item.OreRefrence;
import buildcraft.api.tools.IToolWrench;