From 439f97a6dfed4a75ff56d6f79d41b08b86375cbd Mon Sep 17 00:00:00 2001 From: Hea3veN Date: Tue, 26 May 2015 08:21:12 -0300 Subject: [PATCH] fix planter robot not being able to plant cactus --- .../core/lib/utils/PathFindingSearch.java | 7 +++++-- .../robotics/ai/AIRobotSearchAndGotoBlock.java | 14 +++++++++++--- .../buildcraft/robotics/ai/AIRobotSearchBlock.java | 7 +++++-- .../robotics/boards/BoardRobotPlanter.java | 2 +- 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/common/buildcraft/core/lib/utils/PathFindingSearch.java b/common/buildcraft/core/lib/utils/PathFindingSearch.java index 2b765526..113ba29f 100644 --- a/common/buildcraft/core/lib/utils/PathFindingSearch.java +++ b/common/buildcraft/core/lib/utils/PathFindingSearch.java @@ -35,14 +35,17 @@ public class PathFindingSearch implements IIterableAlgorithm { private float maxDistance; private Iterator blockIter; + private double maxDistanceToEnd; + public PathFindingSearch(World iWorld, BlockIndex iStart, Iterator 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)); } } diff --git a/common/buildcraft/robotics/ai/AIRobotSearchAndGotoBlock.java b/common/buildcraft/robotics/ai/AIRobotSearchAndGotoBlock.java index a9be7560..bd393620 100644 --- a/common/buildcraft/robotics/ai/AIRobotSearchAndGotoBlock.java +++ b/common/buildcraft/robotics/ai/AIRobotSearchAndGotoBlock.java @@ -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 diff --git a/common/buildcraft/robotics/ai/AIRobotSearchBlock.java b/common/buildcraft/robotics/ai/AIRobotSearchBlock.java index ba8b7409..0b5eeb57 100644 --- a/common/buildcraft/robotics/ai/AIRobotSearchBlock.java +++ b/common/buildcraft/robotics/ai/AIRobotSearchBlock.java @@ -25,9 +25,11 @@ public class AIRobotSearchBlock extends AIRobot { private IterableAlgorithmRunner blockScannerJob; private IBlockFilter pathFound; private Iterator 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(); } diff --git a/common/buildcraft/robotics/boards/BoardRobotPlanter.java b/common/buildcraft/robotics/boards/BoardRobotPlanter.java index fe6734f0..6952dd9b 100644 --- a/common/buildcraft/robotics/boards/BoardRobotPlanter.java +++ b/common/buildcraft/robotics/boards/BoardRobotPlanter.java @@ -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)); } }