From 0f61aaafb82277aa731e8f547d811acbedcf4b84 Mon Sep 17 00:00:00 2001 From: Babbaj Date: Sun, 28 Apr 2019 21:27:11 -0400 Subject: [PATCH 01/40] use ImmutableSet --- src/main/java/baritone/cache/CachedChunk.java | 109 +++++++++--------- 1 file changed, 53 insertions(+), 56 deletions(-) diff --git a/src/main/java/baritone/cache/CachedChunk.java b/src/main/java/baritone/cache/CachedChunk.java index 631b7150e..249daa5b3 100644 --- a/src/main/java/baritone/cache/CachedChunk.java +++ b/src/main/java/baritone/cache/CachedChunk.java @@ -19,6 +19,7 @@ package baritone.cache; import baritone.api.utils.BlockUtils; import baritone.utils.pathing.PathingBlockType; +import com.google.common.collect.ImmutableSet; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; @@ -33,64 +34,60 @@ import java.util.*; */ public final class CachedChunk { - public static final Set BLOCKS_TO_KEEP_TRACK_OF; + public static final ImmutableSet BLOCKS_TO_KEEP_TRACK_OF = ImmutableSet.of( + Blocks.DIAMOND_BLOCK, + //Blocks.COAL_ORE, + Blocks.COAL_BLOCK, + //Blocks.IRON_ORE, + Blocks.IRON_BLOCK, + //Blocks.GOLD_ORE, + Blocks.GOLD_BLOCK, + Blocks.EMERALD_ORE, + Blocks.EMERALD_BLOCK, - static { - HashSet temp = new HashSet<>(); - //temp.add(Blocks.DIAMOND_ORE); - temp.add(Blocks.DIAMOND_BLOCK); - //temp.add(Blocks.COAL_ORE); - temp.add(Blocks.COAL_BLOCK); - //temp.add(Blocks.IRON_ORE); - temp.add(Blocks.IRON_BLOCK); - //temp.add(Blocks.GOLD_ORE); - temp.add(Blocks.GOLD_BLOCK); - temp.add(Blocks.EMERALD_ORE); - temp.add(Blocks.EMERALD_BLOCK); + Blocks.ENDER_CHEST, + Blocks.FURNACE, + Blocks.CHEST, + Blocks.TRAPPED_CHEST, + Blocks.END_PORTAL, + Blocks.END_PORTAL_FRAME, + Blocks.MOB_SPAWNER, + Blocks.BARRIER, + Blocks.OBSERVER, + Blocks.WHITE_SHULKER_BOX, + Blocks.ORANGE_SHULKER_BOX, + Blocks.MAGENTA_SHULKER_BOX, + Blocks.LIGHT_BLUE_SHULKER_BOX, + Blocks.YELLOW_SHULKER_BOX, + Blocks.LIME_SHULKER_BOX, + Blocks.PINK_SHULKER_BOX, + Blocks.GRAY_SHULKER_BOX, + Blocks.SILVER_SHULKER_BOX, + Blocks.CYAN_SHULKER_BOX, + Blocks.PURPLE_SHULKER_BOX, + Blocks.BLUE_SHULKER_BOX, + Blocks.BROWN_SHULKER_BOX, + Blocks.GREEN_SHULKER_BOX, + Blocks.RED_SHULKER_BOX, + Blocks.BLACK_SHULKER_BOX, + Blocks.PORTAL, + Blocks.HOPPER, + Blocks.BEACON, + Blocks.BREWING_STAND, + Blocks.SKULL, + Blocks.ENCHANTING_TABLE, + Blocks.ANVIL, + Blocks.LIT_FURNACE, + Blocks.BED, + Blocks.DRAGON_EGG, + Blocks.JUKEBOX, + Blocks.END_GATEWAY, + Blocks.WEB, + Blocks.NETHER_WART, + Blocks.LADDER, + Blocks.VINE + ); - temp.add(Blocks.ENDER_CHEST); - temp.add(Blocks.FURNACE); - temp.add(Blocks.CHEST); - temp.add(Blocks.TRAPPED_CHEST); - temp.add(Blocks.END_PORTAL); - temp.add(Blocks.END_PORTAL_FRAME); - temp.add(Blocks.MOB_SPAWNER); - temp.add(Blocks.BARRIER); - temp.add(Blocks.OBSERVER); - temp.add(Blocks.WHITE_SHULKER_BOX); - temp.add(Blocks.ORANGE_SHULKER_BOX); - temp.add(Blocks.MAGENTA_SHULKER_BOX); - temp.add(Blocks.LIGHT_BLUE_SHULKER_BOX); - temp.add(Blocks.YELLOW_SHULKER_BOX); - temp.add(Blocks.LIME_SHULKER_BOX); - temp.add(Blocks.PINK_SHULKER_BOX); - temp.add(Blocks.GRAY_SHULKER_BOX); - temp.add(Blocks.SILVER_SHULKER_BOX); - temp.add(Blocks.CYAN_SHULKER_BOX); - temp.add(Blocks.PURPLE_SHULKER_BOX); - temp.add(Blocks.BLUE_SHULKER_BOX); - temp.add(Blocks.BROWN_SHULKER_BOX); - temp.add(Blocks.GREEN_SHULKER_BOX); - temp.add(Blocks.RED_SHULKER_BOX); - temp.add(Blocks.BLACK_SHULKER_BOX); - temp.add(Blocks.PORTAL); - temp.add(Blocks.HOPPER); - temp.add(Blocks.BEACON); - temp.add(Blocks.BREWING_STAND); - temp.add(Blocks.SKULL); - temp.add(Blocks.ENCHANTING_TABLE); - temp.add(Blocks.ANVIL); - temp.add(Blocks.LIT_FURNACE); - temp.add(Blocks.BED); - temp.add(Blocks.DRAGON_EGG); - temp.add(Blocks.JUKEBOX); - temp.add(Blocks.END_GATEWAY); - 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); - } /** * The size of the chunk data in bits. Equal to 16 KiB. From 4679e1258832418aeac6b133d237a5aef2fa8876 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 16 May 2019 15:20:52 -0700 Subject: [PATCH 02/40] better usage --- USAGE.md | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/USAGE.md b/USAGE.md index 652c093ea..ce8924a74 100644 --- a/USAGE.md +++ b/USAGE.md @@ -2,24 +2,17 @@ # Prefix -Baritone commands can by default be typed in the chatbox. However if you make a typo, like typing "gola 10000 10000" instead of goal it goes into public chat, which is bad. - -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 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. +Baritone's chat control prefix is `#` by default. In Impact, you can also use `.b` as a prefix. (for example, `.b click` instead of `#click`) +Baritone commands can also by default be typed in the chatbox. However if you make a typo, like typing "gola 10000 10000" instead of "goal" it goes into public chat, which is bad, so using `#` is suggested. +To disable direct chat control (with no prefix), turn off the `chatControl` setting. To disable chat control with the `#` prefix, turn off the `prefixControl` setting. In Impact, `.b` cannot be disabled. Be careful that you don't leave yourself with all control methods disabled (if you do, reset your settings by deleting the file `minecraft/baritone/settings.txt` and relaunching). # Commands **All** of these commands may need a prefix before them, as above ^. -`help` for (rudimentary) help. You can see what it says [here](https://github.com/cabaletta/baritone/blob/master/src/main/java/baritone/utils/ExampleBaritoneControl.java#L53). +`help` for (rudimentary) help. You can see what it says [here](https://github.com/cabaletta/baritone/blob/master/src/api/java/baritone/api/utils/ExampleBaritoneControl.java#L47). To toggle a boolean setting, just say its name in chat (for example saying `allowBreak` toggles whether Baritone will consider breaking blocks). For a numeric setting, say its name then the new value (like `primaryTimeoutMS 250`). It's case insensitive. To reset a setting to its default value, say `acceptableThrowawayItems reset`. To reset all settings, say `reset`. To see all settings that have been modified from their default values, say `modified`. @@ -47,7 +40,7 @@ Some common examples: - `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). +For the rest of the commands, you can take a look at the code [here](https://github.com/cabaletta/baritone/blob/master/src/api/java/baritone/api/utils/ExampleBaritoneControl.java). All the settings and documentation are here. If you find HTML easier to read than Javadoc, you can look here. From 352e4288900b0c6020ced930be7debce9e330643 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Fri, 17 May 2019 22:21:40 -0800 Subject: [PATCH 03/40] explicitly set serialized name post obf --- src/api/java/baritone/api/utils/MyChunkPos.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/api/java/baritone/api/utils/MyChunkPos.java b/src/api/java/baritone/api/utils/MyChunkPos.java index 5748a13dc..0533fb0c1 100644 --- a/src/api/java/baritone/api/utils/MyChunkPos.java +++ b/src/api/java/baritone/api/utils/MyChunkPos.java @@ -17,11 +17,15 @@ package baritone.api.utils; +import com.google.gson.annotations.SerializedName; + /** * Need a non obfed chunkpos that we can load using GSON */ public class MyChunkPos { + @SerializedName("x") public int x; + @SerializedName("y") public int z; @Override From ccc1b04e815c2626bb930396c4fa71c4a50c0522 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 18 May 2019 17:11:16 -0700 Subject: [PATCH 04/40] crucial spacing --- src/api/java/baritone/api/utils/MyChunkPos.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/api/java/baritone/api/utils/MyChunkPos.java b/src/api/java/baritone/api/utils/MyChunkPos.java index 0533fb0c1..b122cdba7 100644 --- a/src/api/java/baritone/api/utils/MyChunkPos.java +++ b/src/api/java/baritone/api/utils/MyChunkPos.java @@ -23,8 +23,10 @@ import com.google.gson.annotations.SerializedName; * Need a non obfed chunkpos that we can load using GSON */ public class MyChunkPos { + @SerializedName("x") public int x; + @SerializedName("y") public int z; From d70da4f37da27a2e7b0e8855baff529657270b82 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 19 May 2019 21:53:09 -0800 Subject: [PATCH 05/40] finalize these --- src/api/java/baritone/api/utils/MyChunkPos.java | 2 +- src/main/java/baritone/process/BackfillProcess.java | 2 +- src/main/java/baritone/process/BuilderProcess.java | 2 +- src/main/java/baritone/process/CustomGoalProcess.java | 2 +- src/main/java/baritone/process/ExploreProcess.java | 2 +- src/main/java/baritone/process/FarmProcess.java | 2 +- src/main/java/baritone/process/GetToBlockProcess.java | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/api/java/baritone/api/utils/MyChunkPos.java b/src/api/java/baritone/api/utils/MyChunkPos.java index b122cdba7..1df7481db 100644 --- a/src/api/java/baritone/api/utils/MyChunkPos.java +++ b/src/api/java/baritone/api/utils/MyChunkPos.java @@ -23,7 +23,7 @@ import com.google.gson.annotations.SerializedName; * Need a non obfed chunkpos that we can load using GSON */ public class MyChunkPos { - + @SerializedName("x") public int x; diff --git a/src/main/java/baritone/process/BackfillProcess.java b/src/main/java/baritone/process/BackfillProcess.java index 8567a049b..65e5692eb 100644 --- a/src/main/java/baritone/process/BackfillProcess.java +++ b/src/main/java/baritone/process/BackfillProcess.java @@ -35,7 +35,7 @@ import net.minecraft.world.chunk.EmptyChunk; import java.util.*; import java.util.stream.Collectors; -public class BackfillProcess extends BaritoneProcessHelper { +public final class BackfillProcess extends BaritoneProcessHelper { public HashMap blocksToReplace = new HashMap<>(); diff --git a/src/main/java/baritone/process/BuilderProcess.java b/src/main/java/baritone/process/BuilderProcess.java index 17424345c..27c1f8856 100644 --- a/src/main/java/baritone/process/BuilderProcess.java +++ b/src/main/java/baritone/process/BuilderProcess.java @@ -55,7 +55,7 @@ import java.util.*; import static baritone.api.pathing.movement.ActionCosts.COST_INF; -public class BuilderProcess extends BaritoneProcessHelper implements IBuilderProcess { +public final class BuilderProcess extends BaritoneProcessHelper implements IBuilderProcess { private HashSet incorrectPositions; private LongOpenHashSet observedCompleted; // positions that are completed even if they're out of render distance and we can't make sure right now diff --git a/src/main/java/baritone/process/CustomGoalProcess.java b/src/main/java/baritone/process/CustomGoalProcess.java index 4003b7a7a..b45c7d6f9 100644 --- a/src/main/java/baritone/process/CustomGoalProcess.java +++ b/src/main/java/baritone/process/CustomGoalProcess.java @@ -29,7 +29,7 @@ import baritone.utils.BaritoneProcessHelper; * * @author leijurv */ -public class CustomGoalProcess extends BaritoneProcessHelper implements ICustomGoalProcess { +public final class CustomGoalProcess extends BaritoneProcessHelper implements ICustomGoalProcess { /** * The current goal diff --git a/src/main/java/baritone/process/ExploreProcess.java b/src/main/java/baritone/process/ExploreProcess.java index 35ddcb841..aa7e2c2a6 100644 --- a/src/main/java/baritone/process/ExploreProcess.java +++ b/src/main/java/baritone/process/ExploreProcess.java @@ -41,7 +41,7 @@ import java.nio.file.Path; import java.util.ArrayList; import java.util.List; -public class ExploreProcess extends BaritoneProcessHelper implements IExploreProcess { +public final class ExploreProcess extends BaritoneProcessHelper implements IExploreProcess { private BlockPos explorationOrigin; diff --git a/src/main/java/baritone/process/FarmProcess.java b/src/main/java/baritone/process/FarmProcess.java index ac6d488fa..9593a192b 100644 --- a/src/main/java/baritone/process/FarmProcess.java +++ b/src/main/java/baritone/process/FarmProcess.java @@ -50,7 +50,7 @@ import java.util.List; import java.util.Optional; import java.util.function.Predicate; -public class FarmProcess extends BaritoneProcessHelper implements IFarmProcess { +public final class FarmProcess extends BaritoneProcessHelper implements IFarmProcess { private boolean active; diff --git a/src/main/java/baritone/process/GetToBlockProcess.java b/src/main/java/baritone/process/GetToBlockProcess.java index 69703894d..4fb4d540e 100644 --- a/src/main/java/baritone/process/GetToBlockProcess.java +++ b/src/main/java/baritone/process/GetToBlockProcess.java @@ -34,7 +34,7 @@ import net.minecraft.util.math.BlockPos; import java.util.*; -public class GetToBlockProcess extends BaritoneProcessHelper implements IGetToBlockProcess { +public final class GetToBlockProcess extends BaritoneProcessHelper implements IGetToBlockProcess { private Block gettingTo; private List knownLocations; From c7fe9c31719fbfbd6dc34e6312f85b8f4884b217 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 20 May 2019 22:37:51 -0700 Subject: [PATCH 06/40] finalize --- src/main/java/baritone/behavior/InventoryBehavior.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/behavior/InventoryBehavior.java b/src/main/java/baritone/behavior/InventoryBehavior.java index 03878ee52..684613af1 100644 --- a/src/main/java/baritone/behavior/InventoryBehavior.java +++ b/src/main/java/baritone/behavior/InventoryBehavior.java @@ -33,7 +33,7 @@ import java.util.OptionalInt; import java.util.Random; import java.util.function.Predicate; -public class InventoryBehavior extends Behavior { +public final class InventoryBehavior extends Behavior { public InventoryBehavior(Baritone baritone) { super(baritone); } From 79da32cc60708ce64501118a8d3705e3e516b778 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 21 May 2019 15:07:05 -0700 Subject: [PATCH 07/40] unused --- src/main/java/baritone/pathing/movement/Movement.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/baritone/pathing/movement/Movement.java b/src/main/java/baritone/pathing/movement/Movement.java index c9849caba..be29b988a 100644 --- a/src/main/java/baritone/pathing/movement/Movement.java +++ b/src/main/java/baritone/pathing/movement/Movement.java @@ -32,7 +32,6 @@ import net.minecraft.util.math.BlockPos; import java.util.ArrayList; import java.util.List; -import java.util.Objects; import java.util.Optional; public abstract class Movement implements IMovement, MovementHelper { From bb924ad83ff8d5754dd039de9f5718fe1e85cf1b Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 22 May 2019 23:41:02 -0700 Subject: [PATCH 08/40] thank you intellij very cool --- src/api/java/baritone/api/utils/ExampleBaritoneControl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/java/baritone/api/utils/ExampleBaritoneControl.java b/src/api/java/baritone/api/utils/ExampleBaritoneControl.java index 67cd5b472..467d4d959 100644 --- a/src/api/java/baritone/api/utils/ExampleBaritoneControl.java +++ b/src/api/java/baritone/api/utils/ExampleBaritoneControl.java @@ -332,7 +332,7 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener if (suffix.isEmpty()) { // clear the area from the current goal to here Goal goal = baritone.getPathingBehavior().getGoal(); - if (goal == null || !(goal instanceof GoalBlock)) { + if (!(goal instanceof GoalBlock)) { logDirect("Need to specify goal of opposite corner"); return true; } From b4d203ab99abf71f3f29e3841839fee57c010922 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 23 May 2019 20:47:22 -0800 Subject: [PATCH 09/40] bye --- .../baritone/api/utils/ExampleBaritoneControl.java | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/api/java/baritone/api/utils/ExampleBaritoneControl.java b/src/api/java/baritone/api/utils/ExampleBaritoneControl.java index 467d4d959..927ba7947 100644 --- a/src/api/java/baritone/api/utils/ExampleBaritoneControl.java +++ b/src/api/java/baritone/api/utils/ExampleBaritoneControl.java @@ -385,17 +385,6 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener logDirect("farming"); return true; } - // this literally doesn't work, memory is disabled lol - /*if (msg.equals("echest")) { - Optional> contents = baritone.getMemoryBehavior().echest(); - if (contents.isPresent()) { - logDirect("echest contents:"); - log(contents.get()); - } else { - logDirect("echest contents unknown"); - } - return true; - }*/ if (msg.equals("chests")) { for (Map.Entry entry : baritone.getWorldProvider().getCurrentWorld().getContainerMemory().getRememberedInventories().entrySet()) { logDirect(entry.getKey() + ""); From a6954aa719ae519a4d17418b3f69665843d41db2 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Fri, 24 May 2019 10:36:01 -0700 Subject: [PATCH 10/40] bye 2 --- .../api/utils/ExampleBaritoneControl.java | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/src/api/java/baritone/api/utils/ExampleBaritoneControl.java b/src/api/java/baritone/api/utils/ExampleBaritoneControl.java index 927ba7947..295472815 100644 --- a/src/api/java/baritone/api/utils/ExampleBaritoneControl.java +++ b/src/api/java/baritone/api/utils/ExampleBaritoneControl.java @@ -638,24 +638,6 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener } return true; } - // this is completely impossible from api - /*if (msg.equals("costs")) { - List moves = Stream.of(Moves.values()).map(x -> x.apply0(new CalculationContext(baritone), ctx.playerFeet())).collect(Collectors.toCollection(ArrayList::new)); - while (moves.contains(null)) { - moves.remove(null); - } - moves.sort(Comparator.comparingDouble(move -> move.getCost(new CalculationContext(baritone)))); - for (Movement move : moves) { - String[] parts = move.getClass().toString().split("\\."); - double cost = move.getCost(); - String strCost = cost + ""; - if (cost >= ActionCosts.COST_INF) { - strCost = "IMPOSSIBLE"; - } - logDirect(parts[parts.length - 1] + " " + move.getDest().getX() + "," + move.getDest().getY() + "," + move.getDest().getZ() + " " + strCost); - } - return true; - }*/ if (msg.equals("damn")) { logDirect("daniel"); } From bd0c7b9391a4d34ea9ada7d3142474ca91b14437 Mon Sep 17 00:00:00 2001 From: Babbaj Date: Sat, 25 May 2019 17:25:23 -0400 Subject: [PATCH 11/40] yet another meaningless commit --- src/api/java/baritone/api/utils/ExampleBaritoneControl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/java/baritone/api/utils/ExampleBaritoneControl.java b/src/api/java/baritone/api/utils/ExampleBaritoneControl.java index 295472815..2b6186b5a 100644 --- a/src/api/java/baritone/api/utils/ExampleBaritoneControl.java +++ b/src/api/java/baritone/api/utils/ExampleBaritoneControl.java @@ -415,7 +415,7 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener return true; } Entity effectivelyFinal = toFollow.get(); - baritone.getFollowProcess().follow(x -> effectivelyFinal.equals(x)); + baritone.getFollowProcess().follow(effectivelyFinal::equals); logDirect("Following " + toFollow.get()); return true; } From de554655a54ab76d2dcc0bc16eb7c0c5fbac9895 Mon Sep 17 00:00:00 2001 From: Babbaj Date: Sat, 25 May 2019 17:27:06 -0400 Subject: [PATCH 12/40] yet another meaningless commit --- src/api/java/baritone/api/utils/ExampleBaritoneControl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/java/baritone/api/utils/ExampleBaritoneControl.java b/src/api/java/baritone/api/utils/ExampleBaritoneControl.java index 295472815..2b6186b5a 100644 --- a/src/api/java/baritone/api/utils/ExampleBaritoneControl.java +++ b/src/api/java/baritone/api/utils/ExampleBaritoneControl.java @@ -415,7 +415,7 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener return true; } Entity effectivelyFinal = toFollow.get(); - baritone.getFollowProcess().follow(x -> effectivelyFinal.equals(x)); + baritone.getFollowProcess().follow(effectivelyFinal::equals); logDirect("Following " + toFollow.get()); return true; } From 18474d872c652a9d61c7ee1159811f2bcd1eebb3 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 26 May 2019 12:14:08 -0700 Subject: [PATCH 13/40] unused --- src/main/java/baritone/process/BuilderProcess.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/baritone/process/BuilderProcess.java b/src/main/java/baritone/process/BuilderProcess.java index 27c1f8856..6c921f8e6 100644 --- a/src/main/java/baritone/process/BuilderProcess.java +++ b/src/main/java/baritone/process/BuilderProcess.java @@ -359,7 +359,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil logDirect("Repeating build in vector " + repeat + ", new origin is " + origin); return onTick(calcFailed, isSafeToCancel); } - trim(bcc); + trim(); Optional> toBreak = toBreakNearPlayer(bcc); if (toBreak.isPresent() && isSafeToCancel && ctx.player().onGround) { @@ -447,7 +447,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil return !incorrectPositions.isEmpty(); } - private void trim(BuilderCalculationContext bcc) { + private void trim() { HashSet copy = new HashSet<>(incorrectPositions); copy.removeIf(pos -> pos.distanceSq(ctx.player().posX, ctx.player().posY, ctx.player().posZ) > 200); if (!copy.isEmpty()) { From 2e2f4aee1b261fade1c4b85d326e2f573fb4c1bf Mon Sep 17 00:00:00 2001 From: Brady Date: Mon, 27 May 2019 02:30:04 -0500 Subject: [PATCH 14/40] critical performance enhancement --- src/main/java/baritone/behavior/PathingBehavior.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/behavior/PathingBehavior.java b/src/main/java/baritone/behavior/PathingBehavior.java index fbe48ad80..a5ffc5987 100644 --- a/src/main/java/baritone/behavior/PathingBehavior.java +++ b/src/main/java/baritone/behavior/PathingBehavior.java @@ -65,7 +65,7 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior, private boolean lastAutoJump; - private BlockPos expectedSegmentStart; + private BetterBlockPos expectedSegmentStart; private final LinkedBlockingQueue toDispatch = new LinkedBlockingQueue<>(); From aa0f664cda65647a62eb384abe16f46550af5ebb Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 27 May 2019 21:20:00 -0700 Subject: [PATCH 15/40] =?UTF-8?q?just=20for=20debugging=20purposes=20?= =?UTF-8?q?=F0=9F=98=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../baritone/api/utils/ExampleBaritoneControl.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/api/java/baritone/api/utils/ExampleBaritoneControl.java b/src/api/java/baritone/api/utils/ExampleBaritoneControl.java index 2b6186b5a..8369d5f9b 100644 --- a/src/api/java/baritone/api/utils/ExampleBaritoneControl.java +++ b/src/api/java/baritone/api/utils/ExampleBaritoneControl.java @@ -33,9 +33,11 @@ import baritone.api.process.IGetToBlockProcess; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.ChunkProviderClient; +import net.minecraft.crash.CrashReport; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; +import net.minecraft.util.ReportedException; import net.minecraft.util.math.BlockPos; import net.minecraft.world.chunk.Chunk; @@ -195,6 +197,17 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener logDirect("Goal: " + goal); return true; } + if (msg.equals("crash")) { + StringBuilder meme = new StringBuilder(); + CrashReport rep = (new CrashReport("Manually triggered debug crash", new Throwable())); + mc.addGraphicsAndWorldToCrashReport(rep); + new ReportedException(rep).printStackTrace(); + rep.getSectionsInStringBuilder(meme); + System.out.println(meme); + logDirect(meme.toString()); + logDirect("ok"); + return true; + } if (msg.equals("path")) { if (pathingBehavior.getGoal() == null) { logDirect("No goal."); From a1e2b018a281053b0b863e732674d646e56de933 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 28 May 2019 14:17:54 -0700 Subject: [PATCH 16/40] very good suggestion --- src/api/java/baritone/api/utils/ExampleBaritoneControl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/java/baritone/api/utils/ExampleBaritoneControl.java b/src/api/java/baritone/api/utils/ExampleBaritoneControl.java index 8369d5f9b..29b42d699 100644 --- a/src/api/java/baritone/api/utils/ExampleBaritoneControl.java +++ b/src/api/java/baritone/api/utils/ExampleBaritoneControl.java @@ -199,7 +199,7 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener } if (msg.equals("crash")) { StringBuilder meme = new StringBuilder(); - CrashReport rep = (new CrashReport("Manually triggered debug crash", new Throwable())); + CrashReport rep = new CrashReport("Manually triggered debug crash", new Throwable()); mc.addGraphicsAndWorldToCrashReport(rep); new ReportedException(rep).printStackTrace(); rep.getSectionsInStringBuilder(meme); From 479b4e334940d9207c299eb9621b0f036ce08772 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 29 May 2019 10:45:59 -0700 Subject: [PATCH 17/40] releases download count --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 71e60aa49..1cfa84d40 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) +[![GitHub All Releases](https://img.shields.io/github/downloads/cabaletta/baritone/total.svg)](https://github.com/cabaletta/baritone/releases) [![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) From 1a52537d0c0aff32a9d466fe2464b8081fb1b149 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 30 May 2019 20:49:04 -0800 Subject: [PATCH 18/40] badges --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1cfa84d40..3b321ff4b 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ [![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.5%20/%20v1.3.0-brightgreen.svg)](https://impactdevelopment.github.io/) +[![Impact integration](https://img.shields.io/badge/Impact%20integration-v1.2.6%20/%20v1.3.2-brightgreen.svg)](https://impactdevelopment.github.io/) [![WWE integration](https://img.shields.io/badge/WWE%20%22integration%22-master%3F-green.svg)](https://wweclient.com/) [![KAMI integration](https://img.shields.io/badge/KAMI%20integration-v1.0.0-red.svg)](https://github.com/zeroeightysix/KAMI/) [![Future integration](https://img.shields.io/badge/Future%20integration-Soon™%3F%3F%3F-red.svg)](https://futureclient.net/) From aca6922be0495660d5a3999aa6dbc9347db0f44b Mon Sep 17 00:00:00 2001 From: Leijurv Date: Fri, 31 May 2019 23:01:16 -0700 Subject: [PATCH 19/40] there is no actual integration --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 3b321ff4b..af30ced06 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,6 @@ [![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.6%20/%20v1.3.2-brightgreen.svg)](https://impactdevelopment.github.io/) [![WWE integration](https://img.shields.io/badge/WWE%20%22integration%22-master%3F-green.svg)](https://wweclient.com/) -[![KAMI integration](https://img.shields.io/badge/KAMI%20integration-v1.0.0-red.svg)](https://github.com/zeroeightysix/KAMI/) [![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) [![forthebadge](https://forthebadge.com/images/badges/built-with-swag.svg)](http://forthebadge.com) From 39a231eae0ac8389a54bab541699322115c77293 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 1 Jun 2019 10:56:24 -0700 Subject: [PATCH 20/40] crucial performance optimization --- 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 ca1b3490a..1e138290c 100644 --- a/src/main/java/baritone/process/MineProcess.java +++ b/src/main/java/baritone/process/MineProcess.java @@ -281,7 +281,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro public static List droppedItemsScan(List mining, World world) { if (!Baritone.settings().mineScanDroppedItems.value) { - return new ArrayList<>(); + return Collections.emptyList(); } Set searchingFor = new HashSet<>(); for (Block block : mining) { From 023aa78d8be4fc7c0bbc6f5eb77e117d7ea5c072 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 1 Jun 2019 15:36:52 -0700 Subject: [PATCH 21/40] yay --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index af30ced06..9d7823726 100644 --- a/README.md +++ b/README.md @@ -18,9 +18,9 @@ [![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.6%20/%20v1.3.2-brightgreen.svg)](https://impactdevelopment.github.io/) +[![ForgeHax integration](https://img.shields.io/badge/ForgeHax%20%22integration%22-v1.2.*-green.svg)](https://github.com/fr1kin/ForgeHax) [![WWE integration](https://img.shields.io/badge/WWE%20%22integration%22-master%3F-green.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) [![forthebadge](https://forthebadge.com/images/badges/built-with-swag.svg)](http://forthebadge.com) [![forthebadge](https://forthebadge.com/images/badges/mom-made-pizza-rolls.svg)](http://forthebadge.com) From 9611cb9057ae00ed31fd0443374df64be68127ed Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 1 Jun 2019 17:54:16 -0700 Subject: [PATCH 22/40] 1.13.2 is supported --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 9d7823726..6ac396c38 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ ![GitHub repo size](https://img.shields.io/github/repo-size/cabaletta/baritone.svg) ![](https://tokei.rs/b1/github/cabaletta/baritone?category=code) [![Minecraft](https://img.shields.io/badge/MC-1.12.2-green.svg)](https://minecraft.gamepedia.com/1.12.2) +[![Minecraft](https://img.shields.io/badge/MC-1.13.2-brightgreen.svg)](https://minecraft.gamepedia.com/1.13.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.6%20/%20v1.3.2-brightgreen.svg)](https://impactdevelopment.github.io/) From 130873d91d0cdfdd16e0552b369e5a9ca1f740fb Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 2 Jun 2019 21:33:10 -0700 Subject: [PATCH 23/40] 1.13.2 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6ac396c38..048f8a569 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ A Minecraft pathfinder bot. Baritone is the pathfinding system used in [Impact](https://impactdevelopment.github.io/) since 4.4. There's a [showcase video](https://www.youtube.com/watch?v=yI8hgW_m6dQ) made by @Adovin#3153 on Baritone's integration into Impact. [Here's](https://www.youtube.com/watch?v=StquF69-_wI) a video I made showing off what it can do. This project is an updated version of [MineBot](https://github.com/leijurv/MineBot/), -the original version of the bot for Minecraft 1.8.9, 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). +the original version of the bot for Minecraft 1.8.9, rebuilt for 1.12.2 and 1.13.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 8 months =D 🦀 From f19e63d6e9778ef0908ccac78590d9690936e3c7 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 3 Jun 2019 13:43:32 -0700 Subject: [PATCH 24/40] mc version support is important --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 048f8a569..5eb0c9200 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,8 @@ [![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) [![GitHub All Releases](https://img.shields.io/github/downloads/cabaletta/baritone/total.svg)](https://github.com/cabaletta/baritone/releases) +[![Minecraft](https://img.shields.io/badge/MC-1.12.2-green.svg)](https://minecraft.gamepedia.com/1.12.2) +[![Minecraft](https://img.shields.io/badge/MC-1.13.2-brightgreen.svg)](https://minecraft.gamepedia.com/1.13.2) [![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) @@ -14,8 +16,6 @@ ![Code size](https://img.shields.io/github/languages/code-size/cabaletta/baritone.svg) ![GitHub repo size](https://img.shields.io/github/repo-size/cabaletta/baritone.svg) ![](https://tokei.rs/b1/github/cabaletta/baritone?category=code) -[![Minecraft](https://img.shields.io/badge/MC-1.12.2-green.svg)](https://minecraft.gamepedia.com/1.12.2) -[![Minecraft](https://img.shields.io/badge/MC-1.13.2-brightgreen.svg)](https://minecraft.gamepedia.com/1.13.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.6%20/%20v1.3.2-brightgreen.svg)](https://impactdevelopment.github.io/) From e1dd580df8943cd1db6e532160cf84b82f031d91 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 3 Jun 2019 15:26:57 -0700 Subject: [PATCH 25/40] fix improper singleplayer check after quitting singleplayer --- .../baritone/launch/mixins/MixinChunkRenderContainer.java | 2 +- .../java/baritone/launch/mixins/MixinChunkRenderWorker.java | 2 +- src/launch/java/baritone/launch/mixins/MixinRenderChunk.java | 4 ++-- src/launch/java/baritone/launch/mixins/MixinRenderList.java | 2 +- .../java/baritone/launch/mixins/MixinVboRenderList.java | 2 +- src/main/java/baritone/cache/WorldProvider.java | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/launch/java/baritone/launch/mixins/MixinChunkRenderContainer.java b/src/launch/java/baritone/launch/mixins/MixinChunkRenderContainer.java index 78bd16073..0d228db95 100644 --- a/src/launch/java/baritone/launch/mixins/MixinChunkRenderContainer.java +++ b/src/launch/java/baritone/launch/mixins/MixinChunkRenderContainer.java @@ -41,7 +41,7 @@ public class MixinChunkRenderContainer { ) ) private BlockPos getPosition(RenderChunk renderChunkIn) { - if (Baritone.settings().renderCachedChunks.value && Minecraft.getMinecraft().getIntegratedServer() == null && Minecraft.getMinecraft().world.getChunk(renderChunkIn.getPosition()).isEmpty()) { + if (Baritone.settings().renderCachedChunks.value && !Minecraft.getMinecraft().isSingleplayer() && Minecraft.getMinecraft().world.getChunk(renderChunkIn.getPosition()).isEmpty()) { GlStateManager.enableAlpha(); GlStateManager.enableBlend(); GL14.glBlendColor(0, 0, 0, Baritone.settings().cachedChunksOpacity.value); diff --git a/src/launch/java/baritone/launch/mixins/MixinChunkRenderWorker.java b/src/launch/java/baritone/launch/mixins/MixinChunkRenderWorker.java index 81e393824..d72fdd41c 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.value && Minecraft.getMinecraft().getIntegratedServer() == null) { + if (Baritone.settings().renderCachedChunks.value && !Minecraft.getMinecraft().isSingleplayer()) { 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 22ab0bdd6..f67d5d220 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.value && Minecraft.getMinecraft().getIntegratedServer() == null) { + if (Baritone.settings().renderCachedChunks.value && !Minecraft.getMinecraft().isSingleplayer()) { 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.value && Minecraft.getMinecraft().getIntegratedServer() == null) { + if (Baritone.settings().renderCachedChunks.value && !Minecraft.getMinecraft().isSingleplayer()) { 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 98ae5bf52..3efb3a10c 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.value && Minecraft.getMinecraft().getIntegratedServer() == null) { + if (Baritone.settings().renderCachedChunks.value && !Minecraft.getMinecraft().isSingleplayer()) { // 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 bab98b3c6..cec62336d 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.value && Minecraft.getMinecraft().getIntegratedServer() == null) { + if (Baritone.settings().renderCachedChunks.value && !Minecraft.getMinecraft().isSingleplayer()) { // 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/cache/WorldProvider.java b/src/main/java/baritone/cache/WorldProvider.java index 63d0b2192..c277a0d06 100644 --- a/src/main/java/baritone/cache/WorldProvider.java +++ b/src/main/java/baritone/cache/WorldProvider.java @@ -62,7 +62,7 @@ public class WorldProvider implements IWorldProvider, Helper { IntegratedServer integratedServer = mc.getIntegratedServer(); // If there is an integrated server running (Aka Singleplayer) then do magic to find the world save file - if (integratedServer != null) { + if (mc.isSingleplayer()) { WorldServer localServerWorld = integratedServer.getWorld(dimension); IChunkProviderServer provider = (IChunkProviderServer) localServerWorld.getChunkProvider(); IAnvilChunkLoader loader = (IAnvilChunkLoader) provider.getChunkLoader(); From 7fa6593bdc38a54424b97dca108cc3c48e86fe03 Mon Sep 17 00:00:00 2001 From: 0x22 <0x22@futureclient.net> Date: Tue, 4 Jun 2019 01:02:54 -0400 Subject: [PATCH 26/40] Added the command delete. Allows you to remove a user defined waypoint. Fixes #334 --- .../baritone/api/utils/ExampleBaritoneControl.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/api/java/baritone/api/utils/ExampleBaritoneControl.java b/src/api/java/baritone/api/utils/ExampleBaritoneControl.java index 29b42d699..2445f6341 100644 --- a/src/api/java/baritone/api/utils/ExampleBaritoneControl.java +++ b/src/api/java/baritone/api/utils/ExampleBaritoneControl.java @@ -68,6 +68,7 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener "get - Same as list\n" + "show - Same as list\n" + "save - Saves a waypoint (works but don't try to make sense of it)\n" + + "delete - Deletes a waypoint\n" + "goto - Paths towards specified block or waypoint\n" + "spawn - Paths towards world spawn or your most recent bed right-click\n" + "sethome - Sets \"home\"\n" + @@ -583,6 +584,17 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener logDirect("Saved user defined position " + pos + " under name '" + name + "'. Say 'goto " + name + "' to set goal, say 'list user' to list custom waypoints."); return true; } + if (msg.startsWith("delete")) { + String name = msg.substring(6).trim(); + IWaypoint waypoint = baritone.getWorldProvider().getCurrentWorld().getWaypoints().getAllWaypoints().stream().filter(w -> w.getTag() == IWaypoint.Tag.USER && w.getName().equalsIgnoreCase(name)).findFirst().orElse(null); + if (waypoint == null) { + logDirect("No user defined position under the name '" + name + "' found."); + return true; + } + baritone.getWorldProvider().getCurrentWorld().getWaypoints().removeWaypoint(waypoint); + logDirect("Deleted user defined position under name '" + name + "'."); + return true; + } if (msg.startsWith("goto")) { String waypointType = msg.substring(4).trim(); if (waypointType.endsWith("s") && IWaypoint.Tag.fromString(waypointType.substring(0, waypointType.length() - 1)) != null) { From 1e43563cc36e9066c6ccdd3ec00c737d1113ce8b Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 4 Jun 2019 20:55:31 -0700 Subject: [PATCH 27/40] fix weird backfill behavior --- src/main/java/baritone/pathing/movement/Movement.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/pathing/movement/Movement.java b/src/main/java/baritone/pathing/movement/Movement.java index be29b988a..5cb4fef98 100644 --- a/src/main/java/baritone/pathing/movement/Movement.java +++ b/src/main/java/baritone/pathing/movement/Movement.java @@ -147,10 +147,10 @@ public abstract class Movement implements IMovement, MovementHelper { } if (!MovementHelper.canWalkThrough(ctx, blockPos) && !(BlockStateInterface.getBlock(ctx, blockPos) instanceof BlockLiquid)) { // can't break liquid, so don't try somethingInTheWay = true; + MovementHelper.switchToBestToolFor(ctx, BlockStateInterface.get(ctx, blockPos)); Optional reachable = RotationUtils.reachable(ctx.player(), blockPos, ctx.playerController().getBlockReachDistance()); if (reachable.isPresent()) { Rotation rotTowardsBlock = reachable.get(); - MovementHelper.switchToBestToolFor(ctx, BlockStateInterface.get(ctx, blockPos)); state.setTarget(new MovementState.MovementTarget(rotTowardsBlock, true)); if (ctx.isLookingAt(blockPos) || ctx.playerRotations().isReallyCloseTo(rotTowardsBlock)) { state.setInput(Input.CLICK_LEFT, true); From a1c03eb6016d2649f5f5b4b786c3e9745a5facf3 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 5 Jun 2019 12:04:09 -0700 Subject: [PATCH 28/40] another tool selection fix --- src/main/java/baritone/pathing/movement/Movement.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/baritone/pathing/movement/Movement.java b/src/main/java/baritone/pathing/movement/Movement.java index 5cb4fef98..2ddcdc55b 100644 --- a/src/main/java/baritone/pathing/movement/Movement.java +++ b/src/main/java/baritone/pathing/movement/Movement.java @@ -114,6 +114,7 @@ public abstract class Movement implements IMovement, MovementHelper { currentState.setInput(Input.JUMP, true); } if (ctx.player().isEntityInsideOpaqueBlock()) { + ctx.getSelectedBlock().ifPresent(pos -> MovementHelper.switchToBestToolFor(ctx, BlockStateInterface.get(ctx, pos))); currentState.setInput(Input.CLICK_LEFT, true); } From 0815e3c1951e78e505bfa69f41e84e6a56204f27 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 5 Jun 2019 12:08:19 -0700 Subject: [PATCH 29/40] thank u intellij very cool suggestion --- .../baritone/pathing/movement/movements/MovementPillar.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/movements/MovementPillar.java b/src/main/java/baritone/pathing/movement/movements/MovementPillar.java index 1d8493538..4b8f18cf5 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementPillar.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementPillar.java @@ -37,7 +37,6 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; import java.util.Objects; -import java.util.Optional; public class MovementPillar extends Movement { @@ -240,10 +239,7 @@ public class MovementPillar extends Movement { Block fr = frState.getBlock(); // TODO: Evaluate usage of getMaterial().isReplaceable() if (!(fr instanceof BlockAir || frState.getMaterial().isReplaceable())) { - Optional reachable = RotationUtils.reachable(ctx.player(), src, ctx.playerController().getBlockReachDistance()); - if (reachable.isPresent()) { - state.setTarget(new MovementState.MovementTarget(reachable.get(), true)); - } + RotationUtils.reachable(ctx.player(), src, ctx.playerController().getBlockReachDistance()).map(rot -> new MovementState.MovementTarget(rot, true)).ifPresent(state::setTarget); state.setInput(Input.JUMP, false); // breaking is like 5x slower when you're jumping state.setInput(Input.CLICK_LEFT, true); blockIsThere = false; From a6ea9ed3a624eb6fa4e92ebc120802a287132b2c Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 5 Jun 2019 12:47:18 -0700 Subject: [PATCH 30/40] =?UTF-8?q?=F0=9F=91=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../baritone/pathing/movement/movements/MovementPillar.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/baritone/pathing/movement/movements/MovementPillar.java b/src/main/java/baritone/pathing/movement/movements/MovementPillar.java index 4b8f18cf5..5e4a409f7 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementPillar.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementPillar.java @@ -239,7 +239,9 @@ public class MovementPillar extends Movement { Block fr = frState.getBlock(); // TODO: Evaluate usage of getMaterial().isReplaceable() if (!(fr instanceof BlockAir || frState.getMaterial().isReplaceable())) { - RotationUtils.reachable(ctx.player(), src, ctx.playerController().getBlockReachDistance()).map(rot -> new MovementState.MovementTarget(rot, true)).ifPresent(state::setTarget); + RotationUtils.reachable(ctx.player(), src, ctx.playerController().getBlockReachDistance()) + .map(rot -> new MovementState.MovementTarget(rot, true)) + .ifPresent(state::setTarget); state.setInput(Input.JUMP, false); // breaking is like 5x slower when you're jumping state.setInput(Input.CLICK_LEFT, true); blockIsThere = false; From aef84eceb8e5e3c581a6774feff0fa27fd307d3d Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 5 Jun 2019 14:26:26 -0700 Subject: [PATCH 31/40] fix a rare crash when the view is occluded by falling sand, fixes #443 --- .../baritone/pathing/movement/movements/MovementTraverse.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java index a9266f14c..07eb20b74 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java @@ -169,6 +169,10 @@ public class MovementTraverse extends Movement { if (dist < 0.83) { return state; } + if (!state.getTarget().getRotation().isPresent()) { + // this can happen rarely when the server lags and doesn't send the falling sand entity until you've already walked through the block and are now mining the next one + return state; + } // combine the yaw to the center of the destination, and the pitch to the specific block we're trying to break // it's safe to do this since the two blocks we break (in a traverse) are right on top of each other and so will have the same yaw From f0210f7c5f4c134e1ca64d4cd0a2438e42e95333 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 5 Jun 2019 22:12:28 -0700 Subject: [PATCH 32/40] add an additional underscore --- src/main/java/baritone/pathing/movement/Movement.java | 2 +- src/main/java/baritone/pathing/movement/MovementHelper.java | 4 ++-- .../baritone/pathing/movement/movements/MovementAscend.java | 6 +++--- .../pathing/movement/movements/MovementParkour.java | 6 +++--- .../pathing/movement/movements/MovementTraverse.java | 6 +++--- src/main/java/baritone/process/BuilderProcess.java | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/Movement.java b/src/main/java/baritone/pathing/movement/Movement.java index 2ddcdc55b..75c93dcae 100644 --- a/src/main/java/baritone/pathing/movement/Movement.java +++ b/src/main/java/baritone/pathing/movement/Movement.java @@ -36,7 +36,7 @@ import java.util.Optional; public abstract class Movement implements IMovement, MovementHelper { - public static final EnumFacing[] HORIZONTALS_BUT_ALSO_DOWN____SO_EVERY_DIRECTION_EXCEPT_UP = {EnumFacing.NORTH, EnumFacing.SOUTH, EnumFacing.EAST, EnumFacing.WEST, EnumFacing.DOWN}; + public static final EnumFacing[] HORIZONTALS_BUT_ALSO_DOWN_____SO_EVERY_DIRECTION_EXCEPT_UP = {EnumFacing.NORTH, EnumFacing.SOUTH, EnumFacing.EAST, EnumFacing.WEST, EnumFacing.DOWN}; protected final IBaritone baritone; protected final IPlayerContext ctx; diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index d8f6a2f72..60b361195 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -37,7 +37,7 @@ import net.minecraft.util.math.Vec3d; import java.util.Optional; -import static baritone.pathing.movement.Movement.HORIZONTALS_BUT_ALSO_DOWN____SO_EVERY_DIRECTION_EXCEPT_UP; +import static baritone.pathing.movement.Movement.HORIZONTALS_BUT_ALSO_DOWN_____SO_EVERY_DIRECTION_EXCEPT_UP; /** * Static helpers for cost calculation @@ -499,7 +499,7 @@ public interface MovementHelper extends ActionCosts, Helper { found = true; } for (int i = 0; i < 5; i++) { - BlockPos against1 = placeAt.offset(HORIZONTALS_BUT_ALSO_DOWN____SO_EVERY_DIRECTION_EXCEPT_UP[i]); + BlockPos against1 = placeAt.offset(HORIZONTALS_BUT_ALSO_DOWN_____SO_EVERY_DIRECTION_EXCEPT_UP[i]); if (MovementHelper.canPlaceAgainst(ctx, against1)) { if (!((Baritone) baritone).getInventoryBehavior().selectThrowawayForLocation(false, placeAt.getX(), placeAt.getY(), placeAt.getZ())) { // get ready to place a throwaway block Helper.HELPER.logDebug("bb pls get me some blocks. dirt, netherrack, cobble"); diff --git a/src/main/java/baritone/pathing/movement/movements/MovementAscend.java b/src/main/java/baritone/pathing/movement/movements/MovementAscend.java index b37fd4d00..6d5ecd857 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementAscend.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementAscend.java @@ -64,9 +64,9 @@ public class MovementAscend extends Movement { } boolean foundPlaceOption = false; for (int i = 0; i < 5; i++) { - int againstX = destX + HORIZONTALS_BUT_ALSO_DOWN____SO_EVERY_DIRECTION_EXCEPT_UP[i].getXOffset(); - int againstY = y + HORIZONTALS_BUT_ALSO_DOWN____SO_EVERY_DIRECTION_EXCEPT_UP[i].getYOffset(); - int againstZ = destZ + HORIZONTALS_BUT_ALSO_DOWN____SO_EVERY_DIRECTION_EXCEPT_UP[i].getZOffset(); + int againstX = destX + HORIZONTALS_BUT_ALSO_DOWN_____SO_EVERY_DIRECTION_EXCEPT_UP[i].getXOffset(); + int againstY = y + HORIZONTALS_BUT_ALSO_DOWN_____SO_EVERY_DIRECTION_EXCEPT_UP[i].getYOffset(); + int againstZ = destZ + HORIZONTALS_BUT_ALSO_DOWN_____SO_EVERY_DIRECTION_EXCEPT_UP[i].getZOffset(); if (againstX == x && againstZ == z) { // we might be able to backplace now, but it doesn't matter because it will have been broken by the time we'd need to use it continue; } diff --git a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java index fbf57e6c6..dfa43a051 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java @@ -134,9 +134,9 @@ public class MovementParkour extends Movement { return; } for (int i = 0; i < 5; i++) { - int againstX = destX + HORIZONTALS_BUT_ALSO_DOWN____SO_EVERY_DIRECTION_EXCEPT_UP[i].getXOffset(); - int againstY = y - 1 + HORIZONTALS_BUT_ALSO_DOWN____SO_EVERY_DIRECTION_EXCEPT_UP[i].getYOffset(); - int againstZ = destZ + HORIZONTALS_BUT_ALSO_DOWN____SO_EVERY_DIRECTION_EXCEPT_UP[i].getZOffset(); + int againstX = destX + HORIZONTALS_BUT_ALSO_DOWN_____SO_EVERY_DIRECTION_EXCEPT_UP[i].getXOffset(); + int againstY = y - 1 + HORIZONTALS_BUT_ALSO_DOWN_____SO_EVERY_DIRECTION_EXCEPT_UP[i].getYOffset(); + int againstZ = destZ + HORIZONTALS_BUT_ALSO_DOWN_____SO_EVERY_DIRECTION_EXCEPT_UP[i].getZOffset(); if (againstX == x + xDiff * 3 && againstZ == z + zDiff * 3) { // we can't turn around that fast continue; } diff --git a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java index 07eb20b74..d6137027d 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java @@ -119,9 +119,9 @@ public class MovementTraverse extends Movement { double hardness2 = MovementHelper.getMiningDurationTicks(context, destX, y + 1, destZ, pb0, true); // only include falling on the upper block to break double WC = throughWater ? context.waterWalkSpeed : WALK_ONE_BLOCK_COST; for (int i = 0; i < 5; i++) { - int againstX = destX + HORIZONTALS_BUT_ALSO_DOWN____SO_EVERY_DIRECTION_EXCEPT_UP[i].getXOffset(); - int againstY = y - 1 + HORIZONTALS_BUT_ALSO_DOWN____SO_EVERY_DIRECTION_EXCEPT_UP[i].getYOffset(); - int againstZ = destZ + HORIZONTALS_BUT_ALSO_DOWN____SO_EVERY_DIRECTION_EXCEPT_UP[i].getZOffset(); + int againstX = destX + HORIZONTALS_BUT_ALSO_DOWN_____SO_EVERY_DIRECTION_EXCEPT_UP[i].getXOffset(); + int againstY = y - 1 + HORIZONTALS_BUT_ALSO_DOWN_____SO_EVERY_DIRECTION_EXCEPT_UP[i].getYOffset(); + int againstZ = destZ + HORIZONTALS_BUT_ALSO_DOWN_____SO_EVERY_DIRECTION_EXCEPT_UP[i].getZOffset(); if (againstX == x && againstZ == z) { // this would be a backplace continue; } diff --git a/src/main/java/baritone/process/BuilderProcess.java b/src/main/java/baritone/process/BuilderProcess.java index 6c921f8e6..29f61a7dc 100644 --- a/src/main/java/baritone/process/BuilderProcess.java +++ b/src/main/java/baritone/process/BuilderProcess.java @@ -602,7 +602,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil return new GoalPlace(pos); } boolean allowSameLevel = ctx.world().getBlockState(pos.up()).getBlock() != Blocks.AIR; - for (EnumFacing facing : Movement.HORIZONTALS_BUT_ALSO_DOWN____SO_EVERY_DIRECTION_EXCEPT_UP) { + for (EnumFacing facing : Movement.HORIZONTALS_BUT_ALSO_DOWN_____SO_EVERY_DIRECTION_EXCEPT_UP) { if (MovementHelper.canPlaceAgainst(ctx, pos.offset(facing)) && ctx.world().mayPlace(bcc.getSchematic(pos.getX(), pos.getY(), pos.getZ()).getBlock(), pos, false, facing, null)) { return new GoalAdjacent(pos, allowSameLevel); } From 4c4bc8058b26add8fbc0c264a283077997a8ccbc Mon Sep 17 00:00:00 2001 From: Brady Date: Thu, 6 Jun 2019 04:15:43 -0500 Subject: [PATCH 33/40] Some clean ups --- .../java/baritone/pathing/calc/AStarPathFinder.java | 3 +-- src/main/java/baritone/pathing/calc/Path.java | 2 +- src/main/java/baritone/utils/pathing/Avoidance.java | 7 +++++-- .../baritone/utils/pathing/SegmentedCalculator.java | 12 ++++++------ .../baritone/pathing/calc/openset/OpenSetsTest.java | 10 +++++----- 5 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/main/java/baritone/pathing/calc/AStarPathFinder.java b/src/main/java/baritone/pathing/calc/AStarPathFinder.java index 57e9200de..fc964d0f1 100644 --- a/src/main/java/baritone/pathing/calc/AStarPathFinder.java +++ b/src/main/java/baritone/pathing/calc/AStarPathFinder.java @@ -86,8 +86,7 @@ public final class AStarPathFinder extends AbstractNodeCostSearch { if (slowPath) { try { Thread.sleep(Baritone.settings().slowPathTimeDelayMS.value); - } catch (InterruptedException ex) { - } + } catch (InterruptedException ignored) {} } PathNode currentNode = openSet.removeLowest(); mostRecentConsidered = currentNode; diff --git a/src/main/java/baritone/pathing/calc/Path.java b/src/main/java/baritone/pathing/calc/Path.java index a3f9dd22e..76cd83960 100644 --- a/src/main/java/baritone/pathing/calc/Path.java +++ b/src/main/java/baritone/pathing/calc/Path.java @@ -96,7 +96,7 @@ class Path extends PathBase { } PathNode current = end; LinkedList tempPath = new LinkedList<>(); - LinkedList tempNodes = new LinkedList(); + LinkedList tempNodes = new LinkedList<>(); // Repeatedly inserting to the beginning of an arraylist is O(n^2) // Instead, do it into a linked list, then convert at the end while (current != null) { diff --git a/src/main/java/baritone/utils/pathing/Avoidance.java b/src/main/java/baritone/utils/pathing/Avoidance.java index 9b32b1dfd..c4b12336e 100644 --- a/src/main/java/baritone/utils/pathing/Avoidance.java +++ b/src/main/java/baritone/utils/pathing/Avoidance.java @@ -64,10 +64,13 @@ public class Avoidance { 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.value))); + 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.value))); + 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/SegmentedCalculator.java b/src/main/java/baritone/utils/pathing/SegmentedCalculator.java index 757ea015d..c1753a8b2 100644 --- a/src/main/java/baritone/utils/pathing/SegmentedCalculator.java +++ b/src/main/java/baritone/utils/pathing/SegmentedCalculator.java @@ -51,7 +51,7 @@ public class SegmentedCalculator { private Optional doCalc() { Optional soFar = Optional.empty(); while (true) { - PathCalculationResult result = segment(soFar); + PathCalculationResult result = segment(soFar.orElse(null)); switch (result.getType()) { case SUCCESS_SEGMENT: case SUCCESS_TO_GOAL: @@ -62,8 +62,8 @@ public class SegmentedCalculator { default: // CANCELLATION and null should not be possible, nothing else has access to this, so it can't have been canceled throw new IllegalStateException(); } - IPath segment = result.getPath().get(); // path calculation result type is SUCCESS_SEGMENT, so the path must be present - IPath combined = soFar.map(previous -> (IPath) SplicedPath.trySplice(previous, segment, true).get()).orElse(segment); + IPath segment = result.getPath().orElseThrow(IllegalStateException::new); // path calculation result type is SUCCESS_SEGMENT, so the path must be present + IPath combined = soFar.map(previous -> (IPath) SplicedPath.trySplice(previous, segment, true).orElseThrow(IllegalStateException::new)).orElse(segment); loadAdjacent(combined.getDest().getX(), combined.getDest().getZ()); soFar = Optional.of(combined); if (result.getType() == PathCalculationResult.Type.SUCCESS_TO_GOAL) { @@ -85,9 +85,9 @@ 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), context); // this is on another thread, so cannot include mob avoidances. + private PathCalculationResult segment(IPath previous) { + BetterBlockPos segmentStart = previous != null ? previous.getDest() : start; + AbstractNodeCostSearch search = new AStarPathFinder(segmentStart.x, segmentStart.y, segmentStart.z, goal, new Favoring(previous, context), context); // this is on another thread, so cannot include mob avoidances. 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 } diff --git a/src/test/java/baritone/pathing/calc/openset/OpenSetsTest.java b/src/test/java/baritone/pathing/calc/openset/OpenSetsTest.java index a12e0b7ae..33a1f4dcd 100644 --- a/src/test/java/baritone/pathing/calc/openset/OpenSetsTest.java +++ b/src/test/java/baritone/pathing/calc/openset/OpenSetsTest.java @@ -50,14 +50,14 @@ public class OpenSetsTest { return testSizes; } - private static void removeAndTest(int amount, IOpenSet[] test, Optional> mustContain) { + private static void removeAndTest(int amount, IOpenSet[] test, Collection mustContain) { double[][] results = new double[test.length][amount]; for (int i = 0; i < test.length; i++) { long before = System.nanoTime() / 1000000L; for (int j = 0; j < amount; j++) { PathNode pn = test[i].removeLowest(); - if (mustContain.isPresent() && !mustContain.get().contains(pn)) { - throw new IllegalStateException(mustContain.get() + " " + pn); + if (mustContain != null && !mustContain.contains(pn)) { + throw new IllegalStateException(mustContain + " " + pn); } results[i][j] = pn.combinedCost; } @@ -131,7 +131,7 @@ public class OpenSetsTest { System.out.println("Removal round 1"); // remove a quarter of the nodes and verify that they are indeed the size/4 lowest ones - removeAndTest(size / 4, test, Optional.of(lowestQuarter)); + removeAndTest(size / 4, test, lowestQuarter); // none of them should be empty (sanity check) for (IOpenSet set : test) { @@ -160,7 +160,7 @@ public class OpenSetsTest { System.out.println("Removal round 2"); // remove the remaining 3/4 - removeAndTest(size - size / 4, test, Optional.empty()); + removeAndTest(size - size / 4, test, null); // every set should now be empty for (IOpenSet set : test) { From ce606f826b1ea3939c9a228d159de6c4b56799ed Mon Sep 17 00:00:00 2001 From: Brady Date: Thu, 6 Jun 2019 19:05:13 -0500 Subject: [PATCH 34/40] consistency --- .../pathing/movement/movements/MovementTraverse.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java index d6137027d..1b19ae57b 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java @@ -195,13 +195,13 @@ public class MovementTraverse extends Movement { boolean door = pb0.getBlock() instanceof BlockDoor || pb1.getBlock() instanceof BlockDoor; if (door) { - boolean isDoorActuallyBlockingUs = false; + boolean blocked = false; if (pb0.getBlock() instanceof BlockDoor && !MovementHelper.isDoorPassable(ctx, src, dest)) { - isDoorActuallyBlockingUs = true; + blocked = true; } else if (pb1.getBlock() instanceof BlockDoor && !MovementHelper.isDoorPassable(ctx, dest, src)) { - isDoorActuallyBlockingUs = true; + blocked = true; } - if (isDoorActuallyBlockingUs && !(Blocks.IRON_DOOR.equals(pb0.getBlock()) || Blocks.IRON_DOOR.equals(pb1.getBlock()))) { + if (blocked && !(Blocks.IRON_DOOR.equals(pb0.getBlock()) || Blocks.IRON_DOOR.equals(pb1.getBlock()))) { return state.setTarget(new MovementState.MovementTarget(RotationUtils.calcRotationFromVec3d(ctx.playerHead(), VecUtils.calculateBlockCenter(ctx.world(), positionsToBreak[0]), ctx.playerRotations()), true)) .setInput(Input.CLICK_RIGHT, true); } From 9822962d9802b1b0a5319c573e0bb0c34bfbec95 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 6 Jun 2019 23:54:52 -0700 Subject: [PATCH 35/40] it is tbh --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5eb0c9200..35ed316e7 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ [![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.6%20/%20v1.3.2-brightgreen.svg)](https://impactdevelopment.github.io/) -[![ForgeHax integration](https://img.shields.io/badge/ForgeHax%20%22integration%22-v1.2.*-green.svg)](https://github.com/fr1kin/ForgeHax) +[![ForgeHax integration](https://img.shields.io/badge/ForgeHax%20%22integration%22-scuffed-yellow.svg)](https://github.com/fr1kin/ForgeHax) [![WWE integration](https://img.shields.io/badge/WWE%20%22integration%22-master%3F-green.svg)](https://wweclient.com/) [![Future integration](https://img.shields.io/badge/Future%20integration-Soon™%3F%3F%3F-red.svg)](https://futureclient.net/) [![forthebadge](https://forthebadge.com/images/badges/built-with-swag.svg)](http://forthebadge.com) From 81d7f3c31926cdb883354bf25fe1b23f77a038eb Mon Sep 17 00:00:00 2001 From: Brady Date: Fri, 7 Jun 2019 03:18:58 -0500 Subject: [PATCH 36/40] crucial performance optimization --- .../movement/movements/MovementTraverse.java | 30 +++++++------------ 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java index 1b19ae57b..39fbab755 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java @@ -183,8 +183,9 @@ public class MovementTraverse extends Movement { pitchToBreak = 26; } - state.setTarget(new MovementState.MovementTarget(new Rotation(yawToDest, pitchToBreak), true)); - return state.setInput(Input.MOVE_FORWARD, true).setInput(Input.SPRINT, true); + return state.setTarget(new MovementState.MovementTarget(new Rotation(yawToDest, pitchToBreak), true)) + .setInput(Input.MOVE_FORWARD, true) + .setInput(Input.SPRINT, true); } //sneak may have been set to true in the PREPPING state while mining an adjacent block @@ -193,28 +194,19 @@ public class MovementTraverse extends Movement { Block fd = BlockStateInterface.get(ctx, src.down()).getBlock(); boolean ladder = fd == Blocks.LADDER || fd == Blocks.VINE; - boolean door = pb0.getBlock() instanceof BlockDoor || pb1.getBlock() instanceof BlockDoor; - if (door) { - boolean blocked = false; - if (pb0.getBlock() instanceof BlockDoor && !MovementHelper.isDoorPassable(ctx, src, dest)) { - blocked = true; - } else if (pb1.getBlock() instanceof BlockDoor && !MovementHelper.isDoorPassable(ctx, dest, src)) { - blocked = true; - } - if (blocked && !(Blocks.IRON_DOOR.equals(pb0.getBlock()) || Blocks.IRON_DOOR.equals(pb1.getBlock()))) { + if (pb0.getBlock() instanceof BlockDoor || pb1.getBlock() instanceof BlockDoor) { + if ((pb0.getBlock() instanceof BlockDoor && !MovementHelper.isDoorPassable(ctx, src, dest) + || pb1.getBlock() instanceof BlockDoor && !MovementHelper.isDoorPassable(ctx, dest, src)) + && !(Blocks.IRON_DOOR.equals(pb0.getBlock()) || Blocks.IRON_DOOR.equals(pb1.getBlock()))) { return state.setTarget(new MovementState.MovementTarget(RotationUtils.calcRotationFromVec3d(ctx.playerHead(), VecUtils.calculateBlockCenter(ctx.world(), positionsToBreak[0]), ctx.playerRotations()), true)) .setInput(Input.CLICK_RIGHT, true); } } if (pb0.getBlock() instanceof BlockFenceGate || pb1.getBlock() instanceof BlockFenceGate) { - BlockPos blocked = null; - if (!MovementHelper.isGatePassable(ctx, positionsToBreak[0], src.up())) { - blocked = positionsToBreak[0]; - } else if (!MovementHelper.isGatePassable(ctx, positionsToBreak[1], src)) { - blocked = positionsToBreak[1]; - } - + BlockPos blocked = !MovementHelper.isGatePassable(ctx, positionsToBreak[0], src.up()) ? positionsToBreak[0] + : !MovementHelper.isGatePassable(ctx, positionsToBreak[1], src) ? positionsToBreak[1] + : null; if (blocked != null) { return state.setTarget(new MovementState.MovementTarget(RotationUtils.calcRotationFromVec3d(ctx.playerHead(), VecUtils.calculateBlockCenter(ctx.world(), blocked), ctx.playerRotations()), true)) .setInput(Input.CLICK_RIGHT, true); @@ -226,7 +218,7 @@ public class MovementTraverse extends Movement { if (whereAmI.getY() != dest.getY() && !ladder) { logDebug("Wrong Y coordinate"); if (whereAmI.getY() < dest.getY()) { - state.setInput(Input.JUMP, true); + return state.setInput(Input.JUMP, true); } return state; } From ee6796d5e28338a3020549131922c8db0b7e6ae7 Mon Sep 17 00:00:00 2001 From: Brady Date: Fri, 7 Jun 2019 03:52:46 -0500 Subject: [PATCH 37/40] crucial performance optimization (pt. 2) --- .../movement/movements/MovementTraverse.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java index 39fbab755..b621632c1 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java @@ -214,17 +214,16 @@ public class MovementTraverse extends Movement { } boolean isTheBridgeBlockThere = MovementHelper.canWalkOn(ctx, positionToPlace) || ladder; - BlockPos whereAmI = ctx.playerFeet(); - if (whereAmI.getY() != dest.getY() && !ladder) { + BlockPos feet = ctx.playerFeet(); + if (feet.getY() != dest.getY() && !ladder) { logDebug("Wrong Y coordinate"); - if (whereAmI.getY() < dest.getY()) { + if (feet.getY() < dest.getY()) { return state.setInput(Input.JUMP, true); } return state; } if (isTheBridgeBlockThere) { - BetterBlockPos feet = ctx.playerFeet(); if (feet.equals(dest)) { return state.setStatus(MovementStatus.SUCCESS); } @@ -241,20 +240,20 @@ 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.value) && (!MovementHelper.avoidWalkingInto(intoBelow) || MovementHelper.isWater(intoBelow)) && !MovementHelper.avoidWalkingInto(intoAbove)) { + if (wasTheBridgeBlockAlwaysThere && (!MovementHelper.isLiquid(ctx, feet) || Baritone.settings().sprintInWater.value) && (!MovementHelper.avoidWalkingInto(intoBelow) || MovementHelper.isWater(intoBelow)) && !MovementHelper.avoidWalkingInto(intoAbove)) { state.setInput(Input.SPRINT, true); } IBlockState destDown = BlockStateInterface.get(ctx, dest.down()); BlockPos against = positionsToBreak[0]; - if (whereAmI.getY() != dest.getY() && ladder && (destDown.getBlock() == Blocks.VINE || destDown.getBlock() == Blocks.LADDER)) { + if (feet.getY() != dest.getY() && ladder && (destDown.getBlock() == Blocks.VINE || destDown.getBlock() == Blocks.LADDER)) { against = destDown.getBlock() == Blocks.VINE ? MovementPillar.getAgainst(new CalculationContext(baritone), dest.down()) : dest.offset(destDown.getValue(BlockLadder.FACING).getOpposite()); } MovementHelper.moveTowards(ctx, state, against); return state; } else { wasTheBridgeBlockAlwaysThere = false; - Block standingOn = BlockStateInterface.get(ctx, ctx.playerFeet().down()).getBlock(); + Block standingOn = BlockStateInterface.get(ctx, feet.down()).getBlock(); if (standingOn.equals(Blocks.SOUL_SAND) || standingOn instanceof BlockSlab) { // see issue #118 double dist = Math.max(Math.abs(dest.getX() + 0.5 - ctx.player().posX), Math.abs(dest.getZ() + 0.5 - ctx.player().posZ)); if (dist < 0.85) { // 0.5 + 0.3 + epsilon @@ -292,7 +291,7 @@ public class MovementTraverse extends Movement { default: break; } - if (whereAmI.equals(dest)) { + if (feet.equals(dest)) { // If we are in the block that we are trying to get to, we are sneaking over air and we need to place a block beneath us against the one we just walked off of // Out.log(from + " " + to + " " + faceX + "," + faceY + "," + faceZ + " " + whereAmI); double faceX = (dest.getX() + src.getX() + 1.0D) * 0.5D; From 1ee6e04f00abad1be946a9dd362075d2dbf4617e Mon Sep 17 00:00:00 2001 From: Leijurv Date: Fri, 7 Jun 2019 20:20:49 -0700 Subject: [PATCH 38/40] this counts as a commit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 35ed316e7..999e10407 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,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.9, rebuilt for 1.12.2 and 1.13.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 8 months =D 🦀 +Have committed at least once a day for the last 10 months =D 🦀 1Leijurv3DWTrGAfmmiTphjhXLvQiHg7K2 From 14bb0a0a80c034af819e16df1edaf59d67187560 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 8 Jun 2019 23:13:27 -0700 Subject: [PATCH 39/40] alt text --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 999e10407..fab6ced98 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ [![Pull Requests](https://img.shields.io/github/issues-pr/cabaletta/baritone.svg)](https://github.com/cabaletta/baritone/pulls/) ![Code size](https://img.shields.io/github/languages/code-size/cabaletta/baritone.svg) ![GitHub repo size](https://img.shields.io/github/repo-size/cabaletta/baritone.svg) -![](https://tokei.rs/b1/github/cabaletta/baritone?category=code) +![Lines of Code](https://tokei.rs/b1/github/cabaletta/baritone?category=code) [![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.6%20/%20v1.3.2-brightgreen.svg)](https://impactdevelopment.github.io/) From 94bf703dde237159d0dc082cb5550a80fbb91c70 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 9 Jun 2019 23:56:54 -0700 Subject: [PATCH 40/40] this counts as a commit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fab6ced98..ff6b83ef2 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().setGoalAnd ## Can I use Baritone as a library in my custom utility client? -That's what it's for, sure! (As long as usage is in compliance with the LGPL 3 License) +That's what it's for, sure! (As long as usage is in compliance with the LGPL 3.0 License) ## How is it so fast?