Added max transfer amount to filter transfer argument.
This commit is contained in:
parent
8b6787b27c
commit
6c91865c5e
|
@ -77,7 +77,7 @@ public class DefaultItemFilter implements IItemFilter
|
||||||
* This method is only called on an input filter to transfer ItemStacks from
|
* This method is only called on an input filter to transfer ItemStacks from
|
||||||
* the input inventory to the output inventory.
|
* 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()];
|
boolean[] canAccessSlot = new boolean[accessedInventory.getSizeInventory()];
|
||||||
if (accessedInventory instanceof ISidedInventory)
|
if (accessedInventory instanceof ISidedInventory)
|
||||||
|
@ -108,7 +108,7 @@ public class DefaultItemFilter implements IItemFilter
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int allowedAmount = inputStack.stackSize;
|
int allowedAmount = Math.min(inputStack.stackSize, maxTransfer);
|
||||||
|
|
||||||
ItemStack testStack = inputStack.copy();
|
ItemStack testStack = inputStack.copy();
|
||||||
testStack.stackSize = allowedAmount;
|
testStack.stackSize = allowedAmount;
|
||||||
|
@ -122,6 +122,7 @@ public class DefaultItemFilter implements IItemFilter
|
||||||
}
|
}
|
||||||
|
|
||||||
inputStack.stackSize -= changeAmount;
|
inputStack.stackSize -= changeAmount;
|
||||||
|
maxTransfer -= changeAmount;
|
||||||
|
|
||||||
accessedInventory.setInventorySlotContents(slot, inputStack.stackSize <= 0 ? null : inputStack); //Sets the slot in the inventory
|
accessedInventory.setInventorySlotContents(slot, inputStack.stackSize <= 0 ? null : inputStack); //Sets the slot in the inventory
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ public interface IItemFilter
|
||||||
* This method is only called on an input filter to transfer ItemStacks from
|
* This method is only called on an input filter to transfer ItemStacks from
|
||||||
* the input inventory to the output inventory.
|
* the input inventory to the output inventory.
|
||||||
*/
|
*/
|
||||||
public void transferThroughInputFilter(IItemFilter outputFilter);
|
public void transferThroughInputFilter(IItemFilter outputFilter, int maxTransfer);
|
||||||
|
|
||||||
public boolean doesStackMatchFilter(ItemStack testStack);
|
public boolean doesStackMatchFilter(ItemStack testStack);
|
||||||
|
|
||||||
|
|
|
@ -186,7 +186,6 @@ public class TestItemFilter implements IItemFilter
|
||||||
ItemStack testStack = inputStack.copy();
|
ItemStack testStack = inputStack.copy();
|
||||||
testStack.stackSize = allowedAmount;
|
testStack.stackSize = allowedAmount;
|
||||||
ItemStack remainderStack = Utils.insertStackIntoInventory(testStack, accessedInventory, accessedSide);
|
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);
|
int changeAmount = allowedAmount - (remainderStack == null ? 0 : remainderStack.stackSize);
|
||||||
testStack = inputStack.copy();
|
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
|
* This method is only called on an input filter to transfer ItemStacks from
|
||||||
* the input inventory to the output inventory.
|
* 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()];
|
boolean[] canAccessSlot = new boolean[accessedInventory.getSizeInventory()];
|
||||||
if (accessedInventory instanceof ISidedInventory)
|
if (accessedInventory instanceof ISidedInventory)
|
||||||
|
@ -249,7 +248,7 @@ public class TestItemFilter implements IItemFilter
|
||||||
{
|
{
|
||||||
if (doStacksMatch(filterStack, inputStack))
|
if (doStacksMatch(filterStack, inputStack))
|
||||||
{
|
{
|
||||||
allowedAmount = Math.min(filterStack.stackSize, inputStack.stackSize);
|
allowedAmount = Math.min(maxTransfer, Math.min(filterStack.stackSize, inputStack.stackSize));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -263,7 +262,6 @@ public class TestItemFilter implements IItemFilter
|
||||||
testStack.stackSize = allowedAmount;
|
testStack.stackSize = allowedAmount;
|
||||||
ItemStack remainderStack = outputFilter.transferStackThroughOutputFilter(testStack);
|
ItemStack remainderStack = outputFilter.transferStackThroughOutputFilter(testStack);
|
||||||
int changeAmount = allowedAmount - (remainderStack == null ? 0 : remainderStack.stackSize);
|
int changeAmount = allowedAmount - (remainderStack == null ? 0 : remainderStack.stackSize);
|
||||||
// System.out.println("Change amount: " + changeAmount);
|
|
||||||
|
|
||||||
if (remainderStack != null && remainderStack.stackSize == allowedAmount)
|
if (remainderStack != null && remainderStack.stackSize == allowedAmount)
|
||||||
{
|
{
|
||||||
|
@ -272,6 +270,7 @@ public class TestItemFilter implements IItemFilter
|
||||||
}
|
}
|
||||||
|
|
||||||
inputStack.stackSize -= changeAmount;
|
inputStack.stackSize -= changeAmount;
|
||||||
|
maxTransfer -= changeAmount;
|
||||||
|
|
||||||
accessedInventory.setInventorySlotContents(slot, inputStack.stackSize <= 0 ? null : inputStack); //Sets the slot in the inventory
|
accessedInventory.setInventorySlotContents(slot, inputStack.stackSize <= 0 ? null : inputStack); //Sets the slot in the inventory
|
||||||
|
|
||||||
|
|
|
@ -124,7 +124,7 @@ public class TileMasterRoutingNode extends TileInventory implements IMasterRouti
|
||||||
List<IItemFilter> inputList = inputEntry.getValue();
|
List<IItemFilter> inputList = inputEntry.getValue();
|
||||||
for (IItemFilter inputFilter : inputList)
|
for (IItemFilter inputFilter : inputList)
|
||||||
{
|
{
|
||||||
inputFilter.transferThroughInputFilter(outputFilter);
|
inputFilter.transferThroughInputFilter(outputFilter, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue