implement patterned input-based blocking mode
remove GTCE-specific handler and adaptor
This commit is contained in:
@@ -148,7 +148,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
|||||||
private IMEInventory<IAEItemStack> destination;
|
private IMEInventory<IAEItemStack> destination;
|
||||||
private int isWorking = -1;
|
private int isWorking = -1;
|
||||||
private final Accessor accessor = new Accessor();
|
private final Accessor accessor = new Accessor();
|
||||||
private GTCEInventoryAdaptor GTad;
|
private EnumSet<EnumFacing> visitedFaces = EnumSet.noneOf( EnumFacing.class );
|
||||||
|
|
||||||
public DualityInterface( final AENetworkProxy networkProxy, final IInterfaceHost ih )
|
public DualityInterface( final AENetworkProxy networkProxy, final IInterfaceHost ih )
|
||||||
{
|
{
|
||||||
@@ -913,18 +913,22 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean invIsBlocked( InventoryAdaptor inv )
|
private boolean invIsBlocked( InventoryAdaptor inv )
|
||||||
{
|
{
|
||||||
if( AEConfig.instance().isFeatureEnabled( AEFeature.INSANE_BLOCKING_MODE ) )
|
final Iterator<ICraftingPatternDetails> i = this.craftingList.iterator();
|
||||||
|
ICraftingPatternDetails patt = i.next();
|
||||||
|
for ( ItemSlot itemSlot : inv)
|
||||||
{
|
{
|
||||||
return !inv.simulateRemove( 1, ItemStack.EMPTY, null ).isEmpty();
|
if (itemSlot.getItemStack().isEmpty()){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for ( IAEItemStack iaeItemStack : patt.getCondensedInputs()){
|
||||||
|
if (iaeItemStack.isSameType( itemSlot.getItemStack() )){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else return inv.containsItems();
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean invIsBlockedGTCE( GTCEInventoryAdaptor inv )
|
|
||||||
{
|
|
||||||
return ( !inv.canRemoveAllExceptCircuits() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -975,22 +979,12 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
|||||||
{
|
{
|
||||||
if( this.isBlocking() )
|
if( this.isBlocking() )
|
||||||
{
|
{
|
||||||
if( te.getBlockType().getRegistryName().getResourceDomain().equals( "gregtech" ) )
|
if( invIsBlocked( ad ) )
|
||||||
{
|
{
|
||||||
GTad = GTCEInventoryAdaptor.getAdaptor( te, s.getOpposite() );
|
continue;
|
||||||
if( invIsBlockedGTCE( GTad ) )
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if( invIsBlocked( ad ) )
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if( this.acceptsItems( ad, table ) )
|
if( this.acceptsItems( ad, table ) )
|
||||||
{
|
{
|
||||||
@@ -1037,23 +1031,10 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
|||||||
final InventoryAdaptor ad = InventoryAdaptor.getAdaptor( te, s.getOpposite() );
|
final InventoryAdaptor ad = InventoryAdaptor.getAdaptor( te, s.getOpposite() );
|
||||||
if( ad != null )
|
if( ad != null )
|
||||||
{
|
{
|
||||||
if( te.getBlockType().getRegistryName().getResourceDomain().equals( "gregtech" ) )
|
if( !invIsBlocked( ad ) )
|
||||||
{
|
{
|
||||||
GTad = GTCEInventoryAdaptor.getAdaptor( te, s.getOpposite() );
|
allAreBusy = false;
|
||||||
if( !invIsBlockedGTCE( GTad ) )
|
break;
|
||||||
{
|
|
||||||
allAreBusy = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if( !invIsBlocked( ad ) )
|
|
||||||
{
|
|
||||||
allAreBusy = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
package appeng.integration.modules.gregtech;
|
|
||||||
|
|
||||||
import appeng.util.inv.ItemSlot;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraft.util.EnumFacing;
|
|
||||||
import net.minecraftforge.items.CapabilityItemHandler;
|
|
||||||
import net.minecraftforge.items.IItemHandler;
|
|
||||||
|
|
||||||
public abstract class GTCEInventoryAdaptor implements Iterable<ItemSlot>
|
|
||||||
{
|
|
||||||
public static GTCEInventoryAdaptor getAdaptor(final TileEntity te, final EnumFacing d)
|
|
||||||
{
|
|
||||||
if (te != null && te.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, d))
|
|
||||||
{
|
|
||||||
// Attempt getting an IItemHandler for the given side via caps
|
|
||||||
IItemHandler itemHandler = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, d);
|
|
||||||
if (itemHandler != null)
|
|
||||||
{
|
|
||||||
return new GTCEItemHandler(itemHandler);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract boolean canRemoveAllExceptCircuits();
|
|
||||||
}
|
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
package appeng.integration.modules.gregtech;
|
|
||||||
|
|
||||||
import appeng.util.inv.ItemSlot;
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraftforge.items.IItemHandler;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Iterator;
|
|
||||||
|
|
||||||
public class GTCEItemHandler extends GTCEInventoryAdaptor
|
|
||||||
{
|
|
||||||
ArrayList<Integer> GTCElenses = new ArrayList<>(Arrays.asList(15085,15214,15092,15111,15113,15219,15218,15243,15244,15209,15117,15206,15216,15331,15212,15213,15154,15122,15157,15190,15247));
|
|
||||||
ArrayList<Integer> GTCEmolds = new ArrayList<>(Arrays.asList(32301,32303,32304,32305,32306,32307,32308,32309,32313,32314,32315,32317,32350,32351,32352,32353,32354,32355,32356,32358,32359,32360,32361,32363,32364,32365,32366,32367,32368,32369,32370,32371,32372,32373));
|
|
||||||
Item smallGearExtruderShape = Item.getByNameOrId("contenttweaker:smallgearextrudershape");
|
|
||||||
Item creativePortableTankMold = Item.getByNameOrId("contenttweaker:creativeportabletankmold");
|
|
||||||
|
|
||||||
protected final IItemHandler itemHandler;
|
|
||||||
|
|
||||||
public GTCEItemHandler(IItemHandler itemHandler)
|
|
||||||
{
|
|
||||||
this.itemHandler = itemHandler;
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean isBlockableItem(ItemStack stack)
|
|
||||||
{
|
|
||||||
if ( stack.getItem() == Item.getByNameOrId("gregtech:meta_item_1") ) {
|
|
||||||
int metadata = stack.getItemDamage();
|
|
||||||
if ( metadata == 32766 || GTCElenses.contains(metadata) || GTCEmolds.contains(metadata)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( stack.getItem() == smallGearExtruderShape ) return false;
|
|
||||||
if ( stack.getItem() == creativePortableTankMold) return false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canRemoveAllExceptCircuits()
|
|
||||||
{
|
|
||||||
int slots = this.itemHandler.getSlots();
|
|
||||||
for ( int slot = 0; slot < slots; slot++ ) {
|
|
||||||
ItemStack is = this.itemHandler.getStackInSlot(slot);
|
|
||||||
if ( is.isEmpty() || !isBlockableItem(is) ) continue;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Iterator<ItemSlot> iterator()
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user