Added "Allow Default" option to transporter filters to allow prevention of default route

This commit is contained in:
aidancbrady committed 2017-04-28 16:43:00 -04:00
1 parent 2b37fdb69f
commit 8d66d4b973
22 files changed
+176 -173

No files matched your search

@@ -3,6 +3,7 @@ package mekanism.common.content.transporter;
import java.util.HashMap;
import java.util.Map;
import mekanism.common.content.transporter.Finder.FirstFinder;
import mekanism.common.util.InventoryUtils;
import mekanism.common.util.StackUtils;
import net.minecraft.inventory.IInventory;
@@ -57,6 +58,11 @@ public class TransitRequest
}
public static TransitRequest getTopStacks(TileEntity tile, EnumFacing side, int amount)
{
return getTopStacks(tile, side, amount, new FirstFinder());
}
public static TransitRequest getTopStacks(TileEntity tile, EnumFacing side, int amount, Finder finder)
{
TransitRequest ret = new TransitRequest();
@@ -68,7 +74,7 @@ public class TransitRequest
{
ItemStack stack = inventory.extractItem(i, amount, true);
if(!stack.isEmpty() && !ret.hasType(stack))
if(!stack.isEmpty() && !ret.hasType(stack) && finder.modifies(stack))
{
ret.setItem(stack, i);
}
@@ -90,7 +96,7 @@ public class TransitRequest
ItemStack toSend = sidedInventory.getStackInSlot(slotID).copy();
toSend.setCount(Math.min(amount, toSend.getCount()));
if(!ret.hasType(toSend) && sidedInventory.canExtractItem(slotID, toSend, side.getOpposite()))
if(!ret.hasType(toSend) && sidedInventory.canExtractItem(slotID, toSend, side.getOpposite()) && finder.modifies(toSend))
{
ret.setItem(toSend, slotID);
}
@@ -109,7 +115,7 @@ public class TransitRequest
ItemStack toSend = inventory.getStackInSlot(i).copy();
toSend.setCount(Math.min(amount, toSend.getCount()));
if(!ret.hasType(toSend))
if(!ret.hasType(toSend) && finder.modifies(toSend))
{
ret.setItem(toSend, i);
}
@@ -135,7 +141,7 @@ public class TransitRequest
public boolean isEmpty()
{
return slotID == -1 || stack.isEmpty();
return stack.isEmpty();
}
public ItemStack getRejected(ItemStack orig)