diff --git a/me/storage/MEMonitorPassthu.java b/me/storage/MEMonitorPassthu.java index 65eff4cf..ba29a0f4 100644 --- a/me/storage/MEMonitorPassthu.java +++ b/me/storage/MEMonitorPassthu.java @@ -12,6 +12,7 @@ import appeng.api.storage.IMEMonitorHandlerReceiver; 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> extends MEPassthru implements IMEMonitor, IMEMonitorHandlerReceiver @@ -35,13 +36,13 @@ public class MEMonitorPassthu> extends MEPassthru imple monitor.removeListener( this ); monitor = null; - IItemList before = getInternal() == null ? new ItemList( clz ) : getInternal().getAvailableItems( new ItemList( clz ) ); + IItemList before = getInternal() == null ? new ItemList( clz ) : getInternal().getAvailableItems( new ItemListIgnoreCrafting( new ItemList( clz ) ) ); super.setInternal( i ); if ( i instanceof IMEMonitor ) monitor = (IMEMonitor) i; - IItemList after = getInternal() == null ? new ItemList( clz ) : getInternal().getAvailableItems( new ItemList( clz ) ); + IItemList after = getInternal() == null ? new ItemList( clz ) : getInternal().getAvailableItems( new ItemListIgnoreCrafting( new ItemList( clz ) ) ); if ( monitor != null ) monitor.addListener( this, monitor ); @@ -49,6 +50,13 @@ public class MEMonitorPassthu> extends MEPassthru imple Platform.postListChanges( before, after, this, changeSource ); } + @Override + public IItemList getAvailableItems(IItemList out) + { + super.getAvailableItems( new ItemListIgnoreCrafting( out ) ); + return out; + } + @Override public void addListener(IMEMonitorHandlerReceiver l, Object verificationToken) { @@ -65,7 +73,11 @@ public class MEMonitorPassthu> extends MEPassthru imple public IItemList getStorageList() { if ( monitor == null ) - return getInternal().getAvailableItems( new ItemList( clz ) ); + { + IItemList out = new ItemList( clz ); + getInternal().getAvailableItems( new ItemListIgnoreCrafting( out ) ); + return out; + } return monitor.getStorageList(); } diff --git a/util/inv/ItemListIgnoreCrafting.java b/util/inv/ItemListIgnoreCrafting.java new file mode 100644 index 00000000..34e0c7ee --- /dev/null +++ b/util/inv/ItemListIgnoreCrafting.java @@ -0,0 +1,90 @@ +package appeng.util.inv; + +import java.util.Collection; +import java.util.Iterator; + +import appeng.api.config.FuzzyMode; +import appeng.api.storage.data.IAEStack; +import appeng.api.storage.data.IItemList; + +public class ItemListIgnoreCrafting implements IItemList +{ + + final IItemList target; + + public ItemListIgnoreCrafting(IItemList cla) { + target = cla; + } + + @Override + public void add(T option) + { + if ( option.isCraftable() ) + { + option = (T) option.copy(); + option.setCraftable( false ); + } + + target.add( option ); + } + + @Override + public void addCrafting(T option) + { + // nothing. + } + + @Override + public T findPrecise(T i) + { + return target.findPrecise( i ); + } + + @Override + public Collection findFuzzy(T input, FuzzyMode fuzzy) + { + return target.findFuzzy( input, fuzzy ); + } + + @Override + public boolean isEmpty() + { + return target.isEmpty(); + } + + @Override + public void addStorage(T option) + { + target.addStorage( option ); + } + + @Override + public void addRequestable(T option) + { + target.addRequestable( option ); + } + + @Override + public T getFirstItem() + { + return target.getFirstItem(); + } + + @Override + public int size() + { + return target.size(); + } + + @Override + public Iterator iterator() + { + return target.iterator(); + } + + @Override + public void resetStatus() + { + target.resetStatus(); + } +}