Added max transfer amount to filter transfer argument.

This commit is contained in:
WayofTime 2016-01-21 10:57:52 -05:00
parent 8b6787b27c
commit 6c91865c5e
4 changed files with 8 additions and 8 deletions

View file

@ -77,7 +77,7 @@ public class DefaultItemFilter implements IItemFilter
* This method is only called on an input filter to transfer ItemStacks from
* the input inventory to the output inventory.
*/
public void transferThroughInputFilter(IItemFilter outputFilter)
public void transferThroughInputFilter(IItemFilter outputFilter, int maxTransfer)
{
boolean[] canAccessSlot = new boolean[accessedInventory.getSizeInventory()];
if (accessedInventory instanceof ISidedInventory)
@ -108,7 +108,7 @@ public class DefaultItemFilter implements IItemFilter
continue;
}
int allowedAmount = inputStack.stackSize;
int allowedAmount = Math.min(inputStack.stackSize, maxTransfer);
ItemStack testStack = inputStack.copy();
testStack.stackSize = allowedAmount;
@ -122,6 +122,7 @@ public class DefaultItemFilter implements IItemFilter
}
inputStack.stackSize -= changeAmount;
maxTransfer -= changeAmount;
accessedInventory.setInventorySlotContents(slot, inputStack.stackSize <= 0 ? null : inputStack); //Sets the slot in the inventory
}

View file

@ -26,7 +26,7 @@ public interface IItemFilter
* This method is only called on an input filter to transfer ItemStacks from
* the input inventory to the output inventory.
*/
public void transferThroughInputFilter(IItemFilter outputFilter);
public void transferThroughInputFilter(IItemFilter outputFilter, int maxTransfer);
public boolean doesStackMatchFilter(ItemStack testStack);

View file

@ -186,7 +186,6 @@ public class TestItemFilter implements IItemFilter
ItemStack testStack = inputStack.copy();
testStack.stackSize = allowedAmount;
ItemStack remainderStack = Utils.insertStackIntoInventory(testStack, accessedInventory, accessedSide);
// System.out.println("Remaining stack size: " + (remainderStack != null ? remainderStack.stackSize : 0) + ", allowed amount: " + allowedAmount);
int changeAmount = allowedAmount - (remainderStack == null ? 0 : remainderStack.stackSize);
testStack = inputStack.copy();
@ -213,7 +212,7 @@ public class TestItemFilter implements IItemFilter
* This method is only called on an input filter to transfer ItemStacks from
* the input inventory to the output inventory.
*/
public void transferThroughInputFilter(IItemFilter outputFilter)
public void transferThroughInputFilter(IItemFilter outputFilter, int maxTransfer)
{
boolean[] canAccessSlot = new boolean[accessedInventory.getSizeInventory()];
if (accessedInventory instanceof ISidedInventory)
@ -249,7 +248,7 @@ public class TestItemFilter implements IItemFilter
{
if (doStacksMatch(filterStack, inputStack))
{
allowedAmount = Math.min(filterStack.stackSize, inputStack.stackSize);
allowedAmount = Math.min(maxTransfer, Math.min(filterStack.stackSize, inputStack.stackSize));
break;
}
}
@ -263,7 +262,6 @@ public class TestItemFilter implements IItemFilter
testStack.stackSize = allowedAmount;
ItemStack remainderStack = outputFilter.transferStackThroughOutputFilter(testStack);
int changeAmount = allowedAmount - (remainderStack == null ? 0 : remainderStack.stackSize);
// System.out.println("Change amount: " + changeAmount);
if (remainderStack != null && remainderStack.stackSize == allowedAmount)
{
@ -272,6 +270,7 @@ public class TestItemFilter implements IItemFilter
}
inputStack.stackSize -= changeAmount;
maxTransfer -= changeAmount;
accessedInventory.setInventorySlotContents(slot, inputStack.stackSize <= 0 ? null : inputStack); //Sets the slot in the inventory

View file

@ -124,7 +124,7 @@ public class TileMasterRoutingNode extends TileInventory implements IMasterRouti
List<IItemFilter> inputList = inputEntry.getValue();
for (IItemFilter inputFilter : inputList)
{
inputFilter.transferThroughInputFilter(outputFilter);
inputFilter.transferThroughInputFilter(outputFilter, 1);
}
}
}