Merge pull request #2540 from Kubuxu/carrier
Make carrier robots load to full from one station
This commit is contained in:
commit
e6df71f1f0
1 changed files with 9 additions and 5 deletions
|
@ -68,6 +68,8 @@ public class AIRobotLoad extends AIRobot {
|
||||||
if (robot.getDockingStation() != null) {
|
if (robot.getDockingStation() != null) {
|
||||||
DockingStation station = (DockingStation) robot.getDockingStation();
|
DockingStation station = (DockingStation) robot.getDockingStation();
|
||||||
|
|
||||||
|
int loaded = 0;
|
||||||
|
|
||||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||||
TileEntity nearbyTile = robot.worldObj.getTileEntity(station.x() + dir.offsetX,
|
TileEntity nearbyTile = robot.worldObj.getTileEntity(station.x() + dir.offsetX,
|
||||||
station.y()
|
station.y()
|
||||||
|
@ -87,20 +89,22 @@ public class AIRobotLoad extends AIRobot {
|
||||||
ITransactor t = Transactor.getTransactorFor(robot);
|
ITransactor t = Transactor.getTransactorFor(robot);
|
||||||
|
|
||||||
if (quantity == -1) {
|
if (quantity == -1) {
|
||||||
|
|
||||||
ItemStack added = t.add(slot.getStackInSlot(), ForgeDirection.UNKNOWN, true);
|
ItemStack added = t.add(slot.getStackInSlot(), ForgeDirection.UNKNOWN, true);
|
||||||
slot.decreaseStackInSlot(added.stackSize);
|
slot.decreaseStackInSlot(added.stackSize);
|
||||||
return;
|
|
||||||
} else {
|
} else {
|
||||||
ItemStack toAdd = slot.getStackInSlot().copy();
|
ItemStack toAdd = slot.getStackInSlot().copy();
|
||||||
|
|
||||||
if (toAdd.stackSize >= quantity) {
|
if (toAdd.stackSize > quantity - loaded) {
|
||||||
toAdd.stackSize = quantity;
|
toAdd.stackSize = quantity - loaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack added = t.add(toAdd, ForgeDirection.UNKNOWN, true);
|
ItemStack added = t.add(toAdd, ForgeDirection.UNKNOWN, true);
|
||||||
slot.decreaseStackInSlot(added.stackSize);
|
slot.decreaseStackInSlot(added.stackSize);
|
||||||
return;
|
loaded += added.stackSize;
|
||||||
|
|
||||||
|
if (quantity - loaded <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue