From aa2caf63d3389bc9c2b5c021c426a40a9aa3c106 Mon Sep 17 00:00:00 2001 From: Brady Date: Sun, 16 Sep 2018 21:18:39 -0500 Subject: [PATCH] Clean up PathingBehavior#findPath --- .../java/baritone/behavior/PathingBehavior.java | 16 ++++------------ .../java/baritone/pathing/goals/GoalBlock.java | 1 + .../baritone/pathing/goals/GoalGetToBlock.java | 1 + .../java/baritone/pathing/goals/GoalNear.java | 1 + .../baritone/pathing/goals/GoalTwoBlocks.java | 1 + 5 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/main/java/baritone/behavior/PathingBehavior.java b/src/main/java/baritone/behavior/PathingBehavior.java index 22440af4..b42075d6 100644 --- a/src/main/java/baritone/behavior/PathingBehavior.java +++ b/src/main/java/baritone/behavior/PathingBehavior.java @@ -33,6 +33,7 @@ import baritone.pathing.path.PathExecutor; import baritone.utils.BlockStateInterface; import baritone.utils.Helper; import baritone.utils.PathRenderer; +import baritone.utils.interfaces.IGoalRenderPos; import net.minecraft.init.Blocks; import net.minecraft.util.math.BlockPos; import net.minecraft.world.chunk.EmptyChunk; @@ -309,18 +310,9 @@ public final class PathingBehavior extends Behavior implements Helper { } if (Baritone.settings().simplifyUnloadedYCoord.get()) { BlockPos pos = null; - if (goal instanceof GoalBlock) { - pos = ((GoalBlock) goal).getGoalPos(); - } - if (goal instanceof GoalTwoBlocks) { - pos = ((GoalTwoBlocks) goal).getGoalPos(); - } - if (goal instanceof GoalNear) { - pos = ((GoalNear) goal).getGoalPos(); - } - if (goal instanceof GoalGetToBlock) { - pos = ((GoalGetToBlock) goal).getGoalPos(); - } + if (goal instanceof IGoalRenderPos) + pos = ((IGoalRenderPos) goal).getGoalPos(); + // TODO simplify each individual goal in a GoalComposite if (pos != null && world().getChunk(pos) instanceof EmptyChunk) { logDebug("Simplifying " + goal.getClass() + " to GoalXZ due to distance"); diff --git a/src/main/java/baritone/pathing/goals/GoalBlock.java b/src/main/java/baritone/pathing/goals/GoalBlock.java index 0c96787c..b85f468a 100644 --- a/src/main/java/baritone/pathing/goals/GoalBlock.java +++ b/src/main/java/baritone/pathing/goals/GoalBlock.java @@ -73,6 +73,7 @@ public class GoalBlock implements Goal, IGoalRenderPos { /** * @return The position of this goal as a {@link BlockPos} */ + @Override public BlockPos getGoalPos() { return new BlockPos(x, y, z); } diff --git a/src/main/java/baritone/pathing/goals/GoalGetToBlock.java b/src/main/java/baritone/pathing/goals/GoalGetToBlock.java index 16cf9f4b..cefed91a 100644 --- a/src/main/java/baritone/pathing/goals/GoalGetToBlock.java +++ b/src/main/java/baritone/pathing/goals/GoalGetToBlock.java @@ -39,6 +39,7 @@ public class GoalGetToBlock implements Goal, IGoalRenderPos { this.z = pos.getZ(); } + @Override public BlockPos getGoalPos() { return new BetterBlockPos(x, y, z); } diff --git a/src/main/java/baritone/pathing/goals/GoalNear.java b/src/main/java/baritone/pathing/goals/GoalNear.java index 7786c4f1..1b214c10 100644 --- a/src/main/java/baritone/pathing/goals/GoalNear.java +++ b/src/main/java/baritone/pathing/goals/GoalNear.java @@ -49,6 +49,7 @@ public class GoalNear implements Goal, IGoalRenderPos { return GoalBlock.calculate(diffX, diffY, diffZ); } + @Override public BlockPos getGoalPos() { return new BlockPos(x, y, z); } diff --git a/src/main/java/baritone/pathing/goals/GoalTwoBlocks.java b/src/main/java/baritone/pathing/goals/GoalTwoBlocks.java index dcd8d17d..edc70483 100644 --- a/src/main/java/baritone/pathing/goals/GoalTwoBlocks.java +++ b/src/main/java/baritone/pathing/goals/GoalTwoBlocks.java @@ -69,6 +69,7 @@ public class GoalTwoBlocks implements Goal, IGoalRenderPos { return GoalBlock.calculate(xDiff, yDiff, zDiff); } + @Override public BlockPos getGoalPos() { return new BlockPos(x, y, z); }