improve robot path handling
This commit is contained in:
parent
eebd393fc2
commit
89b10bbd8f
|
@ -20,6 +20,7 @@ import buildcraft.api.core.BuildCraftAPI;
|
|||
import buildcraft.api.robots.EntityRobotBase;
|
||||
import buildcraft.core.lib.utils.IterableAlgorithmRunner;
|
||||
import buildcraft.core.lib.utils.PathFinding;
|
||||
import buildcraft.robotics.RobotUtils;
|
||||
|
||||
public class AIRobotGotoBlock extends AIRobotGoto {
|
||||
|
||||
|
@ -124,13 +125,21 @@ public class AIRobotGotoBlock extends AIRobotGoto {
|
|||
private void setNextInPath() {
|
||||
if (path.size() > 0) {
|
||||
BlockIndex next = path.getFirst();
|
||||
prevDistance = Double.MAX_VALUE;
|
||||
|
||||
if (BuildCraftAPI.isSoftBlock(robot.worldObj, next.x, next.y, next.z)) {
|
||||
setDestination(robot, next.x + 0.5F, next.y + 0.5F, next.z + 0.5F);
|
||||
prevDistance = Double.MAX_VALUE;
|
||||
robot.aimItemAt(next.x, next.y, next.z);
|
||||
} else {
|
||||
setSuccess(false);
|
||||
terminate();
|
||||
// Path invalid!
|
||||
path = null;
|
||||
|
||||
if (pathSearchJob != null) {
|
||||
pathSearchJob.terminate();
|
||||
robot.motionX = 0;
|
||||
robot.motionY = 0;
|
||||
robot.motionZ = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue