From 3de02cbf21c98d6c7d34fe6a2e7487ed32fed58a Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 26 Feb 2019 18:34:11 -0800 Subject: [PATCH 01/32] brady save me idk how to gl --- .../utils/ExampleBaritoneControl.java | 7 ++ .../java/baritone/utils/GuiClickMeme.java | 97 +++++++++++++++++++ .../java/baritone/utils/PathRenderer.java | 3 + 3 files changed, 107 insertions(+) create mode 100644 src/main/java/baritone/utils/GuiClickMeme.java diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java index 31ee8ff1f..a5fe93e9f 100644 --- a/src/main/java/baritone/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java @@ -407,6 +407,13 @@ public class ExampleBaritoneControl extends Behavior implements Helper { logDirect("Started mining blocks of type " + Arrays.toString(blockTypes)); return true; } + if (msg.equals("click")) { + mc.addScheduledTask(() -> { + mc.displayGuiScreen(new GuiClickMeme()); + }); + logDirect("click owo"); + return true; + } if (msg.startsWith("thisway") || msg.startsWith("forward")) { try { Goal goal = GoalXZ.fromDirection(ctx.playerFeetAsVec(), ctx.player().rotationYaw, Double.parseDouble(msg.substring(7).trim())); diff --git a/src/main/java/baritone/utils/GuiClickMeme.java b/src/main/java/baritone/utils/GuiClickMeme.java new file mode 100644 index 000000000..1e5e096e3 --- /dev/null +++ b/src/main/java/baritone/utils/GuiClickMeme.java @@ -0,0 +1,97 @@ +/* + * This file is part of Baritone. + * + * Baritone is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Baritone. If not, see . + */ + +package baritone.utils; + +import baritone.Baritone; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.entity.Entity; +import net.minecraft.util.math.Vec3d; +import org.lwjgl.BufferUtils; +import org.lwjgl.opengl.Display; +import org.lwjgl.util.glu.GLU; + +import java.awt.*; +import java.nio.FloatBuffer; +import java.nio.IntBuffer; + +import static org.lwjgl.opengl.GL11.*; + +public class GuiClickMeme extends GuiScreen { + private final FloatBuffer MODELVIEW = BufferUtils.createFloatBuffer(16); + private final FloatBuffer PROJECTION = BufferUtils.createFloatBuffer(16); + private final IntBuffer VIEWPORT = BufferUtils.createIntBuffer(16); + private final FloatBuffer TO_SCREEN_BUFFER = BufferUtils.createFloatBuffer(3); + private final FloatBuffer TO_WORLD_BUFFER = BufferUtils.createFloatBuffer(3); + private Vec3d meme; + + @Override + public boolean doesGuiPauseGame() { + return false; + } + + @Override + public void drawScreen(int mouseX, int mouseY, float partialTicks) { + System.out.println("Screen " + mouseX + " " + mouseY); + System.out.println(toWorld(mouseX, mouseY, 0)); + System.out.println(toWorld(mouseX, mouseY, 0.1)); + System.out.println(toWorld(mouseX, mouseY, 1)); + System.out.println(VIEWPORT.get(3) + " " + Display.getHeight()); + meme = toWorld(mouseX, Display.getHeight() - mouseY, 0); + System.out.println(toScreen(mc.player.posX + 1, mc.player.posY, mc.player.posZ)); + System.out.println(toScreen(1, 0, 0)); + } + + public void onRender(float partialTicks) { + System.out.println("on render"); + GlStateManager.getFloat(GL_MODELVIEW_MATRIX, (FloatBuffer) MODELVIEW.clear()); + GlStateManager.getFloat(GL_PROJECTION_MATRIX, (FloatBuffer) PROJECTION.clear()); + GlStateManager.glGetInteger(GL_VIEWPORT, (IntBuffer) VIEWPORT.clear()); + if (meme != null) { + Entity e = mc.getRenderViewEntity(); + GlStateManager.enableBlend(); + GlStateManager.tryBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO); + GlStateManager.color(Color.RED.getColorComponents(null)[0], Color.RED.getColorComponents(null)[1], Color.RED.getColorComponents(null)[2], 0.4F); + GlStateManager.glLineWidth(Baritone.settings().pathRenderLineWidthPixels.get()); + GlStateManager.disableTexture2D(); + GlStateManager.depthMask(false); + PathRenderer.drawLine(e, e.posX + 1, e.posY, e.posZ, e.posX + meme.x + 1, e.posY + meme.y, e.posZ + meme.z, partialTicks); + Tessellator.getInstance().draw(); + GlStateManager.depthMask(true); + GlStateManager.enableTexture2D(); + GlStateManager.disableBlend(); + } + } + + public Vec3d toWorld(double x, double y, double z) { + boolean result = GLU.gluUnProject((float) x, (float) y, (float) z, MODELVIEW, PROJECTION, VIEWPORT, (FloatBuffer) TO_WORLD_BUFFER.clear()); + if (result) { + return new Vec3d(TO_WORLD_BUFFER.get(0), TO_WORLD_BUFFER.get(1), TO_WORLD_BUFFER.get(2)); + } + return null; + } + + public Vec3d toScreen(double x, double y, double z) { + boolean result = GLU.gluProject((float) x, (float) y, (float) z, MODELVIEW, PROJECTION, VIEWPORT, (FloatBuffer) TO_SCREEN_BUFFER.clear()); + if (result) { + return new Vec3d(TO_SCREEN_BUFFER.get(0), Display.getHeight() - TO_SCREEN_BUFFER.get(1), TO_SCREEN_BUFFER.get(2)); + } + return null; + } +} diff --git a/src/main/java/baritone/utils/PathRenderer.java b/src/main/java/baritone/utils/PathRenderer.java index 06e298be3..a51f2e8d7 100644 --- a/src/main/java/baritone/utils/PathRenderer.java +++ b/src/main/java/baritone/utils/PathRenderer.java @@ -59,6 +59,9 @@ public final class PathRenderer implements Helper { public static void render(RenderEvent event, PathingBehavior behavior) { float partialTicks = event.getPartialTicks(); Goal goal = behavior.getGoal(); + if (mc.currentScreen instanceof GuiClickMeme) { + ((GuiClickMeme) mc.currentScreen).onRender(partialTicks); + } int thisPlayerDimension = behavior.baritone.getPlayerContext().world().provider.getDimensionType().getId(); int currentRenderViewDimension = BaritoneAPI.getProvider().getPrimaryBaritone().getPlayerContext().world().provider.getDimensionType().getId(); From c474cdb1f819853f8fb8c430bde713e9d74b7098 Mon Sep 17 00:00:00 2001 From: Brady Date: Tue, 26 Feb 2019 21:41:08 -0600 Subject: [PATCH 02/32] Working clicking goals --- .../utils/ExampleBaritoneControl.java | 11 +++-- .../java/baritone/utils/GuiClickMeme.java | 48 ++++++++++++++----- 2 files changed, 42 insertions(+), 17 deletions(-) diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java index a5fe93e9f..041a54011 100644 --- a/src/main/java/baritone/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java @@ -408,10 +408,13 @@ public class ExampleBaritoneControl extends Behavior implements Helper { return true; } if (msg.equals("click")) { - mc.addScheduledTask(() -> { - mc.displayGuiScreen(new GuiClickMeme()); - }); - logDirect("click owo"); + new Thread(() -> { + try { + Thread.sleep(100); + mc.addScheduledTask(() -> mc.displayGuiScreen(new GuiClickMeme())); + } catch (Exception ignored) {} + }).start(); + logDirect("aight dude"); return true; } if (msg.startsWith("thisway") || msg.startsWith("forward")) { diff --git a/src/main/java/baritone/utils/GuiClickMeme.java b/src/main/java/baritone/utils/GuiClickMeme.java index 1e5e096e3..66a067255 100644 --- a/src/main/java/baritone/utils/GuiClickMeme.java +++ b/src/main/java/baritone/utils/GuiClickMeme.java @@ -18,28 +18,37 @@ package baritone.utils; import baritone.Baritone; +import baritone.api.BaritoneAPI; +import baritone.api.pathing.goals.GoalBlock; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.Tessellator; import net.minecraft.entity.Entity; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.Vec3d; import org.lwjgl.BufferUtils; +import org.lwjgl.input.Mouse; import org.lwjgl.opengl.Display; import org.lwjgl.util.glu.GLU; import java.awt.*; +import java.io.IOException; import java.nio.FloatBuffer; import java.nio.IntBuffer; +import java.util.Collections; import static org.lwjgl.opengl.GL11.*; public class GuiClickMeme extends GuiScreen { + + // My name is Brady and I grant Leijurv permission to use this pasted code private final FloatBuffer MODELVIEW = BufferUtils.createFloatBuffer(16); private final FloatBuffer PROJECTION = BufferUtils.createFloatBuffer(16); private final IntBuffer VIEWPORT = BufferUtils.createIntBuffer(16); private final FloatBuffer TO_SCREEN_BUFFER = BufferUtils.createFloatBuffer(3); private final FloatBuffer TO_WORLD_BUFFER = BufferUtils.createFloatBuffer(3); - private Vec3d meme; + + private BlockPos meme; @Override public boolean doesGuiPauseGame() { @@ -48,21 +57,32 @@ public class GuiClickMeme extends GuiScreen { @Override public void drawScreen(int mouseX, int mouseY, float partialTicks) { - System.out.println("Screen " + mouseX + " " + mouseY); - System.out.println(toWorld(mouseX, mouseY, 0)); - System.out.println(toWorld(mouseX, mouseY, 0.1)); - System.out.println(toWorld(mouseX, mouseY, 1)); - System.out.println(VIEWPORT.get(3) + " " + Display.getHeight()); - meme = toWorld(mouseX, Display.getHeight() - mouseY, 0); - System.out.println(toScreen(mc.player.posX + 1, mc.player.posY, mc.player.posZ)); - System.out.println(toScreen(1, 0, 0)); + int mx = Mouse.getX(); + int my = Mouse.getY(); + Vec3d near = toWorld(mx, my, 0); + Vec3d far = toWorld(mx, my, 1); // "Use 0.945 that's what stack overflow says" - Leijurv + if (near != null && far != null) { + Vec3d viewerPos = new Vec3d(mc.getRenderManager().viewerPosX, mc.getRenderManager().viewerPosY, mc.getRenderManager().viewerPosZ); + RayTraceResult result = mc.world.rayTraceBlocks(near.add(viewerPos), far.add(viewerPos), false, false, true); + if (result != null && result.typeOfHit == RayTraceResult.Type.BLOCK) { + meme = result.getBlockPos(); + } + } + } + + @Override + protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { + super.mouseClicked(mouseX, mouseY, mouseButton); + if (mouseButton == 0) { + BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().setGoal(new GoalBlock(meme)); + } } public void onRender(float partialTicks) { - System.out.println("on render"); GlStateManager.getFloat(GL_MODELVIEW_MATRIX, (FloatBuffer) MODELVIEW.clear()); GlStateManager.getFloat(GL_PROJECTION_MATRIX, (FloatBuffer) PROJECTION.clear()); GlStateManager.glGetInteger(GL_VIEWPORT, (IntBuffer) VIEWPORT.clear()); + if (meme != null) { Entity e = mc.getRenderViewEntity(); GlStateManager.enableBlend(); @@ -71,8 +91,10 @@ public class GuiClickMeme extends GuiScreen { GlStateManager.glLineWidth(Baritone.settings().pathRenderLineWidthPixels.get()); GlStateManager.disableTexture2D(); GlStateManager.depthMask(false); - PathRenderer.drawLine(e, e.posX + 1, e.posY, e.posZ, e.posX + meme.x + 1, e.posY + meme.y, e.posZ + meme.z, partialTicks); - Tessellator.getInstance().draw(); + + // drawSingleSelectionBox WHEN? + PathRenderer.drawManySelectionBoxes(e, Collections.singletonList(meme), partialTicks, Color.CYAN); + GlStateManager.depthMask(true); GlStateManager.enableTexture2D(); GlStateManager.disableBlend(); From 3dbbe053d7a9d90ee0b3f246abde32af6967681f Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 26 Feb 2019 19:45:20 -0800 Subject: [PATCH 03/32] teensy change --- src/main/java/baritone/utils/GuiClickMeme.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/baritone/utils/GuiClickMeme.java b/src/main/java/baritone/utils/GuiClickMeme.java index 66a067255..8f485ffb9 100644 --- a/src/main/java/baritone/utils/GuiClickMeme.java +++ b/src/main/java/baritone/utils/GuiClickMeme.java @@ -20,6 +20,7 @@ package baritone.utils; import baritone.Baritone; import baritone.api.BaritoneAPI; import baritone.api.pathing.goals.GoalBlock; +import baritone.api.pathing.goals.GoalTwoBlocks; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.entity.Entity; @@ -74,7 +75,9 @@ public class GuiClickMeme extends GuiScreen { protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { super.mouseClicked(mouseX, mouseY, mouseButton); if (mouseButton == 0) { - BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().setGoal(new GoalBlock(meme)); + BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().setGoalAndPath(new GoalTwoBlocks(meme)); + } else if (mouseButton == 1) { + BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().setGoalAndPath(new GoalBlock(meme.up())); } } From 76914b78591985e190ee8b00a3405aa6793c72ae Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 26 Feb 2019 19:50:35 -0800 Subject: [PATCH 04/32] awesome --- scripts/proguard.pro | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/proguard.pro b/scripts/proguard.pro index e4189f7f3..1c67e2584 100644 --- a/scripts/proguard.pro +++ b/scripts/proguard.pro @@ -13,8 +13,7 @@ -repackageclasses 'baritone' # lwjgl is weird --dontwarn org.lwjgl.opengl.GL14 --dontwarn org.lwjgl.opengl.GL11 +-dontwarn org.lwjgl.* -keep class baritone.api.** { *; } # this is the keep api From 596849c7e68be492c662e6653602fbb23149e310 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 26 Feb 2019 19:51:20 -0800 Subject: [PATCH 05/32] i am rarted --- scripts/proguard.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/proguard.pro b/scripts/proguard.pro index 1c67e2584..4bed6b5dc 100644 --- a/scripts/proguard.pro +++ b/scripts/proguard.pro @@ -13,7 +13,7 @@ -repackageclasses 'baritone' # lwjgl is weird --dontwarn org.lwjgl.* +-dontwarn org.lwjgl.** -keep class baritone.api.** { *; } # this is the keep api From a47b0c0581b59436e9fdf2ef4af9c4bcae53a4a9 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 27 Feb 2019 12:00:39 -0800 Subject: [PATCH 06/32] rendering cleanup, fixes #317 --- .../java/baritone/utils/GuiClickMeme.java | 22 +------------ .../java/baritone/utils/PathRenderer.java | 33 ++++++++----------- 2 files changed, 15 insertions(+), 40 deletions(-) diff --git a/src/main/java/baritone/utils/GuiClickMeme.java b/src/main/java/baritone/utils/GuiClickMeme.java index 8f485ffb9..1db794bab 100644 --- a/src/main/java/baritone/utils/GuiClickMeme.java +++ b/src/main/java/baritone/utils/GuiClickMeme.java @@ -17,7 +17,6 @@ package baritone.utils; -import baritone.Baritone; import baritone.api.BaritoneAPI; import baritone.api.pathing.goals.GoalBlock; import baritone.api.pathing.goals.GoalTwoBlocks; @@ -88,19 +87,8 @@ public class GuiClickMeme extends GuiScreen { if (meme != null) { Entity e = mc.getRenderViewEntity(); - GlStateManager.enableBlend(); - GlStateManager.tryBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO); - GlStateManager.color(Color.RED.getColorComponents(null)[0], Color.RED.getColorComponents(null)[1], Color.RED.getColorComponents(null)[2], 0.4F); - GlStateManager.glLineWidth(Baritone.settings().pathRenderLineWidthPixels.get()); - GlStateManager.disableTexture2D(); - GlStateManager.depthMask(false); - // drawSingleSelectionBox WHEN? - PathRenderer.drawManySelectionBoxes(e, Collections.singletonList(meme), partialTicks, Color.CYAN); - - GlStateManager.depthMask(true); - GlStateManager.enableTexture2D(); - GlStateManager.disableBlend(); + PathRenderer.drawManySelectionBoxes(e, Collections.singletonList(meme), Color.CYAN); } } @@ -111,12 +99,4 @@ public class GuiClickMeme extends GuiScreen { } return null; } - - public Vec3d toScreen(double x, double y, double z) { - boolean result = GLU.gluProject((float) x, (float) y, (float) z, MODELVIEW, PROJECTION, VIEWPORT, (FloatBuffer) TO_SCREEN_BUFFER.clear()); - if (result) { - return new Vec3d(TO_SCREEN_BUFFER.get(0), Display.getHeight() - TO_SCREEN_BUFFER.get(1), TO_SCREEN_BUFFER.get(2)); - } - return null; - } } diff --git a/src/main/java/baritone/utils/PathRenderer.java b/src/main/java/baritone/utils/PathRenderer.java index a51f2e8d7..c0af870ee 100644 --- a/src/main/java/baritone/utils/PathRenderer.java +++ b/src/main/java/baritone/utils/PathRenderer.java @@ -105,9 +105,9 @@ public final class PathRenderer implements Helper { //long split = System.nanoTime(); if (current != null) { - drawManySelectionBoxes(renderView, current.toBreak(), partialTicks, Baritone.settings().colorBlocksToBreak.get()); - drawManySelectionBoxes(renderView, current.toPlace(), partialTicks, Baritone.settings().colorBlocksToPlace.get()); - drawManySelectionBoxes(renderView, current.toWalkInto(), partialTicks, Baritone.settings().colorBlocksToWalkInto.get()); + drawManySelectionBoxes(renderView, current.toBreak(), Baritone.settings().colorBlocksToBreak.get()); + drawManySelectionBoxes(renderView, current.toPlace(), Baritone.settings().colorBlocksToPlace.get()); + drawManySelectionBoxes(renderView, current.toWalkInto(), Baritone.settings().colorBlocksToWalkInto.get()); } // If there is a path calculation currently running, render the path calculation process @@ -118,7 +118,7 @@ public final class PathRenderer implements Helper { currentlyRunning.pathToMostRecentNodeConsidered().ifPresent(mr -> { drawPath(mr, 0, renderView, partialTicks, Baritone.settings().colorMostRecentConsidered.get(), Baritone.settings().fadePath.get(), 10, 20); - drawManySelectionBoxes(renderView, Collections.singletonList(mr.getDest()), partialTicks, Baritone.settings().colorMostRecentConsidered.get()); + drawManySelectionBoxes(renderView, Collections.singletonList(mr.getDest()), Baritone.settings().colorMostRecentConsidered.get()); }); }); //long end = System.nanoTime(); @@ -175,7 +175,7 @@ public final class PathRenderer implements Helper { } GlStateManager.color(color.getColorComponents(null)[0], color.getColorComponents(null)[1], color.getColorComponents(null)[2], alpha); } - drawLine(player, x1, y1, z1, x2, y2, z2, partialTicks); + drawLine(player, x1, y1, z1, x2, y2, z2); tessellator.draw(); } if (Baritone.settings().renderPathIgnoreDepth.get()) { @@ -187,10 +187,10 @@ public final class PathRenderer implements Helper { GlStateManager.disableBlend(); } - public static void drawLine(Entity player, double bp1x, double bp1y, double bp1z, double bp2x, double bp2y, double bp2z, float partialTicks) { - double d0 = player.lastTickPosX + (player.posX - player.lastTickPosX) * (double) partialTicks; - double d1 = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double) partialTicks; - double d2 = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double) partialTicks; + public static void drawLine(Entity player, double bp1x, double bp1y, double bp1z, double bp2x, double bp2y, double bp2z) { + double d0 = mc.getRenderManager().viewerPosX; + double d1 = mc.getRenderManager().viewerPosY; + double d2 = mc.getRenderManager().viewerPosZ; BUFFER.begin(GL_LINE_STRIP, DefaultVertexFormats.POSITION); BUFFER.pos(bp1x + 0.5D - d0, bp1y + 0.5D - d1, bp1z + 0.5D - d2).endVertex(); BUFFER.pos(bp2x + 0.5D - d0, bp2y + 0.5D - d1, bp2z + 0.5D - d2).endVertex(); @@ -199,7 +199,7 @@ public final class PathRenderer implements Helper { BUFFER.pos(bp1x + 0.5D - d0, bp1y + 0.5D - d1, bp1z + 0.5D - d2).endVertex(); } - public static void drawManySelectionBoxes(Entity player, Collection positions, float partialTicks, Color color) { + public static void drawManySelectionBoxes(Entity player, Collection positions, Color color) { GlStateManager.enableBlend(); GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); GlStateManager.color(color.getColorComponents(null)[0], color.getColorComponents(null)[1], color.getColorComponents(null)[2], 0.4F); @@ -213,10 +213,6 @@ public final class PathRenderer implements Helper { float expand = 0.002F; //BlockPos blockpos = movingObjectPositionIn.getBlockPos(); - - double renderPosX = player.lastTickPosX + (player.posX - player.lastTickPosX) * (double) partialTicks; - double renderPosY = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double) partialTicks; - double renderPosZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double) partialTicks; BlockStateInterface bsi = new BlockStateInterface(BaritoneAPI.getProvider().getPrimaryBaritone().getPlayerContext()); // TODO this assumes same dimension between primary baritone and render view? is this safe? positions.forEach(pos -> { IBlockState state = bsi.get0(pos); @@ -226,7 +222,7 @@ public final class PathRenderer implements Helper { } else { toDraw = state.getSelectedBoundingBox(player.world, pos); } - toDraw = toDraw.expand(expand, expand, expand).offset(-renderPosX, -renderPosY, -renderPosZ); + toDraw = toDraw.expand(expand, expand, expand).offset(-mc.getRenderManager().viewerPosX, -mc.getRenderManager().viewerPosY, -mc.getRenderManager().viewerPosZ); BUFFER.begin(GL_LINE_STRIP, DefaultVertexFormats.POSITION); BUFFER.pos(toDraw.minX, toDraw.minY, toDraw.minZ).endVertex(); BUFFER.pos(toDraw.maxX, toDraw.minY, toDraw.minZ).endVertex(); @@ -263,10 +259,9 @@ public final class PathRenderer implements Helper { } public static void drawDankLitGoalBox(Entity player, Goal goal, float partialTicks, Color color) { - double renderPosX = player.lastTickPosX + (player.posX - player.lastTickPosX) * (double) partialTicks; - double renderPosY = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double) partialTicks; - double renderPosZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double) partialTicks; - + double renderPosX = mc.getRenderManager().viewerPosX; + double renderPosY = mc.getRenderManager().viewerPosY; + double renderPosZ = mc.getRenderManager().viewerPosZ; double minX; double maxX; double minZ; From bf25d7328eaa18e8d5ee9c0289ae917b31b97076 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 27 Feb 2019 12:23:05 -0800 Subject: [PATCH 07/32] revalidate on goal update too --- src/main/java/baritone/process/CustomGoalProcess.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/baritone/process/CustomGoalProcess.java b/src/main/java/baritone/process/CustomGoalProcess.java index 00d3c8025..a62342273 100644 --- a/src/main/java/baritone/process/CustomGoalProcess.java +++ b/src/main/java/baritone/process/CustomGoalProcess.java @@ -55,6 +55,9 @@ public class CustomGoalProcess extends BaritoneProcessHelper implements ICustomG if (this.state == State.NONE) { this.state = State.GOAL_SET; } + if (this.state == State.EXECUTING) { + this.state = State.PATH_REQUESTED; + } } @Override From 0ed6ccab716cefe20ce2de08fafe8c6c7e592453 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 27 Feb 2019 15:46:28 -0800 Subject: [PATCH 08/32] update some documentation --- FEATURES.md | 2 +- INSTALL.md | 90 ----------------------------------------------------- README.md | 6 ++-- SETUP.md | 21 +++++++------ USAGE.md | 3 +- 5 files changed, 17 insertions(+), 105 deletions(-) delete mode 100644 INSTALL.md diff --git a/FEATURES.md b/FEATURES.md index 09c932f04..372a77410 100644 --- a/FEATURES.md +++ b/FEATURES.md @@ -4,7 +4,7 @@ - **Block breaking** Baritone considers breaking blocks as part of its path. It also takes into account your current tool set and hot bar. For example, if you have a Eff V diamond pick, it may choose to mine through a stone barrier, while if you only had a wood pick it might be faster to climb over it. - **Block placing** Baritone considers placing blocks as part of its path. This includes sneak-back-placing, pillaring, etc. It has a configurable penalty of placing a block (set to 1 second by default), to conserve its resources. The list of acceptable throwaway blocks is also configurable, and is cobble, dirt, or netherrack by default. Example - **Falling** Baritone will fall up to 3 blocks onto solid ground (configurable, if you have Feather Falling and/or don't mind taking a little damage). If you have a water bucket on your hotbar, it will fall up to 23 blocks and place the bucket beneath it. It will fall an unlimited distance into existing still water. -- **Vines and ladders** Baritone understands how to climb and descend vines and ladders. There is experimental support for more advanced maneuvers, like strafing to a different ladder / vine column in midair (off by default, setting named `allowVines`). +- **Vines and ladders** Baritone understands how to climb and descend vines and ladders. There is experimental support for more advanced maneuvers, like strafing to a different ladder / vine column in midair (off by default, setting named `allowVines`). Baritone can break its fall by grabbing ladders / vines midair, and understands when that is and isn't possible. - **Opening fence gates and doors** - **Slabs and stairs** - **Falling blocks** Baritone understands the costs of breaking blocks with falling blocks on top, and includes all of their break costs. Additionally, since it avoids breaking any blocks touching a liquid, it won't break the bottom of a gravel stack below a lava lake (anymore). diff --git a/INSTALL.md b/INSTALL.md deleted file mode 100644 index e66054b64..000000000 --- a/INSTALL.md +++ /dev/null @@ -1,90 +0,0 @@ -# Integration between Baritone and Impact -Impact 4.4 has Baritone included. - -These instructions apply to Impact 4.3. - -For Forge follow the instructions in [Setup](SETUP.md). - -To run Baritone on Vanilla, just follow the instructions in the README (it's `./gradlew runClient`). - -## An Introduction -There are some basic steps to getting Baritone setup with Impact. -- Acquiring a build of Baritone -- Placing Baritone in the libraries directory -- Modifying the Impact Profile JSON to run baritone -- How to use Baritone - -## Acquiring a build of Baritone -There are two methods of acquiring a build of Baritone - -### Official Release (Not always up to date) -https://github.com/cabaletta/baritone/releases - -For Impact 4.3, there is no Baritone integration yet, so you will want `baritone-standalone-X.Y.Z.jar`. **For the rest of this guide, replace `X.Y.Z` with the actual numeric version you are using.** - -Any official release will be GPG signed by leijurv (44A3EA646EADAC6A) and ZeroMemes (73A788379A197567). Please verify that the hash of the file you download is in `checksums.txt` and that `checksums_signed.asc` is a valid signature by those two public keys of `checksums.txt`. - -The build is fully deterministic and reproducible, and you can verify Travis did it properly by running `docker build --no-cache -t cabaletta/baritone .` yourself and comparing the shasum. This works identically on Travis, Mac, and Linux (if you have docker on Windows, I'd be grateful if you could let me know if it works there too). - -### Building Baritone yourself -You can either build Baritone through a command line or through IntelliJ's UI, information on that can be found [here](SETUP.md#building). - -## Placing Baritone in the libraries directory -``/libraries`` is a neat directory in your Minecraft Installation Directory -that contains all of the dependencies that are required from the game and some mods. This is where we will be -putting baritone. -- Locate the ``libraries`` folder, it should be in the Minecraft Installation Directory -- Create 3 new subdirectories starting from ``libraries`` - - ``cabaletta`` - - ``baritone`` - - ``X.Y.Z`` - - Copy the build of Baritone that was acquired earlier, and place it into the ``X.Y.Z`` folder, renamed like so: - - The full path should look like ``/libraries/cabaletta/baritone/X.Y.Z/baritone-X.Y.Z.jar`` - -## Modifying the Impact Profile JSON to run baritone -The final step is "registering" the Baritone library with Impact, so that it loads on launch. -- Ensure your Minecraft launcher is closed -- Navigate back to the Minecraft Installation Directory -- Find the ``versions`` directory, and open in -- In here there should be a ``1.12.2-Impact_4.3`` folder. - - If you don't have any Impact folder or have a version older than 4.3, you can download Impact here. -- Open the folder and inside there should be a file called ``1.12.2-Impact_4.3.json`` -- Open the JSON file with a text editor that supports your system's line endings - - For example, Notepad on Windows likely will NOT work for this. You should instead use a Text Editor like - Notepad++ if you're on Windows. (For other systems, I'm not sure - what would work the best so you may have to do some research.) -- Find the ``libraries`` array in the JSON. It should look something like this. - ``` - "libraries": [ - { - "name": "net.minecraft:launchwrapper:1.12" - }, - { - "name": "com.github.ImpactDevelopment:Impact:4.3-1.12.2", - "url": "https://impactdevelopment.github.io/maven/" - }, - { - "name": "com.github.ImpactDeveloment:ClientAPI:3.0.2", - "url": "https://impactdevelopment.github.io/maven/" - }, - ... - ``` -- Create two new objects in the array, between the ``Impact`` and ``ClientAPI`` dependencies preferably. - ``` - { - "name": "cabaletta:baritone:X.Y.Z" - }, - { - "name": "com.github.ImpactDevelopment:SimpleTweaker:1.2", - "url": "https://impactdevelopment.github.io/maven/" - }, - ``` -- Now find the ``"minecraftArguments": "..."`` text near the top. -- At the very end of the quotes where it says ``--tweakClass clientapi.load.ClientTweaker"``, add on the following so it looks like: - - ``--tweakClass clientapi.load.ClientTweaker --tweakClass baritone.launch.BaritoneTweaker"`` -- If you didn't close your launcher for this step, restart it now. -- You can now launch Impact 4.3 as normal, and Baritone should start up - - ## How to use Baritone - -- [Baritone chat control usage](USAGE.md) diff --git a/README.md b/README.md index 928acab80..5aee57022 100644 --- a/README.md +++ b/README.md @@ -40,11 +40,9 @@ Here are some links to help to get started: - [Features](FEATURES.md) -- [Setup](SETUP.md) +- [Installation & setup](SETUP.md) -- [Installation](INSTALL.md) - -- [Javadocs](https://baritone.leijurv.com/) +- [API Javadocs](https://baritone.leijurv.com/) - [Settings](https://baritone.leijurv.com/baritone/api/Settings.html#field.detail) diff --git a/SETUP.md b/SETUP.md index 6d50a85be..33563147d 100644 --- a/SETUP.md +++ b/SETUP.md @@ -1,20 +1,23 @@ -# Setup +# Installation -## Prebuilt -(not always completely up to date with latest features) +## Prebuilt official releases +These releases are not always completely up to date with latest features, and are only released from `master`. (so if you want `builder` branch for example, you'll have to build it yourself) -Download from the [Releases](https://github.com/cabaletta/baritone/releases) +Link to the releases page: [Releases](https://github.com/cabaletta/baritone/releases) -The Forge releases can simply be added as a Forge mod. +Any official release will be GPG signed by leijurv (44A3EA646EADAC6A) and ZeroMemes (73A788379A197567). Please verify that the hash of the file you download is in `checksums.txt` and that `checksums_signed.asc` is a valid signature by those two public keys of `checksums.txt`. -If another one of your Forge mods has a Baritone integration, you want `baritone-api-forge-VERSION.jar`. Otherwise, you want `baritone-standalone-forge-VERSION.jar` +The build is fully deterministic and reproducible, and you can verify Travis did it properly by running `docker build --no-cache -t cabaletta/baritone .` yourself and comparing the shasum. This works identically on Travis, Mac, and Linux (if you have docker on Windows, I'd be grateful if you could let me know if it works there too). -Previously (Baritone v1.1.2 and below), it was not fully compatible with the latest version of Forge. `freeLook` was broken in Forge 14.23.4.2744. Forge 14.23.4.2743 or **older** worked with Baritone v1.1.2 and lower. Newer versions of Forge "worked", sort of, but Baritone's movement became unreliable and `freeLook` must be off. ## Artifacts Building Baritone will result in 5 artifacts created in the ``dist`` directory. These are the same as the artifacts created in the [releases](https://github.com/cabaletta/baritone/releases). +**The Forge release can simply be added as a Forge mod.** + +If another one of your Forge mods has a Baritone integration, you want `baritone-api-forge-VERSION.jar`. Otherwise, you want `baritone-standalone-forge-VERSION.jar` + - **API**: Only the non-api packages are obfuscated. This should be used in environments where other mods would like to use Baritone's features. - **Forge API**: Same as API, but packaged for Forge. This should be used where another mod has a Baritone integration. - **Standalone**: Everything is obfuscated. This should be used in environments where there are no other mods present that would like to use Baritone's features. @@ -22,9 +25,9 @@ Building Baritone will result in 5 artifacts created in the ``dist`` directory. - **Unoptimized**: Nothing is obfuscated. This shouldn't be used ever in production. ## More Info -To replace out Impact 4.4's Baritone build with a customized one, switch to the `impact4.4-compat` branch, build Baritone as above then copy `dist/baritone-api-$VERSION$.jar` into `minecraft/libraries/cabaletta/baritone-api/1.0.0/baritone-api-1.0.0.jar`, replacing the jar that was previously there. You also need to edit `minecraft/versions/1.12.2-Impact_4.4/1.12.2-Impact_4.4.json`, find the line `"name": "cabaletta:baritone-api:1.0.0"`, remove the comma from the end, and entirely remove the line that's immediately after (starts with `"url"`). +To replace out Impact 4.5's Baritone build with a customized one, build Baritone as above then copy `dist/baritone-api-$VERSION$.jar` into `minecraft/libraries/cabaletta/baritone-api/1.2/baritone-api-1.2.jar`, replacing the jar that was previously there. You also need to edit `minecraft/versions/1.12.2-Impact_4.5/1.12.2-Impact_4.5.json`, find the line `"name": "cabaletta:baritone-api:1.2"`, remove the comma from the end, and **entirely remove the next line** (starts with `"url"`). -Impact 4.4 **only** works with builds from the quite outdated `impact4.4-compat` branch. If you must have the latest Baritone features with Impact, and can't wait for 4.5, consider creating a standalone (non forge) build then adding it to Impact 4.**3** via the instructions in [Install](INSTALL.md). +You can verify whether or not it worked by running `.b version` in chat (only valid in Impact). If it says `v1.2.0` then you didn't do it properly, and it's still running the version that came with 4.5. ## Build it yourself - Clone or download Baritone diff --git a/USAGE.md b/USAGE.md index de5b836d3..6a07518b2 100644 --- a/USAGE.md +++ b/USAGE.md @@ -9,7 +9,7 @@ Therefore you can use a prefix before your messages. On Baritone v1.1.0 and newer: The prefix is `#` by default. Anything beginning with `#` isn't sent, and is only interpreted by Baritone. For older than v1.1.0, `#` must be enabled by toggling on the `prefix` setting. -**Only** in Impact 4.4 is `.b` also a valid prefix. In 4.4, `#` does **not** work, neither does saying the commands directly in chat. +**Only** in Impact is `.b` also a valid prefix. In 4.4, `#` does **not** work, neither does saying the commands directly in chat. `#` works by default in 4.5 (not 4.4). Other clients like Kami and Asuna have their own custom things (like `-path`), and can disable direct chat control entirely. @@ -39,6 +39,7 @@ Some common examples: - `axis` to go to an axis or diagonal axis at y=120 (`axisHeight` is a configurable setting, defaults to 120). - `invert` to invert the current goal and path. This gets as far away from it as possible, instead of as close as possible. For example, do `goal` then `invert` to run as far as possible from where you're standing at the start. - `render` to rerender the world in case `renderCachedChunks` is being glitchy +- `version` to get the version of Baritone you're running - `damn` daniel For the rest of the commands, you can take a look at the code [here](https://github.com/cabaletta/baritone/blob/master/src/main/java/baritone/utils/ExampleBaritoneControl.java). From 8ac82ebe2ae44b94c09e5c403b430d347b5b8ee9 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 27 Feb 2019 17:48:57 -0800 Subject: [PATCH 09/32] v1.2.2 --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index a03a89631..2044d3db3 100755 --- a/build.gradle +++ b/build.gradle @@ -16,7 +16,7 @@ */ group 'baritone' -version '1.2.1' +version '1.2.2' buildscript { repositories { From e767e34b92de076dfdc3ecba1256154a581c9a47 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 27 Feb 2019 22:15:54 -0800 Subject: [PATCH 10/32] well that was stupid, thanks thesmarttheorist --- src/main/java/baritone/utils/BlockPlaceHelper.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/baritone/utils/BlockPlaceHelper.java b/src/main/java/baritone/utils/BlockPlaceHelper.java index e0c782bb4..e93bf8073 100644 --- a/src/main/java/baritone/utils/BlockPlaceHelper.java +++ b/src/main/java/baritone/utils/BlockPlaceHelper.java @@ -21,7 +21,6 @@ import baritone.Baritone; import baritone.api.utils.IPlayerContext; import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumHand; -import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; public class BlockPlaceHelper implements Helper { @@ -38,13 +37,12 @@ public class BlockPlaceHelper implements Helper { return; } RayTraceResult mouseOver = ctx.objectMouseOver(); - BlockPos pos = mouseOver.getBlockPos(); - if (!rightClickRequested || ctx.player().isRowingBoat() || pos == null || mouseOver.typeOfHit != RayTraceResult.Type.BLOCK) { + if (!rightClickRequested || ctx.player().isRowingBoat() || mouseOver == null || mouseOver.getBlockPos() == null || mouseOver.typeOfHit != RayTraceResult.Type.BLOCK) { return; } rightClickTimer = Baritone.settings().rightClickSpeed.get(); for (EnumHand hand : EnumHand.values()) { - if (ctx.playerController().processRightClickBlock(ctx.player(), ctx.world(), pos, mouseOver.sideHit, mouseOver.hitVec, hand) == EnumActionResult.SUCCESS) { + if (ctx.playerController().processRightClickBlock(ctx.player(), ctx.world(), mouseOver.getBlockPos(), mouseOver.sideHit, mouseOver.hitVec, hand) == EnumActionResult.SUCCESS) { ctx.player().swingArm(hand); return; } From a4237bf1f943bab7b08cd7a35e295421fafe2530 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 27 Feb 2019 23:04:43 -0800 Subject: [PATCH 11/32] tentative fix to descend, needs testing --- .../pathing/movement/movements/MovementDescend.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDescend.java b/src/main/java/baritone/pathing/movement/movements/MovementDescend.java index 3a8ed913e..2a2679afc 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDescend.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDescend.java @@ -202,7 +202,8 @@ public class MovementDescend extends Movement { } BlockPos playerFeet = ctx.playerFeet(); - if (playerFeet.equals(dest) && (MovementHelper.isLiquid(ctx, dest) || ctx.player().posY - playerFeet.getY() < 0.094)) { // lilypads + BlockPos fakeDest = new BlockPos(dest.getX() * 2 - src.getX(), dest.getY(), dest.getZ() * 2 - src.getZ()); + if ((playerFeet.equals(dest) || playerFeet.equals(fakeDest)) && (MovementHelper.isLiquid(ctx, dest) || ctx.player().posY - dest.getY() < 0.5)) { // lilypads // Wait until we're actually on the ground before saying we're done because sometimes we continue to fall if the next action starts immediately return state.setStatus(MovementStatus.SUCCESS); /* else { @@ -228,12 +229,8 @@ public class MovementDescend extends Movement { double z = ctx.player().posZ - (src.getZ() + 0.5); double fromStart = Math.sqrt(x * x + z * z); if (!playerFeet.equals(dest) || ab > 0.25) { - BlockPos fakeDest = new BlockPos(dest.getX() * 2 - src.getX(), dest.getY(), dest.getZ() * 2 - src.getZ()); - if (numTicks++ < 20) { + if (numTicks++ < 20 && fromStart < 1.25) { MovementHelper.moveTowards(ctx, state, fakeDest); - if (fromStart > 1.25) { - state.getTarget().rotation = new Rotation(state.getTarget().rotation.getYaw() + 180F, state.getTarget().rotation.getPitch()); - } } else { MovementHelper.moveTowards(ctx, state, dest); } From c72eb3e19531c7548e7b9f5972429504f1888d33 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 28 Feb 2019 09:47:47 -0800 Subject: [PATCH 12/32] v1.2.3 --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 2044d3db3..e52cc3704 100755 --- a/build.gradle +++ b/build.gradle @@ -16,7 +16,7 @@ */ group 'baritone' -version '1.2.2' +version '1.2.3' buildscript { repositories { From 4c6f321cfff945b544e8dddc1d9aed99b794edd1 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 28 Feb 2019 12:12:16 -0800 Subject: [PATCH 13/32] clarify --- SETUP.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SETUP.md b/SETUP.md index 33563147d..cd19a5740 100644 --- a/SETUP.md +++ b/SETUP.md @@ -27,7 +27,7 @@ If another one of your Forge mods has a Baritone integration, you want `baritone ## More Info To replace out Impact 4.5's Baritone build with a customized one, build Baritone as above then copy `dist/baritone-api-$VERSION$.jar` into `minecraft/libraries/cabaletta/baritone-api/1.2/baritone-api-1.2.jar`, replacing the jar that was previously there. You also need to edit `minecraft/versions/1.12.2-Impact_4.5/1.12.2-Impact_4.5.json`, find the line `"name": "cabaletta:baritone-api:1.2"`, remove the comma from the end, and **entirely remove the next line** (starts with `"url"`). -You can verify whether or not it worked by running `.b version` in chat (only valid in Impact). If it says `v1.2.0` then you didn't do it properly, and it's still running the version that came with 4.5. +You can verify whether or not it worked by running `.b version` in chat (only valid in Impact). It should print out the version that you downloaded. Note: The version that comes with 4.5 is `v1.2.3`. ## Build it yourself - Clone or download Baritone From 701bc772a8664cbbabddf8fea9084a7c416107bb Mon Sep 17 00:00:00 2001 From: Leijurv Date: Fri, 1 Mar 2019 11:22:21 -0800 Subject: [PATCH 14/32] update impcat badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5aee57022..d59c7ba72 100644 --- a/README.md +++ b/README.md @@ -16,8 +16,8 @@ [![Minecraft](https://img.shields.io/badge/MC-1.12.2-green.svg)](https://minecraft.gamepedia.com/1.12.2) [![GitHub contributors](https://img.shields.io/github/contributors/cabaletta/baritone.svg)](https://github.com/cabaletta/baritone/graphs/contributors/) [![GitHub commits](https://img.shields.io/github/commits-since/cabaletta/baritone/v1.0.0.svg)](https://github.com/cabaletta/baritone/commit/) +[![Impact integration](https://img.shields.io/badge/Impact%20integration-v1.2.3-brightgreen.svg)](https://impactdevelopment.github.io/) [![Asuna integration](https://img.shields.io/badge/Asuna%20integration-builder%20branch-brightgreen.svg)](https://github.com/EmotionalLove/Asuna/) -[![Impact integration](https://img.shields.io/badge/Impact%20integration-v1.0.0--hotfix--4-green.svg)](https://impactdevelopment.github.io/) [![KAMI integration](https://img.shields.io/badge/KAMI%20integration-v1.0.0-orange.svg)](https://github.com/zeroeightysix/KAMI/) [![WWE integration](https://img.shields.io/badge/WWE%20%22integration%22-v1.0.0%3F%3F%20smh%20license%20violations-orange.svg)](https://wweclient.com/) [![Future integration](https://img.shields.io/badge/Future%20integration-Soon™%3F%3F%3F-red.svg)](https://futureclient.net/) From 3e47d485f9ba85854b52631895c069a3d7c7dc53 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Fri, 1 Mar 2019 12:11:47 -0800 Subject: [PATCH 15/32] emphasize and clarify lol --- SETUP.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SETUP.md b/SETUP.md index cd19a5740..49ab838f7 100644 --- a/SETUP.md +++ b/SETUP.md @@ -25,7 +25,7 @@ If another one of your Forge mods has a Baritone integration, you want `baritone - **Unoptimized**: Nothing is obfuscated. This shouldn't be used ever in production. ## More Info -To replace out Impact 4.5's Baritone build with a customized one, build Baritone as above then copy `dist/baritone-api-$VERSION$.jar` into `minecraft/libraries/cabaletta/baritone-api/1.2/baritone-api-1.2.jar`, replacing the jar that was previously there. You also need to edit `minecraft/versions/1.12.2-Impact_4.5/1.12.2-Impact_4.5.json`, find the line `"name": "cabaletta:baritone-api:1.2"`, remove the comma from the end, and **entirely remove the next line** (starts with `"url"`). +To replace out Impact 4.5's Baritone build with a customized one, build Baritone as above then copy & **rename** `dist/baritone-api-$VERSION$.jar` into `minecraft/libraries/cabaletta/baritone-api/1.2/baritone-api-1.2.jar`, replacing the jar that was previously there. You also need to edit `minecraft/versions/1.12.2-Impact_4.5/1.12.2-Impact_4.5.json`, find the line `"name": "cabaletta:baritone-api:1.2"`, remove the comma from the end, and **entirely remove the NEXT line** (starts with `"url"`). **Restart your launcher** then load as normal. You can verify whether or not it worked by running `.b version` in chat (only valid in Impact). It should print out the version that you downloaded. Note: The version that comes with 4.5 is `v1.2.3`. From 81b22019dd2c7d837a262a41cdf565d2863a3395 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 2 Mar 2019 21:43:11 -0800 Subject: [PATCH 16/32] Create CODE_OF_CONDUCT.md --- CODE_OF_CONDUCT.md | 76 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 CODE_OF_CONDUCT.md diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 000000000..3dc44d884 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,76 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, sex characteristics, gender identity and expression, +level of experience, education, socio-economic status, nationality, personal +appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at complaints@leijurv.com. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see +https://www.contributor-covenant.org/faq From c4652285319ae47249105437065a7d9b7a90cfaf Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 2 Mar 2019 21:44:20 -0800 Subject: [PATCH 17/32] consistency with the previously existing anime policy --- CODE_OF_CONDUCT.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 3dc44d884..8811361f3 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -14,6 +14,7 @@ appearance, race, religion, or sexual identity and orientation. Examples of behavior that contributes to creating a positive environment include: +* No Anime * Using welcoming and inclusive language * Being respectful of differing viewpoints and experiences * Gracefully accepting constructive criticism @@ -22,6 +23,7 @@ include: Examples of unacceptable behavior by participants include: +* Anime * The use of sexualized language or imagery and unwelcome sexual attention or advances * Trolling, insulting/derogatory comments, and personal or political attacks From 5904441a7ec88fcb0deea3187a39291549e9d091 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 2 Mar 2019 22:40:42 -0800 Subject: [PATCH 18/32] :heart: code of conduct --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index d59c7ba72..f5cf2b180 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ [![License](https://img.shields.io/badge/license-LGPL--3.0%20with%20anime%20exception-green.svg)](LICENSE) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/a73d037823b64a5faf597a18d71e3400)](https://www.codacy.com/app/leijurv/baritone?utm_source=github.com&utm_medium=referral&utm_content=cabaletta/baritone&utm_campaign=Badge_Grade) [![HitCount](http://hits.dwyl.com/cabaletta/baritone.svg)](http://hits.dwyl.com/cabaletta/baritone) +[![Code of Conduct](https://img.shields.io/badge/%E2%9D%A4-code%20of%20conduct-blue.svg?style=flat)](https://github.com/cabaletta/baritone/blob/master/CODE_OF_CONDUCT.md) [![Known Vulnerabilities](https://snyk.io/test/github/cabaletta/baritone/badge.svg?targetFile=build.gradle)](https://snyk.io/test/github/cabaletta/baritone?targetFile=build.gradle) [![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/cabaletta/baritone/issues) [![Issues](https://img.shields.io/github/issues/cabaletta/baritone.svg)](https://github.com/cabaletta/baritone/issues/) From 66c7a3f513c86ffc89ed724d2af4e0977daed02b Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 3 Mar 2019 21:29:31 -0800 Subject: [PATCH 19/32] this is really bad --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f5cf2b180..686547018 100644 --- a/README.md +++ b/README.md @@ -19,8 +19,8 @@ [![GitHub commits](https://img.shields.io/github/commits-since/cabaletta/baritone/v1.0.0.svg)](https://github.com/cabaletta/baritone/commit/) [![Impact integration](https://img.shields.io/badge/Impact%20integration-v1.2.3-brightgreen.svg)](https://impactdevelopment.github.io/) [![Asuna integration](https://img.shields.io/badge/Asuna%20integration-builder%20branch-brightgreen.svg)](https://github.com/EmotionalLove/Asuna/) -[![KAMI integration](https://img.shields.io/badge/KAMI%20integration-v1.0.0-orange.svg)](https://github.com/zeroeightysix/KAMI/) -[![WWE integration](https://img.shields.io/badge/WWE%20%22integration%22-v1.0.0%3F%3F%20smh%20license%20violations-orange.svg)](https://wweclient.com/) +[![KAMI integration](https://img.shields.io/badge/KAMI%20integration-v1.0.0-red.svg)](https://github.com/zeroeightysix/KAMI/) +[![WWE integration](https://img.shields.io/badge/WWE%20%22integration%22-v1.0.0%3F%3F%20smh%20license%20violations-red.svg)](https://wweclient.com/) [![Future integration](https://img.shields.io/badge/Future%20integration-Soon™%3F%3F%3F-red.svg)](https://futureclient.net/) [![ForgeHax integration](https://img.shields.io/badge/ForgeHax%20integration-Soon™-red.svg)](https://github.com/fr1kin/ForgeHax) From 558c14a3757425d3e294956c900a463e5199b337 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 4 Mar 2019 13:11:36 -0800 Subject: [PATCH 20/32] little cleanup --- src/main/java/baritone/utils/GuiClickMeme.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/baritone/utils/GuiClickMeme.java b/src/main/java/baritone/utils/GuiClickMeme.java index 1db794bab..1163b1b0e 100644 --- a/src/main/java/baritone/utils/GuiClickMeme.java +++ b/src/main/java/baritone/utils/GuiClickMeme.java @@ -28,7 +28,6 @@ import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.Vec3d; import org.lwjgl.BufferUtils; import org.lwjgl.input.Mouse; -import org.lwjgl.opengl.Display; import org.lwjgl.util.glu.GLU; import java.awt.*; @@ -45,7 +44,6 @@ public class GuiClickMeme extends GuiScreen { private final FloatBuffer MODELVIEW = BufferUtils.createFloatBuffer(16); private final FloatBuffer PROJECTION = BufferUtils.createFloatBuffer(16); private final IntBuffer VIEWPORT = BufferUtils.createIntBuffer(16); - private final FloatBuffer TO_SCREEN_BUFFER = BufferUtils.createFloatBuffer(3); private final FloatBuffer TO_WORLD_BUFFER = BufferUtils.createFloatBuffer(3); private BlockPos meme; From 2133ab39b7f8749efaa93d45a5074ce0812bb7ef Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 4 Mar 2019 19:44:36 -0800 Subject: [PATCH 21/32] better cache, needs more testing --- src/main/java/baritone/cache/CachedChunk.java | 35 ++++++++++++++++--- src/main/java/baritone/cache/ChunkPacker.java | 15 +++++--- 2 files changed, 42 insertions(+), 8 deletions(-) diff --git a/src/main/java/baritone/cache/CachedChunk.java b/src/main/java/baritone/cache/CachedChunk.java index d2737190f..05ef8f3e0 100644 --- a/src/main/java/baritone/cache/CachedChunk.java +++ b/src/main/java/baritone/cache/CachedChunk.java @@ -86,6 +86,7 @@ public final class CachedChunk { temp.add(Blocks.WEB); temp.add(Blocks.NETHER_WART); temp.add(Blocks.LADDER); + temp.add(Blocks.VINE); BLOCKS_TO_KEEP_TRACK_OF = Collections.unmodifiableSet(temp); } @@ -118,6 +119,8 @@ public final class CachedChunk { */ private final BitSet data; + private final BitSet special; + /** * The block names of each surface level block for generating an overview */ @@ -139,12 +142,27 @@ public final class CachedChunk { this.heightMap = new int[256]; this.specialBlockLocations = specialBlockLocations; this.cacheTimestamp = cacheTimestamp; + this.special = new BitSet(); calculateHeightMap(); + setSpecial(); + } + + private final void setSpecial() { + for (List list : specialBlockLocations.values()) { + for (BlockPos pos : list) { + System.out.println("Turning on bit"); + special.set(getPositionIndex(pos.getX(), pos.getY(), pos.getZ()) >> 1); + } + } } public final IBlockState getBlock(int x, int y, int z, int dimension) { + int index = getPositionIndex(x, y, z); + PathingBlockType type = getType(index); int internalPos = z << 4 | x; - if (heightMap[internalPos] == y) { + if (heightMap[internalPos] == y && type != PathingBlockType.AVOID) { + // if the top block in a column is water, we cache it as AVOID but we don't want to just return default state water (which is not flowing) beacuse then it would try to path through it + // we have this exact block, it's a surface block /*System.out.println("Saying that " + x + "," + y + "," + z + " is " + state); if (!Minecraft.getMinecraft().world.getBlockState(new BlockPos(x + this.x * 16, y, z + this.z * 16)).getBlock().equals(state.getBlock())) { @@ -152,15 +170,24 @@ public final class CachedChunk { }*/ return overview[internalPos]; } - PathingBlockType type = getType(x, y, z); + if (special.get(index >> 1)) { + // this block is special + for (Map.Entry> entry : specialBlockLocations.entrySet()) { + for (BlockPos pos : entry.getValue()) { + if (pos.getX() == x && pos.getY() == y && pos.getZ() == z) { + return ChunkPacker.stringToBlock(entry.getKey()).getDefaultState(); + } + } + } + } + if (type == PathingBlockType.SOLID && y == 127 && dimension == -1) { return Blocks.BEDROCK.getDefaultState(); } return ChunkPacker.pathingTypeToBlock(type, dimension); } - private PathingBlockType getType(int x, int y, int z) { - int index = getPositionIndex(x, y, z); + private PathingBlockType getType(int index) { return PathingBlockType.fromBits(data.get(index), data.get(index + 1)); } diff --git a/src/main/java/baritone/cache/ChunkPacker.java b/src/main/java/baritone/cache/ChunkPacker.java index 892369d5b..7f447f87b 100644 --- a/src/main/java/baritone/cache/ChunkPacker.java +++ b/src/main/java/baritone/cache/ChunkPacker.java @@ -90,7 +90,8 @@ public final class ChunkPacker { IBlockState[] blocks = new IBlockState[256]; for (int z = 0; z < 16; z++) { - https://www.ibm.com/developerworks/library/j-perry-writing-good-java-code/index.html + https: +//www.ibm.com/developerworks/library/j-perry-writing-good-java-code/index.html for (int x = 0; x < 16; x++) { for (int y = 255; y >= 0; y--) { int index = CachedChunk.getPositionIndex(x, y, z); @@ -124,10 +125,16 @@ public final class ChunkPacker { if (block == Blocks.WATER || block == Blocks.FLOWING_WATER) { // only water source blocks are plausibly usable, flowing water should be avoid // FLOWING_WATER is a waterfall, it doesn't really matter and caching it as AVOID just makes it look wrong - if (!MovementHelper.possiblyFlowing(state)) { - return PathingBlockType.WATER; + if (MovementHelper.possiblyFlowing(state)) { + return PathingBlockType.AVOID; } - if (BlockLiquid.getSlopeAngle(chunk.getWorld(), new BlockPos(x + chunk.x << 4, y, z + chunk.z << 4), state.getMaterial(), state) != -1000.0F) { + if (x == 0 || x == 15 || z == 0 || z == 15) { + if (BlockLiquid.getSlopeAngle(chunk.getWorld(), new BlockPos(x + chunk.x << 4, y, z + chunk.z << 4), state.getMaterial(), state) == -1000.0F) { + return PathingBlockType.WATER; + } + return PathingBlockType.AVOID; + } + if (MovementHelper.possiblyFlowing(chunk.getBlockState(x + 1, y, z)) || MovementHelper.possiblyFlowing(chunk.getBlockState(x - 1, y, z)) || MovementHelper.possiblyFlowing(chunk.getBlockState(x, y, z + 1)) || MovementHelper.possiblyFlowing(chunk.getBlockState(x, y, z - 1))) { return PathingBlockType.AVOID; } return PathingBlockType.WATER; From 826f3788d043a42d74aa2fc84f6d4e0c752bd89f Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 4 Mar 2019 20:39:22 -0800 Subject: [PATCH 22/32] performance improvement and no allocation promise --- src/main/java/baritone/cache/CachedChunk.java | 24 +++++++------------ 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/src/main/java/baritone/cache/CachedChunk.java b/src/main/java/baritone/cache/CachedChunk.java index 05ef8f3e0..390ea3f3e 100644 --- a/src/main/java/baritone/cache/CachedChunk.java +++ b/src/main/java/baritone/cache/CachedChunk.java @@ -18,6 +18,7 @@ package baritone.cache; import baritone.utils.pathing.PathingBlockType; +import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; @@ -119,7 +120,7 @@ public final class CachedChunk { */ private final BitSet data; - private final BitSet special; + private final Int2ObjectOpenHashMap special; /** * The block names of each surface level block for generating an overview @@ -142,16 +143,15 @@ public final class CachedChunk { this.heightMap = new int[256]; this.specialBlockLocations = specialBlockLocations; this.cacheTimestamp = cacheTimestamp; - this.special = new BitSet(); + this.special = new Int2ObjectOpenHashMap<>(); calculateHeightMap(); setSpecial(); } private final void setSpecial() { - for (List list : specialBlockLocations.values()) { - for (BlockPos pos : list) { - System.out.println("Turning on bit"); - special.set(getPositionIndex(pos.getX(), pos.getY(), pos.getZ()) >> 1); + for (Map.Entry> entry : specialBlockLocations.entrySet()) { + for (BlockPos pos : entry.getValue()) { + special.put(getPositionIndex(pos.getX(), pos.getY(), pos.getZ()), entry.getKey()); } } } @@ -170,15 +170,9 @@ public final class CachedChunk { }*/ return overview[internalPos]; } - if (special.get(index >> 1)) { - // this block is special - for (Map.Entry> entry : specialBlockLocations.entrySet()) { - for (BlockPos pos : entry.getValue()) { - if (pos.getX() == x && pos.getY() == y && pos.getZ() == z) { - return ChunkPacker.stringToBlock(entry.getKey()).getDefaultState(); - } - } - } + String str = special.get(index); + if (str != null) { + return ChunkPacker.stringToBlock(str).getDefaultState(); } if (type == PathingBlockType.SOLID && y == 127 && dimension == -1) { From 0d15225b1d089dd09fdb36639e4b8d3a5057a0bf Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 4 Mar 2019 21:00:30 -0800 Subject: [PATCH 23/32] dont construct one unlesss we need to --- src/main/java/baritone/cache/CachedChunk.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/main/java/baritone/cache/CachedChunk.java b/src/main/java/baritone/cache/CachedChunk.java index 390ea3f3e..10c178986 100644 --- a/src/main/java/baritone/cache/CachedChunk.java +++ b/src/main/java/baritone/cache/CachedChunk.java @@ -143,9 +143,13 @@ public final class CachedChunk { this.heightMap = new int[256]; this.specialBlockLocations = specialBlockLocations; this.cacheTimestamp = cacheTimestamp; - this.special = new Int2ObjectOpenHashMap<>(); + if (specialBlockLocations.isEmpty()) { + this.special = null; + } else { + this.special = new Int2ObjectOpenHashMap<>(); + setSpecial(); + } calculateHeightMap(); - setSpecial(); } private final void setSpecial() { @@ -170,9 +174,11 @@ public final class CachedChunk { }*/ return overview[internalPos]; } - String str = special.get(index); - if (str != null) { - return ChunkPacker.stringToBlock(str).getDefaultState(); + if (special != null) { + String str = special.get(index); + if (str != null) { + return ChunkPacker.stringToBlock(str).getDefaultState(); + } } if (type == PathingBlockType.SOLID && y == 127 && dimension == -1) { From 71cb0f6d36387d223a55781e15beb9d1d7b7439e Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 4 Mar 2019 21:00:41 -0800 Subject: [PATCH 24/32] fix a weird way of getting stuck on a ladder --- .../pathing/movement/movements/MovementTraverse.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java index d618cf1a0..4a5687fd9 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java @@ -231,6 +231,13 @@ public class MovementTraverse extends Movement { if (ctx.playerFeet().equals(dest)) { return state.setStatus(MovementStatus.SUCCESS); } + Block low = BlockStateInterface.get(ctx, src).getBlock(); + Block high = BlockStateInterface.get(ctx, src.up()).getBlock(); + if (!ctx.player().onGround && (low == Blocks.VINE || low == Blocks.LADDER || high == Blocks.VINE || high == Blocks.LADDER)) { + // hitting W could cause us to climb the ladder instead of going forward + // wait until we're on the ground + return state; + } BlockPos into = dest.subtract(src).add(dest); Block intoBelow = BlockStateInterface.get(ctx, into).getBlock(); Block intoAbove = BlockStateInterface.get(ctx, into.up()).getBlock(); From a73f5c1359c720d113a7f6ecd576b718deaeea33 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 4 Mar 2019 21:20:13 -0800 Subject: [PATCH 25/32] crapton of performance improvements --- src/api/java/baritone/api/Settings.java | 5 +++++ src/api/java/baritone/api/cache/ICachedWorld.java | 4 ++-- src/main/java/baritone/cache/CachedChunk.java | 4 ++-- src/main/java/baritone/cache/CachedRegion.java | 13 +++++-------- src/main/java/baritone/cache/CachedWorld.java | 7 +++---- src/main/java/baritone/process/MineProcess.java | 5 +++-- .../java/baritone/utils/ExampleBaritoneControl.java | 2 +- 7 files changed, 21 insertions(+), 19 deletions(-) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 7b47a2a6f..6be16dad0 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -535,6 +535,11 @@ public final class Settings { */ public final Setting mineGoalUpdateInterval = new Setting<>(5); + /** + * After finding this many instances of the target block in the cache, it will stop expanding outward the chunk search. + */ + public final Setting maxCachedWorldScanCount = new Setting<>(10); + /** * When GetToBlock doesn't know any locations for the desired block, explore randomly instead of giving up. */ diff --git a/src/api/java/baritone/api/cache/ICachedWorld.java b/src/api/java/baritone/api/cache/ICachedWorld.java index a435ebe02..e681ce51c 100644 --- a/src/api/java/baritone/api/cache/ICachedWorld.java +++ b/src/api/java/baritone/api/cache/ICachedWorld.java @@ -20,7 +20,7 @@ package baritone.api.cache; import net.minecraft.util.math.BlockPos; import net.minecraft.world.chunk.Chunk; -import java.util.LinkedList; +import java.util.ArrayList; /** * @author Brady @@ -68,7 +68,7 @@ public interface ICachedWorld { * @param maxRegionDistanceSq The maximum region distance, squared * @return The locations found that match the special block */ - LinkedList getLocationsOf(String block, int maximum, int centerX, int centerZ, int maxRegionDistanceSq); + ArrayList getLocationsOf(String block, int maximum, int centerX, int centerZ, int maxRegionDistanceSq); /** * Reloads all of the cached regions in this world from disk. Anything that is not saved diff --git a/src/main/java/baritone/cache/CachedChunk.java b/src/main/java/baritone/cache/CachedChunk.java index 10c178986..08c80141a 100644 --- a/src/main/java/baritone/cache/CachedChunk.java +++ b/src/main/java/baritone/cache/CachedChunk.java @@ -215,11 +215,11 @@ public final class CachedChunk { return specialBlockLocations; } - public final LinkedList getAbsoluteBlocks(String blockType) { + public final ArrayList getAbsoluteBlocks(String blockType) { if (specialBlockLocations.get(blockType) == null) { return null; } - LinkedList res = new LinkedList<>(); + ArrayList res = new ArrayList<>(); for (BlockPos pos : specialBlockLocations.get(blockType)) { res.add(new BlockPos(pos.getX() + x * 16, pos.getY(), pos.getZ() + z * 16)); } diff --git a/src/main/java/baritone/cache/CachedRegion.java b/src/main/java/baritone/cache/CachedRegion.java index d8426197a..0081d9419 100644 --- a/src/main/java/baritone/cache/CachedRegion.java +++ b/src/main/java/baritone/cache/CachedRegion.java @@ -87,19 +87,16 @@ public final class CachedRegion implements ICachedRegion { return chunks[x >> 4][z >> 4] != null; } - public final LinkedList getLocationsOf(String block) { - LinkedList res = new LinkedList<>(); + public final ArrayList getLocationsOf(String block) { + ArrayList res = new ArrayList<>(); for (int chunkX = 0; chunkX < 32; chunkX++) { for (int chunkZ = 0; chunkZ < 32; chunkZ++) { if (chunks[chunkX][chunkZ] == null) { continue; } - List locs = chunks[chunkX][chunkZ].getAbsoluteBlocks(block); - if (locs == null) { - continue; - } - for (BlockPos pos : locs) { - res.add(pos); + ArrayList locs = chunks[chunkX][chunkZ].getAbsoluteBlocks(block); + if (locs != null) { + res.addAll(locs); } } } diff --git a/src/main/java/baritone/cache/CachedWorld.java b/src/main/java/baritone/cache/CachedWorld.java index db85339de..025ec773f 100644 --- a/src/main/java/baritone/cache/CachedWorld.java +++ b/src/main/java/baritone/cache/CachedWorld.java @@ -32,7 +32,6 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; -import java.util.LinkedList; import java.util.List; import java.util.concurrent.LinkedBlockingQueue; @@ -109,8 +108,8 @@ public final class CachedWorld implements ICachedWorld, Helper { } @Override - public final LinkedList getLocationsOf(String block, int maximum, int centerX, int centerZ, int maxRegionDistanceSq) { - LinkedList res = new LinkedList<>(); + public final ArrayList getLocationsOf(String block, int maximum, int centerX, int centerZ, int maxRegionDistanceSq) { + ArrayList res = new ArrayList<>(); int centerRegionX = centerX >> 9; int centerRegionZ = centerZ >> 9; @@ -127,7 +126,7 @@ public final class CachedWorld implements ICachedWorld, Helper { CachedRegion region = getOrCreateRegion(regionX, regionZ); if (region != null) { // TODO: 100% verify if this or addAll is faster. - region.getLocationsOf(block).forEach(res::add); + res.addAll(region.getLocationsOf(block)); } } } diff --git a/src/main/java/baritone/process/MineProcess.java b/src/main/java/baritone/process/MineProcess.java index a299bf314..699cf9985 100644 --- a/src/main/java/baritone/process/MineProcess.java +++ b/src/main/java/baritone/process/MineProcess.java @@ -210,7 +210,8 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro //long b = System.currentTimeMillis(); for (Block m : mining) { if (CachedChunk.BLOCKS_TO_KEEP_TRACK_OF.contains(m)) { - locs.addAll(ctx.worldData.getCachedWorld().getLocationsOf(ChunkPacker.blockToString(m), 1, ctx.getBaritone().getPlayerContext().playerFeet().getX(), ctx.getBaritone().getPlayerContext().playerFeet().getZ(), 2)); + // maxRegionDistanceSq 2 means adjacent directly or adjacent diagonally; nothing further than that + locs.addAll(ctx.worldData.getCachedWorld().getLocationsOf(ChunkPacker.blockToString(m), Baritone.settings().maxCachedWorldScanCount.get(), ctx.getBaritone().getPlayerContext().playerFeet().getX(), ctx.getBaritone().getPlayerContext().playerFeet().getZ(), 2)); } else { uninteresting.add(m); } @@ -221,7 +222,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro } if (!uninteresting.isEmpty()) { //long before = System.currentTimeMillis(); - locs.addAll(WorldScanner.INSTANCE.scanChunkRadius(ctx.getBaritone().getPlayerContext(), uninteresting, max, 10, 26)); + locs.addAll(WorldScanner.INSTANCE.scanChunkRadius(ctx.getBaritone().getPlayerContext(), uninteresting, max, 10, 5)); // maxSearchRadius is NOT sq //System.out.println("Scan of loaded chunks took " + (System.currentTimeMillis() - before) + "ms"); } locs.addAll(alreadyKnown); diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java index 041a54011..61b9ebf1d 100644 --- a/src/main/java/baritone/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java @@ -376,7 +376,7 @@ public class ExampleBaritoneControl extends Behavior implements Helper { } if (msg.startsWith("find")) { String blockType = msg.substring(4).trim(); - LinkedList locs = baritone.getWorldProvider().getCurrentWorld().getCachedWorld().getLocationsOf(blockType, 1, ctx.playerFeet().getX(), ctx.playerFeet().getZ(), 4); + ArrayList locs = baritone.getWorldProvider().getCurrentWorld().getCachedWorld().getLocationsOf(blockType, 1, ctx.playerFeet().getX(), ctx.playerFeet().getZ(), 4); logDirect("Have " + locs.size() + " locations"); for (BlockPos pos : locs) { Block actually = BlockStateInterface.get(ctx, pos).getBlock(); From 459720c348055a945cb7a89c86f345a56855d45b Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 4 Mar 2019 21:21:02 -0800 Subject: [PATCH 26/32] eh actually lets do the whole render distance! --- src/main/java/baritone/process/MineProcess.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/process/MineProcess.java b/src/main/java/baritone/process/MineProcess.java index 699cf9985..ac341cb8a 100644 --- a/src/main/java/baritone/process/MineProcess.java +++ b/src/main/java/baritone/process/MineProcess.java @@ -222,7 +222,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro } if (!uninteresting.isEmpty()) { //long before = System.currentTimeMillis(); - locs.addAll(WorldScanner.INSTANCE.scanChunkRadius(ctx.getBaritone().getPlayerContext(), uninteresting, max, 10, 5)); // maxSearchRadius is NOT sq + locs.addAll(WorldScanner.INSTANCE.scanChunkRadius(ctx.getBaritone().getPlayerContext(), uninteresting, max, 10, 32)); // maxSearchRadius is NOT sq //System.out.println("Scan of loaded chunks took " + (System.currentTimeMillis() - before) + "ms"); } locs.addAll(alreadyKnown); From 8050b69f2fd13791b029d840b1c8fe8d11d71dfd Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 4 Mar 2019 21:30:04 -0800 Subject: [PATCH 27/32] no more .get :sunglasses: --- src/api/java/baritone/api/Settings.java | 6 +-- .../baritone/api/pathing/goals/GoalAxis.java | 4 +- .../baritone/api/pathing/goals/GoalXZ.java | 2 +- .../java/baritone/api/utils/SettingsUtil.java | 4 +- .../mixins/MixinChunkRenderContainer.java | 4 +- .../launch/mixins/MixinChunkRenderWorker.java | 2 +- .../launch/mixins/MixinRenderChunk.java | 4 +- .../launch/mixins/MixinRenderList.java | 2 +- .../launch/mixins/MixinVboRenderList.java | 2 +- .../baritone/behavior/InventoryBehavior.java | 4 +- .../java/baritone/behavior/LookBehavior.java | 6 +-- .../baritone/behavior/MemoryBehavior.java | 8 ++-- .../baritone/behavior/PathingBehavior.java | 12 ++--- .../java/baritone/cache/CachedRegion.java | 2 +- src/main/java/baritone/cache/CachedWorld.java | 4 +- .../java/baritone/cache/ContainerMemory.java | 2 +- .../pathing/calc/AStarPathFinder.java | 14 +++--- .../pathing/calc/AbstractNodeCostSearch.java | 2 +- .../pathing/movement/CalculationContext.java | 30 ++++++------- .../pathing/movement/MovementHelper.java | 14 +++--- .../movement/movements/MovementAscend.java | 2 +- .../movement/movements/MovementDiagonal.java | 2 +- .../movement/movements/MovementTraverse.java | 10 ++--- .../baritone/pathing/path/PathExecutor.java | 14 +++--- .../java/baritone/process/FollowProcess.java | 6 +-- .../baritone/process/GetToBlockProcess.java | 10 ++--- .../java/baritone/process/MineProcess.java | 22 +++++----- .../java/baritone/utils/BlockPlaceHelper.java | 2 +- .../baritone/utils/BlockStateInterface.java | 2 +- .../utils/ExampleBaritoneControl.java | 4 +- src/main/java/baritone/utils/Helper.java | 4 +- .../java/baritone/utils/PathRenderer.java | 44 +++++++++---------- .../baritone/utils/PathingControlManager.java | 2 +- src/main/java/baritone/utils/ToolSet.java | 2 +- .../baritone/utils/pathing/Avoidance.java | 10 ++--- .../java/baritone/utils/pathing/Favoring.java | 2 +- .../java/baritone/utils/pathing/PathBase.java | 6 +-- .../utils/pathing/SegmentedCalculator.java | 2 +- 38 files changed, 137 insertions(+), 137 deletions(-) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 6be16dad0..bdebd1172 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -721,9 +721,9 @@ public final class Settings { this.klass = (Class) value.getClass(); } - @SuppressWarnings("unchecked") - public final K get() { - return (K) value; + @Deprecated + public final T get() { + return value; } public final String getName() { diff --git a/src/api/java/baritone/api/pathing/goals/GoalAxis.java b/src/api/java/baritone/api/pathing/goals/GoalAxis.java index d8811cf9e..7c9b26705 100644 --- a/src/api/java/baritone/api/pathing/goals/GoalAxis.java +++ b/src/api/java/baritone/api/pathing/goals/GoalAxis.java @@ -25,7 +25,7 @@ public class GoalAxis implements Goal { @Override public boolean isInGoal(int x, int y, int z) { - return y == BaritoneAPI.getSettings().axisHeight.get() && (x == 0 || z == 0 || Math.abs(x) == Math.abs(z)); + return y == BaritoneAPI.getSettings().axisHeight.value && (x == 0 || z == 0 || Math.abs(x) == Math.abs(z)); } @Override @@ -39,7 +39,7 @@ public class GoalAxis implements Goal { double flatAxisDistance = Math.min(x, Math.min(z, diff * SQRT_2_OVER_2)); - return flatAxisDistance * BaritoneAPI.getSettings().costHeuristic.get() + GoalYLevel.calculate(BaritoneAPI.getSettings().axisHeight.get(), y); + return flatAxisDistance * BaritoneAPI.getSettings().costHeuristic.value + GoalYLevel.calculate(BaritoneAPI.getSettings().axisHeight.value, y); } @Override diff --git a/src/api/java/baritone/api/pathing/goals/GoalXZ.java b/src/api/java/baritone/api/pathing/goals/GoalXZ.java index 636c649f5..7f8d16abe 100644 --- a/src/api/java/baritone/api/pathing/goals/GoalXZ.java +++ b/src/api/java/baritone/api/pathing/goals/GoalXZ.java @@ -80,7 +80,7 @@ public class GoalXZ implements Goal { diagonal = z; } diagonal *= SQRT_2; - return (diagonal + straight) * BaritoneAPI.getSettings().costHeuristic.get(); // big TODO tune + return (diagonal + straight) * BaritoneAPI.getSettings().costHeuristic.value; // big TODO tune } public static GoalXZ fromDirection(Vec3d origin, float yaw, double distance) { diff --git a/src/api/java/baritone/api/utils/SettingsUtil.java b/src/api/java/baritone/api/utils/SettingsUtil.java index 84e9af689..051e87934 100644 --- a/src/api/java/baritone/api/utils/SettingsUtil.java +++ b/src/api/java/baritone/api/utils/SettingsUtil.java @@ -99,7 +99,7 @@ public class SettingsUtil { public static List modifiedSettings(Settings settings) { List modified = new ArrayList<>(); for (Settings.Setting setting : settings.allSettings) { - if (setting.get() == null) { + if (setting.value == null) { System.out.println("NULL SETTING?" + setting.getName()); continue; } @@ -122,7 +122,7 @@ public class SettingsUtil { if (io == null) { throw new IllegalStateException("Missing " + setting.getValueClass() + " " + setting.getName()); } - return setting.getName() + " " + io.toString.apply(setting.get()); + return setting.getName() + " " + io.toString.apply(setting.value); } public static void parseAndApply(Settings settings, String settingName, String settingValue) throws IllegalStateException, NumberFormatException { diff --git a/src/launch/java/baritone/launch/mixins/MixinChunkRenderContainer.java b/src/launch/java/baritone/launch/mixins/MixinChunkRenderContainer.java index 0fc814874..78bd16073 100644 --- a/src/launch/java/baritone/launch/mixins/MixinChunkRenderContainer.java +++ b/src/launch/java/baritone/launch/mixins/MixinChunkRenderContainer.java @@ -41,10 +41,10 @@ public class MixinChunkRenderContainer { ) ) private BlockPos getPosition(RenderChunk renderChunkIn) { - if (Baritone.settings().renderCachedChunks.get() && Minecraft.getMinecraft().getIntegratedServer() == null && Minecraft.getMinecraft().world.getChunk(renderChunkIn.getPosition()).isEmpty()) { + if (Baritone.settings().renderCachedChunks.value && Minecraft.getMinecraft().getIntegratedServer() == null && Minecraft.getMinecraft().world.getChunk(renderChunkIn.getPosition()).isEmpty()) { GlStateManager.enableAlpha(); GlStateManager.enableBlend(); - GL14.glBlendColor(0, 0, 0, Baritone.settings().cachedChunksOpacity.get()); + GL14.glBlendColor(0, 0, 0, Baritone.settings().cachedChunksOpacity.value); GlStateManager.tryBlendFuncSeparate(GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA, GL_ONE, GL_ZERO); } return renderChunkIn.getPosition(); diff --git a/src/launch/java/baritone/launch/mixins/MixinChunkRenderWorker.java b/src/launch/java/baritone/launch/mixins/MixinChunkRenderWorker.java index 2bd1521c7..81e393824 100644 --- a/src/launch/java/baritone/launch/mixins/MixinChunkRenderWorker.java +++ b/src/launch/java/baritone/launch/mixins/MixinChunkRenderWorker.java @@ -43,7 +43,7 @@ public abstract class MixinChunkRenderWorker { ) ) private boolean isChunkExisting(ChunkRenderWorker worker, BlockPos pos, World world) { - if (Baritone.settings().renderCachedChunks.get() && Minecraft.getMinecraft().getIntegratedServer() == null) { + if (Baritone.settings().renderCachedChunks.value && Minecraft.getMinecraft().getIntegratedServer() == null) { Baritone baritone = (Baritone) BaritoneAPI.getProvider().getPrimaryBaritone(); IPlayerContext ctx = baritone.getPlayerContext(); if (ctx.player() != null && ctx.world() != null && baritone.bsi != null) { diff --git a/src/launch/java/baritone/launch/mixins/MixinRenderChunk.java b/src/launch/java/baritone/launch/mixins/MixinRenderChunk.java index 754f523f2..22ab0bdd6 100644 --- a/src/launch/java/baritone/launch/mixins/MixinRenderChunk.java +++ b/src/launch/java/baritone/launch/mixins/MixinRenderChunk.java @@ -47,7 +47,7 @@ public class MixinRenderChunk { if (!chunkCache.isEmpty()) { return false; } - if (Baritone.settings().renderCachedChunks.get() && Minecraft.getMinecraft().getIntegratedServer() == null) { + if (Baritone.settings().renderCachedChunks.value && Minecraft.getMinecraft().getIntegratedServer() == null) { Baritone baritone = (Baritone) BaritoneAPI.getProvider().getPrimaryBaritone(); IPlayerContext ctx = baritone.getPlayerContext(); if (ctx.player() != null && ctx.world() != null && baritone.bsi != null) { @@ -76,7 +76,7 @@ public class MixinRenderChunk { ) ) private IBlockState getBlockState(ChunkCache chunkCache, BlockPos pos) { - if (Baritone.settings().renderCachedChunks.get() && Minecraft.getMinecraft().getIntegratedServer() == null) { + if (Baritone.settings().renderCachedChunks.value && Minecraft.getMinecraft().getIntegratedServer() == null) { Baritone baritone = (Baritone) BaritoneAPI.getProvider().getPrimaryBaritone(); IPlayerContext ctx = baritone.getPlayerContext(); if (ctx.player() != null && ctx.world() != null && baritone.bsi != null) { diff --git a/src/launch/java/baritone/launch/mixins/MixinRenderList.java b/src/launch/java/baritone/launch/mixins/MixinRenderList.java index e2f0ae902..98ae5bf52 100644 --- a/src/launch/java/baritone/launch/mixins/MixinRenderList.java +++ b/src/launch/java/baritone/launch/mixins/MixinRenderList.java @@ -38,7 +38,7 @@ public class MixinRenderList { ) ) private void popMatrix() { - if (Baritone.settings().renderCachedChunks.get() && Minecraft.getMinecraft().getIntegratedServer() == null) { + if (Baritone.settings().renderCachedChunks.value && Minecraft.getMinecraft().getIntegratedServer() == null) { // reset the blend func to normal (not dependent on constant alpha) GlStateManager.tryBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO); } diff --git a/src/launch/java/baritone/launch/mixins/MixinVboRenderList.java b/src/launch/java/baritone/launch/mixins/MixinVboRenderList.java index f51d22341..bab98b3c6 100644 --- a/src/launch/java/baritone/launch/mixins/MixinVboRenderList.java +++ b/src/launch/java/baritone/launch/mixins/MixinVboRenderList.java @@ -38,7 +38,7 @@ public class MixinVboRenderList { ) ) private void popMatrix() { - if (Baritone.settings().renderCachedChunks.get() && Minecraft.getMinecraft().getIntegratedServer() == null) { + if (Baritone.settings().renderCachedChunks.value && Minecraft.getMinecraft().getIntegratedServer() == null) { // reset the blend func to normal (not dependent on constant alpha) GlStateManager.tryBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO); } diff --git a/src/main/java/baritone/behavior/InventoryBehavior.java b/src/main/java/baritone/behavior/InventoryBehavior.java index 8a1ea943c..cb5eb612e 100644 --- a/src/main/java/baritone/behavior/InventoryBehavior.java +++ b/src/main/java/baritone/behavior/InventoryBehavior.java @@ -35,7 +35,7 @@ public class InventoryBehavior extends Behavior { @Override public void onTick(TickEvent event) { - if (!Baritone.settings().allowInventory.get()) { + if (!Baritone.settings().allowInventory.value) { return; } if (event.getType() == TickEvent.Type.OUT) { @@ -61,7 +61,7 @@ public class InventoryBehavior extends Behavior { private int firstValidThrowaway() { // TODO offhand idk NonNullList invy = ctx.player().inventory.mainInventory; for (int i = 0; i < invy.size(); i++) { - if (Baritone.settings().acceptableThrowawayItems.get().contains(invy.get(i).getItem())) { + if (Baritone.settings().acceptableThrowawayItems.value.contains(invy.get(i).getItem())) { return i; } } diff --git a/src/main/java/baritone/behavior/LookBehavior.java b/src/main/java/baritone/behavior/LookBehavior.java index df0921cf4..323d81fc1 100644 --- a/src/main/java/baritone/behavior/LookBehavior.java +++ b/src/main/java/baritone/behavior/LookBehavior.java @@ -53,7 +53,7 @@ public final class LookBehavior extends Behavior implements ILookBehavior { @Override public void updateTarget(Rotation target, boolean force) { this.target = target; - this.force = force || !Baritone.settings().freeLook.get(); + this.force = force || !Baritone.settings().freeLook.value; } @Override @@ -63,7 +63,7 @@ public final class LookBehavior extends Behavior implements ILookBehavior { } // Whether or not we're going to silently set our angles - boolean silent = Baritone.settings().antiCheatCompatibility.get() && !this.force; + boolean silent = Baritone.settings().antiCheatCompatibility.value && !this.force; switch (event.getState()) { case PRE: { @@ -109,7 +109,7 @@ public final class LookBehavior extends Behavior implements ILookBehavior { // If we have antiCheatCompatibility on, we're going to use the target value later in onPlayerUpdate() // Also the type has to be MOTION_UPDATE because that is called after JUMP - if (!Baritone.settings().antiCheatCompatibility.get() && event.getType() == RotationMoveEvent.Type.MOTION_UPDATE && !this.force) { + if (!Baritone.settings().antiCheatCompatibility.value && event.getType() == RotationMoveEvent.Type.MOTION_UPDATE && !this.force) { this.target = null; } } diff --git a/src/main/java/baritone/behavior/MemoryBehavior.java b/src/main/java/baritone/behavior/MemoryBehavior.java index 390ac8592..8d3a0a8c3 100644 --- a/src/main/java/baritone/behavior/MemoryBehavior.java +++ b/src/main/java/baritone/behavior/MemoryBehavior.java @@ -65,7 +65,7 @@ public final class MemoryBehavior extends Behavior { @Override public synchronized void onTick(TickEvent event) { - if (!Baritone.settings().containerMemory.get()) { + if (!Baritone.settings().containerMemory.value) { return; } if (event.getType() == TickEvent.Type.OUT) { @@ -83,7 +83,7 @@ public final class MemoryBehavior extends Behavior { @Override public synchronized void onSendPacket(PacketEvent event) { - if (!Baritone.settings().containerMemory.get()) { + if (!Baritone.settings().containerMemory.value) { return; } Packet p = event.getPacket(); @@ -122,7 +122,7 @@ public final class MemoryBehavior extends Behavior { @Override public synchronized void onReceivePacket(PacketEvent event) { - if (!Baritone.settings().containerMemory.get()) { + if (!Baritone.settings().containerMemory.value) { return; } Packet p = event.getPacket(); @@ -171,7 +171,7 @@ public final class MemoryBehavior extends Behavior { private void updateInventory() { - if (!Baritone.settings().containerMemory.get()) { + if (!Baritone.settings().containerMemory.value) { return; } int windowId = ctx.player().openContainer.windowId; diff --git a/src/main/java/baritone/behavior/PathingBehavior.java b/src/main/java/baritone/behavior/PathingBehavior.java index e9e4d4805..a7c5c34bf 100644 --- a/src/main/java/baritone/behavior/PathingBehavior.java +++ b/src/main/java/baritone/behavior/PathingBehavior.java @@ -201,7 +201,7 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior, // and this path doesn't get us all the way there return; } - if (ticksRemainingInSegment(false).get() < Baritone.settings().planningTickLookahead.get()) { + if (ticksRemainingInSegment(false).get() < Baritone.settings().planningTickLookahead.value) { // and this path has 7.5 seconds or less left // don't include the current movement so a very long last movement (e.g. descend) doesn't trip it up // if we actually included current, it wouldn't start planning ahead until the last movement was done, if the last movement took more than 7.5 seconds on its own @@ -426,11 +426,11 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior, long primaryTimeout; long failureTimeout; if (current == null) { - primaryTimeout = Baritone.settings().primaryTimeoutMS.get(); - failureTimeout = Baritone.settings().failureTimeoutMS.get(); + primaryTimeout = Baritone.settings().primaryTimeoutMS.value; + failureTimeout = Baritone.settings().failureTimeoutMS.value; } else { - primaryTimeout = Baritone.settings().planAheadPrimaryTimeoutMS.get(); - failureTimeout = Baritone.settings().planAheadFailureTimeoutMS.get(); + primaryTimeout = Baritone.settings().planAheadPrimaryTimeoutMS.value; + failureTimeout = Baritone.settings().planAheadFailureTimeoutMS.value; } CalculationContext context = new CalculationContext(baritone, true); // not safe to create on the other thread, it looks up a lot of stuff in minecraft AbstractNodeCostSearch pathfinder = createPathfinder(start, goal, current == null ? null : current.getPath(), context); @@ -494,7 +494,7 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior, public static AbstractNodeCostSearch createPathfinder(BlockPos start, Goal goal, IPath previous, CalculationContext context) { Goal transformed = goal; - if (Baritone.settings().simplifyUnloadedYCoord.get() && goal instanceof IGoalRenderPos) { + if (Baritone.settings().simplifyUnloadedYCoord.value && goal instanceof IGoalRenderPos) { BlockPos pos = ((IGoalRenderPos) goal).getGoalPos(); if (!context.bsi.worldContainsLoadedChunk(pos.getX(), pos.getZ())) { transformed = new GoalXZ(pos.getX(), pos.getZ()); diff --git a/src/main/java/baritone/cache/CachedRegion.java b/src/main/java/baritone/cache/CachedRegion.java index 0081d9419..e3a85dfc4 100644 --- a/src/main/java/baritone/cache/CachedRegion.java +++ b/src/main/java/baritone/cache/CachedRegion.java @@ -303,7 +303,7 @@ public final class CachedRegion implements ICachedRegion { } public synchronized final void removeExpired() { - long expiry = Baritone.settings().cachedChunksExpirySeconds.get(); + long expiry = Baritone.settings().cachedChunksExpirySeconds.value; if (expiry < 0) { return; } diff --git a/src/main/java/baritone/cache/CachedWorld.java b/src/main/java/baritone/cache/CachedWorld.java index 025ec773f..e8ea5cae5 100644 --- a/src/main/java/baritone/cache/CachedWorld.java +++ b/src/main/java/baritone/cache/CachedWorld.java @@ -145,7 +145,7 @@ public final class CachedWorld implements ICachedWorld, Helper { @Override public final void save() { - if (!Baritone.settings().chunkCaching.get()) { + if (!Baritone.settings().chunkCaching.value) { System.out.println("Not saving to disk; chunk caching is disabled."); allRegions().forEach(region -> { if (region != null) { @@ -170,7 +170,7 @@ public final class CachedWorld implements ICachedWorld, Helper { * Delete regions that are too far from the player */ private synchronized void prune() { - if (!Baritone.settings().pruneRegionsFromRAM.get()) { + if (!Baritone.settings().pruneRegionsFromRAM.value) { return; } BlockPos pruneCenter = guessPosition(); diff --git a/src/main/java/baritone/cache/ContainerMemory.java b/src/main/java/baritone/cache/ContainerMemory.java index 466bf710f..c1cb7b34d 100644 --- a/src/main/java/baritone/cache/ContainerMemory.java +++ b/src/main/java/baritone/cache/ContainerMemory.java @@ -70,7 +70,7 @@ public class ContainerMemory implements IContainerMemory { } public synchronized void save() throws IOException { - if (!Baritone.settings().containerMemory.get()) { + if (!Baritone.settings().containerMemory.value) { return; } ByteBuf buf = Unpooled.buffer(0, Integer.MAX_VALUE); diff --git a/src/main/java/baritone/pathing/calc/AStarPathFinder.java b/src/main/java/baritone/pathing/calc/AStarPathFinder.java index fda41cfdc..57e9200de 100644 --- a/src/main/java/baritone/pathing/calc/AStarPathFinder.java +++ b/src/main/java/baritone/pathing/calc/AStarPathFinder.java @@ -62,20 +62,20 @@ public final class AStarPathFinder extends AbstractNodeCostSearch { MutableMoveResult res = new MutableMoveResult(); BetterWorldBorder worldBorder = new BetterWorldBorder(calcContext.world.getWorldBorder()); long startTime = System.currentTimeMillis(); - boolean slowPath = Baritone.settings().slowPath.get(); + boolean slowPath = Baritone.settings().slowPath.value; if (slowPath) { - logDebug("slowPath is on, path timeout will be " + Baritone.settings().slowPathTimeoutMS.get() + "ms instead of " + primaryTimeout + "ms"); + logDebug("slowPath is on, path timeout will be " + Baritone.settings().slowPathTimeoutMS.value + "ms instead of " + primaryTimeout + "ms"); } - long primaryTimeoutTime = startTime + (slowPath ? Baritone.settings().slowPathTimeoutMS.get() : primaryTimeout); - long failureTimeoutTime = startTime + (slowPath ? Baritone.settings().slowPathTimeoutMS.get() : failureTimeout); + long primaryTimeoutTime = startTime + (slowPath ? Baritone.settings().slowPathTimeoutMS.value : primaryTimeout); + long failureTimeoutTime = startTime + (slowPath ? Baritone.settings().slowPathTimeoutMS.value : failureTimeout); boolean failing = true; int numNodes = 0; int numMovementsConsidered = 0; int numEmptyChunk = 0; boolean isFavoring = !favoring.isEmpty(); int timeCheckInterval = 1 << 6; - int pathingMaxChunkBorderFetch = Baritone.settings().pathingMaxChunkBorderFetch.get(); // grab all settings beforehand so that changing settings during pathing doesn't cause a crash or unpredictable behavior - double minimumImprovement = Baritone.settings().minimumImprovementRepropagation.get() ? MIN_IMPROVEMENT : 0; + int pathingMaxChunkBorderFetch = Baritone.settings().pathingMaxChunkBorderFetch.value; // grab all settings beforehand so that changing settings during pathing doesn't cause a crash or unpredictable behavior + double minimumImprovement = Baritone.settings().minimumImprovementRepropagation.value ? MIN_IMPROVEMENT : 0; while (!openSet.isEmpty() && numEmptyChunk < pathingMaxChunkBorderFetch && !cancelRequested) { if ((numNodes & (timeCheckInterval - 1)) == 0) { // only call this once every 64 nodes (about half a millisecond) long now = System.currentTimeMillis(); // since nanoTime is slow on windows (takes many microseconds) @@ -85,7 +85,7 @@ public final class AStarPathFinder extends AbstractNodeCostSearch { } if (slowPath) { try { - Thread.sleep(Baritone.settings().slowPathTimeDelayMS.get()); + Thread.sleep(Baritone.settings().slowPathTimeDelayMS.value); } catch (InterruptedException ex) { } } diff --git a/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java b/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java index a9974e8df..a7d104cf1 100644 --- a/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java +++ b/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java @@ -87,7 +87,7 @@ public abstract class AbstractNodeCostSearch implements IPathFinder, Helper { this.startZ = startZ; this.goal = goal; this.context = context; - this.map = new Long2ObjectOpenHashMap<>(Baritone.settings().pathingMapDefaultSize.value, Baritone.settings().pathingMapLoadFactor.get()); + this.map = new Long2ObjectOpenHashMap<>(Baritone.settings().pathingMapDefaultSize.value, Baritone.settings().pathingMapLoadFactor.value); } public void cancel() { diff --git a/src/main/java/baritone/pathing/movement/CalculationContext.java b/src/main/java/baritone/pathing/movement/CalculationContext.java index 4c3b299d2..6c4c326b4 100644 --- a/src/main/java/baritone/pathing/movement/CalculationContext.java +++ b/src/main/java/baritone/pathing/movement/CalculationContext.java @@ -76,27 +76,27 @@ public class CalculationContext { this.worldData = (WorldData) baritone.getWorldProvider().getCurrentWorld(); this.bsi = new BlockStateInterface(world, worldData, forUseOnAnotherThread); // TODO TODO TODO this.toolSet = new ToolSet(player); - this.hasThrowaway = Baritone.settings().allowPlace.get() && MovementHelper.throwaway(baritone.getPlayerContext(), false); - this.hasWaterBucket = Baritone.settings().allowWaterBucketFall.get() && InventoryPlayer.isHotbar(player.inventory.getSlotFor(STACK_BUCKET_WATER)) && !world.provider.isNether(); - this.canSprint = Baritone.settings().allowSprint.get() && player.getFoodStats().getFoodLevel() > 6; - this.placeBlockCost = Baritone.settings().blockPlacementPenalty.get(); - this.allowBreak = Baritone.settings().allowBreak.get(); - this.allowParkour = Baritone.settings().allowParkour.get(); - this.allowParkourPlace = Baritone.settings().allowParkourPlace.get(); - this.allowJumpAt256 = Baritone.settings().allowJumpAt256.get(); - this.assumeWalkOnWater = Baritone.settings().assumeWalkOnWater.get(); - this.allowDiagonalDescend = Baritone.settings().allowDiagonalDescend.get(); - this.maxFallHeightNoWater = Baritone.settings().maxFallHeightNoWater.get(); - this.maxFallHeightBucket = Baritone.settings().maxFallHeightBucket.get(); + this.hasThrowaway = Baritone.settings().allowPlace.value && MovementHelper.throwaway(baritone.getPlayerContext(), false); + this.hasWaterBucket = Baritone.settings().allowWaterBucketFall.value && InventoryPlayer.isHotbar(player.inventory.getSlotFor(STACK_BUCKET_WATER)) && !world.provider.isNether(); + this.canSprint = Baritone.settings().allowSprint.value && player.getFoodStats().getFoodLevel() > 6; + this.placeBlockCost = Baritone.settings().blockPlacementPenalty.value; + this.allowBreak = Baritone.settings().allowBreak.value; + this.allowParkour = Baritone.settings().allowParkour.value; + this.allowParkourPlace = Baritone.settings().allowParkourPlace.value; + this.allowJumpAt256 = Baritone.settings().allowJumpAt256.value; + this.assumeWalkOnWater = Baritone.settings().assumeWalkOnWater.value; + this.allowDiagonalDescend = Baritone.settings().allowDiagonalDescend.value; + this.maxFallHeightNoWater = Baritone.settings().maxFallHeightNoWater.value; + this.maxFallHeightBucket = Baritone.settings().maxFallHeightBucket.value; int depth = EnchantmentHelper.getDepthStriderModifier(player); if (depth > 3) { depth = 3; } float mult = depth / 3.0F; this.waterWalkSpeed = ActionCosts.WALK_ONE_IN_WATER_COST * (1 - mult) + ActionCosts.WALK_ONE_BLOCK_COST * mult; - this.breakBlockAdditionalCost = Baritone.settings().blockBreakAdditionalPenalty.get(); - this.jumpPenalty = Baritone.settings().jumpPenalty.get(); - this.walkOnWaterOnePenalty = Baritone.settings().walkOnWaterOnePenalty.get(); + this.breakBlockAdditionalCost = Baritone.settings().blockBreakAdditionalPenalty.value; + this.jumpPenalty = Baritone.settings().jumpPenalty.value; + this.walkOnWaterOnePenalty = Baritone.settings().walkOnWaterOnePenalty.value; // why cache these things here, why not let the movements just get directly from settings? // because if some movements are calculated one way and others are calculated another way, // then you get a wildly inconsistent path that isn't optimal for either scenario. diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index 592aecd0e..7d2552b50 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -113,7 +113,7 @@ public interface MovementHelper extends ActionCosts, Helper { return false; // Don't walk through flowing liquids } if (block instanceof BlockLiquid) { - if (Baritone.settings().assumeWalkOnWater.get()) { + if (Baritone.settings().assumeWalkOnWater.value) { return false; } IBlockState up = bsi.get0(x, y + 1, z); @@ -275,7 +275,7 @@ public interface MovementHelper extends ActionCosts, Helper { if (state.isBlockNormalCube()) { return true; } - if (block == Blocks.LADDER || (block == Blocks.VINE && Baritone.settings().allowVines.get())) { // TODO reconsider this + if (block == Blocks.LADDER || (block == Blocks.VINE && Baritone.settings().allowVines.value)) { // TODO reconsider this return true; } if (block == Blocks.FARMLAND || block == Blocks.GRASS_PATH) { @@ -293,17 +293,17 @@ public interface MovementHelper extends ActionCosts, Helper { } if (isFlowing(x, y, z, state, bsi) || block == Blocks.FLOWING_WATER) { // the only scenario in which we can walk on flowing water is if it's under still water with jesus off - return isWater(up) && !Baritone.settings().assumeWalkOnWater.get(); + return isWater(up) && !Baritone.settings().assumeWalkOnWater.value; } // if assumeWalkOnWater is on, we can only walk on water if there isn't water above it // if assumeWalkOnWater is off, we can only walk on water if there is water above it - return isWater(up) ^ Baritone.settings().assumeWalkOnWater.get(); + return isWater(up) ^ Baritone.settings().assumeWalkOnWater.value; } if (block == Blocks.GLASS || block == Blocks.STAINED_GLASS) { return true; } if (block instanceof BlockSlab) { - if (!Baritone.settings().allowWalkOnBottomSlab.get()) { + if (!Baritone.settings().allowWalkOnBottomSlab.value) { if (((BlockSlab) block).isDouble()) { return true; } @@ -415,14 +415,14 @@ public interface MovementHelper extends ActionCosts, Helper { // and then it's called during execution // since this function is never called during cost calculation, we don't need to migrate // acceptableThrowawayItems to the CalculationContext - if (Baritone.settings().acceptableThrowawayItems.get().contains(item.getItem())) { + if (Baritone.settings().acceptableThrowawayItems.value.contains(item.getItem())) { if (select) { p.inventory.currentItem = i; } return true; } } - if (Baritone.settings().acceptableThrowawayItems.get().contains(p.inventory.offHandInventory.get(0).getItem())) { + if (Baritone.settings().acceptableThrowawayItems.value.contains(p.inventory.offHandInventory.get(0).getItem())) { // main hand takes precedence over off hand // that means that if we have block A selected in main hand and block B in off hand, right clicking places block B // we've already checked above ^ and the main hand can't possible have an acceptablethrowawayitem diff --git a/src/main/java/baritone/pathing/movement/movements/MovementAscend.java b/src/main/java/baritone/pathing/movement/movements/MovementAscend.java index 5bb6281fe..3dc65990f 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementAscend.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementAscend.java @@ -176,7 +176,7 @@ public class MovementAscend extends Movement { return state; // don't jump while walking from a non double slab into a bottom slab } - if (Baritone.settings().assumeStep.get() || ctx.playerFeet().equals(src.up())) { + if (Baritone.settings().assumeStep.value || ctx.playerFeet().equals(src.up())) { // no need to hit space if we're already jumping return state; } diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java b/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java index f156ff1b4..9761f6174 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java @@ -182,7 +182,7 @@ public class MovementDiagonal extends Movement { } public boolean sprint() { - if (MovementHelper.isLiquid(ctx, ctx.playerFeet()) && !Baritone.settings().sprintInWater.get()) { + if (MovementHelper.isLiquid(ctx, ctx.playerFeet()) && !Baritone.settings().sprintInWater.value) { return false; } for (int i = 0; i < 4; i++) { diff --git a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java index 4a5687fd9..21783605d 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java @@ -152,7 +152,7 @@ public class MovementTraverse extends Movement { super.updateState(state); if (state.getStatus() != MovementStatus.RUNNING) { // if the setting is enabled - if (!Baritone.settings().walkWhileBreaking.get()) { + if (!Baritone.settings().walkWhileBreaking.value) { return state; } // and if we're prepping (aka mining the block in front) @@ -241,7 +241,7 @@ public class MovementTraverse extends Movement { BlockPos into = dest.subtract(src).add(dest); Block intoBelow = BlockStateInterface.get(ctx, into).getBlock(); Block intoAbove = BlockStateInterface.get(ctx, into.up()).getBlock(); - if (wasTheBridgeBlockAlwaysThere && (!MovementHelper.isLiquid(ctx, ctx.playerFeet()) || Baritone.settings().sprintInWater.get()) && (!MovementHelper.avoidWalkingInto(intoBelow) || MovementHelper.isWater(intoBelow)) && !MovementHelper.avoidWalkingInto(intoAbove)) { + if (wasTheBridgeBlockAlwaysThere && (!MovementHelper.isLiquid(ctx, ctx.playerFeet()) || Baritone.settings().sprintInWater.value) && (!MovementHelper.avoidWalkingInto(intoBelow) || MovementHelper.isWater(intoBelow)) && !MovementHelper.avoidWalkingInto(intoAbove)) { state.setInput(Input.SPRINT, true); } Block destDown = BlockStateInterface.get(ctx, dest.down()).getBlock(); @@ -264,12 +264,12 @@ public class MovementTraverse extends Movement { } double dist1 = Math.max(Math.abs(ctx.player().posX - (dest.getX() + 0.5D)), Math.abs(ctx.player().posZ - (dest.getZ() + 0.5D))); PlaceResult p = MovementHelper.attemptToPlaceABlock(state, baritone, dest.down(), false); - if ((p == PlaceResult.READY_TO_PLACE || dist1 < 0.6) && !Baritone.settings().assumeSafeWalk.get()) { + if ((p == PlaceResult.READY_TO_PLACE || dist1 < 0.6) && !Baritone.settings().assumeSafeWalk.value) { state.setInput(Input.SNEAK, true); } switch (p) { case READY_TO_PLACE: { - if (ctx.player().isSneaking() || Baritone.settings().assumeSafeWalk.get()) { + if (ctx.player().isSneaking() || Baritone.settings().assumeSafeWalk.value) { state.setInput(Input.CLICK_RIGHT, true); } return state; @@ -343,4 +343,4 @@ public class MovementTraverse extends Movement { } return super.prepared(state); } -} \ No newline at end of file +} diff --git a/src/main/java/baritone/pathing/path/PathExecutor.java b/src/main/java/baritone/pathing/path/PathExecutor.java index b025f6899..2c2f7ad96 100644 --- a/src/main/java/baritone/pathing/path/PathExecutor.java +++ b/src/main/java/baritone/pathing/path/PathExecutor.java @@ -229,7 +229,7 @@ public class PathExecutor implements IPathExecutor, Helper { costEstimateIndex = pathPosition; // do this only once, when the movement starts, and deliberately get the cost as cached when this path was calculated, not the cost as it is right now currentMovementOriginalCostEstimate = movement.getCost(); - for (int i = 1; i < Baritone.settings().costVerificationLookahead.get() && pathPosition + i < path.length() - 1; i++) { + for (int i = 1; i < Baritone.settings().costVerificationLookahead.value && pathPosition + i < path.length() - 1; i++) { if (path.movements().get(pathPosition + i).calculateCostWithoutCaching() >= ActionCosts.COST_INF && canCancel) { logDebug("Something has changed in the world and a future movement has become impossible. Cancelling."); cancel(); @@ -243,7 +243,7 @@ public class PathExecutor implements IPathExecutor, Helper { cancel(); return true; } - if (!movement.calculatedWhileLoaded() && currentCost - currentMovementOriginalCostEstimate > Baritone.settings().maxCostIncrease.get() && canCancel) { + if (!movement.calculatedWhileLoaded() && currentCost - currentMovementOriginalCostEstimate > Baritone.settings().maxCostIncrease.value && canCancel) { // don't do this if the movement was calculated while loaded // that means that this isn't a cache error, it's just part of the path interfering with a later part logDebug("Original cost " + currentMovementOriginalCostEstimate + " current cost " + currentCost + ". Cancelling."); @@ -273,7 +273,7 @@ public class PathExecutor implements IPathExecutor, Helper { ctx.player().setSprinting(false); // letting go of control doesn't make you stop sprinting actually } ticksOnCurrent++; - if (ticksOnCurrent > currentMovementOriginalCostEstimate + Baritone.settings().movementTimeoutTicks.get()) { + if (ticksOnCurrent > currentMovementOriginalCostEstimate + Baritone.settings().movementTimeoutTicks.value) { // only cancel if the total time has exceeded the initial estimate // as you break the blocks required, the remaining cost goes down, to the point where // ticksOnCurrent is greater than recalculateCost + 100 @@ -527,7 +527,7 @@ public class PathExecutor implements IPathExecutor, Helper { } private static boolean sprintableAscend(IPlayerContext ctx, MovementTraverse current, MovementAscend next, IMovement nextnext) { - if (!Baritone.settings().sprintAscends.get()) { + if (!Baritone.settings().sprintAscends.value) { return false; } if (!current.getDirection().equals(next.getDirection().down())) { @@ -569,7 +569,7 @@ public class PathExecutor implements IPathExecutor, Helper { if (next instanceof MovementTraverse && next.getDirection().down().equals(current.getDirection()) && MovementHelper.canWalkOn(ctx, next.getDest().down())) { return true; } - return next instanceof MovementDiagonal && Baritone.settings().allowOvershootDiagonalDescend.get(); + return next instanceof MovementDiagonal && Baritone.settings().allowOvershootDiagonalDescend.value; } private void onChangeInPathPosition() { @@ -612,8 +612,8 @@ public class PathExecutor implements IPathExecutor, Helper { } private PathExecutor cutIfTooLong() { - if (pathPosition > Baritone.settings().maxPathHistoryLength.get()) { - int cutoffAmt = Baritone.settings().pathHistoryCutoffAmount.get(); + if (pathPosition > Baritone.settings().maxPathHistoryLength.value) { + int cutoffAmt = Baritone.settings().pathHistoryCutoffAmount.value; CutoffPath newPath = new CutoffPath(path, cutoffAmt, path.length() - 1); if (!newPath.getDest().equals(path.getDest())) { throw new IllegalStateException(); diff --git a/src/main/java/baritone/process/FollowProcess.java b/src/main/java/baritone/process/FollowProcess.java index 3d25c0765..6e377decb 100644 --- a/src/main/java/baritone/process/FollowProcess.java +++ b/src/main/java/baritone/process/FollowProcess.java @@ -58,13 +58,13 @@ public final class FollowProcess extends BaritoneProcessHelper implements IFollo private Goal towards(Entity following) { BlockPos pos; - if (Baritone.settings().followOffsetDistance.get() == 0) { + if (Baritone.settings().followOffsetDistance.value == 0) { pos = new BlockPos(following); } else { - GoalXZ g = GoalXZ.fromDirection(following.getPositionVector(), Baritone.settings().followOffsetDirection.get(), Baritone.settings().followOffsetDistance.get()); + GoalXZ g = GoalXZ.fromDirection(following.getPositionVector(), Baritone.settings().followOffsetDirection.value, Baritone.settings().followOffsetDistance.value); pos = new BlockPos(g.getX(), following.posY, g.getZ()); } - return new GoalNear(pos, Baritone.settings().followRadius.get()); + return new GoalNear(pos, Baritone.settings().followRadius.value); } diff --git a/src/main/java/baritone/process/GetToBlockProcess.java b/src/main/java/baritone/process/GetToBlockProcess.java index cb80926b1..7f63c6e21 100644 --- a/src/main/java/baritone/process/GetToBlockProcess.java +++ b/src/main/java/baritone/process/GetToBlockProcess.java @@ -67,7 +67,7 @@ public class GetToBlockProcess extends BaritoneProcessHelper implements IGetToBl rescan(new ArrayList<>(), new CalculationContext(baritone)); } if (knownLocations.isEmpty()) { - if (Baritone.settings().exploreForBlocks.get() && !calcFailed) { + if (Baritone.settings().exploreForBlocks.value && !calcFailed) { return new PathingCommand(new GoalRunAway(1, start) { @Override public boolean isInGoal(int x, int y, int z) { @@ -83,7 +83,7 @@ public class GetToBlockProcess extends BaritoneProcessHelper implements IGetToBl } Goal goal = new GoalComposite(knownLocations.stream().map(this::createGoal).toArray(Goal[]::new)); if (calcFailed) { - if (Baritone.settings().blacklistOnGetToBlockFailure.get()) { + if (Baritone.settings().blacklistOnGetToBlockFailure.value) { logDirect("Unable to find any path to " + gettingTo + ", blacklisting presumably unreachable closest instances"); blacklistClosest(); return onTick(false, isSafeToCancel); // gamer moment @@ -95,7 +95,7 @@ public class GetToBlockProcess extends BaritoneProcessHelper implements IGetToBl return new PathingCommand(goal, PathingCommandType.CANCEL_AND_SET_GOAL); } } - int mineGoalUpdateInterval = Baritone.settings().mineGoalUpdateInterval.get(); + int mineGoalUpdateInterval = Baritone.settings().mineGoalUpdateInterval.value; if (mineGoalUpdateInterval != 0 && tickCount++ % mineGoalUpdateInterval == 0) { // big brain List current = new ArrayList<>(knownLocations); CalculationContext context = new CalculationContext(baritone, true); @@ -200,14 +200,14 @@ public class GetToBlockProcess extends BaritoneProcessHelper implements IGetToBl } private boolean walkIntoInsteadOfAdjacent(Block block) { - if (!Baritone.settings().enterPortal.get()) { + if (!Baritone.settings().enterPortal.value) { return false; } return block == Blocks.PORTAL; } private boolean rightClickOnArrival(Block block) { - if (!Baritone.settings().rightClickContainerOnArrival.get()) { + if (!Baritone.settings().rightClickContainerOnArrival.value) { return false; } return block == Blocks.CRAFTING_TABLE || block == Blocks.FURNACE || block == Blocks.ENDER_CHEST || block == Blocks.CHEST || block == Blocks.TRAPPED_CHEST; diff --git a/src/main/java/baritone/process/MineProcess.java b/src/main/java/baritone/process/MineProcess.java index ac341cb8a..121ddb8f9 100644 --- a/src/main/java/baritone/process/MineProcess.java +++ b/src/main/java/baritone/process/MineProcess.java @@ -85,13 +85,13 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro cancel(); return null; } - int mineGoalUpdateInterval = Baritone.settings().mineGoalUpdateInterval.get(); + int mineGoalUpdateInterval = Baritone.settings().mineGoalUpdateInterval.value; if (mineGoalUpdateInterval != 0 && tickCount++ % mineGoalUpdateInterval == 0) { // big brain List curr = new ArrayList<>(knownOreLocations); CalculationContext context = new CalculationContext(baritone, true); Baritone.getExecutor().execute(() -> rescan(curr, context)); } - if (Baritone.settings().legitMine.get()) { + if (Baritone.settings().legitMine.value) { addNearby(); } PathingCommand command = updateGoal(); @@ -115,7 +115,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro } private PathingCommand updateGoal() { - boolean legit = Baritone.settings().legitMine.get(); + boolean legit = Baritone.settings().legitMine.value; List locs = knownOreLocations; if (!locs.isEmpty()) { List locs2 = prune(new CalculationContext(baritone), new ArrayList<>(locs), mining, ORE_LOCATIONS_COUNT); @@ -129,7 +129,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro return null; } // only in non-Xray mode (aka legit mode) do we do this - int y = Baritone.settings().legitMineYLevel.get(); + int y = Baritone.settings().legitMineYLevel.value; if (branchPoint == null) { /*if (!baritone.getPathingBehavior().isPathing() && playerFeet().y == y) { // cool, path is over and we are at desired y @@ -157,7 +157,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro if (mining == null) { return; } - if (Baritone.settings().legitMine.get()) { + if (Baritone.settings().legitMine.value) { return; } List locs = searchWorld(context, mining, ORE_LOCATIONS_COUNT, already); @@ -171,18 +171,18 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro } private static Goal coalesce(IPlayerContext ctx, BlockPos loc, List locs) { - if (!Baritone.settings().forceInternalMining.get()) { + if (!Baritone.settings().forceInternalMining.value) { return new GoalTwoBlocks(loc); } // Here, BlockStateInterface is used because the position may be in a cached chunk (the targeted block is one that is kept track of) - boolean upwardGoal = locs.contains(loc.up()) || (Baritone.settings().internalMiningAirException.get() && BlockStateInterface.getBlock(ctx, loc.up()) == Blocks.AIR); - boolean downwardGoal = locs.contains(loc.down()) || (Baritone.settings().internalMiningAirException.get() && BlockStateInterface.getBlock(ctx, loc.down()) == Blocks.AIR); + boolean upwardGoal = locs.contains(loc.up()) || (Baritone.settings().internalMiningAirException.value && BlockStateInterface.getBlock(ctx, loc.up()) == Blocks.AIR); + boolean downwardGoal = locs.contains(loc.down()) || (Baritone.settings().internalMiningAirException.value && BlockStateInterface.getBlock(ctx, loc.down()) == Blocks.AIR); return upwardGoal == downwardGoal ? new GoalTwoBlocks(loc) : upwardGoal ? new GoalBlock(loc) : new GoalBlock(loc.down()); } public static List droppedItemsScan(List mining, World world) { - if (!Baritone.settings().mineScanDroppedItems.get()) { + if (!Baritone.settings().mineScanDroppedItems.value) { return new ArrayList<>(); } Set searchingFor = new HashSet<>(); @@ -211,7 +211,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro for (Block m : mining) { if (CachedChunk.BLOCKS_TO_KEEP_TRACK_OF.contains(m)) { // maxRegionDistanceSq 2 means adjacent directly or adjacent diagonally; nothing further than that - locs.addAll(ctx.worldData.getCachedWorld().getLocationsOf(ChunkPacker.blockToString(m), Baritone.settings().maxCachedWorldScanCount.get(), ctx.getBaritone().getPlayerContext().playerFeet().getX(), ctx.getBaritone().getPlayerContext().playerFeet().getZ(), 2)); + locs.addAll(ctx.worldData.getCachedWorld().getLocationsOf(ChunkPacker.blockToString(m), Baritone.settings().maxCachedWorldScanCount.value, ctx.getBaritone().getPlayerContext().playerFeet().getX(), ctx.getBaritone().getPlayerContext().playerFeet().getZ(), 2)); } else { uninteresting.add(m); } @@ -242,7 +242,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro // is an x-ray and it'll get caught if (mining.contains(bsi.get0(x, y, z).getBlock())) { BlockPos pos = new BlockPos(x, y, z); - if ((Baritone.settings().legitMineIncludeDiagonals.get() && knownOreLocations.stream().anyMatch(ore -> ore.distanceSq(pos) <= 2 /* sq means this is pytha dist <= sqrt(2) */)) || RotationUtils.reachable(ctx.player(), pos, fakedBlockReachDistance).isPresent()) { + if ((Baritone.settings().legitMineIncludeDiagonals.value && knownOreLocations.stream().anyMatch(ore -> ore.distanceSq(pos) <= 2 /* sq means this is pytha dist <= sqrt(2) */)) || RotationUtils.reachable(ctx.player(), pos, fakedBlockReachDistance).isPresent()) { knownOreLocations.add(pos); } } diff --git a/src/main/java/baritone/utils/BlockPlaceHelper.java b/src/main/java/baritone/utils/BlockPlaceHelper.java index e93bf8073..8e7ef44a6 100644 --- a/src/main/java/baritone/utils/BlockPlaceHelper.java +++ b/src/main/java/baritone/utils/BlockPlaceHelper.java @@ -40,7 +40,7 @@ public class BlockPlaceHelper implements Helper { if (!rightClickRequested || ctx.player().isRowingBoat() || mouseOver == null || mouseOver.getBlockPos() == null || mouseOver.typeOfHit != RayTraceResult.Type.BLOCK) { return; } - rightClickTimer = Baritone.settings().rightClickSpeed.get(); + rightClickTimer = Baritone.settings().rightClickSpeed.value; for (EnumHand hand : EnumHand.values()) { if (ctx.playerController().processRightClickBlock(ctx.player(), ctx.world(), mouseOver.getBlockPos(), mouseOver.sideHit, mouseOver.hitVec, hand) == EnumActionResult.SUCCESS) { ctx.player().swingArm(hand); diff --git a/src/main/java/baritone/utils/BlockStateInterface.java b/src/main/java/baritone/utils/BlockStateInterface.java index 5f8cac6ad..84bdce5fe 100644 --- a/src/main/java/baritone/utils/BlockStateInterface.java +++ b/src/main/java/baritone/utils/BlockStateInterface.java @@ -66,7 +66,7 @@ public class BlockStateInterface { } else { this.loadedChunks = worldLoaded; // this will only be used on the main thread } - this.useTheRealWorld = !Baritone.settings().pathThroughCachedOnly.get(); + this.useTheRealWorld = !Baritone.settings().pathThroughCachedOnly.value; if (!Minecraft.getMinecraft().isCallingFromMinecraftThread()) { throw new IllegalStateException(); } diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java index 61b9ebf1d..7988d7968 100644 --- a/src/main/java/baritone/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java @@ -89,14 +89,14 @@ public class ExampleBaritoneControl extends Behavior implements Helper { @Override public void onSendChatMessage(ChatEvent event) { String msg = event.getMessage(); - if (Baritone.settings().prefixControl.get() && msg.startsWith(COMMAND_PREFIX)) { + if (Baritone.settings().prefixControl.value && msg.startsWith(COMMAND_PREFIX)) { if (!runCommand(msg.substring(COMMAND_PREFIX.length()))) { logDirect("Invalid command"); } event.cancel(); // always cancel if using prefixControl return; } - if (!Baritone.settings().chatControl.get() && !Baritone.settings().removePrefix.get()) { + if (!Baritone.settings().chatControl.value && !Baritone.settings().removePrefix.value) { return; } if (runCommand(msg)) { diff --git a/src/main/java/baritone/utils/Helper.java b/src/main/java/baritone/utils/Helper.java index f85f240cc..7bcc605c1 100755 --- a/src/main/java/baritone/utils/Helper.java +++ b/src/main/java/baritone/utils/Helper.java @@ -50,7 +50,7 @@ public interface Helper { * @param message The message to display in chat */ default void logDebug(String message) { - if (!Baritone.settings().chatDebug.get()) { + if (!Baritone.settings().chatDebug.value) { //System.out.println("Suppressed debug message:"); //System.out.println(message); return; @@ -67,6 +67,6 @@ public interface Helper { ITextComponent component = MESSAGE_PREFIX.createCopy(); component.getStyle().setColor(TextFormatting.GRAY); component.appendSibling(new TextComponentString(" " + message)); - Minecraft.getMinecraft().addScheduledTask(() -> Baritone.settings().logger.get().accept(component)); + Minecraft.getMinecraft().addScheduledTask(() -> Baritone.settings().logger.value.accept(component)); } } diff --git a/src/main/java/baritone/utils/PathRenderer.java b/src/main/java/baritone/utils/PathRenderer.java index c0af870ee..e3da0e3e2 100644 --- a/src/main/java/baritone/utils/PathRenderer.java +++ b/src/main/java/baritone/utils/PathRenderer.java @@ -81,9 +81,9 @@ public final class PathRenderer implements Helper { } if (goal != null && Baritone.settings().renderGoal.value) { - drawDankLitGoalBox(renderView, goal, partialTicks, Baritone.settings().colorGoalBox.get()); + drawDankLitGoalBox(renderView, goal, partialTicks, Baritone.settings().colorGoalBox.value); } - if (!Baritone.settings().renderPath.get()) { + if (!Baritone.settings().renderPath.value) { return; } @@ -97,28 +97,28 @@ public final class PathRenderer implements Helper { // Render the current path, if there is one if (current != null && current.getPath() != null) { int renderBegin = Math.max(current.getPosition() - 3, 0); - drawPath(current.getPath(), renderBegin, renderView, partialTicks, Baritone.settings().colorCurrentPath.get(), Baritone.settings().fadePath.get(), 10, 20); + drawPath(current.getPath(), renderBegin, renderView, partialTicks, Baritone.settings().colorCurrentPath.value, Baritone.settings().fadePath.value, 10, 20); } if (next != null && next.getPath() != null) { - drawPath(next.getPath(), 0, renderView, partialTicks, Baritone.settings().colorNextPath.get(), Baritone.settings().fadePath.get(), 10, 20); + drawPath(next.getPath(), 0, renderView, partialTicks, Baritone.settings().colorNextPath.value, Baritone.settings().fadePath.value, 10, 20); } //long split = System.nanoTime(); if (current != null) { - drawManySelectionBoxes(renderView, current.toBreak(), Baritone.settings().colorBlocksToBreak.get()); - drawManySelectionBoxes(renderView, current.toPlace(), Baritone.settings().colorBlocksToPlace.get()); - drawManySelectionBoxes(renderView, current.toWalkInto(), Baritone.settings().colorBlocksToWalkInto.get()); + drawManySelectionBoxes(renderView, current.toBreak(), Baritone.settings().colorBlocksToBreak.value); + drawManySelectionBoxes(renderView, current.toPlace(), Baritone.settings().colorBlocksToPlace.value); + drawManySelectionBoxes(renderView, current.toWalkInto(), Baritone.settings().colorBlocksToWalkInto.value); } // If there is a path calculation currently running, render the path calculation process behavior.getInProgress().ifPresent(currentlyRunning -> { currentlyRunning.bestPathSoFar().ifPresent(p -> { - drawPath(p, 0, renderView, partialTicks, Baritone.settings().colorBestPathSoFar.get(), Baritone.settings().fadePath.get(), 10, 20); + drawPath(p, 0, renderView, partialTicks, Baritone.settings().colorBestPathSoFar.value, Baritone.settings().fadePath.value, 10, 20); }); currentlyRunning.pathToMostRecentNodeConsidered().ifPresent(mr -> { - drawPath(mr, 0, renderView, partialTicks, Baritone.settings().colorMostRecentConsidered.get(), Baritone.settings().fadePath.get(), 10, 20); - drawManySelectionBoxes(renderView, Collections.singletonList(mr.getDest()), Baritone.settings().colorMostRecentConsidered.get()); + drawPath(mr, 0, renderView, partialTicks, Baritone.settings().colorMostRecentConsidered.value, Baritone.settings().fadePath.value, 10, 20); + drawManySelectionBoxes(renderView, Collections.singletonList(mr.getDest()), Baritone.settings().colorMostRecentConsidered.value); }); }); //long end = System.nanoTime(); @@ -132,10 +132,10 @@ public final class PathRenderer implements Helper { GlStateManager.enableBlend(); GlStateManager.tryBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO); GlStateManager.color(color.getColorComponents(null)[0], color.getColorComponents(null)[1], color.getColorComponents(null)[2], 0.4F); - GlStateManager.glLineWidth(Baritone.settings().pathRenderLineWidthPixels.get()); + GlStateManager.glLineWidth(Baritone.settings().pathRenderLineWidthPixels.value); GlStateManager.disableTexture2D(); GlStateManager.depthMask(false); - if (Baritone.settings().renderPathIgnoreDepth.get()) { + if (Baritone.settings().renderPathIgnoreDepth.value) { GlStateManager.disableDepth(); } List positions = path.positions(); @@ -178,7 +178,7 @@ public final class PathRenderer implements Helper { drawLine(player, x1, y1, z1, x2, y2, z2); tessellator.draw(); } - if (Baritone.settings().renderPathIgnoreDepth.get()) { + if (Baritone.settings().renderPathIgnoreDepth.value) { GlStateManager.enableDepth(); } //GlStateManager.color(0.0f, 0.0f, 0.0f, 0.4f); @@ -203,11 +203,11 @@ public final class PathRenderer implements Helper { GlStateManager.enableBlend(); GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); GlStateManager.color(color.getColorComponents(null)[0], color.getColorComponents(null)[1], color.getColorComponents(null)[2], 0.4F); - GlStateManager.glLineWidth(Baritone.settings().pathRenderLineWidthPixels.get()); + GlStateManager.glLineWidth(Baritone.settings().pathRenderLineWidthPixels.value); GlStateManager.disableTexture2D(); GlStateManager.depthMask(false); - if (Baritone.settings().renderSelectionBoxesIgnoreDepth.get()) { + if (Baritone.settings().renderSelectionBoxesIgnoreDepth.value) { GlStateManager.disableDepth(); } @@ -249,7 +249,7 @@ public final class PathRenderer implements Helper { TESSELLATOR.draw(); }); - if (Baritone.settings().renderSelectionBoxesIgnoreDepth.get()) { + if (Baritone.settings().renderSelectionBoxesIgnoreDepth.value) { GlStateManager.enableDepth(); } @@ -292,12 +292,12 @@ public final class PathRenderer implements Helper { } else if (goal instanceof GoalXZ) { GoalXZ goalPos = (GoalXZ) goal; - if (Baritone.settings().renderGoalXZBeacon.get()) { + if (Baritone.settings().renderGoalXZBeacon.value) { glPushAttrib(GL_LIGHTING_BIT); mc.getTextureManager().bindTexture(TileEntityBeaconRenderer.TEXTURE_BEACON_BEAM); - if (Baritone.settings().renderGoalIgnoreDepth.get()) { + if (Baritone.settings().renderGoalIgnoreDepth.value) { GlStateManager.disableDepth(); } @@ -313,7 +313,7 @@ public final class PathRenderer implements Helper { color.getColorComponents(null) ); - if (Baritone.settings().renderGoalIgnoreDepth.get()) { + if (Baritone.settings().renderGoalIgnoreDepth.value) { GlStateManager.enableDepth(); } @@ -342,10 +342,10 @@ public final class PathRenderer implements Helper { GlStateManager.enableBlend(); GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); GlStateManager.color(color.getColorComponents(null)[0], color.getColorComponents(null)[1], color.getColorComponents(null)[2], 0.6F); - GlStateManager.glLineWidth(Baritone.settings().goalRenderLineWidthPixels.get()); + GlStateManager.glLineWidth(Baritone.settings().goalRenderLineWidthPixels.value); GlStateManager.disableTexture2D(); GlStateManager.depthMask(false); - if (Baritone.settings().renderGoalIgnoreDepth.get()) { + if (Baritone.settings().renderGoalIgnoreDepth.value) { GlStateManager.disableDepth(); } @@ -363,7 +363,7 @@ public final class PathRenderer implements Helper { BUFFER.pos(minX, maxY, maxZ).endVertex(); TESSELLATOR.draw(); - if (Baritone.settings().renderGoalIgnoreDepth.get()) { + if (Baritone.settings().renderGoalIgnoreDepth.value) { GlStateManager.enableDepth(); } GlStateManager.depthMask(true); diff --git a/src/main/java/baritone/utils/PathingControlManager.java b/src/main/java/baritone/utils/PathingControlManager.java index 54ed848a8..8d1616c4e 100644 --- a/src/main/java/baritone/utils/PathingControlManager.java +++ b/src/main/java/baritone/utils/PathingControlManager.java @@ -136,7 +136,7 @@ public class PathingControlManager implements IPathingControlManager { p.secretInternalSetGoalAndPath(command.goal); break; case REVALIDATE_GOAL_AND_PATH: - if (Baritone.settings().cancelOnGoalInvalidation.get() && (command.goal == null || revalidateGoal(command.goal))) { + if (Baritone.settings().cancelOnGoalInvalidation.value && (command.goal == null || revalidateGoal(command.goal))) { p.softCancelIfSafe(); } p.secretInternalSetGoalAndPath(command.goal); diff --git a/src/main/java/baritone/utils/ToolSet.java b/src/main/java/baritone/utils/ToolSet.java index bfa4e2513..31f23f209 100644 --- a/src/main/java/baritone/utils/ToolSet.java +++ b/src/main/java/baritone/utils/ToolSet.java @@ -55,7 +55,7 @@ public class ToolSet { breakStrengthCache = new HashMap<>(); this.player = player; - if (Baritone.settings().considerPotionEffects.get()) { + if (Baritone.settings().considerPotionEffects.value) { double amplifier = potionAmplifier(); Function amplify = x -> amplifier * x; backendCalculation = amplify.compose(this::getBestDestructionTime); diff --git a/src/main/java/baritone/utils/pathing/Avoidance.java b/src/main/java/baritone/utils/pathing/Avoidance.java index 1f61dc57a..9b32b1dfd 100644 --- a/src/main/java/baritone/utils/pathing/Avoidance.java +++ b/src/main/java/baritone/utils/pathing/Avoidance.java @@ -57,17 +57,17 @@ public class Avoidance { } public static List create(IPlayerContext ctx) { - if (!Baritone.settings().avoidance.get()) { + if (!Baritone.settings().avoidance.value) { return Collections.emptyList(); } List res = new ArrayList<>(); - double mobSpawnerCoeff = Baritone.settings().mobSpawnerAvoidanceCoefficient.get(); - double mobCoeff = Baritone.settings().mobAvoidanceCoefficient.get(); + double mobSpawnerCoeff = Baritone.settings().mobSpawnerAvoidanceCoefficient.value; + double mobCoeff = Baritone.settings().mobAvoidanceCoefficient.value; if (mobSpawnerCoeff != 1.0D) { - ctx.worldData().getCachedWorld().getLocationsOf("mob_spawner", 1, ctx.playerFeet().x, ctx.playerFeet().z, 2).forEach(mobspawner -> res.add(new Avoidance(mobspawner, mobSpawnerCoeff, Baritone.settings().mobSpawnerAvoidanceRadius.get()))); + ctx.worldData().getCachedWorld().getLocationsOf("mob_spawner", 1, ctx.playerFeet().x, ctx.playerFeet().z, 2).forEach(mobspawner -> res.add(new Avoidance(mobspawner, mobSpawnerCoeff, Baritone.settings().mobSpawnerAvoidanceRadius.value))); } if (mobCoeff != 1.0D) { - ctx.world().loadedEntityList.stream().filter(entity -> entity instanceof EntityMob).forEach(entity -> res.add(new Avoidance(new BlockPos(entity), mobCoeff, Baritone.settings().mobAvoidanceRadius.get()))); + ctx.world().loadedEntityList.stream().filter(entity -> entity instanceof EntityMob).forEach(entity -> res.add(new Avoidance(new BlockPos(entity), mobCoeff, Baritone.settings().mobAvoidanceRadius.value))); } return res; } diff --git a/src/main/java/baritone/utils/pathing/Favoring.java b/src/main/java/baritone/utils/pathing/Favoring.java index 7ffe49ffd..45bb8a09e 100644 --- a/src/main/java/baritone/utils/pathing/Favoring.java +++ b/src/main/java/baritone/utils/pathing/Favoring.java @@ -37,7 +37,7 @@ public final class Favoring { public Favoring(IPath previous) { // create one just from previous path, no mob avoidances favorings = new Long2DoubleOpenHashMap(); favorings.defaultReturnValue(1.0D); - double coeff = Baritone.settings().backtrackCostFavoringCoefficient.get(); + double coeff = Baritone.settings().backtrackCostFavoringCoefficient.value; if (coeff != 1D && previous != null) { previous.positions().forEach(pos -> favorings.put(BetterBlockPos.longHash(pos), coeff)); } diff --git a/src/main/java/baritone/utils/pathing/PathBase.java b/src/main/java/baritone/utils/pathing/PathBase.java index 3acf80b4e..8bac2dc77 100644 --- a/src/main/java/baritone/utils/pathing/PathBase.java +++ b/src/main/java/baritone/utils/pathing/PathBase.java @@ -28,7 +28,7 @@ import net.minecraft.util.math.BlockPos; public abstract class PathBase implements IPath { @Override public PathBase cutoffAtLoadedChunks(Object bsi0) { // <-- cursed cursed cursed - if (!Baritone.settings().cutoffAtLoadBoundary.get()) { + if (!Baritone.settings().cutoffAtLoadBoundary.value) { return this; } BlockStateInterface bsi = (BlockStateInterface) bsi0; @@ -43,14 +43,14 @@ public abstract class PathBase implements IPath { @Override public PathBase staticCutoff(Goal destination) { - int min = BaritoneAPI.getSettings().pathCutoffMinimumLength.get(); + int min = BaritoneAPI.getSettings().pathCutoffMinimumLength.value; if (length() < min) { return this; } if (destination == null || destination.isInGoal(getDest())) { return this; } - double factor = BaritoneAPI.getSettings().pathCutoffFactor.get(); + double factor = BaritoneAPI.getSettings().pathCutoffFactor.value; int newLength = (int) ((length() - min) * factor) + min - 1; return new CutoffPath(this, newLength); } diff --git a/src/main/java/baritone/utils/pathing/SegmentedCalculator.java b/src/main/java/baritone/utils/pathing/SegmentedCalculator.java index e1d6dd106..489d560d8 100644 --- a/src/main/java/baritone/utils/pathing/SegmentedCalculator.java +++ b/src/main/java/baritone/utils/pathing/SegmentedCalculator.java @@ -88,7 +88,7 @@ public class SegmentedCalculator { private PathCalculationResult segment(Optional previous) { BetterBlockPos segmentStart = previous.map(IPath::getDest).orElse(start); // <-- e p i c AbstractNodeCostSearch search = new AStarPathFinder(segmentStart.x, segmentStart.y, segmentStart.z, goal, new Favoring(previous.orElse(null)), context); // this is on another thread, so cannot include mob avoidances. - return search.calculate(Baritone.settings().primaryTimeoutMS.get(), Baritone.settings().failureTimeoutMS.get()); // use normal time settings, not the plan ahead settings, so as to not overwhelm the computer + return search.calculate(Baritone.settings().primaryTimeoutMS.value, Baritone.settings().failureTimeoutMS.value); // use normal time settings, not the plan ahead settings, so as to not overwhelm the computer } public static void calculateSegmentsThreaded(BetterBlockPos start, Goal goal, CalculationContext context, Consumer onCompletion, Runnable onFailure) { From b3c580e657218a18d2fdeb920ab7608a39256e92 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 4 Mar 2019 21:49:21 -0800 Subject: [PATCH 28/32] teensy javadoc --- src/api/java/baritone/api/Settings.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index bdebd1172..0e31d942e 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -721,6 +721,11 @@ public final class Settings { this.klass = (Class) value.getClass(); } + /** + * Deprecated! Please use .value directly instead + * + * @return the current setting value + */ @Deprecated public final T get() { return value; @@ -739,6 +744,9 @@ public final class Settings { return SettingsUtil.settingToString(this); } + /** + * Reset this setting to its default value + */ public void reset() { value = defaultValue; } From 74d7483b3c228ab464c16ff4b4005df2a568ffee Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 5 Mar 2019 12:26:52 -0800 Subject: [PATCH 29/32] explore --- src/api/java/baritone/api/Settings.java | 7 ++ src/main/java/baritone/Baritone.java | 11 +- src/main/java/baritone/cache/CachedWorld.java | 4 + .../java/baritone/process/ExploreProcess.java | 100 ++++++++++++++++++ .../utils/ExampleBaritoneControl.java | 15 +++ 5 files changed, 133 insertions(+), 4 deletions(-) create mode 100644 src/main/java/baritone/process/ExploreProcess.java diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 0e31d942e..b9a45960a 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -625,6 +625,13 @@ public final class Settings { */ public final Setting followRadius = new Setting<>(3); + /** + * true = exploration uses pythagorean distance to choose closest uncached chunk + *

+ * false = exploration uses manhattan / taxicab distance to choose + */ + public final Setting exploreUsePythagorean = new Setting<>(false); + /** * Cached chunks (regardless of if they're in RAM or saved to disk) expire and are deleted after this number of seconds * -1 to disable diff --git a/src/main/java/baritone/Baritone.java b/src/main/java/baritone/Baritone.java index 51a6ff699..ea8d40f2b 100755 --- a/src/main/java/baritone/Baritone.java +++ b/src/main/java/baritone/Baritone.java @@ -25,10 +25,7 @@ import baritone.api.utils.IPlayerContext; import baritone.behavior.*; import baritone.cache.WorldProvider; import baritone.event.GameEventHandler; -import baritone.process.CustomGoalProcess; -import baritone.process.FollowProcess; -import baritone.process.GetToBlockProcess; -import baritone.process.MineProcess; +import baritone.process.*; import baritone.utils.*; import baritone.utils.player.PrimaryPlayerContext; import net.minecraft.client.Minecraft; @@ -80,6 +77,7 @@ public class Baritone implements IBaritone { private MineProcess mineProcess; private GetToBlockProcess getToBlockProcess; private CustomGoalProcess customGoalProcess; + private ExploreProcess exploreProcess; private PathingControlManager pathingControlManager; @@ -118,6 +116,7 @@ public class Baritone implements IBaritone { mineProcess = new MineProcess(this); customGoalProcess = new CustomGoalProcess(this); // very high iq getToBlockProcess = new GetToBlockProcess(this); + exploreProcess = new ExploreProcess(this); } this.worldProvider = new WorldProvider(); @@ -177,6 +176,10 @@ public class Baritone implements IBaritone { return this.lookBehavior; } + public ExploreProcess getExploreProcess() { + return this.exploreProcess; + } + @Override public MineProcess getMineProcess() { return this.mineProcess; diff --git a/src/main/java/baritone/cache/CachedWorld.java b/src/main/java/baritone/cache/CachedWorld.java index e8ea5cae5..7e34fa081 100644 --- a/src/main/java/baritone/cache/CachedWorld.java +++ b/src/main/java/baritone/cache/CachedWorld.java @@ -107,6 +107,10 @@ public final class CachedWorld implements ICachedWorld, Helper { return region.isCached(blockX & 511, blockZ & 511); } + public final boolean regionLoaded(int blockX, int blockZ) { + return getRegion(blockX >> 9, blockZ >> 9) != null; + } + @Override public final ArrayList getLocationsOf(String block, int maximum, int centerX, int centerZ, int maxRegionDistanceSq) { ArrayList res = new ArrayList<>(); diff --git a/src/main/java/baritone/process/ExploreProcess.java b/src/main/java/baritone/process/ExploreProcess.java new file mode 100644 index 000000000..3f8d0f825 --- /dev/null +++ b/src/main/java/baritone/process/ExploreProcess.java @@ -0,0 +1,100 @@ +/* + * This file is part of Baritone. + * + * Baritone is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Baritone. If not, see . + */ + +package baritone.process; + +import baritone.Baritone; +import baritone.api.cache.ICachedWorld; +import baritone.api.pathing.goals.GoalXZ; +import baritone.api.process.PathingCommand; +import baritone.api.process.PathingCommandType; +import baritone.cache.CachedWorld; +import baritone.utils.BaritoneProcessHelper; +import net.minecraft.util.math.BlockPos; + +public class ExploreProcess extends BaritoneProcessHelper { + + private BlockPos explorationOrigin; + + public ExploreProcess(Baritone baritone) { + super(baritone, 0); + } + + @Override + public boolean isActive() { + return explorationOrigin != null; + } + + public void explore(int centerX, int centerZ) { + explorationOrigin = new BlockPos(centerX, 0, centerZ); + } + + @Override + public PathingCommand onTick(boolean calcFailed, boolean isSafeToCancel) { + if (calcFailed) { + logDirect("Failed"); + onLostControl(); + return null; + } + BlockPos closestUncached = closestUncachedChunk(explorationOrigin); + if (closestUncached == null) { + logDebug("awaiting region load from disk"); + return new PathingCommand(null, PathingCommandType.REQUEST_PAUSE); + } + System.out.println("Closest uncached: " + closestUncached); + return new PathingCommand(new GoalXZ(closestUncached.getX(), closestUncached.getZ()), PathingCommandType.FORCE_REVALIDATE_GOAL_AND_PATH); + } + + private BlockPos closestUncachedChunk(BlockPos pos) { + int chunkX = pos.getX() >> 4; + int chunkZ = pos.getZ() >> 4; + ICachedWorld cache = baritone.getWorldProvider().getCurrentWorld().getCachedWorld(); + for (int dist = 0; ; dist++) { + for (int dx = -dist; dx <= dist; dx++) { + for (int dz = -dist; dz <= dist; dz++) { + int trueDist = Baritone.settings().exploreUsePythagorean.value ? dx * dx + dz + dz : Math.abs(dx) + Math.abs(dz); + if (trueDist != dist) { + continue; // not considering this one just yet in our expanding search + } + int centerX = (chunkX + dx) * 16 + 8; + int centerZ = (chunkZ + dz) * 18 + 8; + + if (cache.isCached(centerX, centerZ)) { + continue; + } + if (!((CachedWorld) cache).regionLoaded(centerX, centerZ)) { + Baritone.getExecutor().execute(() -> { + ((CachedWorld) cache).tryLoadFromDisk(centerX >> 9, centerZ >> 9); + }); + return null; // we still need to load regions from disk in order to decide properly + } + return new BlockPos(centerX, 0, centerZ); + } + } + } + } + + @Override + public void onLostControl() { + explorationOrigin = null; + } + + @Override + public String displayName() { + return "Exploring around " + explorationOrigin + ", currently going to " + closestUncachedChunk(explorationOrigin); + } +} diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java index 7988d7968..89aa0fb52 100644 --- a/src/main/java/baritone/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java @@ -374,6 +374,21 @@ public class ExampleBaritoneControl extends Behavior implements Helper { logDirect("ok"); return true; } + if (msg.startsWith("explore")) { + String rest = msg.substring("explore".length()).trim(); + int centerX; + int centerZ; + try { + centerX = Integer.parseInt(rest.split(" ")[0]); + centerZ = Integer.parseInt(rest.split(" ")[1]); + } catch (Exception ex) { + centerX = ctx.playerFeet().x; + centerZ = ctx.playerFeet().z; + } + baritone.getExploreProcess().explore(centerX, centerZ); + logDirect("Exploring from " + centerX + "," + centerZ); + return true; + } if (msg.startsWith("find")) { String blockType = msg.substring(4).trim(); ArrayList locs = baritone.getWorldProvider().getCurrentWorld().getCachedWorld().getLocationsOf(blockType, 1, ctx.playerFeet().getX(), ctx.playerFeet().getZ(), 4); From d80ae57964f0175fa8c8b1c83482f73b4e71c3f4 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 6 Mar 2019 22:44:57 -0800 Subject: [PATCH 30/32] disconnect on arrival --- src/api/java/baritone/api/Settings.java | 5 +++++ src/main/java/baritone/behavior/PathingBehavior.java | 3 +++ 2 files changed, 8 insertions(+) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index b9a45960a..99fe52412 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -570,6 +570,11 @@ public final class Settings { */ public final Setting axisHeight = new Setting<>(120); + /** + * Disconnect from the server upon arriving at your goal + */ + public final Setting disconnectOnArrival = new Setting<>(false); + /** * Disallow MineBehavior from using X-Ray to see where the ores are. Turn this option on to force it to mine "legit" * where it will only mine an ore once it can actually see it, so it won't do or know anything that a normal player diff --git a/src/main/java/baritone/behavior/PathingBehavior.java b/src/main/java/baritone/behavior/PathingBehavior.java index a7c5c34bf..915e50663 100644 --- a/src/main/java/baritone/behavior/PathingBehavior.java +++ b/src/main/java/baritone/behavior/PathingBehavior.java @@ -141,6 +141,9 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior, logDebug("All done. At " + goal); queuePathEvent(PathEvent.AT_GOAL); next = null; + if (Baritone.settings().disconnectOnArrival.value) { + ctx.world().sendQuittingDisconnectingPacket(); + } return; } if (next != null && !next.getPath().positions().contains(ctx.playerFeet()) && !next.getPath().positions().contains(expectedSegmentStart)) { // can contain either one From d90f391b5e9dae3fc99ef371fcc70fb442f0678e Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 7 Mar 2019 18:18:31 -0800 Subject: [PATCH 31/32] 7 lmao --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 686547018..9216add1c 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ Baritone is the pathfinding system used in [Impact](https://impactdevelopment.gi This project is an updated version of [MineBot](https://github.com/leijurv/MineBot/), the original version of the bot for Minecraft 1.8, rebuilt for 1.12.2. Baritone focuses on reliability and particularly performance (it's over [30x faster](https://github.com/cabaletta/baritone/pull/180#issuecomment-423822928) than MineBot at calculating paths). -Have committed at least once a day for the last 6 months =D 🦀 +Have committed at least once a day for the last 7 months =D 🦀 1Leijurv3DWTrGAfmmiTphjhXLvQiHg7K2 From 76297e817669c4757cf9f8a2304cf953c506fb5f Mon Sep 17 00:00:00 2001 From: Leijurv Date: Fri, 8 Mar 2019 08:43:28 -0800 Subject: [PATCH 32/32] add click to usage --- USAGE.md | 1 + 1 file changed, 1 insertion(+) diff --git a/USAGE.md b/USAGE.md index 6a07518b2..2750ac781 100644 --- a/USAGE.md +++ b/USAGE.md @@ -34,6 +34,7 @@ Some common examples: - `cancel` or `stop` to stop everything - `goto portal` or `goto ender_chest` or `goto block_type` to go to a block. (in Impact, `.goto` is an alias for `.b goto` for the most part) - `mine diamond_ore` to mine diamond ore (turn on the setting `legitMine` to only mine ores that it can actually see. It will explore randomly around y=11 until it finds them.) +- `click` to click your destination on the screen. left click to path into it, right click to path on top of it. - `follow playerName` to follow a player. `follow` to follow the entity you're looking at (only works if it hitting range). `followplayers` to follow any players in range (combine with Kill Aura for a fun time). - `save waypointName` to save a waypoint. `goto waypointName` to go to it. - `axis` to go to an axis or diagonal axis at y=120 (`axisHeight` is a configurable setting, defaults to 120).