Interfaces now filter additions to hide crafting from super-nets.
This commit is contained in:
parent
3f29590fad
commit
3ef02cb485
2 changed files with 105 additions and 3 deletions
|
@ -12,6 +12,7 @@ import appeng.api.storage.IMEMonitorHandlerReceiver;
|
||||||
import appeng.api.storage.data.IAEStack;
|
import appeng.api.storage.data.IAEStack;
|
||||||
import appeng.api.storage.data.IItemList;
|
import appeng.api.storage.data.IItemList;
|
||||||
import appeng.util.Platform;
|
import appeng.util.Platform;
|
||||||
|
import appeng.util.inv.ItemListIgnoreCrafting;
|
||||||
import appeng.util.item.ItemList;
|
import appeng.util.item.ItemList;
|
||||||
|
|
||||||
public class MEMonitorPassthu<T extends IAEStack<T>> extends MEPassthru<T> implements IMEMonitor<T>, IMEMonitorHandlerReceiver<T>
|
public class MEMonitorPassthu<T extends IAEStack<T>> extends MEPassthru<T> implements IMEMonitor<T>, IMEMonitorHandlerReceiver<T>
|
||||||
|
@ -35,13 +36,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( clz ) : getInternal().getAvailableItems( new ItemList( clz ) );
|
IItemList<T> before = getInternal() == null ? new ItemList( clz ) : getInternal().getAvailableItems( new ItemListIgnoreCrafting( 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( clz ) : getInternal().getAvailableItems( new ItemList( clz ) );
|
IItemList<T> after = getInternal() == null ? new ItemList( clz ) : getInternal().getAvailableItems( new ItemListIgnoreCrafting( new ItemList( clz ) ) );
|
||||||
|
|
||||||
if ( monitor != null )
|
if ( monitor != null )
|
||||||
monitor.addListener( this, monitor );
|
monitor.addListener( this, monitor );
|
||||||
|
@ -49,6 +50,13 @@ public class MEMonitorPassthu<T extends IAEStack<T>> extends MEPassthru<T> imple
|
||||||
Platform.postListChanges( before, after, this, changeSource );
|
Platform.postListChanges( before, after, this, changeSource );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IItemList<T> getAvailableItems(IItemList out)
|
||||||
|
{
|
||||||
|
super.getAvailableItems( new ItemListIgnoreCrafting( out ) );
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addListener(IMEMonitorHandlerReceiver<T> l, Object verificationToken)
|
public void addListener(IMEMonitorHandlerReceiver<T> l, Object verificationToken)
|
||||||
{
|
{
|
||||||
|
@ -65,7 +73,11 @@ 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>( clz ) );
|
{
|
||||||
|
IItemList<T> out = new ItemList( clz );
|
||||||
|
getInternal().getAvailableItems( new ItemListIgnoreCrafting( out ) );
|
||||||
|
return out;
|
||||||
|
}
|
||||||
return monitor.getStorageList();
|
return monitor.getStorageList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
90
util/inv/ItemListIgnoreCrafting.java
Normal file
90
util/inv/ItemListIgnoreCrafting.java
Normal file
|
@ -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<T extends IAEStack> implements IItemList<T>
|
||||||
|
{
|
||||||
|
|
||||||
|
final IItemList<T> target;
|
||||||
|
|
||||||
|
public ItemListIgnoreCrafting(IItemList<T> 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<T> 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<T> iterator()
|
||||||
|
{
|
||||||
|
return target.iterator();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void resetStatus()
|
||||||
|
{
|
||||||
|
target.resetStatus();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue