From 3261687ee08ecadbe37d1f1fb608501673e252a3 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Fri, 7 Sep 2018 18:23:32 -0700 Subject: [PATCH] render more goals, fixes #25 --- .../baritone/pathing/goals/GoalBlock.java | 3 ++- .../pathing/goals/GoalGetToBlock.java | 3 ++- .../java/baritone/pathing/goals/GoalNear.java | 3 ++- .../baritone/pathing/goals/GoalTwoBlocks.java | 5 ++-- .../java/baritone/utils/PathRenderer.java | 13 ++++++---- .../utils/interfaces/IGoalRenderPos.java | 24 +++++++++++++++++++ 6 files changed, 41 insertions(+), 10 deletions(-) create mode 100644 src/main/java/baritone/utils/interfaces/IGoalRenderPos.java diff --git a/src/main/java/baritone/pathing/goals/GoalBlock.java b/src/main/java/baritone/pathing/goals/GoalBlock.java index 78d7b87d..9e6ea556 100644 --- a/src/main/java/baritone/pathing/goals/GoalBlock.java +++ b/src/main/java/baritone/pathing/goals/GoalBlock.java @@ -17,6 +17,7 @@ package baritone.pathing.goals; +import baritone.utils.interfaces.IGoalRenderPos; import net.minecraft.util.math.BlockPos; /** @@ -24,7 +25,7 @@ import net.minecraft.util.math.BlockPos; * * @author leijurv */ -public class GoalBlock implements Goal { +public class GoalBlock implements Goal, IGoalRenderPos { /** * The X block position of this goal diff --git a/src/main/java/baritone/pathing/goals/GoalGetToBlock.java b/src/main/java/baritone/pathing/goals/GoalGetToBlock.java index 30937772..4e81018b 100644 --- a/src/main/java/baritone/pathing/goals/GoalGetToBlock.java +++ b/src/main/java/baritone/pathing/goals/GoalGetToBlock.java @@ -17,6 +17,7 @@ package baritone.pathing.goals; +import baritone.utils.interfaces.IGoalRenderPos; import baritone.utils.pathing.BetterBlockPos; import net.minecraft.util.math.BlockPos; @@ -26,7 +27,7 @@ import net.minecraft.util.math.BlockPos; * * @author avecowa */ -public class GoalGetToBlock implements Goal { +public class GoalGetToBlock implements Goal, IGoalRenderPos { private final int x; private final int y; diff --git a/src/main/java/baritone/pathing/goals/GoalNear.java b/src/main/java/baritone/pathing/goals/GoalNear.java index 2ec6bf1d..e78788ac 100644 --- a/src/main/java/baritone/pathing/goals/GoalNear.java +++ b/src/main/java/baritone/pathing/goals/GoalNear.java @@ -17,9 +17,10 @@ package baritone.pathing.goals; +import baritone.utils.interfaces.IGoalRenderPos; import net.minecraft.util.math.BlockPos; -public class GoalNear implements Goal { +public class GoalNear implements Goal, IGoalRenderPos { final int x; final int y; final int z; diff --git a/src/main/java/baritone/pathing/goals/GoalTwoBlocks.java b/src/main/java/baritone/pathing/goals/GoalTwoBlocks.java index 65571a49..021103a1 100644 --- a/src/main/java/baritone/pathing/goals/GoalTwoBlocks.java +++ b/src/main/java/baritone/pathing/goals/GoalTwoBlocks.java @@ -17,6 +17,7 @@ package baritone.pathing.goals; +import baritone.utils.interfaces.IGoalRenderPos; import net.minecraft.util.math.BlockPos; /** @@ -25,7 +26,7 @@ import net.minecraft.util.math.BlockPos; * * @author leijurv */ -public class GoalTwoBlocks implements Goal { +public class GoalTwoBlocks implements Goal, IGoalRenderPos { /** * The X block position of this goal @@ -69,7 +70,7 @@ public class GoalTwoBlocks implements Goal { } public BlockPos getGoalPos() { - return new BlockPos(x, y, z); + return new BlockPos(x, y - 1, z); } @Override diff --git a/src/main/java/baritone/utils/PathRenderer.java b/src/main/java/baritone/utils/PathRenderer.java index 6fd3466e..c4ea8103 100644 --- a/src/main/java/baritone/utils/PathRenderer.java +++ b/src/main/java/baritone/utils/PathRenderer.java @@ -19,9 +19,10 @@ package baritone.utils; import baritone.Baritone; import baritone.pathing.goals.Goal; -import baritone.pathing.goals.GoalBlock; +import baritone.pathing.goals.GoalComposite; import baritone.pathing.goals.GoalXZ; import baritone.pathing.path.IPath; +import baritone.utils.interfaces.IGoalRenderPos; import baritone.utils.pathing.BetterBlockPos; import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; @@ -183,13 +184,13 @@ public final class PathRenderer implements Helper { double maxY; double y1; double y2; - if (goal instanceof GoalBlock) { - BlockPos goalPos = ((GoalBlock) goal).getGoalPos(); + if (goal instanceof IGoalRenderPos) { + BlockPos goalPos = ((IGoalRenderPos) goal).getGoalPos(); minX = goalPos.getX() + 0.002 - renderPosX; maxX = goalPos.getX() + 1 - 0.002 - renderPosX; minZ = goalPos.getZ() + 0.002 - renderPosZ; maxZ = goalPos.getZ() + 1 - 0.002 - renderPosZ; - double y = MathHelper.sin((float) (((float) (System.nanoTime() / 1000000L) % 2000L) / 2000F * Math.PI * 2)); + double y = MathHelper.cos((float) (((float) ((System.nanoTime() / 100000L) % 20000L)) / 20000F * Math.PI * 2)); y1 = 1 + y + goalPos.getY() - renderPosY; y2 = 1 - y + goalPos.getY() - renderPosY; minY = goalPos.getY() - renderPosY; @@ -207,7 +208,9 @@ public final class PathRenderer implements Helper { minY = 0 - renderPosY; maxY = 256 - renderPosY; } else { - // TODO GoalComposite + for (Goal g : ((GoalComposite) goal).goals()) { + drawLitDankGoalBox(player, g, partialTicks, color); + } return; } diff --git a/src/main/java/baritone/utils/interfaces/IGoalRenderPos.java b/src/main/java/baritone/utils/interfaces/IGoalRenderPos.java new file mode 100644 index 00000000..0aed1ea4 --- /dev/null +++ b/src/main/java/baritone/utils/interfaces/IGoalRenderPos.java @@ -0,0 +1,24 @@ +/* + * This file is part of Baritone. + * + * Baritone is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Baritone is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Baritone. If not, see . + */ + +package baritone.utils.interfaces; + +import net.minecraft.util.math.BlockPos; + +public interface IGoalRenderPos { + BlockPos getGoalPos(); +}