Fixed inventory slot offset for tank controller upgrade.

Fixed drain and fill not always returning the amount transferred.
This commit is contained in:
Florian Nücke 2015-01-10 22:22:42 +01:00
parent c760503aec
commit d7d62254b3
3 changed files with 12 additions and 11 deletions

View File

@ -57,9 +57,9 @@ object UpgradeTankController {
override def inventory = host.dynamicInventory
override def selectedSlot = host.selectedSlot
override def selectedSlot = host.selectedSlot - host.actualSlot(0)
override def selectedSlot_=(value: Int) = host.selectedSlot = value
override def selectedSlot_=(value: Int) = host.selectedSlot = host.actualSlot(value)
override def tank = host.tank

View File

@ -55,7 +55,7 @@ trait TankInventoryControl extends WorldAware with InventoryAware with TankAware
if (container.stackSize > 0) {
InventoryUtils.spawnStackInWorld(position, container)
}
result(true)
result(true, contents.amount)
}
}
else stack.getItem match {
@ -64,7 +64,7 @@ trait TankInventoryControl extends WorldAware with InventoryAware with TankAware
val transferred = into.fill(drained, true)
if (transferred > 0) {
from.drain(stack, transferred, true)
result(true)
result(true, transferred)
}
else result(Unit, "incompatible or no fluid")
case _ => result(Unit, "item is empty or not a fluid container")
@ -88,13 +88,14 @@ trait TankInventoryControl extends WorldAware with InventoryAware with TankAware
result(Unit, "tank is empty")
}
else {
from.drain(FluidContainerRegistry.getFluidForFilledItem(filled).amount, true)
val amount = FluidContainerRegistry.getFluidForFilledItem(filled).amount
from.drain(amount, true)
inventory.decrStackSize(selectedSlot, 1)
InventoryUtils.insertIntoInventory(filled, inventory, slots = Option(insertionSlots))
if (filled.stackSize > 0) {
InventoryUtils.spawnStackInWorld(position, filled)
}
result(true)
result(true, amount)
}
}
else stack.getItem match {
@ -103,7 +104,7 @@ trait TankInventoryControl extends WorldAware with InventoryAware with TankAware
val transferred = into.fill(stack, drained, true)
if (transferred > 0) {
from.drain(transferred, true)
result(true)
result(true, transferred)
}
else result(Unit, "incompatible or no fluid")
case _ => result(Unit, "item is full or not a fluid container")

View File

@ -51,7 +51,7 @@ trait TankWorldControl extends TankAware with WorldAware with SideRestricted {
val drained = handler.drain(facing.getOpposite, new FluidStack(stack, amount), true)
if ((drained != null && drained.amount > 0) || amount == 0) {
tank.fill(drained, true)
result(true)
result(true, drained.amount)
}
else result(Unit, "incompatible or no fluid")
case _ =>
@ -67,7 +67,7 @@ trait TankWorldControl extends TankAware with WorldAware with SideRestricted {
else if (tank.fill(new FluidStack(fluid, 1000), false) == 1000) {
tank.fill(new FluidStack(fluid, 1000), true)
world.setBlockToAir(blockPos)
result(true)
result(true, 1000)
}
else result(Unit, "tank is full")
}
@ -95,7 +95,7 @@ trait TankWorldControl extends TankAware with WorldAware with SideRestricted {
val filled = handler.fill(facing.getOpposite, new FluidStack(stack, amount), true)
if (filled > 0 || amount == 0) {
tank.drain(filled, true)
result(true)
result(true, filled)
}
else result(Unit, "incompatible or no fluid")
case _ =>
@ -119,7 +119,7 @@ trait TankWorldControl extends TankAware with WorldAware with SideRestricted {
world.setBlock(blockPos, fluidBlock)
// This fake neighbor update is required to get stills to start flowing.
world.notifyBlockOfNeighborChange(blockPos, world.getBlock(position))
result(true)
result(true, 1000)
}
}
else result(Unit, "no space")