From a589cb0d9ec37dbdac7e790dba417b089a545d6e Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 16 Sep 2018 20:16:05 -0700 Subject: [PATCH] rearranged constructors --- src/main/java/baritone/behavior/FollowBehavior.java | 7 +++---- src/main/java/baritone/behavior/LookBehavior.java | 4 ++-- src/main/java/baritone/behavior/MemoryBehavior.java | 4 ++-- src/main/java/baritone/behavior/MineBehavior.java | 5 ++--- src/main/java/baritone/behavior/PathingBehavior.java | 6 ++---- .../java/baritone/pathing/calc/AStarPathFinder.java | 4 ++-- .../java/baritone/pathing/movement/Movement.java | 12 ++++++------ src/main/java/baritone/utils/BlockBreakHelper.java | 6 +++--- src/main/java/baritone/utils/PathRenderer.java | 7 +++---- 9 files changed, 25 insertions(+), 30 deletions(-) diff --git a/src/main/java/baritone/behavior/FollowBehavior.java b/src/main/java/baritone/behavior/FollowBehavior.java index 0a7fff6b..8eb51708 100644 --- a/src/main/java/baritone/behavior/FollowBehavior.java +++ b/src/main/java/baritone/behavior/FollowBehavior.java @@ -17,8 +17,8 @@ package baritone.behavior; -import baritone.api.event.events.TickEvent; import baritone.api.behavior.Behavior; +import baritone.api.event.events.TickEvent; import baritone.pathing.goals.GoalNear; import net.minecraft.entity.Entity; import net.minecraft.util.math.BlockPos; @@ -32,11 +32,10 @@ public final class FollowBehavior extends Behavior { public static final FollowBehavior INSTANCE = new FollowBehavior(); - private FollowBehavior() { - } - private Entity following; + private FollowBehavior() {} + @Override public void onTick(TickEvent event) { if (event.getType() == TickEvent.Type.OUT) { diff --git a/src/main/java/baritone/behavior/LookBehavior.java b/src/main/java/baritone/behavior/LookBehavior.java index ef5b6b7d..c577588f 100644 --- a/src/main/java/baritone/behavior/LookBehavior.java +++ b/src/main/java/baritone/behavior/LookBehavior.java @@ -29,8 +29,6 @@ public final class LookBehavior extends Behavior implements Helper { public static final LookBehavior INSTANCE = new LookBehavior(); - private LookBehavior() {} - /** * Target's values are as follows: *

@@ -51,6 +49,8 @@ public final class LookBehavior extends Behavior implements Helper { */ private float lastYaw; + private LookBehavior() {} + public void updateTarget(Rotation target, boolean force) { this.target = target; this.force = force || !Baritone.settings().freeLook.get(); diff --git a/src/main/java/baritone/behavior/MemoryBehavior.java b/src/main/java/baritone/behavior/MemoryBehavior.java index d8794a66..716dfaee 100644 --- a/src/main/java/baritone/behavior/MemoryBehavior.java +++ b/src/main/java/baritone/behavior/MemoryBehavior.java @@ -42,8 +42,6 @@ public final class MemoryBehavior extends Behavior implements Helper { public static MemoryBehavior INSTANCE = new MemoryBehavior(); - private MemoryBehavior() {} - /** * Possible future inventories that we will be able to remember */ @@ -54,6 +52,8 @@ public final class MemoryBehavior extends Behavior implements Helper { */ private final Map rememberedInventories = new HashMap<>(); + private MemoryBehavior() {} + @Override public void onPlayerUpdate(PlayerUpdateEvent event) { if (event.getState() == EventState.PRE) { diff --git a/src/main/java/baritone/behavior/MineBehavior.java b/src/main/java/baritone/behavior/MineBehavior.java index 4c542c47..33a8e96d 100644 --- a/src/main/java/baritone/behavior/MineBehavior.java +++ b/src/main/java/baritone/behavior/MineBehavior.java @@ -49,12 +49,11 @@ public final class MineBehavior extends Behavior implements Helper { public static final MineBehavior INSTANCE = new MineBehavior(); - private MineBehavior() { - } - private List mining; private List locationsCache; + private MineBehavior() {} + @Override public void onTick(TickEvent event) { if (mining == null) { diff --git a/src/main/java/baritone/behavior/PathingBehavior.java b/src/main/java/baritone/behavior/PathingBehavior.java index 34358b5d..8d962bd6 100644 --- a/src/main/java/baritone/behavior/PathingBehavior.java +++ b/src/main/java/baritone/behavior/PathingBehavior.java @@ -47,9 +47,6 @@ public final class PathingBehavior extends Behavior implements Helper { public static final PathingBehavior INSTANCE = new PathingBehavior(); - private PathingBehavior() { - } - private PathExecutor current; private PathExecutor next; @@ -62,6 +59,8 @@ public final class PathingBehavior extends Behavior implements Helper { private boolean lastAutoJump; + private PathingBehavior() {} + private void dispatchPathEvent(PathEvent event) { Baritone.INSTANCE.getExecutor().execute(() -> Baritone.INSTANCE.getGameEventHandler().onPathEvent(event)); } @@ -391,6 +390,5 @@ public final class PathingBehavior extends Behavior implements Helper { // if (end - start > 0) { // System.out.println("Frame took " + (split - start) + " " + (end - split)); //} - } } diff --git a/src/main/java/baritone/pathing/calc/AStarPathFinder.java b/src/main/java/baritone/pathing/calc/AStarPathFinder.java index 8868e1fe..4c47639e 100644 --- a/src/main/java/baritone/pathing/calc/AStarPathFinder.java +++ b/src/main/java/baritone/pathing/calc/AStarPathFinder.java @@ -50,6 +50,8 @@ public class AStarPathFinder extends AbstractNodeCostSearch implements Helper { private final Optional> favoredPositions; + private final Random random = new Random(); + public AStarPathFinder(BlockPos start, Goal goal, Optional> favoredPositions) { super(start, goal); this.favoredPositions = favoredPositions.map(HashSet::new); // <-- okay this is epic @@ -250,8 +252,6 @@ public class AStarPathFinder extends AbstractNodeCostSearch implements Helper { }; } - private final Random random = new Random(); - private void shuffle(T[] list) { int len = list.length; for (int i = 0; i < len; i++) { diff --git a/src/main/java/baritone/pathing/movement/Movement.java b/src/main/java/baritone/pathing/movement/Movement.java index 4f31d1a0..7b1bce61 100644 --- a/src/main/java/baritone/pathing/movement/Movement.java +++ b/src/main/java/baritone/pathing/movement/Movement.java @@ -59,6 +59,12 @@ public abstract class Movement implements Helper, MovementHelper { private Double cost; + public List toBreakCached = null; + public List toPlaceCached = null; + public List toWalkIntoCached = null; + + private Boolean calculatedWhileLoaded; + protected Movement(BetterBlockPos src, BetterBlockPos dest, BlockPos[] toBreak, BlockPos toPlace) { this.src = src; this.dest = dest; @@ -290,8 +296,6 @@ public abstract class Movement implements Helper, MovementHelper { return getDest().subtract(getSrc()); } - private Boolean calculatedWhileLoaded; - public void checkLoadedChunk() { calculatedWhileLoaded = !(world().getChunk(getDest()) instanceof EmptyChunk); } @@ -300,10 +304,6 @@ public abstract class Movement implements Helper, MovementHelper { return calculatedWhileLoaded; } - public List toBreakCached = null; - public List toPlaceCached = null; - public List toWalkIntoCached = null; - public List toBreak() { if (toBreakCached != null) { return toBreakCached; diff --git a/src/main/java/baritone/utils/BlockBreakHelper.java b/src/main/java/baritone/utils/BlockBreakHelper.java index 8c224a2b..b293f01e 100644 --- a/src/main/java/baritone/utils/BlockBreakHelper.java +++ b/src/main/java/baritone/utils/BlockBreakHelper.java @@ -26,15 +26,15 @@ import net.minecraft.util.math.BlockPos; * @since 8/25/2018 */ public final class BlockBreakHelper implements Helper { - - private BlockBreakHelper() {} - + /** * The last block that we tried to break, if this value changes * between attempts, then we re-initialize the breaking process. */ private static BlockPos lastBlock; + private BlockBreakHelper() {} + public static void tryBreakBlock(BlockPos pos, EnumFacing side) { if (!pos.equals(lastBlock)) { mc.playerController.clickBlock(pos, side); diff --git a/src/main/java/baritone/utils/PathRenderer.java b/src/main/java/baritone/utils/PathRenderer.java index ee9a585c..a05e89bf 100644 --- a/src/main/java/baritone/utils/PathRenderer.java +++ b/src/main/java/baritone/utils/PathRenderer.java @@ -49,13 +49,12 @@ import static org.lwjgl.opengl.GL11.*; * @since 8/9/2018 4:39 PM */ public final class PathRenderer implements Helper { - - private PathRenderer() { - } - + private static final Tessellator TESSELLATOR = Tessellator.getInstance(); private static final BufferBuilder BUFFER = TESSELLATOR.getBuffer(); + private PathRenderer() {} + public static void drawPath(IPath path, int startIndex, EntityPlayerSP player, float partialTicks, Color color, boolean fadeOut, int fadeStart0, int fadeEnd0) { GlStateManager.enableBlend(); GlStateManager.tryBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO);