Fortify ItemLists.

This commit is contained in:
AlgorithmX2 2014-02-21 14:36:40 -06:00
parent eb15bd3a68
commit cf6b0986fc
23 changed files with 93 additions and 66 deletions

2
api

@ -1 +1 @@
Subproject commit 7834e09f349699868a1074879a7a3902e3fd2bf4 Subproject commit 2fed92eaa8c7dd3434e6c0c20552c6fd2605959c

View file

@ -5,6 +5,7 @@ import java.util.Collections;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import appeng.api.AEApi;
import appeng.api.config.Settings; import appeng.api.config.Settings;
import appeng.api.config.SortOrder; import appeng.api.config.SortOrder;
import appeng.api.config.YesNo; import appeng.api.config.YesNo;
@ -15,14 +16,13 @@ import appeng.client.gui.widgets.ISortSource;
import appeng.core.AEConfig; import appeng.core.AEConfig;
import appeng.util.ItemSorters; import appeng.util.ItemSorters;
import appeng.util.Platform; import appeng.util.Platform;
import appeng.util.item.ItemList;
public class ItemRepo public class ItemRepo
{ {
final private IItemList<IAEItemStack> list = new ItemList(); final private IItemList<IAEItemStack> list = AEApi.instance().storage().createItemList();
final private ArrayList<IAEItemStack> view = new ArrayList(); final private ArrayList<IAEItemStack> view = new ArrayList<IAEItemStack>();
final private ArrayList<ItemStack> dsp = new ArrayList(); final private ArrayList<ItemStack> dsp = new ArrayList<ItemStack>();
final private IScrollSource src; final private IScrollSource src;
final private ISortSource sortSrc; final private ISortSource sortSrc;

View file

@ -22,7 +22,6 @@ import appeng.container.slot.SlotRestrictedInput.PlaceableItemType;
import appeng.tile.inventory.AppEngNullInventory; import appeng.tile.inventory.AppEngNullInventory;
import appeng.tile.misc.TileCellWorkbench; import appeng.tile.misc.TileCellWorkbench;
import appeng.util.Platform; import appeng.util.Platform;
import appeng.util.item.ItemList;
import appeng.util.iterators.NullIterator; import appeng.util.iterators.NullIterator;
public class ContainerCellWorkbench extends ContainerUpgradeable public class ContainerCellWorkbench extends ContainerUpgradeable
@ -268,7 +267,7 @@ public class ContainerCellWorkbench extends ContainerUpgradeable
Iterator<IAEItemStack> i = new NullIterator<IAEItemStack>(); Iterator<IAEItemStack> i = new NullIterator<IAEItemStack>();
if ( cellInv != null ) if ( cellInv != null )
{ {
IItemList<IAEItemStack> list = cellInv.getAvailableItems( new ItemList() ); IItemList<IAEItemStack> list = cellInv.getAvailableItems( AEApi.instance().storage().createItemList() );
i = list.iterator(); i = list.iterator();
} }

View file

@ -9,6 +9,7 @@ import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.ICrafting;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.AEApi;
import appeng.api.config.Settings; import appeng.api.config.Settings;
import appeng.api.config.SortDir; import appeng.api.config.SortDir;
import appeng.api.config.SortOrder; import appeng.api.config.SortOrder;
@ -36,13 +37,12 @@ import appeng.core.sync.packets.PacketValueConfig;
import appeng.util.ConfigManager; import appeng.util.ConfigManager;
import appeng.util.IConfigManagerHost; import appeng.util.IConfigManagerHost;
import appeng.util.Platform; import appeng.util.Platform;
import appeng.util.item.ItemList;
public class ContainerMEMonitorable extends AEBaseContainer implements IConfigManagerHost, IConfigureableObject, IMEMonitorHandlerReceiver<IAEItemStack> public class ContainerMEMonitorable extends AEBaseContainer implements IConfigManagerHost, IConfigureableObject, IMEMonitorHandlerReceiver<IAEItemStack>
{ {
final IMEMonitor<IAEItemStack> monitor; final IMEMonitor<IAEItemStack> monitor;
final IItemList<IAEItemStack> items = new ItemList<IAEItemStack>(); final IItemList<IAEItemStack> items = AEApi.instance().storage().createItemList();
IConfigManager serverCM; IConfigManager serverCM;
IConfigManager clientCM; IConfigManager clientCM;

View file

@ -34,9 +34,15 @@ public class ApiStorage implements IStorageHelper
} }
@Override @Override
public IItemList createItemList() public IItemList<IAEItemStack> createItemList()
{ {
return new ItemList(); return new ItemList( IAEItemStack.class);
}
@Override
public IItemList<IAEFluidStack> createFluidList()
{
return new ItemList( IAEFluidStack.class);
} }
@Override @Override

View file

@ -285,8 +285,8 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt
return patterns; return patterns;
} }
MEMonitorPassthu<IAEItemStack> items = new MEMonitorPassthu<IAEItemStack>( new NullInventory() ); MEMonitorPassthu<IAEItemStack> items = new MEMonitorPassthu<IAEItemStack>( new NullInventory(), IAEItemStack.class );
MEMonitorPassthu<IAEFluidStack> fluids = new MEMonitorPassthu<IAEFluidStack>( new NullInventory() ); MEMonitorPassthu<IAEFluidStack> fluids = new MEMonitorPassthu<IAEFluidStack>( new NullInventory(), IAEFluidStack.class );
public void gridChanged() public void gridChanged()
{ {

View file

@ -41,7 +41,6 @@ import appeng.items.tools.powered.powersink.AEBasePoweredItem;
import appeng.me.storage.CellInventory; import appeng.me.storage.CellInventory;
import appeng.me.storage.CellInventoryHandler; import appeng.me.storage.CellInventoryHandler;
import appeng.util.Platform; import appeng.util.Platform;
import appeng.util.item.ItemList;
public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
{ {
@ -84,7 +83,7 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
IMEInventory inv = AEApi.instance().registries().cell().getCellInventory( item, StorageChannel.ITEMS ); IMEInventory inv = AEApi.instance().registries().cell().getCellInventory( item, StorageChannel.ITEMS );
if ( inv != null ) if ( inv != null )
{ {
IItemList itemList = inv.getAvailableItems( new ItemList() ); IItemList itemList = inv.getAvailableItems( AEApi.instance().storage().createItemList() );
IAEStack aeammo = itemList.getFirstItem(); IAEStack aeammo = itemList.getFirstItem();
if ( aeammo instanceof IAEItemStack ) if ( aeammo instanceof IAEItemStack )
{ {

View file

@ -4,6 +4,7 @@ import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedList; import java.util.LinkedList;
import appeng.api.AEApi;
import appeng.api.networking.IGrid; import appeng.api.networking.IGrid;
import appeng.api.networking.IGridHost; import appeng.api.networking.IGridHost;
import appeng.api.networking.IGridNode; import appeng.api.networking.IGridNode;
@ -26,8 +27,6 @@ import appeng.api.storage.data.IAEStack;
import appeng.api.storage.data.IItemList; import appeng.api.storage.data.IItemList;
import appeng.me.storage.ItemWatcher; import appeng.me.storage.ItemWatcher;
import appeng.me.storage.NetworkInventoryHandler; import appeng.me.storage.NetworkInventoryHandler;
import appeng.util.item.ItemList;
import com.google.common.collect.HashMultimap; import com.google.common.collect.HashMultimap;
import com.google.common.collect.SetMultimap; import com.google.common.collect.SetMultimap;
@ -68,12 +67,12 @@ public class GridStorageCache implements IStorageGrid
for (IMEInventoryHandler<IAEItemStack> h : cc.getCellArray( StorageChannel.ITEMS )) for (IMEInventoryHandler<IAEItemStack> h : cc.getCellArray( StorageChannel.ITEMS ))
{ {
postChanges( StorageChannel.ITEMS, 1, h.getAvailableItems( new ItemList<IAEItemStack>() ), new MachineSource( cc ) ); postChanges( StorageChannel.ITEMS, 1, h.getAvailableItems( AEApi.instance().storage().createItemList() ), new MachineSource( cc ) );
} }
for (IMEInventoryHandler<IAEFluidStack> h : cc.getCellArray( StorageChannel.FLUIDS )) for (IMEInventoryHandler<IAEFluidStack> h : cc.getCellArray( StorageChannel.FLUIDS ))
{ {
postChanges( StorageChannel.FLUIDS, 1, h.getAvailableItems( new ItemList<IAEFluidStack>() ), new MachineSource( cc ) ); postChanges( StorageChannel.FLUIDS, 1, h.getAvailableItems( AEApi.instance().storage().createFluidList() ), new MachineSource( cc ) );
} }
} }
} }
@ -87,12 +86,12 @@ public class GridStorageCache implements IStorageGrid
for (IMEInventoryHandler<IAEItemStack> h : cc.getCellArray( StorageChannel.ITEMS )) for (IMEInventoryHandler<IAEItemStack> h : cc.getCellArray( StorageChannel.ITEMS ))
{ {
postChanges( StorageChannel.ITEMS, -1, h.getAvailableItems( new ItemList<IAEItemStack>() ), new MachineSource( cc ) ); postChanges( StorageChannel.ITEMS, -1, h.getAvailableItems( AEApi.instance().storage().createItemList() ), new MachineSource( cc ) );
} }
for (IMEInventoryHandler<IAEFluidStack> h : cc.getCellArray( StorageChannel.FLUIDS )) for (IMEInventoryHandler<IAEFluidStack> h : cc.getCellArray( StorageChannel.FLUIDS ))
{ {
postChanges( StorageChannel.FLUIDS, -1, h.getAvailableItems( new ItemList<IAEFluidStack>() ), new MachineSource( cc ) ); postChanges( StorageChannel.FLUIDS, -1, h.getAvailableItems( AEApi.instance().storage().createFluidList() ), new MachineSource( cc ) );
} }
} }
} }

