Fix #3120
The inventory trigger now takes the max stacksize of the inventory into account.
This commit is contained in:
parent
ebbdbdaef7
commit
077f38ea13
1 changed files with 3 additions and 2 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue