diff --git a/.gitignore b/.gitignore
index 270356275..6aeefb22e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -16,6 +16,8 @@ classes/
# IntelliJ Files
.idea/
*.iml
+*.ipr
+*.iws
/logs/
# Copyright Files
diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md
index 37c1b703a..474ecf7e6 100644
--- a/CODE_OF_CONDUCT.md
+++ b/CODE_OF_CONDUCT.md
@@ -14,10 +14,10 @@ appearance, race, religion, or sexual identity and orientation.
Examples of behavior that contributes to creating a positive environment
include:
-* No Anime
+* No Anime (including uwu's or owo's)
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
-* Gracefully accepting constructive criticism
+* Giving and gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
@@ -29,7 +29,7 @@ Examples of unacceptable behavior by participants include:
* ~~Trolling, insulting/derogatory comments, and personal or political attacks~~
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
- address, without explicit permission
+ address, without explicit permission or consent
* Other conduct which could reasonably be considered inappropriate in a
professional setting
diff --git a/README.md b/README.md
index 6a62c32d5..19ec0e879 100644
--- a/README.md
+++ b/README.md
@@ -19,9 +19,9 @@

[](https://github.com/cabaletta/baritone/graphs/contributors/)
[](https://github.com/cabaletta/baritone/commit/)
-[](https://impactdevelopment.github.io/)
+[](https://impactclient.net/)
[](https://github.com/fr1kin/ForgeHax/)
-[](https://gitlab.com/emc-mods-indrit/baritone_api)
+[](https://gitlab.com/emc-mods-indrit/baritone_api)
[](https://wweclient.com/)
[](https://futureclient.net/)
[](http://forthebadge.com/)
@@ -29,9 +29,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.
+Baritone is the pathfinding system used in [Impact](https://impactclient.net/) 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.
-The easiest way to install Baritone is to install [Impact](https://impactdevelopment.github.io/), which comes with Baritone. The second easiest way (for 1.12.2 only) is to install the v1.2.* forge api jar from [releases](https://github.com/cabaletta/baritone/releases). Otherwise, see [Installation & setup](SETUP.md). Once Baritone is installed, look [here](USAGE.md) for instructions on how to use it.
+The easiest way to install Baritone is to install [Impact](https://impactclient.net/), which comes with Baritone. The second easiest way (for 1.12.2 only) is to install the v1.2.* forge api jar from [releases](https://github.com/cabaletta/baritone/releases). Otherwise, see [Installation & setup](SETUP.md). Once Baritone is installed, look [here](USAGE.md) for instructions on how to use it.
For 1.14.4, [click here](https://www.dropbox.com/s/rkml3hjokd3qv0m/1.14.4-Baritone.zip?dl=1). Or [with optifine](https://github.com/cabaletta/baritone/issues/797).
diff --git a/SETUP.md b/SETUP.md
index 909da5a8f..1fcaf1d2b 100644
--- a/SETUP.md
+++ b/SETUP.md
@@ -1,6 +1,6 @@
# Installation
-The easiest way to install Baritone is to install [Impact](https://impactdevelopment.github.io/), which comes with Baritone.
+The easiest way to install Baritone is to install [Impact](https://impactclient.net/), which comes with Baritone.
For 1.14.4, [click here](https://www.dropbox.com/s/rkml3hjokd3qv0m/1.14.4-Baritone.zip?dl=1).
@@ -103,4 +103,4 @@ $ gradlew build

-- Double click on **build** to run it
\ No newline at end of file
+- Double click on **build** to run it
diff --git a/USAGE.md b/USAGE.md
index 869d68c27..25fef11e8 100644
--- a/USAGE.md
+++ b/USAGE.md
@@ -24,7 +24,7 @@ Some common examples:
- `goal clear` to clear the goal
- `cancel` or `stop` to stop everything
- `goto portal` or `goto ender_chest` or `goto block_type` to go to a block. (in Impact, `.goto` is an alias for `.b goto` for the most part)
-- `mine diamond_ore` to mine diamond ore (turn on the setting `legitMine` to only mine ores that it can actually see. It will explore randomly around y=11 until it finds them.) An amount of blocks can also be specified, for example, `mine diamond_ore 64`.
+- `mine diamond_ore iron_ore` to mine diamond ore or iron ore (turn on the setting `legitMine` to only mine ores that it can actually see. It will explore randomly around y=11 until it finds them.) An amount of blocks can also be specified, for example, `mine diamond_ore 64`.
- `click` to click your destination on the screen. Right click path to on top of the block, left click to path into it (either at foot level or eye level), and left click and drag to clear all blocks from an area.
- `follow playerName` to follow a player. `followplayers` to follow any players in range (combine with Kill Aura for a fun time). `followentities` to follow any entities. `followentity pig` to follow entities of a specific type.
- `save waypointName` to save a waypoint. `goto waypointName` to go to it.
@@ -39,6 +39,11 @@ Some common examples:
- `damn` daniel
+New commands:
+- `sel` to manage selections
+- some others
+
+
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/BaritoneAPI.java b/src/api/java/baritone/api/BaritoneAPI.java
index 4ea6ef3eb..53937bd80 100644
--- a/src/api/java/baritone/api/BaritoneAPI.java
+++ b/src/api/java/baritone/api/BaritoneAPI.java
@@ -34,12 +34,12 @@ public final class BaritoneAPI {
private static final Settings settings;
static {
+ settings = new Settings();
+ SettingsUtil.readAndApply(settings);
+
ServiceLoader baritoneLoader = ServiceLoader.load(IBaritoneProvider.class);
Iterator instances = baritoneLoader.iterator();
provider = instances.next();
-
- settings = new Settings();
- SettingsUtil.readAndApply(settings);
}
public static IBaritoneProvider getProvider() {
diff --git a/src/api/java/baritone/api/IBaritone.java b/src/api/java/baritone/api/IBaritone.java
index 2c892d982..8c5de47ab 100644
--- a/src/api/java/baritone/api/IBaritone.java
+++ b/src/api/java/baritone/api/IBaritone.java
@@ -23,8 +23,10 @@ import baritone.api.cache.IWorldProvider;
import baritone.api.event.listener.IEventBus;
import baritone.api.pathing.calc.IPathingControlManager;
import baritone.api.process.*;
+import baritone.api.selection.ISelectionManager;
import baritone.api.utils.IInputOverrideHandler;
import baritone.api.utils.IPlayerContext;
+import baritone.api.utils.command.manager.ICommandManager;
/**
* @author Brady
@@ -32,15 +34,6 @@ import baritone.api.utils.IPlayerContext;
*/
public interface IBaritone {
- /**
- * Call as soon as Minecraft is ready, initializes all of the processes, behaviors, etc. This will
- * only effectively be ran once, any additional calls are redundant because the initialization state
- * is saved.
- *
- * Or whenever your overeager utility client wants.
- */
- void init();
-
/**
* @return The {@link IPathingBehavior} instance
* @see IPathingBehavior
@@ -128,6 +121,18 @@ public interface IBaritone {
*/
IEventBus getGameEventHandler();
+ /**
+ * @return The {@link ISelectionManager} instance
+ * @see ISelectionManager
+ */
+ ISelectionManager getSelectionManager();
+
+ /**
+ * @return The {@link ICommandManager} instance
+ * @see ICommandManager
+ */
+ ICommandManager getCommandManager();
+
/**
* Open click
*/
diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java
index 1b47c4e33..d1bb68679 100644
--- a/src/api/java/baritone/api/Settings.java
+++ b/src/api/java/baritone/api/Settings.java
@@ -140,6 +140,13 @@ public final class Settings {
*/
public final Setting allowDiagonalDescend = new Setting<>(false);
+ /**
+ * Allow diagonal ascending
+ *
+ * Actually pretty safe, much safer than diagonal descend tbh
+ */
+ public final Setting allowDiagonalAscend = new Setting<>(false);
+
/**
* Allow mining the block directly beneath its feet
*
@@ -171,7 +178,9 @@ public final class Settings {
Blocks.CRAFTING_TABLE,
Blocks.FURNACE,
Blocks.CHEST,
- Blocks.TRAPPED_CHEST
+ Blocks.TRAPPED_CHEST,
+ Blocks.SIGN,
+ Blocks.WALL_SIGN
)));
/**
@@ -241,7 +250,12 @@ public final class Settings {
/**
* How many degrees to randomize the yaw every tick. Set to 0 to disable
*/
- public final Setting randomLooking = new Setting<>(2d);
+ public final Setting randomLooking113 = new Setting<>(2d);
+
+ /**
+ * How many degrees to randomize the pitch and yaw every tick. Set to 0 to disable
+ */
+ public final Setting randomLooking = new Setting<>(0.01d);
/**
* This is the big A* setting.
@@ -485,15 +499,20 @@ public final class Settings {
public final Setting chatControl = new Setting<>(true);
/**
- * A second override over chatControl to force it on
+ * Some clients like Impact try to force chatControl to off, so here's a second setting to do it anyway
*/
- public final Setting removePrefix = new Setting<>(false);
+ public final Setting chatControlAnyway = new Setting<>(false);
/**
* Render the path
*/
public final Setting renderPath = new Setting<>(true);
+ /**
+ * Render the path as a line instead of a frickin thingy
+ */
+ public final Setting renderPathAsLine = new Setting<>(false);
+
/**
* Render the goal
*/
@@ -594,10 +613,41 @@ public final class Settings {
public final Setting cachedChunksOpacity = new Setting<>(0.5f);
/**
- * Whether or not to use the "#" command prefix
+ * Whether or not to allow you to run Baritone commands with the prefix
*/
public final Setting prefixControl = new Setting<>(true);
+ /**
+ * The command prefix for chat control
+ */
+ public final Setting prefix = new Setting<>("#");
+
+ /**
+ * Use a short Baritone prefix [B] instead of [Baritone] when logging to chat
+ */
+ public final Setting shortBaritonePrefix = new Setting<>(false);
+
+ /**
+ * Echo commands to chat when they are run
+ */
+ public final Setting echoCommands = new Setting<>(true);
+
+ /**
+ * Censor coordinates in goals and block positions
+ */
+ public final Setting censorCoordinates = new Setting<>(false);
+
+ /**
+ * Censor arguments to ran commands, to hide, for example, coordinates to #goal
+ */
+ public final Setting censorRanCommands = new Setting<>(false);
+
+ /**
+ * Always prefer silk touch tools over regular tools. This will not sacrifice speed, but it will always prefer silk
+ * touch tools over other tools of the same speed. This includes always choosing ANY silk touch tool over your hand.
+ */
+ public final Setting preferSilkTouch = new Setting<>(false);
+
/**
* Don't stop walking forward when you need to break blocks in your way
*/
@@ -659,7 +709,12 @@ public final class Settings {
public final Setting exploreMaintainY = new Setting<>(64);
/**
- * Replant nether wart while farming
+ * Replant normal Crops while farming and leave cactus and sugarcane to regrow
+ */
+ public final Setting replantCrops = new Setting<>(true);
+
+ /**
+ * Replant nether wart while farming. This setting only has an effect when replantCrops is also enabled
*/
public final Setting replantNetherWart = new Setting<>(false);
@@ -721,11 +776,37 @@ public final class Settings {
*/
public final Setting breakCorrectBlockPenaltyMultiplier = new Setting<>(10d);
+ /**
+ * When this setting is true, build a schematic with the highest X coordinate being the origin, instead of the lowest
+ */
+ public final Setting schematicOrientationX = new Setting<>(false);
+
+ /**
+ * When this setting is true, build a schematic with the highest Y coordinate being the origin, instead of the lowest
+ */
+ public final Setting schematicOrientationY = new Setting<>(false);
+
+ /**
+ * When this setting is true, build a schematic with the highest Z coordinate being the origin, instead of the lowest
+ */
+ public final Setting schematicOrientationZ = new Setting<>(false);
+
+ /**
+ * Distance to scan every tick for updates. Expanding this beyond player reach distance (i.e. setting it to 6 or above)
+ * is only necessary in very large schematics where rescanning the whole thing is costly.
+ */
+ public final Setting builderTickScanRadius = new Setting<>(5);
+
/**
* While mining, should it also consider dropped items of the correct type as a pathing destination (as well as ore blocks)?
*/
public final Setting mineScanDroppedItems = new Setting<>(true);
+ /**
+ * Trim incorrect positions too far away, helps performance but hurts reliability in very large schematics
+ */
+ public final Setting distanceTrim = new Setting<>(true);
+
/**
* Cancel the current path if the goal has changed, and the path originally ended in the goal but doesn't anymore.
*
@@ -886,6 +967,51 @@ public final class Settings {
*/
public final Setting colorGoalBox = new Setting<>(Color.GREEN);
+ /**
+ * The color of the goal box when it's inverted
+ */
+ public final Setting colorInvertedGoalBox = new Setting<>(Color.RED);
+
+ /**
+ * The color of all selections
+ */
+ public final Setting colorSelection = new Setting<>(Color.CYAN);
+
+ /**
+ * The color of the selection pos 1
+ */
+ public final Setting colorSelectionPos1 = new Setting<>(Color.BLACK);
+
+ /**
+ * The color of the selection pos 2
+ */
+ public final Setting colorSelectionPos2 = new Setting<>(Color.ORANGE);
+
+ /**
+ * The opacity of the selection. 0 is completely transparent, 1 is completely opaque
+ */
+ public final Setting selectionOpacity = new Setting<>(.5f);
+
+ /**
+ * Line width of the goal when rendered, in pixels
+ */
+ public final Setting selectionLineWidth = new Setting<>(2F);
+
+ /**
+ * Render selections
+ */
+ public final Setting renderSelection = new Setting<>(true);
+
+ /**
+ * Ignore depth when rendering selections
+ */
+ public final Setting renderSelectionIgnoreDepth = new Setting<>(true);
+
+ /**
+ * Render selection corners
+ */
+ public final Setting renderSelectionCorners = new Setting<>(true);
+
/**
* A map of lowercase setting field names to their respective setting
@@ -900,6 +1026,7 @@ public final class Settings {
public final Map, Type> settingTypes;
public final class Setting {
+
public T value;
public final T defaultValue;
private String name;
@@ -982,10 +1109,10 @@ public final class Settings {
}
@SuppressWarnings("unchecked")
- public List> getAllValuesByType(Class klass) {
+ public List> getAllValuesByType(Class cla$$) {
List> result = new ArrayList<>();
for (Setting> setting : allSettings) {
- if (setting.getValueClass().equals(klass)) {
+ if (setting.getValueClass().equals(cla$$)) {
result.add((Setting) setting);
}
}
diff --git a/src/api/java/baritone/api/accessor/IGuiScreen.java b/src/api/java/baritone/api/accessor/IGuiScreen.java
new file mode 100644
index 000000000..ba01e2755
--- /dev/null
+++ b/src/api/java/baritone/api/accessor/IGuiScreen.java
@@ -0,0 +1,25 @@
+/*
+ * This file is part of Baritone.
+ *
+ * Baritone is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Baritone is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Baritone. If not, see .
+ */
+
+package baritone.api.accessor;
+
+import java.net.URI;
+
+public interface IGuiScreen {
+
+ void openLink(URI url);
+}
diff --git a/src/api/java/baritone/api/accessor/IItemStack.java b/src/api/java/baritone/api/accessor/IItemStack.java
new file mode 100644
index 000000000..480c713fa
--- /dev/null
+++ b/src/api/java/baritone/api/accessor/IItemStack.java
@@ -0,0 +1,23 @@
+/*
+ * This file is part of Baritone.
+ *
+ * Baritone is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Baritone is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Baritone. If not, see .
+ */
+
+package baritone.api.accessor;
+
+public interface IItemStack {
+
+ int getBaritoneHash();
+}
diff --git a/src/api/java/baritone/api/behavior/IPathingBehavior.java b/src/api/java/baritone/api/behavior/IPathingBehavior.java
index 157774489..5444bb838 100644
--- a/src/api/java/baritone/api/behavior/IPathingBehavior.java
+++ b/src/api/java/baritone/api/behavior/IPathingBehavior.java
@@ -64,9 +64,17 @@ public interface IPathingBehavior extends IBehavior {
Goal getGoal();
/**
- * @return Whether or not a path is currently being executed.
+ * @return Whether or not a path is currently being executed. This will be false if there's currently a pause.
+ * @see #hasPath()
*/
- default boolean isPathing() {
+ boolean isPathing();
+
+ /**
+ * @return If there is a current path. Note that the path is not necessarily being executed, for example when there
+ * is a pause in effect.
+ * @see #isPathing()
+ */
+ default boolean hasPath() {
return getCurrent() != null;
}
diff --git a/src/api/java/baritone/api/cache/IWaypoint.java b/src/api/java/baritone/api/cache/IWaypoint.java
index 01df2a48b..ff2350993 100644
--- a/src/api/java/baritone/api/cache/IWaypoint.java
+++ b/src/api/java/baritone/api/cache/IWaypoint.java
@@ -17,12 +17,9 @@
package baritone.api.cache;
-import net.minecraft.util.math.BlockPos;
-import org.apache.commons.lang3.ArrayUtils;
+import baritone.api.utils.BetterBlockPos;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
+import java.util.*;
/**
* A marker for a position in the world.
@@ -60,7 +57,7 @@ public interface IWaypoint {
*
* @return The block position of this waypoint
*/
- BlockPos getLocation();
+ BetterBlockPos getLocation();
enum Tag {
@@ -92,20 +89,48 @@ public interface IWaypoint {
/**
* The names for the tag, anything that the tag can be referred to as.
*/
- private final String[] names;
+ public final String[] names;
Tag(String... names) {
this.names = names;
}
/**
- * Finds a tag from one of the names that could be used to identify said tag.
- *
- * @param name The name of the tag
- * @return The tag, if one is found, otherwise, {@code null}
+ * @return A name that can be passed to {@link #getByName(String)} to retrieve this tag
*/
- public static Tag fromString(String name) {
- return TAG_LIST.stream().filter(tag -> ArrayUtils.contains(tag.names, name.toLowerCase())).findFirst().orElse(null);
+ public String getName() {
+ return names[0];
+ }
+
+ /**
+ * Gets a tag by one of its names.
+ *
+ * @param name The name to search for.
+ * @return The tag, if found, or null.
+ */
+ public static Tag getByName(String name) {
+ for (Tag action : Tag.values()) {
+ for (String alias : action.names) {
+ if (alias.equalsIgnoreCase(name)) {
+ return action;
+ }
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * @return All tag names.
+ */
+ public static String[] getAllNames() {
+ Set names = new HashSet<>();
+
+ for (Tag tag : Tag.values()) {
+ names.addAll(Arrays.asList(tag.names));
+ }
+
+ return names.toArray(new String[0]);
}
}
}
diff --git a/src/api/java/baritone/api/cache/IWorldScanner.java b/src/api/java/baritone/api/cache/IWorldScanner.java
index caa44cbc6..325d4bd0e 100644
--- a/src/api/java/baritone/api/cache/IWorldScanner.java
+++ b/src/api/java/baritone/api/cache/IWorldScanner.java
@@ -17,6 +17,7 @@
package baritone.api.cache;
+import baritone.api.utils.BlockOptionalMetaLookup;
import baritone.api.utils.IPlayerContext;
import net.minecraft.block.Block;
import net.minecraft.util.math.BlockPos;
@@ -33,28 +34,53 @@ public interface IWorldScanner {
/**
* Scans the world, up to the specified max chunk radius, for the specified blocks.
*
- * @param ctx The {@link IPlayerContext} containing player and world info that the
- * scan is based upon
- * @param blocks The blocks to scan for
+ * @param ctx The {@link IPlayerContext} containing player and world info that the scan is based upon
+ * @param filter The blocks to scan for
* @param max The maximum number of blocks to scan before cutoff
- * @param yLevelThreshold If a block is found within this Y level, the current result will be
- * returned, if the value is negative, then this condition doesn't apply.
+ * @param yLevelThreshold If a block is found within this Y level, the current result will be returned, if the value
+ * is negative, then this condition doesn't apply.
* @param maxSearchRadius The maximum chunk search radius
* @return The matching block positions
*/
- List scanChunkRadius(IPlayerContext ctx, List blocks, int max, int yLevelThreshold, int maxSearchRadius);
+ List scanChunkRadius(IPlayerContext ctx, BlockOptionalMetaLookup filter, int max, int yLevelThreshold, int maxSearchRadius);
+
+ default List scanChunkRadius(IPlayerContext ctx, List filter, int max, int yLevelThreshold, int maxSearchRadius) {
+ return scanChunkRadius(ctx, new BlockOptionalMetaLookup(filter.toArray(new Block[0])), max, yLevelThreshold, maxSearchRadius);
+ }
/**
* Scans a single chunk for the specified blocks.
*
- * @param ctx The {@link IPlayerContext} containing player and world info that the
- * scan is based upon
+ * @param ctx The {@link IPlayerContext} containing player and world info that the scan is based upon
+ * @param filter The blocks to scan for
+ * @param pos The position of the target chunk
+ * @param max The maximum number of blocks to scan before cutoff
+ * @param yLevelThreshold If a block is found within this Y level, the current result will be returned, if the value
+ * is negative, then this condition doesn't apply.
+ * @return The matching block positions
+ */
+ List scanChunk(IPlayerContext ctx, BlockOptionalMetaLookup filter, ChunkPos pos, int max, int yLevelThreshold);
+
+ /**
+ * Scans a single chunk for the specified blocks.
+ *
+ * @param ctx The {@link IPlayerContext} containing player and world info that the scan is based upon
* @param blocks The blocks to scan for
* @param pos The position of the target chunk
* @param max The maximum number of blocks to scan before cutoff
- * @param yLevelThreshold If a block is found within this Y level, the current result will be
- * returned, if the value is negative, then this condition doesn't apply.
+ * @param yLevelThreshold If a block is found within this Y level, the current result will be returned, if the value
+ * is negative, then this condition doesn't apply.
* @return The matching block positions
*/
- List scanChunk(IPlayerContext ctx, List blocks, ChunkPos pos, int max, int yLevelThreshold);
+ default List scanChunk(IPlayerContext ctx, List blocks, ChunkPos pos, int max, int yLevelThreshold) {
+ return scanChunk(ctx, new BlockOptionalMetaLookup(blocks), pos, max, yLevelThreshold);
+ }
+
+ /**
+ * Repacks 40 chunks around the player.
+ *
+ * @param ctx The player context for that player.
+ * @return The number of chunks queued for repacking.
+ */
+ int repack(IPlayerContext ctx);
}
diff --git a/src/api/java/baritone/api/cache/Waypoint.java b/src/api/java/baritone/api/cache/Waypoint.java
index 2b9a7232b..9c4fbfbfc 100644
--- a/src/api/java/baritone/api/cache/Waypoint.java
+++ b/src/api/java/baritone/api/cache/Waypoint.java
@@ -17,7 +17,7 @@
package baritone.api.cache;
-import net.minecraft.util.math.BlockPos;
+import baritone.api.utils.BetterBlockPos;
import java.util.Date;
@@ -31,9 +31,9 @@ public class Waypoint implements IWaypoint {
private final String name;
private final Tag tag;
private final long creationTimestamp;
- private final BlockPos location;
+ private final BetterBlockPos location;
- public Waypoint(String name, Tag tag, BlockPos location) {
+ public Waypoint(String name, Tag tag, BetterBlockPos location) {
this(name, tag, location, System.currentTimeMillis());
}
@@ -46,7 +46,7 @@ public class Waypoint implements IWaypoint {
* @param location The waypoint location
* @param creationTimestamp When the waypoint was created
*/
- public Waypoint(String name, Tag tag, BlockPos location, long creationTimestamp) {
+ public Waypoint(String name, Tag tag, BetterBlockPos location, long creationTimestamp) {
this.name = name;
this.tag = tag;
this.location = location;
@@ -55,7 +55,7 @@ public class Waypoint implements IWaypoint {
@Override
public int hashCode() {
- return name.hashCode() + tag.hashCode() + location.hashCode(); //lol
+ return name.hashCode() ^ tag.hashCode() ^ location.hashCode() ^ Long.hashCode(creationTimestamp);
}
@Override
@@ -74,13 +74,18 @@ public class Waypoint implements IWaypoint {
}
@Override
- public BlockPos getLocation() {
+ public BetterBlockPos getLocation() {
return this.location;
}
@Override
public String toString() {
- return name + " " + location.toString() + " " + new Date(creationTimestamp).toString();
+ return String.format(
+ "%s %s %s",
+ name,
+ BetterBlockPos.from(location).toString(),
+ new Date(creationTimestamp).toString()
+ );
}
@Override
diff --git a/src/api/java/baritone/api/event/events/TabCompleteEvent.java b/src/api/java/baritone/api/event/events/TabCompleteEvent.java
new file mode 100644
index 000000000..fea1da292
--- /dev/null
+++ b/src/api/java/baritone/api/event/events/TabCompleteEvent.java
@@ -0,0 +1,53 @@
+/*
+ * This file is part of Baritone.
+ *
+ * Baritone is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Baritone is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Baritone. If not, see .
+ */
+
+package baritone.api.event.events;
+
+import baritone.api.event.events.type.Cancellable;
+import baritone.api.event.events.type.Overrideable;
+
+/**
+ * @author LoganDark
+ */
+public abstract class TabCompleteEvent extends Cancellable {
+
+ public final Overrideable prefix;
+ public final Overrideable completions;
+
+ TabCompleteEvent(String prefix, String[] completions) {
+ this.prefix = new Overrideable<>(prefix);
+ this.completions = new Overrideable<>(completions);
+ }
+
+ public boolean wasModified() {
+ return prefix.wasModified() || completions.wasModified();
+ }
+
+ public static final class Pre extends TabCompleteEvent {
+
+ public Pre(String prefix) {
+ super(prefix, null);
+ }
+ }
+
+ public static final class Post extends TabCompleteEvent {
+
+ public Post(String prefix, String[] completions) {
+ super(prefix, completions);
+ }
+ }
+}
diff --git a/src/api/java/baritone/api/event/events/type/Overrideable.java b/src/api/java/baritone/api/event/events/type/Overrideable.java
new file mode 100644
index 000000000..cbad9b999
--- /dev/null
+++ b/src/api/java/baritone/api/event/events/type/Overrideable.java
@@ -0,0 +1,53 @@
+/*
+ * This file is part of Baritone.
+ *
+ * Baritone is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Baritone is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Baritone. If not, see .
+ */
+
+package baritone.api.event.events.type;
+
+/**
+ * @author LoganDark
+ */
+public class Overrideable {
+
+ private T value;
+ private boolean modified;
+
+ public Overrideable(T current) {
+ value = current;
+ }
+
+ public T get() {
+ return value;
+ }
+
+ public void set(T newValue) {
+ value = newValue;
+ modified = true;
+ }
+
+ public boolean wasModified() {
+ return modified;
+ }
+
+ @Override
+ public String toString() {
+ return String.format(
+ "Overrideable{modified=%b,value=%s}",
+ modified,
+ value.toString()
+ );
+ }
+}
diff --git a/src/api/java/baritone/api/event/listener/AbstractGameEventListener.java b/src/api/java/baritone/api/event/listener/AbstractGameEventListener.java
index 71045768a..e7d4dc292 100644
--- a/src/api/java/baritone/api/event/listener/AbstractGameEventListener.java
+++ b/src/api/java/baritone/api/event/listener/AbstractGameEventListener.java
@@ -39,6 +39,12 @@ public interface AbstractGameEventListener extends IGameEventListener {
@Override
default void onSendChatMessage(ChatEvent event) {}
+ @Override
+ default void onPreTabComplete(TabCompleteEvent.Pre event) {}
+
+ @Override
+ default void onPostTabComplete(TabCompleteEvent.Post event) {}
+
@Override
default void onChunkEvent(ChunkEvent event) {}
diff --git a/src/api/java/baritone/api/event/listener/IGameEventListener.java b/src/api/java/baritone/api/event/listener/IGameEventListener.java
index 93bdb7a61..44db8f62f 100644
--- a/src/api/java/baritone/api/event/listener/IGameEventListener.java
+++ b/src/api/java/baritone/api/event/listener/IGameEventListener.java
@@ -56,6 +56,21 @@ public interface IGameEventListener {
*/
void onSendChatMessage(ChatEvent event);
+ /**
+ * Runs whenever the client player tries to tab complete in chat.
+ *
+ * @param event The event
+ */
+ void onPreTabComplete(TabCompleteEvent.Pre event);
+
+ /**
+ * Runs whenever the client player tries to tab complete in chat once completions have been recieved from the
+ * server. This will only be called if the {@link TabCompleteEvent#cancel()} method was not called.
+ *
+ * @param event The event
+ */
+ void onPostTabComplete(TabCompleteEvent.Post event);
+
/**
* Runs before and after whenever a chunk is either loaded, unloaded, or populated.
*
diff --git a/src/api/java/baritone/api/pathing/goals/GoalBlock.java b/src/api/java/baritone/api/pathing/goals/GoalBlock.java
index 89dd63048..c85e5cadd 100644
--- a/src/api/java/baritone/api/pathing/goals/GoalBlock.java
+++ b/src/api/java/baritone/api/pathing/goals/GoalBlock.java
@@ -17,6 +17,7 @@
package baritone.api.pathing.goals;
+import baritone.api.utils.SettingsUtil;
import baritone.api.utils.interfaces.IGoalRenderPos;
import net.minecraft.util.math.BlockPos;
@@ -67,7 +68,12 @@ public class GoalBlock implements Goal, IGoalRenderPos {
@Override
public String toString() {
- return "GoalBlock{x=" + x + ",y=" + y + ",z=" + z + "}";
+ return String.format(
+ "GoalBlock{x=%s,y=%s,z=%s}",
+ SettingsUtil.maybeCensor(x),
+ SettingsUtil.maybeCensor(y),
+ SettingsUtil.maybeCensor(z)
+ );
}
/**
diff --git a/src/api/java/baritone/api/pathing/goals/GoalGetToBlock.java b/src/api/java/baritone/api/pathing/goals/GoalGetToBlock.java
index fb2a07aaf..8d6fdcb30 100644
--- a/src/api/java/baritone/api/pathing/goals/GoalGetToBlock.java
+++ b/src/api/java/baritone/api/pathing/goals/GoalGetToBlock.java
@@ -17,6 +17,7 @@
package baritone.api.pathing.goals;
+import baritone.api.utils.SettingsUtil;
import baritone.api.utils.interfaces.IGoalRenderPos;
import net.minecraft.util.math.BlockPos;
@@ -61,6 +62,11 @@ public class GoalGetToBlock implements Goal, IGoalRenderPos {
@Override
public String toString() {
- return "GoalGetToBlock{x=" + x + ",y=" + y + ",z=" + z + "}";
+ return String.format(
+ "GoalGetToBlock{x=%s,y=%s,z=%s}",
+ SettingsUtil.maybeCensor(x),
+ SettingsUtil.maybeCensor(y),
+ SettingsUtil.maybeCensor(z)
+ );
}
}
diff --git a/src/api/java/baritone/api/pathing/goals/GoalInverted.java b/src/api/java/baritone/api/pathing/goals/GoalInverted.java
new file mode 100644
index 000000000..197369241
--- /dev/null
+++ b/src/api/java/baritone/api/pathing/goals/GoalInverted.java
@@ -0,0 +1,52 @@
+/*
+ * This file is part of Baritone.
+ *
+ * Baritone is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Baritone is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Baritone. If not, see .
+ */
+
+package baritone.api.pathing.goals;
+
+/**
+ * Invert any goal.
+ *
+ * In the old chat control system, #invert just tried to pick a {@link GoalRunAway} that effectively inverted the
+ * current goal. This goal just reverses the heuristic to act as a TRUE invert. Inverting a Y level? Baritone tries to
+ * get away from that Y level. Inverting a GoalBlock? Baritone will try to make distance whether it's in the X, Y or Z
+ * directions. And of course, you can always invert a GoalXZ.
+ *
+ * @author LoganDark
+ */
+public class GoalInverted implements Goal {
+
+ public final Goal origin;
+
+ public GoalInverted(Goal origin) {
+ this.origin = origin;
+ }
+
+ @Override
+ public boolean isInGoal(int x, int y, int z) {
+ return false;
+ }
+
+ @Override
+ public double heuristic(int x, int y, int z) {
+ return -origin.heuristic(x, y, z);
+ }
+
+ @Override
+ public String toString() {
+ return String.format("GoalInverted{%s}", origin.toString());
+ }
+}
diff --git a/src/api/java/baritone/api/pathing/goals/GoalNear.java b/src/api/java/baritone/api/pathing/goals/GoalNear.java
index 4f75aba72..73d64ed9f 100644
--- a/src/api/java/baritone/api/pathing/goals/GoalNear.java
+++ b/src/api/java/baritone/api/pathing/goals/GoalNear.java
@@ -17,10 +17,12 @@
package baritone.api.pathing.goals;
+import baritone.api.utils.SettingsUtil;
import baritone.api.utils.interfaces.IGoalRenderPos;
import net.minecraft.util.math.BlockPos;
public class GoalNear implements Goal, IGoalRenderPos {
+
private final int x;
private final int y;
private final int z;
@@ -56,11 +58,12 @@ public class GoalNear implements Goal, IGoalRenderPos {
@Override
public String toString() {
- return "GoalNear{" +
- "x=" + x +
- ", y=" + y +
- ", z=" + z +
- ", rangeSq=" + rangeSq +
- "}";
+ return String.format(
+ "GoalNear{x=%s, y=%s, z=%s, rangeSq=%d}",
+ SettingsUtil.maybeCensor(x),
+ SettingsUtil.maybeCensor(y),
+ SettingsUtil.maybeCensor(z),
+ rangeSq
+ );
}
}
diff --git a/src/api/java/baritone/api/pathing/goals/GoalRunAway.java b/src/api/java/baritone/api/pathing/goals/GoalRunAway.java
index 3f4a02de1..a1a153780 100644
--- a/src/api/java/baritone/api/pathing/goals/GoalRunAway.java
+++ b/src/api/java/baritone/api/pathing/goals/GoalRunAway.java
@@ -17,6 +17,7 @@
package baritone.api.pathing.goals;
+import baritone.api.utils.SettingsUtil;
import net.minecraft.util.math.BlockPos;
import java.util.Arrays;
@@ -82,7 +83,11 @@ public class GoalRunAway implements Goal {
@Override
public String toString() {
if (maintainY != null) {
- return "GoalRunAwayFromMaintainY y=" + maintainY + ", " + Arrays.asList(from);
+ return String.format(
+ "GoalRunAwayFromMaintainY y=%s, %s",
+ SettingsUtil.maybeCensor(maintainY),
+ Arrays.asList(from)
+ );
} else {
return "GoalRunAwayFrom" + Arrays.asList(from);
}
diff --git a/src/api/java/baritone/api/pathing/goals/GoalStrictDirection.java b/src/api/java/baritone/api/pathing/goals/GoalStrictDirection.java
index 24ae385ac..b48a029ad 100644
--- a/src/api/java/baritone/api/pathing/goals/GoalStrictDirection.java
+++ b/src/api/java/baritone/api/pathing/goals/GoalStrictDirection.java
@@ -17,6 +17,7 @@
package baritone.api.pathing.goals;
+import baritone.api.utils.SettingsUtil;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
@@ -24,6 +25,7 @@ import net.minecraft.util.math.BlockPos;
* Dig a tunnel in a certain direction, but if you have to deviate from the path, go back to where you started
*/
public class GoalStrictDirection implements Goal {
+
public final int x;
public final int y;
public final int z;
@@ -64,12 +66,13 @@ public class GoalStrictDirection implements Goal {
@Override
public String toString() {
- return "GoalStrictDirection{" +
- "x=" + x +
- ", y=" + y +
- ", z=" + z +
- ", dx=" + dx +
- ", dz=" + dz +
- "}";
+ return String.format(
+ "GoalStrictDirection{x=%s, y=%s, z=%s, dx=%s, dz=%s}",
+ SettingsUtil.maybeCensor(x),
+ SettingsUtil.maybeCensor(y),
+ SettingsUtil.maybeCensor(z),
+ SettingsUtil.maybeCensor(dx),
+ SettingsUtil.maybeCensor(dz)
+ );
}
}
diff --git a/src/api/java/baritone/api/pathing/goals/GoalTwoBlocks.java b/src/api/java/baritone/api/pathing/goals/GoalTwoBlocks.java
index f1026ab50..27be981e4 100644
--- a/src/api/java/baritone/api/pathing/goals/GoalTwoBlocks.java
+++ b/src/api/java/baritone/api/pathing/goals/GoalTwoBlocks.java
@@ -17,6 +17,7 @@
package baritone.api.pathing.goals;
+import baritone.api.utils.SettingsUtil;
import baritone.api.utils.interfaces.IGoalRenderPos;
import net.minecraft.util.math.BlockPos;
@@ -73,6 +74,11 @@ public class GoalTwoBlocks implements Goal, IGoalRenderPos {
@Override
public String toString() {
- return "GoalTwoBlocks{x=" + x + ",y=" + y + ",z=" + z + "}";
+ return String.format(
+ "GoalTwoBlocks{x=%s,y=%s,z=%s}",
+ SettingsUtil.maybeCensor(x),
+ SettingsUtil.maybeCensor(y),
+ SettingsUtil.maybeCensor(z)
+ );
}
}
diff --git a/src/api/java/baritone/api/pathing/goals/GoalXZ.java b/src/api/java/baritone/api/pathing/goals/GoalXZ.java
index 7f8d16abe..63d39cd78 100644
--- a/src/api/java/baritone/api/pathing/goals/GoalXZ.java
+++ b/src/api/java/baritone/api/pathing/goals/GoalXZ.java
@@ -18,6 +18,8 @@
package baritone.api.pathing.goals;
import baritone.api.BaritoneAPI;
+import baritone.api.utils.BetterBlockPos;
+import baritone.api.utils.SettingsUtil;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
@@ -45,6 +47,11 @@ public class GoalXZ implements Goal {
this.z = z;
}
+ public GoalXZ(BetterBlockPos pos) {
+ this.x = pos.x;
+ this.z = pos.z;
+ }
+
@Override
public boolean isInGoal(int x, int y, int z) {
return x == this.x && z == this.z;
@@ -59,7 +66,11 @@ public class GoalXZ implements Goal {
@Override
public String toString() {
- return "GoalXZ{x=" + x + ",z=" + z + "}";
+ return String.format(
+ "GoalXZ{x=%s,z=%s}",
+ SettingsUtil.maybeCensor(x),
+ SettingsUtil.maybeCensor(z)
+ );
}
public static double calculate(double xDiff, double zDiff) {
@@ -87,7 +98,7 @@ public class GoalXZ implements Goal {
float theta = (float) Math.toRadians(yaw);
double x = origin.x - MathHelper.sin(theta) * distance;
double z = origin.z + MathHelper.cos(theta) * distance;
- return new GoalXZ((int) x, (int) z);
+ return new GoalXZ(MathHelper.floor(x), MathHelper.floor(z));
}
public int getX() {
diff --git a/src/api/java/baritone/api/pathing/goals/GoalYLevel.java b/src/api/java/baritone/api/pathing/goals/GoalYLevel.java
index 9add7176a..603ef9bd1 100644
--- a/src/api/java/baritone/api/pathing/goals/GoalYLevel.java
+++ b/src/api/java/baritone/api/pathing/goals/GoalYLevel.java
@@ -18,6 +18,7 @@
package baritone.api.pathing.goals;
import baritone.api.pathing.movement.ActionCosts;
+import baritone.api.utils.SettingsUtil;
/**
* Useful for mining (getting to diamond / iron level)
@@ -59,6 +60,9 @@ public class GoalYLevel implements Goal, ActionCosts {
@Override
public String toString() {
- return "GoalYLevel{y=" + level + "}";
+ return String.format(
+ "GoalYLevel{y=%s}",
+ SettingsUtil.maybeCensor(level)
+ );
}
}
diff --git a/src/api/java/baritone/api/process/IBuilderProcess.java b/src/api/java/baritone/api/process/IBuilderProcess.java
index 90aba4eaf..efd96d9fa 100644
--- a/src/api/java/baritone/api/process/IBuilderProcess.java
+++ b/src/api/java/baritone/api/process/IBuilderProcess.java
@@ -18,11 +18,13 @@
package baritone.api.process;
import baritone.api.utils.ISchematic;
+import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3i;
import java.io.File;
+import java.util.List;
/**
* @author Brady
@@ -58,7 +60,16 @@ public interface IBuilderProcess extends IBaritoneProcess {
void pause();
+ boolean isPaused();
+
void resume();
void clearArea(BlockPos corner1, BlockPos corner2);
+
+ /**
+ * @return A list of block states that are estimated to be placeable by this builder process. You can use this in
+ * schematics, for example, to pick a state that the builder process will be happy with, because any variation will
+ * cause it to give up. This is updated every tick, but only while the builder process is active.
+ */
+ List getApproxPlaceable();
}
diff --git a/src/api/java/baritone/api/process/IExploreProcess.java b/src/api/java/baritone/api/process/IExploreProcess.java
index 811a509f0..4950d31d5 100644
--- a/src/api/java/baritone/api/process/IExploreProcess.java
+++ b/src/api/java/baritone/api/process/IExploreProcess.java
@@ -20,6 +20,7 @@ package baritone.api.process;
import java.nio.file.Path;
public interface IExploreProcess extends IBaritoneProcess {
+
void explore(int centerX, int centerZ);
void applyJsonFilter(Path path, boolean invert) throws Exception;
diff --git a/src/api/java/baritone/api/process/IFarmProcess.java b/src/api/java/baritone/api/process/IFarmProcess.java
index c9234a24a..6ced16fba 100644
--- a/src/api/java/baritone/api/process/IFarmProcess.java
+++ b/src/api/java/baritone/api/process/IFarmProcess.java
@@ -18,5 +18,6 @@
package baritone.api.process;
public interface IFarmProcess extends IBaritoneProcess {
+
void farm();
}
diff --git a/src/api/java/baritone/api/process/IMineProcess.java b/src/api/java/baritone/api/process/IMineProcess.java
index 7ebabc9cb..9cd76a09a 100644
--- a/src/api/java/baritone/api/process/IMineProcess.java
+++ b/src/api/java/baritone/api/process/IMineProcess.java
@@ -17,8 +17,12 @@
package baritone.api.process;
+import baritone.api.utils.BlockOptionalMeta;
+import baritone.api.utils.BlockOptionalMetaLookup;
import net.minecraft.block.Block;
+import java.util.stream.Stream;
+
/**
* @author Brady
* @since 9/23/2018
@@ -28,9 +32,9 @@ public interface IMineProcess extends IBaritoneProcess {
/**
* Begin to search for and mine the specified blocks until
* the number of specified items to get from the blocks that
- * are mined. This is based on the first target block to mine.
+ * are mined.
*
- * @param quantity The number of items to get from blocks mined
+ * @param quantity The total number of items to get
* @param blocks The blocks to mine
*/
void mineByName(int quantity, String... blocks);
@@ -41,9 +45,18 @@ public interface IMineProcess extends IBaritoneProcess {
* are mined. This is based on the first target block to mine.
*
* @param quantity The number of items to get from blocks mined
- * @param blocks The blocks to mine
+ * @param filter The blocks to mine
*/
- void mine(int quantity, Block... blocks);
+ void mine(int quantity, BlockOptionalMetaLookup filter);
+
+ /**
+ * Begin to search for and mine the specified blocks.
+ *
+ * @param filter The blocks to mine
+ */
+ default void mine(BlockOptionalMetaLookup filter) {
+ mine(0, filter);
+ }
/**
* Begin to search for and mine the specified blocks.
@@ -54,6 +67,38 @@ public interface IMineProcess extends IBaritoneProcess {
mineByName(0, blocks);
}
+ /**
+ * Begin to search for and mine the specified blocks.
+ *
+ * @param boms The blocks to mine
+ */
+ default void mine(int quantity, BlockOptionalMeta... boms) {
+ mine(quantity, new BlockOptionalMetaLookup(boms));
+ }
+
+ /**
+ * Begin to search for and mine the specified blocks.
+ *
+ * @param boms The blocks to mine
+ */
+ default void mine(BlockOptionalMeta... boms) {
+ mine(0, boms);
+ }
+
+ /**
+ * Begin to search for and mine the specified blocks.
+ *
+ * @param quantity The total number of items to get
+ * @param blocks The blocks to mine
+ */
+ default void mine(int quantity, Block... blocks) {
+ mine(quantity, new BlockOptionalMetaLookup(
+ Stream.of(blocks)
+ .map(BlockOptionalMeta::new)
+ .toArray(BlockOptionalMeta[]::new)
+ ));
+ }
+
/**
* Begin to search for and mine the specified blocks.
*
diff --git a/src/api/java/baritone/api/schematic/AbstractSchematic.java b/src/api/java/baritone/api/schematic/AbstractSchematic.java
new file mode 100644
index 000000000..7a24e803f
--- /dev/null
+++ b/src/api/java/baritone/api/schematic/AbstractSchematic.java
@@ -0,0 +1,48 @@
+/*
+ * This file is part of Baritone.
+ *
+ * Baritone is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Baritone is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Baritone. If not, see .
+ */
+
+package baritone.api.schematic;
+
+import baritone.api.utils.ISchematic;
+
+public abstract class AbstractSchematic implements ISchematic {
+
+ protected int x;
+ protected int y;
+ protected int z;
+
+ public AbstractSchematic(int x, int y, int z) {
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ }
+
+ @Override
+ public int widthX() {
+ return x;
+ }
+
+ @Override
+ public int heightY() {
+ return y;
+ }
+
+ @Override
+ public int lengthZ() {
+ return z;
+ }
+}
diff --git a/src/api/java/baritone/api/schematic/CompositeSchematic.java b/src/api/java/baritone/api/schematic/CompositeSchematic.java
new file mode 100644
index 000000000..21df29b4d
--- /dev/null
+++ b/src/api/java/baritone/api/schematic/CompositeSchematic.java
@@ -0,0 +1,75 @@
+/*
+ * This file is part of Baritone.
+ *
+ * Baritone is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Baritone is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Baritone. If not, see .
+ */
+
+package baritone.api.schematic;
+
+import baritone.api.utils.ISchematic;
+import net.minecraft.block.state.IBlockState;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class CompositeSchematic extends AbstractSchematic {
+
+ private final List schematics;
+ private CompositeSchematicEntry[] schematicArr;
+
+ private void recalcArr() {
+ schematicArr = schematics.toArray(new CompositeSchematicEntry[0]);
+ for (CompositeSchematicEntry entry : schematicArr) {
+ this.x = Math.max(x, entry.x + entry.schematic.widthX());
+ this.y = Math.max(y, entry.y + entry.schematic.heightY());
+ this.z = Math.max(z, entry.z + entry.schematic.lengthZ());
+ }
+ }
+
+ public CompositeSchematic(int x, int y, int z) {
+ super(x, y, z);
+ schematics = new ArrayList<>();
+ recalcArr();
+ }
+
+ public void put(ISchematic extra, int x, int y, int z) {
+ schematics.add(new CompositeSchematicEntry(extra, x, y, z));
+ recalcArr();
+ }
+
+ private CompositeSchematicEntry getSchematic(int x, int y, int z, IBlockState currentState) {
+ for (CompositeSchematicEntry entry : schematicArr) {
+ if (x >= entry.x && y >= entry.y && z >= entry.z &&
+ entry.schematic.inSchematic(x - entry.x, y - entry.y, z - entry.z, currentState)) {
+ return entry;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public boolean inSchematic(int x, int y, int z, IBlockState currentState) {
+ CompositeSchematicEntry entry = getSchematic(x, y, z, currentState);
+ return entry != null && entry.schematic.inSchematic(x - entry.x, y - entry.y, z - entry.z, currentState);
+ }
+
+ @Override
+ public IBlockState desiredState(int x, int y, int z, IBlockState current, List approxPlaceable) {
+ CompositeSchematicEntry entry = getSchematic(x, y, z, current);
+ if (entry == null) {
+ throw new IllegalStateException("couldn't find schematic for this position");
+ }
+ return entry.schematic.desiredState(x - entry.x, y - entry.y, z - entry.z, current, approxPlaceable);
+ }
+}
diff --git a/src/api/java/baritone/api/schematic/CompositeSchematicEntry.java b/src/api/java/baritone/api/schematic/CompositeSchematicEntry.java
new file mode 100644
index 000000000..a26f356bf
--- /dev/null
+++ b/src/api/java/baritone/api/schematic/CompositeSchematicEntry.java
@@ -0,0 +1,35 @@
+/*
+ * This file is part of Baritone.
+ *
+ * Baritone is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Baritone is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Baritone. If not, see .
+ */
+
+package baritone.api.schematic;
+
+import baritone.api.utils.ISchematic;
+
+public class CompositeSchematicEntry {
+
+ public final ISchematic schematic;
+ public final int x;
+ public final int y;
+ public final int z;
+
+ public CompositeSchematicEntry(ISchematic schematic, int x, int y, int z) {
+ this.schematic = schematic;
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ }
+}
diff --git a/src/api/java/baritone/api/schematic/FillSchematic.java b/src/api/java/baritone/api/schematic/FillSchematic.java
new file mode 100644
index 000000000..aaaeb5dd1
--- /dev/null
+++ b/src/api/java/baritone/api/schematic/FillSchematic.java
@@ -0,0 +1,53 @@
+/*
+ * This file is part of Baritone.
+ *
+ * Baritone is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Baritone is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Baritone. If not, see .
+ */
+
+package baritone.api.schematic;
+
+import baritone.api.utils.BlockOptionalMeta;
+import net.minecraft.block.state.IBlockState;
+import net.minecraft.init.Blocks;
+
+import java.util.List;
+
+public class FillSchematic extends AbstractSchematic {
+
+ private final BlockOptionalMeta bom;
+
+ public FillSchematic(int x, int y, int z, BlockOptionalMeta bom) {
+ super(x, y, z);
+ this.bom = bom;
+ }
+
+ public BlockOptionalMeta getBom() {
+ return bom;
+ }
+
+ @Override
+ public IBlockState desiredState(int x, int y, int z, IBlockState current, List approxPlaceable) {
+ if (bom.matches(current)) {
+ return current;
+ } else if (current.getBlock() != Blocks.AIR) {
+ return Blocks.AIR.getDefaultState();
+ }
+ for (IBlockState placeable : approxPlaceable) {
+ if (bom.matches(placeable)) {
+ return placeable;
+ }
+ }
+ return bom.getAnyBlockState();
+ }
+}
diff --git a/src/api/java/baritone/api/schematic/MaskSchematic.java b/src/api/java/baritone/api/schematic/MaskSchematic.java
new file mode 100644
index 000000000..fa9b81269
--- /dev/null
+++ b/src/api/java/baritone/api/schematic/MaskSchematic.java
@@ -0,0 +1,45 @@
+/*
+ * This file is part of Baritone.
+ *
+ * Baritone is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Baritone is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Baritone. If not, see .
+ */
+
+package baritone.api.schematic;
+
+import baritone.api.utils.ISchematic;
+import net.minecraft.block.state.IBlockState;
+
+import java.util.List;
+
+public abstract class MaskSchematic extends AbstractSchematic {
+
+ private final ISchematic schematic;
+
+ public MaskSchematic(ISchematic schematic) {
+ super(schematic.widthX(), schematic.heightY(), schematic.lengthZ());
+ this.schematic = schematic;
+ }
+
+ protected abstract boolean partOfMask(int x, int y, int z, IBlockState currentState);
+
+ @Override
+ public boolean inSchematic(int x, int y, int z, IBlockState currentState) {
+ return schematic.inSchematic(x, y, z, currentState) && partOfMask(x, y, z, currentState);
+ }
+
+ @Override
+ public IBlockState desiredState(int x, int y, int z, IBlockState current, List approxPlaceable) {
+ return schematic.desiredState(x, y, z, current, approxPlaceable);
+ }
+}
diff --git a/src/api/java/baritone/api/schematic/ReplaceSchematic.java b/src/api/java/baritone/api/schematic/ReplaceSchematic.java
new file mode 100644
index 000000000..988cfd7f1
--- /dev/null
+++ b/src/api/java/baritone/api/schematic/ReplaceSchematic.java
@@ -0,0 +1,42 @@
+/*
+ * This file is part of Baritone.
+ *
+ * Baritone is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Baritone is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Baritone. If not, see .
+ */
+
+package baritone.api.schematic;
+
+import baritone.api.utils.BlockOptionalMetaLookup;
+import baritone.api.utils.ISchematic;
+import net.minecraft.block.state.IBlockState;
+
+public class ReplaceSchematic extends MaskSchematic {
+
+ private final BlockOptionalMetaLookup filter;
+ private final Boolean[][][] cache;
+
+ public ReplaceSchematic(ISchematic schematic, BlockOptionalMetaLookup filter) {
+ super(schematic);
+ this.filter = filter;
+ this.cache = new Boolean[widthX()][heightY()][lengthZ()];
+ }
+
+ @Override
+ protected boolean partOfMask(int x, int y, int z, IBlockState currentState) {
+ if (cache[x][y][z] == null) {
+ cache[x][y][z] = filter.has(currentState);
+ }
+ return cache[x][y][z];
+ }
+}
diff --git a/src/api/java/baritone/api/schematic/ShellSchematic.java b/src/api/java/baritone/api/schematic/ShellSchematic.java
new file mode 100644
index 000000000..4ead61b6c
--- /dev/null
+++ b/src/api/java/baritone/api/schematic/ShellSchematic.java
@@ -0,0 +1,33 @@
+/*
+ * This file is part of Baritone.
+ *
+ * Baritone is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Baritone is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Baritone. If not, see .
+ */
+
+package baritone.api.schematic;
+
+import baritone.api.utils.ISchematic;
+import net.minecraft.block.state.IBlockState;
+
+public class ShellSchematic extends MaskSchematic {
+
+ public ShellSchematic(ISchematic schematic) {
+ super(schematic);
+ }
+
+ @Override
+ protected boolean partOfMask(int x, int y, int z, IBlockState currentState) {
+ return x == 0 || y == 0 || z == 0 || x == widthX() - 1 || y == heightY() - 1 || z == lengthZ() - 1;
+ }
+}
diff --git a/src/api/java/baritone/api/schematic/WallsSchematic.java b/src/api/java/baritone/api/schematic/WallsSchematic.java
new file mode 100644
index 000000000..e05de1e70
--- /dev/null
+++ b/src/api/java/baritone/api/schematic/WallsSchematic.java
@@ -0,0 +1,33 @@
+/*
+ * This file is part of Baritone.
+ *
+ * Baritone is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Baritone is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Baritone. If not, see .
+ */
+
+package baritone.api.schematic;
+
+import baritone.api.utils.ISchematic;
+import net.minecraft.block.state.IBlockState;
+
+public class WallsSchematic extends MaskSchematic {
+
+ public WallsSchematic(ISchematic schematic) {
+ super(schematic);
+ }
+
+ @Override
+ protected boolean partOfMask(int x, int y, int z, IBlockState currentState) {
+ return x == 0 || z == 0 || x == widthX() - 1 || z == lengthZ() - 1;
+ }
+}
diff --git a/src/api/java/baritone/api/selection/ISelection.java b/src/api/java/baritone/api/selection/ISelection.java
new file mode 100644
index 000000000..59651feb0
--- /dev/null
+++ b/src/api/java/baritone/api/selection/ISelection.java
@@ -0,0 +1,91 @@
+/*
+ * This file is part of Baritone.
+ *
+ * Baritone is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Baritone is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Baritone. If not, see .
+ */
+
+package baritone.api.selection;
+
+import baritone.api.utils.BetterBlockPos;
+import net.minecraft.util.EnumFacing;
+import net.minecraft.util.math.AxisAlignedBB;
+import net.minecraft.util.math.Vec3i;
+
+/**
+ * A selection is an immutable object representing the current selection. The selection is commonly used for certain
+ * types of build commands, however it can be used for anything.
+ */
+public interface ISelection {
+
+ /**
+ * @return The first corner of this selection. This is meant to preserve the user's original first corner.
+ */
+ BetterBlockPos pos1();
+
+ /**
+ * @return The second corner of this selection. This is meant to preserve the user's original second corner.
+ */
+ BetterBlockPos pos2();
+
+ /**
+ * @return The {@link BetterBlockPos} with the lowest x, y, and z position in the selection.
+ */
+ BetterBlockPos min();
+
+ /**
+ * @return The opposite corner from the {@link #min()}.
+ */
+ BetterBlockPos max();
+
+ /**
+ * @return The size of this ISelection.
+ */
+ Vec3i size();
+
+ /**
+ * @return An {@link AxisAlignedBB} encompassing all blocks in this selection.
+ */
+ AxisAlignedBB aabb();
+
+ /**
+ * Returns a new {@link ISelection} expanded in the specified direction by the specified number of blocks.
+ *
+ * @param direction The direction to expand the selection.
+ * @param blocks How many blocks to expand it.
+ * @return A new selection, expanded as specified.
+ */
+ ISelection expand(EnumFacing direction, int blocks);
+
+ /**
+ * Returns a new {@link ISelection} contracted in the specified direction by the specified number of blocks.
+ *
+ * Note that, for example, if the direction specified is UP, the bottom of the selection will be shifted up. If it
+ * is DOWN, the top of the selection will be shifted down.
+ *
+ * @param direction The direction to contract the selection.
+ * @param blocks How many blocks to contract it.
+ * @return A new selection, contracted as specified.
+ */
+ ISelection contract(EnumFacing direction, int blocks);
+
+ /**
+ * Returns a new {@link ISelection} shifted in the specified direction by the specified number of blocks. This moves
+ * the whole selection.
+ *
+ * @param direction The direction to shift the selection.
+ * @param blocks How many blocks to shift it.
+ * @return A new selection, shifted as specified.
+ */
+ ISelection shift(EnumFacing direction, int blocks);
+}
diff --git a/src/api/java/baritone/api/selection/ISelectionManager.java b/src/api/java/baritone/api/selection/ISelectionManager.java
new file mode 100644
index 000000000..de5ee2887
--- /dev/null
+++ b/src/api/java/baritone/api/selection/ISelectionManager.java
@@ -0,0 +1,116 @@
+/*
+ * This file is part of Baritone.
+ *
+ * Baritone is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Baritone is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Baritone. If not, see .
+ */
+
+package baritone.api.selection;
+
+import baritone.api.utils.BetterBlockPos;
+import net.minecraft.util.EnumFacing;
+
+/**
+ * The selection manager handles setting Baritone's selections. You can set the selection here, as well as retrieving
+ * the current selection.
+ */
+public interface ISelectionManager {
+
+ /**
+ * Adds a new selection. The added selection is returned.
+ *
+ * @param selection The new selection to add.
+ */
+ ISelection addSelection(ISelection selection);
+
+ /**
+ * Adds a new {@link ISelection} constructed from the given block positions. The new selection is returned.
+ *
+ * @param pos1 One corner of the selection
+ * @param pos2 The new corner of the selection
+ */
+ ISelection addSelection(BetterBlockPos pos1, BetterBlockPos pos2);
+
+ /**
+ * Removes the selection from the current selections.
+ *
+ * @param selection The selection to remove.
+ * @return The removed selection.
+ */
+ ISelection removeSelection(ISelection selection);
+
+ /**
+ * Removes all selections.
+ *
+ * @return The selections that were removed, sorted from oldest to newest..
+ */
+ ISelection[] removeAllSelections();
+
+ /**
+ * @return The current selections, sorted from oldest to newest.
+ */
+ ISelection[] getSelections();
+
+ /**
+ * For anything expecting only one selection, this method is provided. However, to enforce multi-selection support,
+ * this method will only return a selection if there is ONLY one.
+ *
+ * @return The only selection, or null if there isn't only one.
+ */
+ ISelection getOnlySelection();
+
+ /**
+ * This method will always return the last selection. ONLY use this if you want to, for example, modify the most
+ * recent selection based on user input. ALWAYS use {@link #getOnlySelection()} or, ideally,
+ * {@link #getSelections()} for retrieving the content of selections.
+ *
+ * @return The last selection, or null if it doesn't exist.
+ */
+ ISelection getLastSelection();
+
+ /**
+ * Replaces the specified {@link ISelection} with one expanded in the specified direction by the specified number of
+ * blocks. Returns the new selection.
+ *
+ * @param selection The selection to expand.
+ * @param direction The direction to expand the selection.
+ * @param blocks How many blocks to expand it.
+ * @return The new selection, expanded as specified.
+ */
+ ISelection expand(ISelection selection, EnumFacing direction, int blocks);
+
+ /**
+ * Replaces the specified {@link ISelection} with one contracted in the specified direction by the specified number
+ * of blocks.
+ *
+ * Note that, for example, if the direction specified is UP, the bottom of the selection will be shifted up. If it
+ * is DOWN, the top of the selection will be shifted down.
+ *
+ * @param selection The selection to contract.
+ * @param direction The direction to contract the selection.
+ * @param blocks How many blocks to contract it.
+ * @return The new selection, contracted as specified.
+ */
+ ISelection contract(ISelection selection, EnumFacing direction, int blocks);
+
+ /**
+ * Replaces the specified {@link ISelection} with one shifted in the specified direction by the specified number of
+ * blocks. This moves the whole selection.
+ *
+ * @param selection The selection to shift.
+ * @param direction The direction to shift the selection.
+ * @param blocks How many blocks to shift it.
+ * @return The new selection, shifted as specified.
+ */
+ ISelection shift(ISelection selection, EnumFacing direction, int blocks);
+}
diff --git a/src/api/java/baritone/api/utils/BetterBlockPos.java b/src/api/java/baritone/api/utils/BetterBlockPos.java
index 3b94a8339..a9b02445b 100644
--- a/src/api/java/baritone/api/utils/BetterBlockPos.java
+++ b/src/api/java/baritone/api/utils/BetterBlockPos.java
@@ -22,6 +22,8 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3i;
+import javax.annotation.Nonnull;
+
/**
* A better BlockPos that has fewer hash collisions (and slightly more performant offsets)
*
@@ -32,6 +34,9 @@ import net.minecraft.util.math.Vec3i;
* @author leijurv
*/
public final class BetterBlockPos extends BlockPos {
+
+ public static final BetterBlockPos ORIGIN = new BetterBlockPos(0, 0, 0);
+
public final int x;
public final int y;
public final int z;
@@ -51,6 +56,20 @@ public final class BetterBlockPos extends BlockPos {
this(pos.getX(), pos.getY(), pos.getZ());
}
+ /**
+ * Like constructor but returns null if pos is null, good if you just need to possibly censor coordinates
+ *
+ * @param pos The BlockPos, possibly null, to convert
+ * @return A BetterBlockPos or null if pos was null
+ */
+ public static BetterBlockPos from(BlockPos pos) {
+ if (pos == null) {
+ return null;
+ }
+
+ return new BetterBlockPos(pos);
+ }
+
@Override
public int hashCode() {
return (int) longHash(x, y, z);
@@ -182,4 +201,15 @@ public final class BetterBlockPos extends BlockPos {
public BetterBlockPos west(int amt) {
return amt == 0 ? this : new BetterBlockPos(x - amt, y, z);
}
+
+ @Override
+ @Nonnull
+ public String toString() {
+ return String.format(
+ "BetterBlockPos{x=%s,y=%s,z=%s}",
+ SettingsUtil.maybeCensor(x),
+ SettingsUtil.maybeCensor(y),
+ SettingsUtil.maybeCensor(z)
+ );
+ }
}
diff --git a/src/api/java/baritone/api/utils/BlockOptionalMeta.java b/src/api/java/baritone/api/utils/BlockOptionalMeta.java
new file mode 100644
index 000000000..9a1891c8c
--- /dev/null
+++ b/src/api/java/baritone/api/utils/BlockOptionalMeta.java
@@ -0,0 +1,294 @@
+/*
+ * This file is part of Baritone.
+ *
+ * Baritone is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Baritone is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Baritone. If not, see .
+ */
+
+package baritone.api.utils;
+
+import baritone.api.accessor.IItemStack;
+import com.google.common.collect.ImmutableSet;
+import net.minecraft.block.*;
+import net.minecraft.block.state.IBlockState;
+import net.minecraft.item.ItemStack;
+import net.minecraft.state.IProperty;
+import net.minecraft.state.properties.*;
+import net.minecraft.util.EnumFacing;
+import net.minecraft.util.ResourceLocation;
+import net.minecraft.util.registry.IRegistry;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.function.Consumer;
+import java.util.regex.MatchResult;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public final class BlockOptionalMeta {
+
+ private final Block block;
+ private final int meta;
+ private final boolean noMeta;
+ private final Set blockstates;
+ private final ImmutableSet stateHashes;
+ private final ImmutableSet stackHashes;
+ private static final Pattern pattern = Pattern.compile("^(.+?)(?::(\\d+))?$");
+ private static final Map