View file

@ -9,6 +9,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.OreDictionary;
import appeng.api.AEApi;
import appeng.api.config.Actionable; import appeng.api.config.Actionable;
import appeng.api.config.FuzzyMode; import appeng.api.config.FuzzyMode;
import appeng.api.exceptions.AppEngException; import appeng.api.exceptions.AppEngException;
@ -21,7 +22,6 @@ import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList; import appeng.api.storage.data.IItemList;
import appeng.util.Platform; import appeng.util.Platform;
import appeng.util.item.AEItemStack; import appeng.util.item.AEItemStack;
import appeng.util.item.ItemList;
public class CellInventory implements IMEInventory<IAEItemStack> public class CellInventory implements IMEInventory<IAEItemStack>
{ {
@ -42,7 +42,7 @@ public class CellInventory implements IMEInventory<IAEItemStack>
protected int MAX_ITEM_TYPES = 63; protected int MAX_ITEM_TYPES = 63;
protected short storedItems = 0; protected short storedItems = 0;
protected int storedItemCount = 0; protected int storedItemCount = 0;
protected ItemList<IAEItemStack> cellItems; protected IItemList<IAEItemStack> cellItems;
protected ItemStack i; protected ItemStack i;
protected IStorageCell CellType; protected IStorageCell CellType;
@ -54,7 +54,7 @@ public class CellInventory implements IMEInventory<IAEItemStack>
protected void loadCellItems() protected void loadCellItems()
{ {
if ( cellItems == null ) if ( cellItems == null )
cellItems = new ItemList(); cellItems = AEApi.instance().storage().createItemList();
cellItems.resetStatus(); // clears totals and stuff. cellItems.resetStatus(); // clears totals and stuff.
@ -181,11 +181,11 @@ public class CellInventory implements IMEInventory<IAEItemStack>
cellItems = null; cellItems = null;
} }
ItemList<IAEItemStack> getCellItems() IItemList<IAEItemStack> getCellItems()
{ {
if ( cellItems == null ) if ( cellItems == null )
{ {
cellItems = new ItemList(); cellItems = AEApi.instance().storage().createItemList();
loadCellItems(); loadCellItems();
} }
@ -333,7 +333,7 @@ public class CellInventory implements IMEInventory<IAEItemStack>
private boolean isEmpty(IMEInventory meinv) private boolean isEmpty(IMEInventory meinv)
{ {
return meinv.getAvailableItems( new ItemList() ).isEmpty(); return meinv.getAvailableItems( AEApi.instance().storage().createItemList() ).isEmpty();
} }
@Override @Override

View file

@ -3,6 +3,7 @@ package appeng.me.storage;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import appeng.api.AEApi;
import appeng.api.config.FuzzyMode; import appeng.api.config.FuzzyMode;
import appeng.api.config.IncludeExclude; import appeng.api.config.IncludeExclude;
import appeng.api.config.Upgrades; import appeng.api.config.Upgrades;
@ -12,7 +13,6 @@ import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList; import appeng.api.storage.data.IItemList;
import appeng.util.Platform; import appeng.util.Platform;
import appeng.util.item.AEItemStack; import appeng.util.item.AEItemStack;
import appeng.util.item.ItemList;
import appeng.util.prioitylist.FuzzyPriorityList; import appeng.util.prioitylist.FuzzyPriorityList;
import appeng.util.prioitylist.PrecisePriorityList; import appeng.util.prioitylist.PrecisePriorityList;
@ -35,12 +35,12 @@ public class CellInventoryHandler extends MEInventoryHandler<IAEItemStack>
} }
CellInventoryHandler(IMEInventory c) { CellInventoryHandler(IMEInventory c) {
super( c ); super( c, IAEItemStack.class );
CellInventory ci = getCellInv(); CellInventory ci = getCellInv();
if ( ci != null ) if ( ci != null )
{ {
IItemList priorityList = new ItemList(); IItemList<IAEItemStack> priorityList = AEApi.instance().storage().createItemList();
IInventory upgrades = ci.getUpgradesInventory(); IInventory upgrades = ci.getUpgradesInventory();
IInventory config = ci.getConfigInventory(); IInventory config = ci.getConfigInventory();

View file

@ -1,6 +1,7 @@
package appeng.me.storage; package appeng.me.storage;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import appeng.api.AEApi;
import appeng.api.config.AccessRestriction; import appeng.api.config.AccessRestriction;
import appeng.api.config.Actionable; import appeng.api.config.Actionable;
import appeng.api.exceptions.AppEngException; import appeng.api.exceptions.AppEngException;
@ -11,12 +12,11 @@ import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList; import appeng.api.storage.data.IItemList;
import appeng.items.contents.CellConfig; import appeng.items.contents.CellConfig;
import appeng.util.item.AEItemStack; import appeng.util.item.AEItemStack;
import appeng.util.item.ItemList;
public class CreativeCellInventory implements IMEInventoryHandler<IAEItemStack> public class CreativeCellInventory implements IMEInventoryHandler<IAEItemStack>
{ {
ItemList<IAEItemStack> itemListCache = new ItemList(); IItemList<IAEItemStack> itemListCache = AEApi.instance().storage().createItemList();
public static IMEInventoryHandler getCell(ItemStack o) public static IMEInventoryHandler getCell(ItemStack o)
{ {

View file

@ -17,7 +17,7 @@ public class DriveWatcher<T extends IAEStack<T>> extends MEInventoryHandler<T>
final IChestOrDrive cord; final IChestOrDrive cord;
public DriveWatcher(IMEInventory<T> i, ItemStack is, ICellHandler han, IChestOrDrive cod) { public DriveWatcher(IMEInventory<T> i, ItemStack is, ICellHandler han, IChestOrDrive cod) {
super( i ); super( i, i.getChannel().type );
this.is = is; this.is = is;
handler = han; handler = han;
cord = cod; cord = cod;

View file

@ -16,19 +16,22 @@ import appeng.util.prioitylist.IPartitionList;
public class MEInventoryHandler<T extends IAEStack<T>> implements IMEInventoryHandler<T> public class MEInventoryHandler<T extends IAEStack<T>> implements IMEInventoryHandler<T>
{ {
Class<? extends IAEStack> clz;
final protected IMEMonitor<T> monitor; final protected IMEMonitor<T> monitor;
final protected IMEInventoryHandler<T> internal; final protected IMEInventoryHandler<T> internal;
public int myPriority = 0; public int myPriority = 0;
public IncludeExclude myWhitelist = IncludeExclude.WHITELIST; public IncludeExclude myWhitelist = IncludeExclude.WHITELIST;
public AccessRestriction myAccess = AccessRestriction.READ_WRITE; public AccessRestriction myAccess = AccessRestriction.READ_WRITE;
public IPartitionList<T> myPartitionList = new DefaultPriorityList(); public IPartitionList<T> myPartitionList = new DefaultPriorityList<T>();
public MEInventoryHandler(IMEInventory<T> i,Class<? extends IAEStack> cla) {
clz = cla;
public MEInventoryHandler(IMEInventory<T> i) {
if ( i instanceof IMEInventoryHandler ) if ( i instanceof IMEInventoryHandler )
internal = (IMEInventoryHandler<T>) i; internal = (IMEInventoryHandler<T>) i;
else else
internal = new MEPassthru<T>( i ); internal = new MEPassthru<T>( i,clz );
monitor = internal instanceof IMEMonitor ? (IMEMonitor<T>) internal : null; monitor = internal instanceof IMEMonitor ? (IMEMonitor<T>) internal : null;
} }
@ -52,7 +55,7 @@ public class MEInventoryHandler<T extends IAEStack<T>> implements IMEInventoryHa
} }
@Override @Override
public IItemList<T> getAvailableItems(IItemList out) public IItemList<T> getAvailableItems(IItemList<T> out)
{ {
if ( !getAccess().hasPermission( AccessRestriction.READ ) ) if ( !getAccess().hasPermission( AccessRestriction.READ ) )
return out; return out;
@ -105,7 +108,7 @@ public class MEInventoryHandler<T extends IAEStack<T>> implements IMEInventoryHa
return internal.getSlot(); return internal.getSlot();
} }
public IMEInventory getInternal() public IMEInventory<T> getInternal()
{ {
return internal; return internal;
} }

View file

@ -23,7 +23,6 @@ import appeng.util.InventoryAdaptor;
import appeng.util.Platform; import appeng.util.Platform;
import appeng.util.inv.ItemSlot; import appeng.util.inv.ItemSlot;
import appeng.util.item.AEItemStack; import appeng.util.item.AEItemStack;
import appeng.util.item.ItemList;
public class MEMonitorIInventory implements IMEInventory<IAEItemStack>, IMEMonitor<IAEItemStack> public class MEMonitorIInventory implements IMEInventory<IAEItemStack>, IMEMonitor<IAEItemStack>
{ {
@ -53,7 +52,7 @@ public class MEMonitorIInventory implements IMEInventory<IAEItemStack>, IMEMonit
final InventoryAdaptor adaptor; final InventoryAdaptor adaptor;
final TreeMap<Integer, CachedItemStack> memory; final TreeMap<Integer, CachedItemStack> memory;
final IItemList<IAEItemStack> list = new ItemList(); final IItemList<IAEItemStack> list = AEApi.instance().storage().createItemList();
final HashMap<IMEMonitorHandlerReceiver<IAEItemStack>, Object> listeners = new HashMap(); final HashMap<IMEMonitorHandlerReceiver<IAEItemStack>, Object> listeners = new HashMap();
public BaseActionSource mySource; public BaseActionSource mySource;

View file

@ -21,8 +21,8 @@ public class MEMonitorPassthu<T extends IAEStack<T>> extends MEPassthru<T> imple
public BaseActionSource changeSource; public BaseActionSource changeSource;
public MEMonitorPassthu(IMEInventory<T> i) { public MEMonitorPassthu(IMEInventory<T> i, Class<? extends IAEStack> cla) {
super( i ); super( i,cla );
if ( i instanceof IMEMonitor ) if ( i instanceof IMEMonitor )
monitor = (IMEMonitor<T>) i; monitor = (IMEMonitor<T>) i;
} }
@ -34,13 +34,13 @@ public class MEMonitorPassthu<T extends IAEStack<T>> extends MEPassthru<T> imple
monitor.removeListener( this ); monitor.removeListener( this );
monitor = null; monitor = null;
IItemList<T> before = getInternal() == null ? new ItemList() : getInternal().getAvailableItems( new ItemList() ); IItemList<T> before = getInternal() == null ? new ItemList(clz) : getInternal().getAvailableItems( new ItemList(clz) );
super.setInternal( i ); super.setInternal( i );
if ( i instanceof IMEMonitor ) if ( i instanceof IMEMonitor )
monitor = (IMEMonitor<T>) i; monitor = (IMEMonitor<T>) i;
IItemList<T> after = getInternal() == null ? new ItemList() : getInternal().getAvailableItems( new ItemList() ); IItemList<T> after = getInternal() == null ? new ItemList(clz) : getInternal().getAvailableItems( new ItemList(clz) );
if ( monitor != null ) if ( monitor != null )
monitor.addListener( this, monitor ); monitor.addListener( this, monitor );
@ -64,7 +64,7 @@ public class MEMonitorPassthu<T extends IAEStack<T>> extends MEPassthru<T> imple
public IItemList<T> getStorageList() public IItemList<T> getStorageList()
{ {
if ( monitor == null ) if ( monitor == null )
return getInternal().getAvailableItems( new ItemList<T>() ); return getInternal().getAvailableItems( new ItemList<T>(clz) );
return monitor.getStorageList(); return monitor.getStorageList();
} }

View file

@ -12,6 +12,7 @@ import appeng.api.storage.data.IItemList;
public class MEPassthru<T extends IAEStack<T>> implements IMEInventoryHandler<T> public class MEPassthru<T extends IAEStack<T>> implements IMEInventoryHandler<T>
{ {
Class<? extends IAEStack> clz;
private IMEInventory<T> internal; private IMEInventory<T> internal;
protected IMEInventory<T> getInternal() protected IMEInventory<T> getInternal()
@ -19,8 +20,9 @@ public class MEPassthru<T extends IAEStack<T>> implements IMEInventoryHandler<T>
return internal; return internal;
} }
public MEPassthru(IMEInventory<T> i) { public MEPassthru(IMEInventory<T> i,Class<? extends IAEStack> cla) {
setInternal( i ); setInternal( i );
clz = cla;
} }
public void setInternal(IMEInventory<T> i) public void setInternal(IMEInventory<T> i)

View file

@ -19,7 +19,7 @@ public class SecurityInventory implements IMEInventoryHandler<IAEItemStack>
{ {
final TileSecurity securityTile; final TileSecurity securityTile;
final public IItemList<IAEItemStack> storedItems = new ItemList(); final public IItemList<IAEItemStack> storedItems = new ItemList(IAEItemStack.class);
public SecurityInventory(TileSecurity ts) { public SecurityInventory(TileSecurity ts) {
securityTile = ts; securityTile = ts;

View file

@ -17,6 +17,7 @@ import net.minecraft.world.WorldServer;
import net.minecraft.world.chunk.Chunk; import net.minecraft.world.chunk.Chunk;
import net.minecraftforge.common.IPlantable; import net.minecraftforge.common.IPlantable;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.AEApi;
import appeng.api.config.AccessRestriction; import appeng.api.config.AccessRestriction;
import appeng.api.config.Actionable; import appeng.api.config.Actionable;
import appeng.api.config.FuzzyMode; import appeng.api.config.FuzzyMode;
@ -47,7 +48,6 @@ import appeng.me.storage.MEInventoryHandler;
import appeng.tile.inventory.AppEngInternalAEInventory; import appeng.tile.inventory.AppEngInternalAEInventory;
import appeng.tile.inventory.InvOperation; import appeng.tile.inventory.InvOperation;
import appeng.util.Platform; import appeng.util.Platform;
import appeng.util.item.ItemList;
import appeng.util.prioitylist.FuzzyPriorityList; import appeng.util.prioitylist.FuzzyPriorityList;
import appeng.util.prioitylist.PrecisePriorityList; import appeng.util.prioitylist.PrecisePriorityList;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
@ -59,7 +59,7 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
int priority = 0; int priority = 0;
boolean wasActive = false; boolean wasActive = false;
boolean blocked = false; boolean blocked = false;
MEInventoryHandler myHandler = new MEInventoryHandler( this ); MEInventoryHandler myHandler = new MEInventoryHandler( this, IAEItemStack.class );
AppEngInternalAEInventory Config = new AppEngInternalAEInventory( this, 63 ); AppEngInternalAEInventory Config = new AppEngInternalAEInventory( this, 63 );
public PartFormationPlane(ItemStack is) { public PartFormationPlane(ItemStack is) {
@ -271,7 +271,7 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
myHandler.myWhitelist = getInstalledUpgrades( Upgrades.INVERTER ) > 0 ? IncludeExclude.BLACKLIST : IncludeExclude.WHITELIST; myHandler.myWhitelist = getInstalledUpgrades( Upgrades.INVERTER ) > 0 ? IncludeExclude.BLACKLIST : IncludeExclude.WHITELIST;
myHandler.myPriority = priority; myHandler.myPriority = priority;
IItemList priorityList = new ItemList(); IItemList<IAEItemStack> priorityList = AEApi.instance().storage().createItemList();
int slotsToUse = 18 + getInstalledUpgrades( Upgrades.CAPACITY ) * 9; int slotsToUse = 18 + getInstalledUpgrades( Upgrades.CAPACITY ) * 9;
for (int x = 0; x < Config.getSizeInventory() && x < slotsToUse; x++) for (int x = 0; x < Config.getSizeInventory() && x < slotsToUse; x++)

View file

@ -49,7 +49,6 @@ import appeng.parts.automation.PartUpgradeable;
import appeng.tile.inventory.AppEngInternalAEInventory; import appeng.tile.inventory.AppEngInternalAEInventory;
import appeng.tile.inventory.InvOperation; import appeng.tile.inventory.InvOperation;
import appeng.util.Platform; import appeng.util.Platform;
import appeng.util.item.ItemList;
import appeng.util.prioitylist.FuzzyPriorityList; import appeng.util.prioitylist.FuzzyPriorityList;
import appeng.util.prioitylist.PrecisePriorityList; import appeng.util.prioitylist.PrecisePriorityList;
import buildcraft.api.transport.IPipeConnection; import buildcraft.api.transport.IPipeConnection;
@ -216,13 +215,13 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
if ( inv != null ) if ( inv != null )
{ {
handler = new MEInventoryHandler( inv ); handler = new MEInventoryHandler( inv, IAEItemStack.class );
handler.myAccess = (AccessRestriction) this.getConfigManager().getSetting( Settings.ACCESS ); handler.myAccess = (AccessRestriction) this.getConfigManager().getSetting( Settings.ACCESS );
handler.myWhitelist = getInstalledUpgrades( Upgrades.INVERTER ) > 0 ? IncludeExclude.BLACKLIST : IncludeExclude.WHITELIST; handler.myWhitelist = getInstalledUpgrades( Upgrades.INVERTER ) > 0 ? IncludeExclude.BLACKLIST : IncludeExclude.WHITELIST;
handler.myPriority = priority; handler.myPriority = priority;
IItemList priorityList = new ItemList(); IItemList<IAEItemStack> priorityList = AEApi.instance().storage().createItemList();
int slotsToUse = 18 + getInstalledUpgrades( Upgrades.CAPACITY ) * 9; int slotsToUse = 18 + getInstalledUpgrades( Upgrades.CAPACITY ) * 9;
for (int x = 0; x < Config.getSizeInventory() && x < slotsToUse; x++) for (int x = 0; x < Config.getSizeInventory() && x < slotsToUse; x++)

View file

@ -336,7 +336,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
if ( h == null ) if ( h == null )
return null; return null;
MEInventoryHandler ih = new MEInventoryHandler( h ); MEInventoryHandler ih = new MEInventoryHandler( h, h.getChannel().type );
ih.myPriority = priority; ih.myPriority = priority;
MEMonitorHandler<StackType> g = new ChestMonitorHandler<StackType>( ih ); MEMonitorHandler<StackType> g = new ChestMonitorHandler<StackType>( ih );

View file

@ -301,7 +301,7 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
if ( src instanceof IMEMonitor ) if ( src instanceof IMEMonitor )
myList = ((IMEMonitor) src).getStorageList(); myList = ((IMEMonitor) src).getStorageList();
else else
myList = src.getAvailableItems( new ItemList() ); myList = src.getAvailableItems( new ItemList( src.getChannel().type ) );
if ( fm == FullnessMode.EMPTY ) if ( fm == FullnessMode.EMPTY )
return myList.isEmpty(); return myList.isEmpty();
@ -340,7 +340,7 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
if ( src instanceof IMEMonitor ) if ( src instanceof IMEMonitor )
myList = ((IMEMonitor) src).getStorageList(); myList = ((IMEMonitor) src).getStorageList();
else else
myList = src.getAvailableItems( new ItemList() ); myList = src.getAvailableItems( new ItemList( src.getChannel().type ) );
boolean didStuff; boolean didStuff;

View file

@ -1306,7 +1306,7 @@ public class Platform
if ( myItems != null ) if ( myItems != null )
{ {
for (IAEItemStack is : myItems.getAvailableItems( new ItemList() )) for (IAEItemStack is : myItems.getAvailableItems( AEApi.instance().storage().createItemList() ))
{ {
is.setStackSize( -is.getStackSize() ); is.setStackSize( -is.getStackSize() );
gs.postAlterationOfStoredItems( StorageChannel.ITEMS, is, src ); gs.postAlterationOfStoredItems( StorageChannel.ITEMS, is, src );
@ -1317,7 +1317,7 @@ public class Platform
if ( myFluids != null ) if ( myFluids != null )
{ {
for (IAEFluidStack is : myFluids.getAvailableItems( new ItemList() )) for (IAEFluidStack is : myFluids.getAvailableItems( AEApi.instance().storage().createFluidList() ))
{ {
is.setStackSize( -is.getStackSize() ); is.setStackSize( -is.getStackSize() );
gs.postAlterationOfStoredItems( StorageChannel.ITEMS, is, src ); gs.postAlterationOfStoredItems( StorageChannel.ITEMS, is, src );
@ -1331,7 +1331,7 @@ public class Platform
if ( myItems != null ) if ( myItems != null )
{ {
for (IAEItemStack is : myItems.getAvailableItems( new ItemList() )) for (IAEItemStack is : myItems.getAvailableItems( new ItemList(IAEItemStack.class) ))
{ {
gs.postAlterationOfStoredItems( StorageChannel.ITEMS, is, src ); gs.postAlterationOfStoredItems( StorageChannel.ITEMS, is, src );
} }
@ -1341,7 +1341,7 @@ public class Platform
if ( myFluids != null ) if ( myFluids != null )
{ {
for (IAEFluidStack is : myFluids.getAvailableItems( new ItemList() )) for (IAEFluidStack is : myFluids.getAvailableItems( new ItemList(IAEFluidStack.class) ))
{ {
gs.postAlterationOfStoredItems( StorageChannel.ITEMS, is, src ); gs.postAlterationOfStoredItems( StorageChannel.ITEMS, is, src );
} }

View file

@ -1,5 +1,6 @@
package appeng.util.item; package appeng.util.item;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Iterator; import java.util.Iterator;
@ -18,15 +19,32 @@ public final class ItemList<StackType extends IAEStack> implements IItemList<Sta
{ {
private final TreeMap<StackType, StackType> records = new TreeMap(); private final TreeMap<StackType, StackType> records = new TreeMap();
private final Class<? extends IAEStack> clz;
// private int currentPriority = Integer.MIN_VALUE; // private int currentPriority = Integer.MIN_VALUE;
int iteration = Integer.MIN_VALUE; int iteration = Integer.MIN_VALUE;
public Throwable stacktrace; public Throwable stacktrace;
public ItemList( Class<? extends IAEStack> cla) {
clz = cla;
}
private boolean checkStackType( StackType st )
{
if ( st == null)
return true;
if ( !clz.isInstance(st) )
throw new RuntimeException("WRONG TYPE - got "+st.getClass().getName()+" expected "+clz.getName() );
return false;
}
@Override @Override
synchronized public void add(StackType option) synchronized public void add(StackType option)
{ {
if ( option == null ) if ( checkStackType( option ) )
return; return;
StackType st = records.get( option ); StackType st = records.get( option );
@ -47,7 +65,7 @@ public final class ItemList<StackType extends IAEStack> implements IItemList<Sta
synchronized public void addStorage(StackType option) // adds a stack as synchronized public void addStorage(StackType option) // adds a stack as
// stored. // stored.
{ {
if ( option == null ) if ( checkStackType( option ) )
return; return;
StackType st = records.get( option ); StackType st = records.get( option );
@ -68,7 +86,7 @@ public final class ItemList<StackType extends IAEStack> implements IItemList<Sta
synchronized public void addCrafting(StackType option) // adds a stack as synchronized public void addCrafting(StackType option) // adds a stack as
// craftable. // craftable.
{ {
if ( option == null ) if ( checkStackType( option ) )
return; return;
StackType st = records.get( option ); StackType st = records.get( option );
@ -93,7 +111,7 @@ public final class ItemList<StackType extends IAEStack> implements IItemList<Sta
// as // as
// requestable. // requestable.
{ {
if ( option == null ) if ( checkStackType( option ) )
return; return;
StackType st = records.get( option ); StackType st = records.get( option );
@ -144,7 +162,7 @@ public final class ItemList<StackType extends IAEStack> implements IItemList<Sta
@Override @Override
synchronized public StackType findPrecise(StackType i) synchronized public StackType findPrecise(StackType i)
{ {
if ( i == null ) if ( checkStackType( i ) )
return null; return null;
StackType is = records.get( i ); StackType is = records.get( i );
@ -178,6 +196,9 @@ public final class ItemList<StackType extends IAEStack> implements IItemList<Sta
@Override @Override
public Collection<StackType> findFuzzy(StackType filter, FuzzyMode fuzzy) public Collection<StackType> findFuzzy(StackType filter, FuzzyMode fuzzy)
{ {
if ( checkStackType( filter ) )
return new ArrayList();
if ( filter instanceof IAEFluidStack ) if ( filter instanceof IAEFluidStack )
return filter.equals( this ) ? (List<StackType>) Arrays.asList( new IAEFluidStack[] { (IAEFluidStack) filter } ) : (List<StackType>) Arrays return filter.equals( this ) ? (List<StackType>) Arrays.asList( new IAEFluidStack[] { (IAEFluidStack) filter } ) : (List<StackType>) Arrays
.asList( new IAEFluidStack[] {} ); .asList( new IAEFluidStack[] {} );