mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-14 01:39:36 -04:00
Fix InventoryUtils.insertIntoInventory
According to the documentation inventory_controller.suckFromSlot, robot.suck and friends try to put the sucked item into the selected slot, and only if it's occupied try others. However the implementation first tried to merge the stack with existing stacks in the inventory, and only if it failed put into the selected slot. This commit fixes it.
This commit is contained in:
parent
dbf99cdf4e
commit
b051b10c18
@ -155,6 +155,12 @@ object InventoryUtils {
|
||||
var remaining = limit
|
||||
val range = slots.getOrElse(0 until inventory.getSizeInventory)
|
||||
|
||||
val stackSize = stack.stackSize
|
||||
if ((inventory.getStackInSlot(range.head) == null) && insertIntoInventorySlot(stack, inventory, side, range.head, remaining, simulate)) {
|
||||
remaining -= stackSize - stack.stackSize
|
||||
success = true
|
||||
}
|
||||
|
||||
val shouldTryMerge = !stack.isItemStackDamageable && stack.getMaxStackSize > 1 && inventory.getInventoryStackLimit > 1
|
||||
if (shouldTryMerge) {
|
||||
for (slot <- range) {
|
||||
@ -166,7 +172,7 @@ object InventoryUtils {
|
||||
}
|
||||
}
|
||||
|
||||
for (slot <- range) {
|
||||
for (slot <- range.tail) {
|
||||
val stackSize = stack.stackSize
|
||||
if ((inventory.getStackInSlot(slot) == null) && insertIntoInventorySlot(stack, inventory, side, slot, remaining, simulate)) {
|
||||
remaining -= stackSize - stack.stackSize
|
||||
|
Loading…
x
Reference in New Issue
Block a user