The inventory trigger now takes the max stacksize of the inventory into account.
This commit is contained in:
iTitus 2015-11-08 11:57:22 +01:00
parent ebbdbdaef7
commit 077f38ea13

View file

@ -70,6 +70,7 @@ public class TriggerInventoryLevel extends BCStatement implements ITriggerExtern
}
if (tile instanceof IInventory) {
IInventory inventory = (IInventory) tile;
ItemStack searchStack = parameters[0].getItemStack();
if (searchStack == null) {
@ -78,7 +79,7 @@ public class TriggerInventoryLevel extends BCStatement implements ITriggerExtern
int stackSpace = 0;
int foundItems = 0;
for (IInvSlot slot : InventoryIterator.getIterable((IInventory) tile, side.getOpposite())) {
for (IInvSlot slot : InventoryIterator.getIterable(inventory, side.getOpposite())) {
if (slot.canPutStackInSlot(searchStack)) {
ItemStack stackInSlot = slot.getStackInSlot();
if (stackInSlot == null || StackHelper.canStacksOrListsMerge(stackInSlot, searchStack)) {
@ -89,7 +90,7 @@ public class TriggerInventoryLevel extends BCStatement implements ITriggerExtern
}
if (stackSpace > 0) {
float percentage = foundItems / ((float) stackSpace * (float) searchStack.getMaxStackSize());
float percentage = foundItems / ((float) stackSpace * (float) Math.min(searchStack.getMaxStackSize(), inventory.getInventoryStackLimit()));
return percentage < type.level;
}