Re-do Blocking mode logic
This commit is contained in:
@@ -46,6 +46,7 @@ import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.wrapper.RangedWrapper;
|
||||
@@ -900,8 +901,10 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
}
|
||||
|
||||
private static boolean invIsBlocked(InventoryAdaptor inv) {
|
||||
if (AEConfig.instance().isFeatureEnabled(AEFeature.INSANE_BLOCKING_MODE))
|
||||
return !inv.simulateRemove( 1, ItemStack.EMPTY, null ).isEmpty();
|
||||
if (AEConfig.instance().isFeatureEnabled(AEFeature.INSANE_BLOCKING_MODE)) {
|
||||
if (Loader.isModLoaded("gregtech")) return !inv.canRemoveAllExceptCircuits();
|
||||
else return !inv.simulateRemove( 1, ItemStack.EMPTY, null ).isEmpty();
|
||||
}
|
||||
else
|
||||
return inv.containsItems();
|
||||
}
|
||||
|
||||
@@ -69,6 +69,8 @@ public abstract class InventoryAdaptor implements Iterable<ItemSlot>
|
||||
|
||||
public abstract ItemStack simulateRemove( int amount, ItemStack filter, IInventoryDestination destination );
|
||||
|
||||
public abstract boolean canRemoveAllExceptCircuits();
|
||||
|
||||
// return what was extracted.
|
||||
public abstract ItemStack removeSimilarItems( int amount, ItemStack filter, FuzzyMode fuzzyMode, IInventoryDestination destination );
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ package appeng.util.inv;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
@@ -31,6 +32,7 @@ import appeng.util.Platform;
|
||||
|
||||
public class AdaptorItemHandler extends InventoryAdaptor
|
||||
{
|
||||
final static ItemStack integratedCircuit = new ItemStack((Item.getByNameOrId("gregtech:meta_item_1")),1,32766); // Gregtech Community Edition Integrated Circuit
|
||||
protected final IItemHandler itemHandler;
|
||||
|
||||
public AdaptorItemHandler( IItemHandler itemHandler )
|
||||
@@ -264,4 +266,18 @@ public class AdaptorItemHandler extends InventoryAdaptor
|
||||
{
|
||||
return new ItemHandlerIterator( this.itemHandler );
|
||||
}
|
||||
|
||||
@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() || is.isItemEqual(integratedCircuit)) continue;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -225,4 +225,10 @@ public class AdaptorList extends InventoryAdaptor
|
||||
{
|
||||
return new StackToSlotIterator( this.i.iterator() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRemoveAllExceptCircuits() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -203,4 +203,10 @@ public class IMEAdaptor extends InventoryAdaptor
|
||||
{
|
||||
this.maxSlots = maxSlots;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRemoveAllExceptCircuits() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user