diff --git a/README.md b/README.md
index c9f68ea8a..4f41d72b2 100644
--- a/README.md
+++ b/README.md
@@ -4,6 +4,9 @@
[](LICENSE)
[](https://www.codacy.com/app/leijurv/baritone?utm_source=github.com&utm_medium=referral&utm_content=cabaletta/baritone&utm_campaign=Badge_Grade)
[](http://hits.dwyl.com/cabaletta/baritone)
+[](https://github.com/cabaletta/baritone/releases)
+[](https://minecraft.gamepedia.com/1.12.2)
+[](https://minecraft.gamepedia.com/1.13.2)
[](https://github.com/cabaletta/baritone/blob/master/CODE_OF_CONDUCT.md)
[](https://snyk.io/test/github/cabaletta/baritone?targetFile=build.gradle)
[](https://github.com/cabaletta/baritone/issues)
@@ -12,15 +15,18 @@
[](https://github.com/cabaletta/baritone/pulls/)


+<<<<<<< HEAD

[](https://minecraft.gamepedia.com/1.13.2)
+=======
+
+>>>>>>> master
[](https://github.com/cabaletta/baritone/graphs/contributors/)
[](https://github.com/cabaletta/baritone/commit/)
-[](https://impactdevelopment.github.io/)
+[](https://impactdevelopment.github.io/)
+[](https://github.com/fr1kin/ForgeHax)
[](https://wweclient.com/)
-[](https://github.com/zeroeightysix/KAMI/)
[](https://futureclient.net/)
-[](https://github.com/fr1kin/ForgeHax)
[](http://forthebadge.com)
[](http://forthebadge.com)
@@ -29,9 +35,9 @@ 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 🦀
+Have committed at least once a day for the last 10 months =D 🦀
1Leijurv3DWTrGAfmmiTphjhXLvQiHg7K2
@@ -68,7 +74,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?
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.
diff --git a/src/api/java/baritone/api/utils/ExampleBaritoneControl.java b/src/api/java/baritone/api/utils/ExampleBaritoneControl.java
index 7a7cf9b37..b63fec4ad 100644
--- a/src/api/java/baritone/api/utils/ExampleBaritoneControl.java
+++ b/src/api/java/baritone/api/utils/ExampleBaritoneControl.java
@@ -33,6 +33,7 @@ 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;
@@ -66,6 +67,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" +
@@ -195,6 +197,16 @@ 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);
+ 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.");
@@ -332,7 +344,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;
}
@@ -385,17 +397,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() + "");
@@ -426,7 +427,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;
}
@@ -581,6 +582,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) {
@@ -649,24 +661,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");
}
diff --git a/src/api/java/baritone/api/utils/MyChunkPos.java b/src/api/java/baritone/api/utils/MyChunkPos.java
index 5748a13dc..1df7481db 100644
--- a/src/api/java/baritone/api/utils/MyChunkPos.java
+++ b/src/api/java/baritone/api/utils/MyChunkPos.java
@@ -17,11 +17,17 @@
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
diff --git a/src/launch/java/baritone/launch/mixins/MixinChunkRenderContainer.java b/src/launch/java/baritone/launch/mixins/MixinChunkRenderContainer.java
index b3c0b6fa8..dc35f7570 100644
--- a/src/launch/java/baritone/launch/mixins/MixinChunkRenderContainer.java
+++ b/src/launch/java/baritone/launch/mixins/MixinChunkRenderContainer.java
@@ -44,7 +44,7 @@ public class MixinChunkRenderContainer {
)
)
private BlockPos getPosition(RenderChunk renderChunkIn) {
- if (Baritone.settings().renderCachedChunks.value && Minecraft.getInstance().getIntegratedServer() == null && Minecraft.getInstance().world.getChunk(renderChunkIn.getPosition()).isEmpty()) {
+ if (Baritone.settings().renderCachedChunks.value && !Minecraft.getInstance().isSingleplayer() && Minecraft.getInstance().world.getChunk(renderChunkIn.getPosition()).isEmpty()) {
GlStateManager.enableAlphaTest();
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 de934e555..6e02d0f9c 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.getInstance().getIntegratedServer() == null) {
+ if (Baritone.settings().renderCachedChunks.value && !Minecraft.getInstance().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 c5b0d7b44..125e45c89 100644
--- a/src/launch/java/baritone/launch/mixins/MixinRenderChunk.java
+++ b/src/launch/java/baritone/launch/mixins/MixinRenderChunk.java
@@ -44,7 +44,7 @@ public class MixinRenderChunk {
)
)
private IBlockState getBlockState(RenderChunkCache chunkCache, BlockPos pos) {
- if (Baritone.settings().renderCachedChunks.value && Minecraft.getInstance().getIntegratedServer() == null) {
+ if (Baritone.settings().renderCachedChunks.value && !Minecraft.getInstance().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 a96a438c7..ec3053f11 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.getInstance().getIntegratedServer() == null) {
+ if (Baritone.settings().renderCachedChunks.value && !Minecraft.getInstance().isSingleplayer()) {
// reset the blend func to normal (not dependent on constant alpha)
GlStateManager.blendFuncSeparate(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 e7c992850..5cda68034 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.getInstance().getIntegratedServer() == null) {
+ if (Baritone.settings().renderCachedChunks.value && !Minecraft.getInstance().isSingleplayer()) {
// reset the blend func to normal (not dependent on constant alpha)
GlStateManager.blendFuncSeparate(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 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);
}
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<>();
diff --git a/src/main/java/baritone/cache/CachedChunk.java b/src/main/java/baritone/cache/CachedChunk.java
index bdffec94e..cac48514a 100644
--- a/src/main/java/baritone/cache/CachedChunk.java
+++ b/src/main/java/baritone/cache/CachedChunk.java
@@ -19,13 +19,17 @@ 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;
import net.minecraft.init.Blocks;
import net.minecraft.util.math.BlockPos;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.BitSet;
+import java.util.List;
+import java.util.Map;
/**
* @author Brady
@@ -33,99 +37,77 @@ 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.ENDER_CHEST,
+ Blocks.FURNACE,
+ Blocks.CHEST,
+ Blocks.TRAPPED_CHEST,
+ Blocks.END_PORTAL,
+ Blocks.END_PORTAL_FRAME,
+ Blocks.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.LIGHT_GRAY_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.NETHER_PORTAL,
+ Blocks.HOPPER,
+ Blocks.BEACON,
+ Blocks.BREWING_STAND,
- 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);
-
- 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.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.LIGHT_GRAY_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.NETHER_PORTAL);
- temp.add(Blocks.HOPPER);
- temp.add(Blocks.BEACON);
- temp.add(Blocks.BREWING_STAND);
-
- // TODO: Maybe add a predicate for blocks to keep track of?
- // This should really not need to happen
- temp.add(Blocks.CREEPER_HEAD);
- temp.add(Blocks.CREEPER_WALL_HEAD);
- temp.add(Blocks.DRAGON_HEAD);
- temp.add(Blocks.DRAGON_WALL_HEAD);
- temp.add(Blocks.PLAYER_HEAD);
- temp.add(Blocks.PLAYER_WALL_HEAD);
- temp.add(Blocks.ZOMBIE_HEAD);
- temp.add(Blocks.ZOMBIE_WALL_HEAD);
- temp.add(Blocks.SKELETON_SKULL);
- temp.add(Blocks.SKELETON_WALL_SKULL);
- temp.add(Blocks.WITHER_SKELETON_SKULL);
- temp.add(Blocks.WITHER_SKELETON_WALL_SKULL);
-
- temp.add(Blocks.ENCHANTING_TABLE);
- temp.add(Blocks.ANVIL);
-
- temp.add(Blocks.WHITE_BED);
- temp.add(Blocks.ORANGE_BED);
- temp.add(Blocks.MAGENTA_BED);
- temp.add(Blocks.LIGHT_BLUE_BED);
- temp.add(Blocks.YELLOW_BED);
- temp.add(Blocks.LIME_BED);
- temp.add(Blocks.PINK_BED);
- temp.add(Blocks.GRAY_BED);
- temp.add(Blocks.LIGHT_GRAY_BED);
- temp.add(Blocks.CYAN_BED);
- temp.add(Blocks.PURPLE_BED);
- temp.add(Blocks.BLUE_BED);
- temp.add(Blocks.BROWN_BED);
- temp.add(Blocks.GREEN_BED);
- temp.add(Blocks.RED_BED);
- temp.add(Blocks.BLACK_BED);
-
- temp.add(Blocks.DRAGON_EGG);
- temp.add(Blocks.JUKEBOX);
- temp.add(Blocks.END_GATEWAY);
- temp.add(Blocks.COBWEB);
- temp.add(Blocks.NETHER_WART);
- temp.add(Blocks.LADDER);
- temp.add(Blocks.VINE);
- BLOCKS_TO_KEEP_TRACK_OF = Collections.unmodifiableSet(temp);
-
- // TODO: Lit Furnaces
- }
+// TODO: Maybe add a predicate for blocks to keep track of?
+// This should really not need to happen
+ Blocks.CREEPER_HEAD,
+ Blocks.CREEPER_WALL_HEAD,
+ Blocks.DRAGON_HEAD,
+ Blocks.DRAGON_WALL_HEAD,
+ Blocks.PLAYER_HEAD,
+ Blocks.PLAYER_WALL_HEAD,
+ Blocks.ZOMBIE_HEAD,
+ Blocks.ZOMBIE_WALL_HEAD,
+ Blocks.SKELETON_SKULL,
+ Blocks.SKELETON_WALL_SKULL,
+ Blocks.WITHER_SKELETON_SKULL,
+ Blocks.WITHER_SKELETON_WALL_SKULL,
+ Blocks.ENCHANTING_TABLE,
+ Blocks.ANVIL,
+ Blocks.WHITE_BED,
+ Blocks.ORANGE_BED,
+ Blocks.MAGENTA_BED,
+ Blocks.LIGHT_BLUE_BED,
+ Blocks.YELLOW_BED,
+ Blocks.LIME_BED,
+ Blocks.PINK_BED,
+ Blocks.GRAY_BED,
+ Blocks.LIGHT_GRAY_BED,
+ Blocks.CYAN_BED,
+ Blocks.PURPLE_BED,
+ Blocks.BLUE_BED,
+ Blocks.BROWN_BED,
+ Blocks.GREEN_BED,
+ Blocks.RED_BED,
+ Blocks.BLACK_BED,
+ Blocks.DRAGON_EGG,
+ Blocks.JUKEBOX,
+ Blocks.END_GATEWAY,
+ Blocks.COBWEB,
+ Blocks.NETHER_WART,
+ Blocks.LADDER,
+ Blocks.VINE
+ );
/**
* The size of the chunk data in bits. Equal to 16 KiB.
diff --git a/src/main/java/baritone/cache/WorldProvider.java b/src/main/java/baritone/cache/WorldProvider.java
index e5a924268..412e16ee5 100644
--- a/src/main/java/baritone/cache/WorldProvider.java
+++ b/src/main/java/baritone/cache/WorldProvider.java
@@ -63,7 +63,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();
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/pathing/movement/Movement.java b/src/main/java/baritone/pathing/movement/Movement.java
index 20fa7386b..23b1cf216 100644
--- a/src/main/java/baritone/pathing/movement/Movement.java
+++ b/src/main/java/baritone/pathing/movement/Movement.java
@@ -35,7 +35,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;
@@ -113,6 +113,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);
}
@@ -146,10 +147,10 @@ public abstract class Movement implements IMovement, MovementHelper {
}
if (!MovementHelper.canWalkThrough(ctx, blockPos)) { // can't break air, 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);
diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java
index bfee71e6d..eff91e123 100644
--- a/src/main/java/baritone/pathing/movement/MovementHelper.java
+++ b/src/main/java/baritone/pathing/movement/MovementHelper.java
@@ -44,7 +44,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
@@ -512,7 +512,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 613948da8..e993ebac0 100644
--- a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java
+++ b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java
@@ -135,9 +135,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/MovementPillar.java b/src/main/java/baritone/pathing/movement/movements/MovementPillar.java
index 93ca58e08..20f7fde31 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 {
@@ -241,10 +240,9 @@ 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;
diff --git a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java
index cdd3484b7..d0d88cae7 100644
--- a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java
+++ b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java
@@ -122,9 +122,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;
}
@@ -172,6 +172,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
@@ -182,8 +186,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
@@ -192,28 +197,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 isDoorActuallyBlockingUs = false;
- if (pb0.getBlock() instanceof BlockDoor && !MovementHelper.isDoorPassable(ctx, src, dest)) {
- isDoorActuallyBlockingUs = true;
- } else if (pb1.getBlock() instanceof BlockDoor && !MovementHelper.isDoorPassable(ctx, dest, src)) {
- isDoorActuallyBlockingUs = true;
- }
- if (isDoorActuallyBlockingUs && !(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);
@@ -221,17 +217,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()) {
- state.setInput(Input.JUMP, true);
+ 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);
}
@@ -248,20 +243,20 @@ public class MovementTraverse extends Movement {
BlockPos into = dest.subtract(src).add(dest);
IBlockState intoBelow = BlockStateInterface.get(ctx, into);
IBlockState intoAbove = BlockStateInterface.get(ctx, into.up());
- 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.get(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
@@ -299,7 +294,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;
diff --git a/src/main/java/baritone/process/BackfillProcess.java b/src/main/java/baritone/process/BackfillProcess.java
index 8ed9b3c94..1c7b46f4d 100644
--- a/src/main/java/baritone/process/BackfillProcess.java
+++ b/src/main/java/baritone/process/BackfillProcess.java
@@ -34,7 +34,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 e3257ce13..4921b6978 100644
--- a/src/main/java/baritone/process/BuilderProcess.java
+++ b/src/main/java/baritone/process/BuilderProcess.java
@@ -58,7 +58,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
@@ -376,7 +376,7 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro
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) {
@@ -464,7 +464,7 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro
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()) {
@@ -619,7 +619,7 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro
return new GoalPlace(pos);
}
boolean allowSameLevel = !(ctx.world().getBlockState(pos.up()).getBlock() instanceof BlockAir);
- 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)) && placementPlausible(pos, bcc.getSchematic(pos.getX(), pos.getY(), pos.getZ()))) {
return new GoalAdjacent(pos, allowSameLevel);
}
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 c688fbbed..a783cb495 100644
--- a/src/main/java/baritone/process/FarmProcess.java
+++ b/src/main/java/baritone/process/FarmProcess.java
@@ -48,7 +48,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 292e4c6d0..4c43cd6f2 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;
diff --git a/src/main/java/baritone/process/MineProcess.java b/src/main/java/baritone/process/MineProcess.java
index c5a7c8efc..1590d1279 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) {
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) {