fix planter robot not being able to plant cactus

This commit is contained in:
Hea3veN 2015-05-26 08:21:12 -03:00
parent c6aeb94285
commit 439f97a6df
4 changed files with 22 additions and 8 deletions

View file

@ -35,14 +35,17 @@ public class PathFindingSearch implements IIterableAlgorithm {
private float maxDistance;
private Iterator<BlockIndex> blockIter;
private double maxDistanceToEnd;
public PathFindingSearch(World iWorld, BlockIndex iStart,
Iterator<BlockIndex> iBlockIter, IBlockFilter iPathFound,
float iMaxDistance, IZone iZone) {
double iMaxDistanceToEnd, float iMaxDistance, IZone iZone) {
world = iWorld;
start = iStart;
pathFound = iPathFound;
maxDistance = iMaxDistance;
maxDistanceToEnd = iMaxDistanceToEnd;
zone = iZone;
blockIter = iBlockIter;
@ -69,7 +72,7 @@ public class PathFindingSearch implements IIterableAlgorithm {
start.z + delta.z);
if (isLoadedChunk(block.x, block.z)) {
if (isTarget(block)) {
pathFinders.add(new PathFinding(world, start, block, 0, maxDistance));
pathFinders.add(new PathFinding(world, start, block, maxDistanceToEnd, maxDistance));
}
}

View file

@ -18,10 +18,11 @@ import buildcraft.core.lib.utils.IBlockFilter;
public class AIRobotSearchAndGotoBlock extends AIRobot {
protected BlockIndex blockFound;
private BlockIndex blockFound;
private IBlockFilter filter;
private boolean random;
private double maxDistanceToEnd;
public AIRobotSearchAndGotoBlock(EntityRobotBase iRobot) {
super(iRobot);
@ -32,16 +33,23 @@ public class AIRobotSearchAndGotoBlock extends AIRobot {
filter = null;
}
public AIRobotSearchAndGotoBlock(EntityRobotBase iRobot, boolean iRandom, IBlockFilter iPathFound) {
public AIRobotSearchAndGotoBlock(EntityRobotBase iRobot, boolean iRandom,
IBlockFilter iPathFound) {
this(iRobot, iRandom, iPathFound, 0);
}
public AIRobotSearchAndGotoBlock(EntityRobotBase iRobot, boolean iRandom,
IBlockFilter iPathFound, double iMaxDistanceToEnd) {
this(iRobot);
random = iRandom;
filter = iPathFound;
maxDistanceToEnd = iMaxDistanceToEnd;
}
@Override
public void start() {
startDelegateAI(new AIRobotSearchBlock(robot, random, filter));
startDelegateAI(new AIRobotSearchBlock(robot, random, filter, maxDistanceToEnd));
}
@Override

View file

@ -25,9 +25,11 @@ public class AIRobotSearchBlock extends AIRobot {
private IterableAlgorithmRunner blockScannerJob;
private IBlockFilter pathFound;
private Iterator<BlockIndex> blockIter;
private double maxDistanceToEnd;
private IZone zone;
public AIRobotSearchBlock(EntityRobotBase iRobot, boolean random, IBlockFilter iPathFound) {
public AIRobotSearchBlock(EntityRobotBase iRobot, boolean random, IBlockFilter iPathFound,
double iMaxDistanceToEnd) {
super(iRobot);
pathFound = iPathFound;
@ -45,12 +47,13 @@ public class AIRobotSearchBlock extends AIRobot {
}
blockFound = null;
path = null;
maxDistanceToEnd = iMaxDistanceToEnd;
}
@Override
public void start() {
blockScanner = new PathFindingSearch(robot.worldObj, new BlockIndex(
robot), blockIter, pathFound, 96, zone);
robot), blockIter, pathFound, maxDistanceToEnd, 96, zone);
blockScannerJob = new IterableAlgorithmRunner(blockScanner);
blockScannerJob.start();
}

View file

@ -62,7 +62,7 @@ public class BoardRobotPlanter extends RedstoneBoardRobot {
&& !robot.getRegistry().isTaken(new ResourceIdBlock(x, y, z));
}
};
startDelegateAI(new AIRobotSearchAndGotoBlock(robot, true, blockFilter));
startDelegateAI(new AIRobotSearchAndGotoBlock(robot, true, blockFilter, 1));
}
}