From 1c8b0b48ba6018cf1c6255cb795a9a025b61cc0b Mon Sep 17 00:00:00 2001 From: Kubuxu Date: Sun, 8 Mar 2015 14:54:54 +0100 Subject: [PATCH] Make carrier robots load to full from one station --- common/buildcraft/robots/ai/AIRobotLoad.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/common/buildcraft/robots/ai/AIRobotLoad.java b/common/buildcraft/robots/ai/AIRobotLoad.java index 2b48b9ad..a2afb64e 100755 --- a/common/buildcraft/robots/ai/AIRobotLoad.java +++ b/common/buildcraft/robots/ai/AIRobotLoad.java @@ -68,6 +68,8 @@ public class AIRobotLoad extends AIRobot { if (robot.getDockingStation() != null) { DockingStation station = (DockingStation) robot.getDockingStation(); + int loaded = 0; + for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { TileEntity nearbyTile = robot.worldObj.getTileEntity(station.x() + dir.offsetX, station.y() @@ -87,20 +89,22 @@ public class AIRobotLoad extends AIRobot { ITransactor t = Transactor.getTransactorFor(robot); if (quantity == -1) { - ItemStack added = t.add(slot.getStackInSlot(), ForgeDirection.UNKNOWN, true); slot.decreaseStackInSlot(added.stackSize); - return; } else { ItemStack toAdd = slot.getStackInSlot().copy(); - if (toAdd.stackSize >= quantity) { - toAdd.stackSize = quantity; + if (toAdd.stackSize > quantity - loaded) { + toAdd.stackSize = quantity - loaded; } ItemStack added = t.add(toAdd, ForgeDirection.UNKNOWN, true); slot.decreaseStackInSlot(added.stackSize); - return; + loaded += added.stackSize; + + if (quantity - loaded <= 0) { + return; + } } } }