diff --git a/FEATURES.md b/FEATURES.md
index 998b546a7..397755eb4 100644
--- a/FEATURES.md
+++ b/FEATURES.md
@@ -37,11 +37,11 @@ And finally `GoalComposite`. `GoalComposite` is a list of other goals, any one o
Things it doesn't have yet
- Trapdoors
- Sprint jumping in a 1x2 corridor
+- Parkour (jumping over gaps of any length) [IN PROGRESS]
See issues for more.
Things it may not ever have, from most likely to least likely =(
-- Parkour (jumping over gaps of any length)
- Boats
- Pigs
- Horses (2x3 path instead of 1x2)
diff --git a/README.md b/README.md
index b95cc9571..ba4897ee5 100644
--- a/README.md
+++ b/README.md
@@ -17,6 +17,14 @@ the original version of the bot for Minecraft 1.8, rebuilt for 1.12.2.
## Command Line
On Mac OSX and Linux, use `./gradlew` instead of `gradlew`.
+
+Running Baritone:
+
+```
+$ gradlew run
+```
+
+Setting up for IntelliJ:
```
$ gradlew setupDecompWorkspace
$ gradlew --refresh-dependencies
diff --git a/build.gradle b/build.gradle
index bdb3c311b..8a2639f87 100755
--- a/build.gradle
+++ b/build.gradle
@@ -38,14 +38,19 @@ buildscript {
}
apply plugin: 'java'
+apply plugin: 'net.minecraftforge.gradle.tweaker-client'
+apply plugin: 'org.spongepowered.mixin'
sourceCompatibility = targetCompatibility = '1.8'
compileJava {
sourceCompatibility = targetCompatibility = '1.8'
}
-apply plugin: 'net.minecraftforge.gradle.tweaker-client'
-apply plugin: 'org.spongepowered.mixin'
+sourceSets {
+ launch {
+ compileClasspath += main.compileClasspath + main.runtimeClasspath + main.output
+ }
+}
minecraft {
version = '1.12.2'
@@ -65,7 +70,7 @@ repositories {
}
dependencies {
- runtime implementation('org.spongepowered:mixin:0.7.11-SNAPSHOT') {
+ runtime launchCompile('org.spongepowered:mixin:0.7.11-SNAPSHOT') {
// Mixin includes a lot of dependencies that are too up-to-date
exclude module: 'launchwrapper'
exclude module: 'guava'
@@ -78,5 +83,9 @@ dependencies {
mixin {
defaultObfuscationEnv notch
- add sourceSets.main, 'mixins.baritone.refmap.json'
+ add sourceSets.launch, 'mixins.baritone.refmap.json'
+}
+
+jar {
+ from sourceSets.launch.output
}
diff --git a/src/main/java/baritone/launch/BaritoneTweaker.java b/src/launch/java/baritone/launch/BaritoneTweaker.java
old mode 100755
new mode 100644
similarity index 97%
rename from src/main/java/baritone/launch/BaritoneTweaker.java
rename to src/launch/java/baritone/launch/BaritoneTweaker.java
index 04941f79a..e281ece3d
--- a/src/main/java/baritone/launch/BaritoneTweaker.java
+++ b/src/launch/java/baritone/launch/BaritoneTweaker.java
@@ -1,71 +1,71 @@
-/*
- * This file is part of Baritone.
- *
- * Baritone is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Baritone. If not, see .
- */
-
-package baritone.launch;
-
-import net.minecraft.launchwrapper.ITweaker;
-import net.minecraft.launchwrapper.LaunchClassLoader;
-import org.spongepowered.asm.launch.MixinBootstrap;
-import org.spongepowered.asm.mixin.MixinEnvironment;
-import org.spongepowered.asm.mixin.Mixins;
-import org.spongepowered.tools.obfuscation.mcp.ObfuscationServiceMCP;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Brady
- * @since 7/31/2018 9:59 PM
- */
-public class BaritoneTweaker implements ITweaker {
-
- List args;
-
- @Override
- public void acceptOptions(List args, File gameDir, File assetsDir, String profile) {
- this.args = new ArrayList<>(args);
- if (gameDir != null) addArg("gameDir", gameDir.getAbsolutePath());
- if (assetsDir != null) addArg("assetsDir", assetsDir.getAbsolutePath());
- if (profile != null) addArg("version", profile);
- }
-
- @Override
- public void injectIntoClassLoader(LaunchClassLoader classLoader) {
- MixinBootstrap.init();
- MixinEnvironment.getDefaultEnvironment().setSide(MixinEnvironment.Side.CLIENT);
- MixinEnvironment.getDefaultEnvironment().setObfuscationContext(ObfuscationServiceMCP.NOTCH);
- Mixins.addConfiguration("mixins.baritone.json");
- }
-
- @Override
- public final String getLaunchTarget() {
- return "net.minecraft.client.main.Main";
- }
-
- @Override
- public final String[] getLaunchArguments() {
- return this.args.toArray(new String[0]);
- }
-
- private void addArg(String label, String value) {
- if (!args.contains("--" + label) && value != null) {
- this.args.add("--" + label);
- this.args.add(value);
- }
- }
-}
+/*
+ * This file is part of Baritone.
+ *
+ * Baritone is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Baritone. If not, see .
+ */
+
+package baritone.launch;
+
+import net.minecraft.launchwrapper.ITweaker;
+import net.minecraft.launchwrapper.LaunchClassLoader;
+import org.spongepowered.asm.launch.MixinBootstrap;
+import org.spongepowered.asm.mixin.MixinEnvironment;
+import org.spongepowered.asm.mixin.Mixins;
+import org.spongepowered.tools.obfuscation.mcp.ObfuscationServiceMCP;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Brady
+ * @since 7/31/2018 9:59 PM
+ */
+public class BaritoneTweaker implements ITweaker {
+
+ List args;
+
+ @Override
+ public void acceptOptions(List args, File gameDir, File assetsDir, String profile) {
+ this.args = new ArrayList<>(args);
+ if (gameDir != null) addArg("gameDir", gameDir.getAbsolutePath());
+ if (assetsDir != null) addArg("assetsDir", assetsDir.getAbsolutePath());
+ if (profile != null) addArg("version", profile);
+ }
+
+ @Override
+ public void injectIntoClassLoader(LaunchClassLoader classLoader) {
+ MixinBootstrap.init();
+ MixinEnvironment.getDefaultEnvironment().setSide(MixinEnvironment.Side.CLIENT);
+ MixinEnvironment.getDefaultEnvironment().setObfuscationContext(ObfuscationServiceMCP.NOTCH);
+ Mixins.addConfiguration("mixins.baritone.json");
+ }
+
+ @Override
+ public final String getLaunchTarget() {
+ return "net.minecraft.client.main.Main";
+ }
+
+ @Override
+ public final String[] getLaunchArguments() {
+ return this.args.toArray(new String[0]);
+ }
+
+ private void addArg(String label, String value) {
+ if (!args.contains("--" + label) && value != null) {
+ this.args.add("--" + label);
+ this.args.add(value);
+ }
+ }
+}
diff --git a/src/main/java/baritone/launch/BaritoneTweakerForge.java b/src/launch/java/baritone/launch/BaritoneTweakerForge.java
old mode 100755
new mode 100644
similarity index 97%
rename from src/main/java/baritone/launch/BaritoneTweakerForge.java
rename to src/launch/java/baritone/launch/BaritoneTweakerForge.java
index 9a45520c2..c16990582
--- a/src/main/java/baritone/launch/BaritoneTweakerForge.java
+++ b/src/launch/java/baritone/launch/BaritoneTweakerForge.java
@@ -1,44 +1,44 @@
-/*
- * This file is part of Baritone.
- *
- * Baritone is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Baritone. If not, see .
- */
-
-package baritone.launch;
-
-import net.minecraft.launchwrapper.LaunchClassLoader;
-import org.spongepowered.asm.mixin.MixinEnvironment;
-import org.spongepowered.tools.obfuscation.mcp.ObfuscationServiceMCP;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Brady
- * @since 7/31/2018 10:09 PM
- */
-public class BaritoneTweakerForge extends BaritoneTweaker {
-
- @Override
- public final void acceptOptions(List args, File gameDir, File assetsDir, String profile) {
- this.args = new ArrayList<>();
- }
-
- @Override
- public final void injectIntoClassLoader(LaunchClassLoader classLoader) {
- super.injectIntoClassLoader(classLoader);
- MixinEnvironment.getDefaultEnvironment().setObfuscationContext(ObfuscationServiceMCP.SEARGE);
- }
-}
+/*
+ * This file is part of Baritone.
+ *
+ * Baritone is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Baritone. If not, see .
+ */
+
+package baritone.launch;
+
+import net.minecraft.launchwrapper.LaunchClassLoader;
+import org.spongepowered.asm.mixin.MixinEnvironment;
+import org.spongepowered.tools.obfuscation.mcp.ObfuscationServiceMCP;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Brady
+ * @since 7/31/2018 10:09 PM
+ */
+public class BaritoneTweakerForge extends BaritoneTweaker {
+
+ @Override
+ public final void acceptOptions(List args, File gameDir, File assetsDir, String profile) {
+ this.args = new ArrayList<>();
+ }
+
+ @Override
+ public final void injectIntoClassLoader(LaunchClassLoader classLoader) {
+ super.injectIntoClassLoader(classLoader);
+ MixinEnvironment.getDefaultEnvironment().setObfuscationContext(ObfuscationServiceMCP.SEARGE);
+ }
+}
diff --git a/src/main/java/baritone/launch/BaritoneTweakerOptifine.java b/src/launch/java/baritone/launch/BaritoneTweakerOptifine.java
old mode 100755
new mode 100644
similarity index 96%
rename from src/main/java/baritone/launch/BaritoneTweakerOptifine.java
rename to src/launch/java/baritone/launch/BaritoneTweakerOptifine.java
index 380a0b0f3..8d0872aa3
--- a/src/main/java/baritone/launch/BaritoneTweakerOptifine.java
+++ b/src/launch/java/baritone/launch/BaritoneTweakerOptifine.java
@@ -1,34 +1,34 @@
-/*
- * This file is part of Baritone.
- *
- * Baritone is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Baritone. If not, see .
- */
-
-package baritone.launch;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Brady
- * @since 7/31/2018 10:10 PM
- */
-public class BaritoneTweakerOptifine extends BaritoneTweaker {
-
- @Override
- public final void acceptOptions(List args, File gameDir, File assetsDir, String profile) {
- this.args = new ArrayList<>();
- }
-}
+/*
+ * This file is part of Baritone.
+ *
+ * Baritone is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Baritone. If not, see .
+ */
+
+package baritone.launch;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Brady
+ * @since 7/31/2018 10:10 PM
+ */
+public class BaritoneTweakerOptifine extends BaritoneTweaker {
+
+ @Override
+ public final void acceptOptions(List args, File gameDir, File assetsDir, String profile) {
+ this.args = new ArrayList<>();
+ }
+}
diff --git a/src/main/java/baritone/launch/mixins/MixinAnvilChunkLoader.java b/src/launch/java/baritone/launch/mixins/MixinAnvilChunkLoader.java
similarity index 65%
rename from src/main/java/baritone/launch/mixins/MixinAnvilChunkLoader.java
rename to src/launch/java/baritone/launch/mixins/MixinAnvilChunkLoader.java
index 96f38b87b..3133c9cd6 100644
--- a/src/main/java/baritone/launch/mixins/MixinAnvilChunkLoader.java
+++ b/src/launch/java/baritone/launch/mixins/MixinAnvilChunkLoader.java
@@ -15,6 +15,23 @@
* along with Baritone. If not, see .
*/
+/*
+ * This file is part of Baritone.
+ *
+ * Baritone is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Baritone. If not, see .
+ */
+
package baritone.launch.mixins;
import baritone.utils.accessor.IAnvilChunkLoader;
diff --git a/src/main/java/baritone/launch/mixins/MixinBlockPos.java b/src/launch/java/baritone/launch/mixins/MixinBlockPos.java
similarity index 96%
rename from src/main/java/baritone/launch/mixins/MixinBlockPos.java
rename to src/launch/java/baritone/launch/mixins/MixinBlockPos.java
index 1cf52132b..49e01c966 100644
--- a/src/main/java/baritone/launch/mixins/MixinBlockPos.java
+++ b/src/launch/java/baritone/launch/mixins/MixinBlockPos.java
@@ -29,7 +29,7 @@ import javax.annotation.Nonnull;
* @since 8/25/2018
*/
@Mixin(BlockPos.class)
-public abstract class MixinBlockPos extends Vec3i {
+public class MixinBlockPos extends Vec3i {
public MixinBlockPos(int xIn, int yIn, int zIn) {
super(xIn, yIn, zIn);
diff --git a/src/main/java/baritone/launch/mixins/MixinChunkProviderServer.java b/src/launch/java/baritone/launch/mixins/MixinChunkProviderServer.java
similarity index 65%
rename from src/main/java/baritone/launch/mixins/MixinChunkProviderServer.java
rename to src/launch/java/baritone/launch/mixins/MixinChunkProviderServer.java
index 9a454d01c..41f904810 100644
--- a/src/main/java/baritone/launch/mixins/MixinChunkProviderServer.java
+++ b/src/launch/java/baritone/launch/mixins/MixinChunkProviderServer.java
@@ -15,6 +15,23 @@
* along with Baritone. If not, see .
*/
+/*
+ * This file is part of Baritone.
+ *
+ * Baritone is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Baritone. If not, see .
+ */
+
package baritone.launch.mixins;
import baritone.utils.accessor.IChunkProviderServer;
diff --git a/src/main/java/baritone/launch/mixins/MixinEntity.java b/src/launch/java/baritone/launch/mixins/MixinEntity.java
similarity index 100%
rename from src/main/java/baritone/launch/mixins/MixinEntity.java
rename to src/launch/java/baritone/launch/mixins/MixinEntity.java
diff --git a/src/main/java/baritone/launch/mixins/MixinEntityPlayerSP.java b/src/launch/java/baritone/launch/mixins/MixinEntityPlayerSP.java
similarity index 100%
rename from src/main/java/baritone/launch/mixins/MixinEntityPlayerSP.java
rename to src/launch/java/baritone/launch/mixins/MixinEntityPlayerSP.java
diff --git a/src/main/java/baritone/launch/mixins/MixinEntityRenderer.java b/src/launch/java/baritone/launch/mixins/MixinEntityRenderer.java
similarity index 100%
rename from src/main/java/baritone/launch/mixins/MixinEntityRenderer.java
rename to src/launch/java/baritone/launch/mixins/MixinEntityRenderer.java
diff --git a/src/main/java/baritone/launch/mixins/MixinGameSettings.java b/src/launch/java/baritone/launch/mixins/MixinGameSettings.java
old mode 100755
new mode 100644
similarity index 97%
rename from src/main/java/baritone/launch/mixins/MixinGameSettings.java
rename to src/launch/java/baritone/launch/mixins/MixinGameSettings.java
index b68cce516..f5bae8ef2
--- a/src/main/java/baritone/launch/mixins/MixinGameSettings.java
+++ b/src/launch/java/baritone/launch/mixins/MixinGameSettings.java
@@ -1,44 +1,44 @@
-/*
- * This file is part of Baritone.
- *
- * Baritone is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Baritone. If not, see .
- */
-
-package baritone.launch.mixins;
-
-import baritone.Baritone;
-import net.minecraft.client.settings.GameSettings;
-import org.spongepowered.asm.mixin.Mixin;
-import org.spongepowered.asm.mixin.injection.At;
-import org.spongepowered.asm.mixin.injection.Redirect;
-
-/**
- * @author Brady
- * @since 8/1/2018 12:28 AM
- */
-@Mixin(GameSettings.class)
-public class MixinGameSettings {
-
- @Redirect(
- method = "isKeyDown",
- at = @At(
- value = "INVOKE",
- target = "org/lwjgl/input/Keyboard.isKeyDown(I)Z",
- remap = false
- )
- )
- private static boolean isKeyDown(int keyCode) {
- return Baritone.INSTANCE.getInputOverrideHandler().isKeyDown(keyCode);
- }
-}
+/*
+ * This file is part of Baritone.
+ *
+ * Baritone is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Baritone. If not, see .
+ */
+
+package baritone.launch.mixins;
+
+import baritone.Baritone;
+import net.minecraft.client.settings.GameSettings;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Redirect;
+
+/**
+ * @author Brady
+ * @since 8/1/2018 12:28 AM
+ */
+@Mixin(GameSettings.class)
+public class MixinGameSettings {
+
+ @Redirect(
+ method = "isKeyDown",
+ at = @At(
+ value = "INVOKE",
+ target = "org/lwjgl/input/Keyboard.isKeyDown(I)Z",
+ remap = false
+ )
+ )
+ private static boolean isKeyDown(int keyCode) {
+ return Baritone.INSTANCE.getInputOverrideHandler().isKeyDown(keyCode);
+ }
+}
diff --git a/src/main/java/baritone/launch/mixins/MixinGuiContainer.java b/src/launch/java/baritone/launch/mixins/MixinGuiContainer.java
old mode 100755
new mode 100644
similarity index 96%
rename from src/main/java/baritone/launch/mixins/MixinGuiContainer.java
rename to src/launch/java/baritone/launch/mixins/MixinGuiContainer.java
index dd9bf715e..c2c62d76a
--- a/src/main/java/baritone/launch/mixins/MixinGuiContainer.java
+++ b/src/launch/java/baritone/launch/mixins/MixinGuiContainer.java
@@ -1,47 +1,47 @@
-/*
- * This file is part of Baritone.
- *
- * Baritone is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Baritone. If not, see .
- */
-
-package baritone.launch.mixins;
-
-import baritone.Baritone;
-import net.minecraft.client.gui.inventory.GuiContainer;
-import org.spongepowered.asm.mixin.Mixin;
-import org.spongepowered.asm.mixin.injection.At;
-import org.spongepowered.asm.mixin.injection.Redirect;
-
-/**
- * @author Brady
- * @since 7/31/2018 10:47 PM
- */
-@Mixin(GuiContainer.class)
-public class MixinGuiContainer {
-
- @Redirect(
- method = {
- "mouseClicked",
- "mouseReleased"
- },
- at = @At(
- value = "INVOKE",
- target = "org/lwjgl/input/Keyboard.isKeyDown(I)Z",
- remap = false
- )
- )
- private boolean isKeyDown(int keyCode) {
- return Baritone.INSTANCE.getInputOverrideHandler().isKeyDown(keyCode);
- }
-}
+/*
+ * This file is part of Baritone.
+ *
+ * Baritone is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Baritone. If not, see .
+ */
+
+package baritone.launch.mixins;
+
+import baritone.Baritone;
+import net.minecraft.client.gui.inventory.GuiContainer;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Redirect;
+
+/**
+ * @author Brady
+ * @since 7/31/2018 10:47 PM
+ */
+@Mixin(GuiContainer.class)
+public class MixinGuiContainer {
+
+ @Redirect(
+ method = {
+ "mouseClicked",
+ "mouseReleased"
+ },
+ at = @At(
+ value = "INVOKE",
+ target = "org/lwjgl/input/Keyboard.isKeyDown(I)Z",
+ remap = false
+ )
+ )
+ private boolean isKeyDown(int keyCode) {
+ return Baritone.INSTANCE.getInputOverrideHandler().isKeyDown(keyCode);
+ }
+}
diff --git a/src/main/java/baritone/launch/mixins/MixinGuiScreen.java b/src/launch/java/baritone/launch/mixins/MixinGuiScreen.java
old mode 100755
new mode 100644
similarity index 96%
rename from src/main/java/baritone/launch/mixins/MixinGuiScreen.java
rename to src/launch/java/baritone/launch/mixins/MixinGuiScreen.java
index 478770583..11a3e7f4b
--- a/src/main/java/baritone/launch/mixins/MixinGuiScreen.java
+++ b/src/launch/java/baritone/launch/mixins/MixinGuiScreen.java
@@ -1,48 +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 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Baritone. If not, see .
- */
-
-package baritone.launch.mixins;
-
-import baritone.Baritone;
-import net.minecraft.client.gui.GuiScreen;
-import org.spongepowered.asm.mixin.Mixin;
-import org.spongepowered.asm.mixin.injection.At;
-import org.spongepowered.asm.mixin.injection.Redirect;
-
-/**
- * @author Brady
- * @since 7/31/2018 10:38 PM
- */
-@Mixin(GuiScreen.class)
-public class MixinGuiScreen {
-
- @Redirect(
- method = {
- "isCtrlKeyDown",
- "isShiftKeyDown",
- "isAltKeyDown"
- },
- at = @At(
- value = "INVOKE",
- target = "org/lwjgl/input/Keyboard.isKeyDown(I)Z",
- remap = false
- )
- )
- private static boolean isKeyDown(int keyCode) {
- return Baritone.INSTANCE.getInputOverrideHandler().isKeyDown(keyCode);
- }
-}
+/*
+ * This file is part of Baritone.
+ *
+ * Baritone is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Baritone. If not, see .
+ */
+
+package baritone.launch.mixins;
+
+import baritone.Baritone;
+import net.minecraft.client.gui.GuiScreen;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Redirect;
+
+/**
+ * @author Brady
+ * @since 7/31/2018 10:38 PM
+ */
+@Mixin(GuiScreen.class)
+public class MixinGuiScreen {
+
+ @Redirect(
+ method = {
+ "isCtrlKeyDown",
+ "isShiftKeyDown",
+ "isAltKeyDown"
+ },
+ at = @At(
+ value = "INVOKE",
+ target = "org/lwjgl/input/Keyboard.isKeyDown(I)Z",
+ remap = false
+ )
+ )
+ private static boolean isKeyDown(int keyCode) {
+ return Baritone.INSTANCE.getInputOverrideHandler().isKeyDown(keyCode);
+ }
+}
diff --git a/src/main/java/baritone/launch/mixins/MixinKeyBinding.java b/src/launch/java/baritone/launch/mixins/MixinKeyBinding.java
old mode 100755
new mode 100644
similarity index 94%
rename from src/main/java/baritone/launch/mixins/MixinKeyBinding.java
rename to src/launch/java/baritone/launch/mixins/MixinKeyBinding.java
index 085ddc747..838802cd7
--- a/src/main/java/baritone/launch/mixins/MixinKeyBinding.java
+++ b/src/launch/java/baritone/launch/mixins/MixinKeyBinding.java
@@ -1,43 +1,43 @@
-/*
- * This file is part of Baritone.
- *
- * Baritone is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Baritone. If not, see .
- */
-
-package baritone.launch.mixins;
-
-import baritone.Baritone;
-import net.minecraft.client.settings.KeyBinding;
-import org.spongepowered.asm.mixin.Mixin;
-import org.spongepowered.asm.mixin.injection.At;
-import org.spongepowered.asm.mixin.injection.Inject;
-import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
-
-/**
- * @author Brady
- * @since 7/31/2018 11:44 PM
- */
-@Mixin(KeyBinding.class)
-public abstract class MixinKeyBinding {
-
- @Inject(
- method = "isKeyDown",
- at = @At("HEAD"),
- cancellable = true
- )
- private void isKeyDown(CallbackInfoReturnable cir) {
- if (Baritone.INSTANCE.getInputOverrideHandler().isInputForcedDown((KeyBinding) (Object) this))
- cir.setReturnValue(true);
- }
-}
+/*
+ * This file is part of Baritone.
+ *
+ * Baritone is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Baritone. If not, see .
+ */
+
+package baritone.launch.mixins;
+
+import baritone.Baritone;
+import net.minecraft.client.settings.KeyBinding;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
+
+/**
+ * @author Brady
+ * @since 7/31/2018 11:44 PM
+ */
+@Mixin(KeyBinding.class)
+public class MixinKeyBinding {
+
+ @Inject(
+ method = "isKeyDown",
+ at = @At("HEAD"),
+ cancellable = true
+ )
+ private void isKeyDown(CallbackInfoReturnable cir) {
+ if (Baritone.INSTANCE.getInputOverrideHandler().isInputForcedDown((KeyBinding) (Object) this))
+ cir.setReturnValue(true);
+ }
+}
diff --git a/src/main/java/baritone/launch/mixins/MixinMinecraft.java b/src/launch/java/baritone/launch/mixins/MixinMinecraft.java
old mode 100755
new mode 100644
similarity index 97%
rename from src/main/java/baritone/launch/mixins/MixinMinecraft.java
rename to src/launch/java/baritone/launch/mixins/MixinMinecraft.java
index 49c587ba9..bc4195162
--- a/src/main/java/baritone/launch/mixins/MixinMinecraft.java
+++ b/src/launch/java/baritone/launch/mixins/MixinMinecraft.java
@@ -1,176 +1,176 @@
-/*
- * This file is part of Baritone.
- *
- * Baritone is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Baritone. If not, see .
- */
-
-package baritone.launch.mixins;
-
-import baritone.Baritone;
-import baritone.api.event.events.BlockInteractEvent;
-import baritone.api.event.events.TickEvent;
-import baritone.api.event.events.WorldEvent;
-import baritone.api.event.events.type.EventState;
-import baritone.behavior.impl.PathingBehavior;
-import baritone.utils.ExampleBaritoneControl;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.entity.EntityPlayerSP;
-import net.minecraft.client.gui.GuiScreen;
-import net.minecraft.client.multiplayer.WorldClient;
-import net.minecraft.item.ItemStack;
-import net.minecraft.util.EnumActionResult;
-import net.minecraft.util.EnumHand;
-import net.minecraft.util.math.BlockPos;
-import org.spongepowered.asm.lib.Opcodes;
-import org.spongepowered.asm.mixin.Mixin;
-import org.spongepowered.asm.mixin.Shadow;
-import org.spongepowered.asm.mixin.injection.At;
-import org.spongepowered.asm.mixin.injection.Inject;
-import org.spongepowered.asm.mixin.injection.Redirect;
-import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
-import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
-
-/**
- * @author Brady
- * @since 7/31/2018 10:51 PM
- */
-@Mixin(Minecraft.class)
-public class MixinMinecraft {
-
- @Shadow
- private int leftClickCounter;
- @Shadow
- public EntityPlayerSP player;
- @Shadow
- public WorldClient world;
-
- @Inject(
- method = "init",
- at = @At("RETURN")
- )
- private void init(CallbackInfo ci) {
- Baritone.INSTANCE.init();
- ExampleBaritoneControl.INSTANCE.initAndRegister();
- }
-
- @Inject(
- method = "runTick",
- at = @At(
- value = "FIELD",
- opcode = Opcodes.GETFIELD,
- target = "net/minecraft/client/Minecraft.currentScreen:Lnet/minecraft/client/gui/GuiScreen;",
- ordinal = 5,
- shift = At.Shift.BY,
- by = -3
- )
- )
- private void runTick(CallbackInfo ci) {
- Minecraft mc = (Minecraft) (Object) this;
- Baritone.INSTANCE.getGameEventHandler().onTick(new TickEvent(
- EventState.PRE,
- (mc.player != null && mc.world != null)
- ? TickEvent.Type.IN
- : TickEvent.Type.OUT
- ));
- }
-
- @Redirect(
- method = "runTickKeyboard",
- at = @At(
- value = "INVOKE",
- target = "org/lwjgl/input/Keyboard.isKeyDown(I)Z",
- remap = false
- )
- )
- private boolean Keyboard$isKeyDown(int keyCode) {
- return Baritone.INSTANCE.getInputOverrideHandler().isKeyDown(keyCode);
- }
-
- @Inject(
- method = "processKeyBinds",
- at = @At("HEAD")
- )
- private void runTickKeyboard(CallbackInfo ci) {
- Baritone.INSTANCE.getGameEventHandler().onProcessKeyBinds();
- }
-
- @Inject(
- method = "loadWorld(Lnet/minecraft/client/multiplayer/WorldClient;Ljava/lang/String;)V",
- at = @At("HEAD")
- )
- private void preLoadWorld(WorldClient world, String loadingMessage, CallbackInfo ci) {
- // If we're unloading the world but one doesn't exist, ignore it
- if (this.world == null && world == null) {
- return;
- }
-
- Baritone.INSTANCE.getGameEventHandler().onWorldEvent(
- new WorldEvent(
- world,
- EventState.PRE
- )
- );
- }
-
- @Inject(
- method = "loadWorld(Lnet/minecraft/client/multiplayer/WorldClient;Ljava/lang/String;)V",
- at = @At("RETURN")
- )
- private void postLoadWorld(WorldClient world, String loadingMessage, CallbackInfo ci) {
- // still fire event for both null, as that means we've just finished exiting a world
-
- Baritone.INSTANCE.getGameEventHandler().onWorldEvent(
- new WorldEvent(
- world,
- EventState.POST
- )
- );
- }
-
- @Redirect(
- method = "runTick",
- at = @At(
- value = "FIELD",
- opcode = Opcodes.GETFIELD,
- target = "net/minecraft/client/gui/GuiScreen.allowUserInput:Z"
- )
- )
- private boolean isAllowUserInput(GuiScreen screen) {
- return (PathingBehavior.INSTANCE.getCurrent() != null && player != null) || screen.allowUserInput;
- }
-
- @Inject(
- method = "clickMouse",
- at = @At(
- value = "INVOKE",
- target = "net/minecraft/client/multiplayer/PlayerControllerMP.clickBlock(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/EnumFacing;)Z"
- ),
- locals = LocalCapture.CAPTURE_FAILHARD
- )
- private void onBlockBreak(CallbackInfo ci, BlockPos pos) {
- Baritone.INSTANCE.getGameEventHandler().onBlockInteract(new BlockInteractEvent(pos, BlockInteractEvent.Type.BREAK));
- }
-
- @Inject(
- method = "rightClickMouse",
- at = @At(
- value = "INVOKE",
- target = "net/minecraft/client/entity/EntityPlayerSP.swingArm(Lnet/minecraft/util/EnumHand;)V"
- ),
- locals = LocalCapture.CAPTURE_FAILHARD
- )
- private void onBlockUse(CallbackInfo ci, EnumHand var1[], int var2, int var3, EnumHand enumhand, ItemStack itemstack, BlockPos blockpos, int i, EnumActionResult enumactionresult) {
- Baritone.INSTANCE.getGameEventHandler().onBlockInteract(new BlockInteractEvent(blockpos, BlockInteractEvent.Type.USE));
- }
-}
+/*
+ * This file is part of Baritone.
+ *
+ * Baritone is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Baritone. If not, see .
+ */
+
+package baritone.launch.mixins;
+
+import baritone.Baritone;
+import baritone.api.event.events.BlockInteractEvent;
+import baritone.api.event.events.TickEvent;
+import baritone.api.event.events.WorldEvent;
+import baritone.api.event.events.type.EventState;
+import baritone.behavior.impl.PathingBehavior;
+import baritone.utils.ExampleBaritoneControl;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.entity.EntityPlayerSP;
+import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.client.multiplayer.WorldClient;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.EnumActionResult;
+import net.minecraft.util.EnumHand;
+import net.minecraft.util.math.BlockPos;
+import org.spongepowered.asm.lib.Opcodes;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.Shadow;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.Redirect;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
+import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
+
+/**
+ * @author Brady
+ * @since 7/31/2018 10:51 PM
+ */
+@Mixin(Minecraft.class)
+public class MixinMinecraft {
+
+ @Shadow
+ private int leftClickCounter;
+ @Shadow
+ public EntityPlayerSP player;
+ @Shadow
+ public WorldClient world;
+
+ @Inject(
+ method = "init",
+ at = @At("RETURN")
+ )
+ private void init(CallbackInfo ci) {
+ Baritone.INSTANCE.init();
+ ExampleBaritoneControl.INSTANCE.initAndRegister();
+ }
+
+ @Inject(
+ method = "runTick",
+ at = @At(
+ value = "FIELD",
+ opcode = Opcodes.GETFIELD,
+ target = "net/minecraft/client/Minecraft.currentScreen:Lnet/minecraft/client/gui/GuiScreen;",
+ ordinal = 5,
+ shift = At.Shift.BY,
+ by = -3
+ )
+ )
+ private void runTick(CallbackInfo ci) {
+ Minecraft mc = (Minecraft) (Object) this;
+ Baritone.INSTANCE.getGameEventHandler().onTick(new TickEvent(
+ EventState.PRE,
+ (mc.player != null && mc.world != null)
+ ? TickEvent.Type.IN
+ : TickEvent.Type.OUT
+ ));
+ }
+
+ @Redirect(
+ method = "runTickKeyboard",
+ at = @At(
+ value = "INVOKE",
+ target = "org/lwjgl/input/Keyboard.isKeyDown(I)Z",
+ remap = false
+ )
+ )
+ private boolean Keyboard$isKeyDown(int keyCode) {
+ return Baritone.INSTANCE.getInputOverrideHandler().isKeyDown(keyCode);
+ }
+
+ @Inject(
+ method = "processKeyBinds",
+ at = @At("HEAD")
+ )
+ private void runTickKeyboard(CallbackInfo ci) {
+ Baritone.INSTANCE.getGameEventHandler().onProcessKeyBinds();
+ }
+
+ @Inject(
+ method = "loadWorld(Lnet/minecraft/client/multiplayer/WorldClient;Ljava/lang/String;)V",
+ at = @At("HEAD")
+ )
+ private void preLoadWorld(WorldClient world, String loadingMessage, CallbackInfo ci) {
+ // If we're unloading the world but one doesn't exist, ignore it
+ if (this.world == null && world == null) {
+ return;
+ }
+
+ Baritone.INSTANCE.getGameEventHandler().onWorldEvent(
+ new WorldEvent(
+ world,
+ EventState.PRE
+ )
+ );
+ }
+
+ @Inject(
+ method = "loadWorld(Lnet/minecraft/client/multiplayer/WorldClient;Ljava/lang/String;)V",
+ at = @At("RETURN")
+ )
+ private void postLoadWorld(WorldClient world, String loadingMessage, CallbackInfo ci) {
+ // still fire event for both null, as that means we've just finished exiting a world
+
+ Baritone.INSTANCE.getGameEventHandler().onWorldEvent(
+ new WorldEvent(
+ world,
+ EventState.POST
+ )
+ );
+ }
+
+ @Redirect(
+ method = "runTick",
+ at = @At(
+ value = "FIELD",
+ opcode = Opcodes.GETFIELD,
+ target = "net/minecraft/client/gui/GuiScreen.allowUserInput:Z"
+ )
+ )
+ private boolean isAllowUserInput(GuiScreen screen) {
+ return (PathingBehavior.INSTANCE.getCurrent() != null && player != null) || screen.allowUserInput;
+ }
+
+ @Inject(
+ method = "clickMouse",
+ at = @At(
+ value = "INVOKE",
+ target = "net/minecraft/client/multiplayer/PlayerControllerMP.clickBlock(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/EnumFacing;)Z"
+ ),
+ locals = LocalCapture.CAPTURE_FAILHARD
+ )
+ private void onBlockBreak(CallbackInfo ci, BlockPos pos) {
+ Baritone.INSTANCE.getGameEventHandler().onBlockInteract(new BlockInteractEvent(pos, BlockInteractEvent.Type.BREAK));
+ }
+
+ @Inject(
+ method = "rightClickMouse",
+ at = @At(
+ value = "INVOKE",
+ target = "net/minecraft/client/entity/EntityPlayerSP.swingArm(Lnet/minecraft/util/EnumHand;)V"
+ ),
+ locals = LocalCapture.CAPTURE_FAILHARD
+ )
+ private void onBlockUse(CallbackInfo ci, EnumHand var1[], int var2, int var3, EnumHand enumhand, ItemStack itemstack, BlockPos blockpos, int i, EnumActionResult enumactionresult) {
+ Baritone.INSTANCE.getGameEventHandler().onBlockInteract(new BlockInteractEvent(blockpos, BlockInteractEvent.Type.USE));
+ }
+}
diff --git a/src/main/java/baritone/launch/mixins/MixinNetHandlerPlayClient.java b/src/launch/java/baritone/launch/mixins/MixinNetHandlerPlayClient.java
similarity index 100%
rename from src/main/java/baritone/launch/mixins/MixinNetHandlerPlayClient.java
rename to src/launch/java/baritone/launch/mixins/MixinNetHandlerPlayClient.java
diff --git a/src/main/java/baritone/launch/mixins/MixinNetworkManager.java b/src/launch/java/baritone/launch/mixins/MixinNetworkManager.java
similarity index 94%
rename from src/main/java/baritone/launch/mixins/MixinNetworkManager.java
rename to src/launch/java/baritone/launch/mixins/MixinNetworkManager.java
index 472d4f04b..46664e7c5 100644
--- a/src/main/java/baritone/launch/mixins/MixinNetworkManager.java
+++ b/src/launch/java/baritone/launch/mixins/MixinNetworkManager.java
@@ -37,12 +37,10 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
* @since 8/6/2018 9:30 PM
*/
@Mixin(NetworkManager.class)
-public abstract class MixinNetworkManager {
+public class MixinNetworkManager {
@Shadow private Channel channel;
- @Shadow protected abstract void channelRead0(ChannelHandlerContext p_channelRead0_1_, Packet> p_channelRead0_2_) throws Exception;
-
@Inject(
method = "dispatchPacket",
at = @At("HEAD")
diff --git a/src/main/java/baritone/launch/mixins/MixinWorldClient.java b/src/launch/java/baritone/launch/mixins/MixinWorldClient.java
similarity index 100%
rename from src/main/java/baritone/launch/mixins/MixinWorldClient.java
rename to src/launch/java/baritone/launch/mixins/MixinWorldClient.java
diff --git a/src/main/resources/mixins.baritone.json b/src/launch/resources/mixins.baritone.json
old mode 100755
new mode 100644
similarity index 91%
rename from src/main/resources/mixins.baritone.json
rename to src/launch/resources/mixins.baritone.json
index 989c9355e..b1a8ed316
--- a/src/main/resources/mixins.baritone.json
+++ b/src/launch/resources/mixins.baritone.json
@@ -1,27 +1,26 @@
-{
- "required": true,
- "package": "baritone.launch.mixins",
- "refmap": "mixins.baritone.refmap.json",
- "compatibilityLevel": "JAVA_8",
- "verbose": false,
- "injectors": {
- "maxShiftBy": 2
- },
- "client": [
- "MixinAnvilChunkLoader",
- "MixinBlockPos",
- "MixinChunkProviderServer",
- "MixinEntity",
- "MixinEntityPlayerSP",
- "MixinEntityRenderer",
- "MixinGameSettings",
- "MixinGuiContainer",
- "MixinGuiScreen",
- "MixinInventoryPlayer",
- "MixinKeyBinding",
- "MixinMinecraft",
- "MixinNetHandlerPlayClient",
- "MixinNetworkManager",
- "MixinWorldClient"
- ]
+{
+ "required": true,
+ "package": "baritone.launch.mixins",
+ "refmap": "mixins.baritone.refmap.json",
+ "compatibilityLevel": "JAVA_8",
+ "verbose": false,
+ "injectors": {
+ "maxShiftBy": 2
+ },
+ "client": [
+ "MixinAnvilChunkLoader",
+ "MixinBlockPos",
+ "MixinChunkProviderServer",
+ "MixinEntity",
+ "MixinEntityPlayerSP",
+ "MixinEntityRenderer",
+ "MixinGameSettings",
+ "MixinGuiContainer",
+ "MixinGuiScreen",
+ "MixinKeyBinding",
+ "MixinMinecraft",
+ "MixinNetHandlerPlayClient",
+ "MixinNetworkManager",
+ "MixinWorldClient"
+ ]
}
\ No newline at end of file
diff --git a/src/main/java/baritone/Baritone.java b/src/main/java/baritone/Baritone.java
index 0b571264e..5baacec80 100755
--- a/src/main/java/baritone/Baritone.java
+++ b/src/main/java/baritone/Baritone.java
@@ -21,7 +21,6 @@ import baritone.api.event.GameEventHandler;
import baritone.behavior.Behavior;
import baritone.behavior.impl.*;
import baritone.utils.InputOverrideHandler;
-import baritone.utils.ToolSet;
import net.minecraft.client.Minecraft;
import java.io.File;
@@ -82,7 +81,6 @@ public enum Baritone {
registerBehavior(LocationTrackingBehavior.INSTANCE);
registerBehavior(FollowBehavior.INSTANCE);
registerBehavior(MineBehavior.INSTANCE);
- this.gameEventHandler.registerEventListener(ToolSet.INTERNAL_EVENT_LISTENER);
}
this.dir = new File(Minecraft.getMinecraft().gameDir, "baritone");
if (!Files.exists(dir.toPath())) {
diff --git a/src/main/java/baritone/Settings.java b/src/main/java/baritone/Settings.java
index 2e6f0e398..1eed43334 100644
--- a/src/main/java/baritone/Settings.java
+++ b/src/main/java/baritone/Settings.java
@@ -83,6 +83,11 @@ public class Settings {
*/
public Setting allowWalkOnBottomSlab = new Setting<>(true);
+ /**
+ * For example, if you have Mining Fatigue or Haste, adjust the costs of breaking blocks accordingly.
+ */
+ public Setting considerPotionEffects = new Setting<>(true);
+
/**
* This is the big A* setting.
* As long as your cost heuristic is an *underestimate*, it's guaranteed to find you the best path.
diff --git a/src/main/java/baritone/api/event/GameEventHandler.java b/src/main/java/baritone/api/event/GameEventHandler.java
index 45e86885c..1ec2d8345 100644
--- a/src/main/java/baritone/api/event/GameEventHandler.java
+++ b/src/main/java/baritone/api/event/GameEventHandler.java
@@ -159,11 +159,6 @@ public final class GameEventHandler implements IGameEventListener, Helper {
dispatch(listener -> listener.onReceivePacket(event));
}
- @Override
- public final void onQueryItemSlotForBlocks(ItemSlotEvent event) {
- dispatch(listener -> listener.onQueryItemSlotForBlocks(event));
- }
-
@Override
public void onPlayerRelativeMove(RelativeMoveEvent event) {
dispatch(listener -> listener.onPlayerRelativeMove(event));
diff --git a/src/main/java/baritone/api/event/listener/AbstractGameEventListener.java b/src/main/java/baritone/api/event/listener/AbstractGameEventListener.java
index b47468bd3..3b228e9d4 100644
--- a/src/main/java/baritone/api/event/listener/AbstractGameEventListener.java
+++ b/src/main/java/baritone/api/event/listener/AbstractGameEventListener.java
@@ -74,9 +74,6 @@ public interface AbstractGameEventListener extends IGameEventListener {
@Override
default void onReceivePacket(PacketEvent event) {}
- @Override
- default void onQueryItemSlotForBlocks(ItemSlotEvent event) {}
-
@Override
default void onPlayerRelativeMove(RelativeMoveEvent event) {}
diff --git a/src/main/java/baritone/api/event/listener/IGameEventListener.java b/src/main/java/baritone/api/event/listener/IGameEventListener.java
index 9be19aabf..81f917742 100644
--- a/src/main/java/baritone/api/event/listener/IGameEventListener.java
+++ b/src/main/java/baritone/api/event/listener/IGameEventListener.java
@@ -36,7 +36,6 @@ package baritone.api.event.listener;
import baritone.api.event.events.*;
import io.netty.util.concurrent.GenericFutureListener;
-import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.gui.GuiGameOver;
@@ -44,7 +43,6 @@ import net.minecraft.client.multiplayer.WorldClient;
import net.minecraft.client.renderer.EntityRenderer;
import net.minecraft.client.settings.GameSettings;
import net.minecraft.entity.Entity;
-import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.util.text.ITextComponent;
@@ -120,14 +118,6 @@ public interface IGameEventListener {
*/
void onReceivePacket(PacketEvent event);
- /**
- * Run when a query is made for a player's inventory current slot in the context of blocks
- *
- * @see InventoryPlayer#getDestroySpeed(IBlockState)
- * @see InventoryPlayer#canHarvestBlock(IBlockState)
- */
- void onQueryItemSlotForBlocks(ItemSlotEvent event);
-
/**
* Run once per game tick from before and after the player's moveRelative method is called
*
diff --git a/src/main/java/baritone/chunk/WorldScanner.java b/src/main/java/baritone/chunk/WorldScanner.java
index cf4fb1171..09edd1e56 100644
--- a/src/main/java/baritone/chunk/WorldScanner.java
+++ b/src/main/java/baritone/chunk/WorldScanner.java
@@ -47,7 +47,7 @@ public enum WorldScanner implements Helper {
int playerChunkX = playerFeet().getX() >> 4;
int playerChunkZ = playerFeet().getZ() >> 4;
- int searchRadius = 0;
+ int searchRadius = 2;
while (true) {
boolean allUnloaded = true;
for (int xoff = -searchRadius; xoff <= searchRadius; xoff++) {
diff --git a/src/main/java/baritone/launch/mixins/MixinInventoryPlayer.java b/src/main/java/baritone/launch/mixins/MixinInventoryPlayer.java
deleted file mode 100644
index dfaa4b192..000000000
--- a/src/main/java/baritone/launch/mixins/MixinInventoryPlayer.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * This file is part of Baritone.
- *
- * Baritone is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Baritone. If not, see .
- */
-
-package baritone.launch.mixins;
-
-import baritone.Baritone;
-import baritone.api.event.events.ItemSlotEvent;
-import net.minecraft.entity.player.InventoryPlayer;
-import org.spongepowered.asm.lib.Opcodes;
-import org.spongepowered.asm.mixin.Mixin;
-import org.spongepowered.asm.mixin.injection.At;
-import org.spongepowered.asm.mixin.injection.Redirect;
-
-/**
- * @author Brady
- * @since 8/20/2018
- */
-@Mixin(InventoryPlayer.class)
-public class MixinInventoryPlayer {
-
- @Redirect(
- method = "getDestroySpeed",
- at = @At(
- value = "FIELD",
- opcode = Opcodes.GETFIELD,
- target = "net/minecraft/entity/player/InventoryPlayer.currentItem:I"
- )
- )
- private int getDestroySpeed$getCurrentItem(InventoryPlayer inventory) {
- ItemSlotEvent event = new ItemSlotEvent(inventory.currentItem);
- Baritone.INSTANCE.getGameEventHandler().onQueryItemSlotForBlocks(event);
- return event.getSlot();
- }
-
- @Redirect(
- method = "canHarvestBlock",
- at = @At(
- value = "FIELD",
- opcode = Opcodes.GETFIELD,
- target = "net/minecraft/entity/player/InventoryPlayer.currentItem:I"
- )
- )
- private int canHarvestBlock$getCurrentItem(InventoryPlayer inventory) {
- ItemSlotEvent event = new ItemSlotEvent(inventory.currentItem);
- Baritone.INSTANCE.getGameEventHandler().onQueryItemSlotForBlocks(event);
- return event.getSlot();
- }
-}
diff --git a/src/main/java/baritone/pathing/goals/GoalGetToBlock.java b/src/main/java/baritone/pathing/goals/GoalGetToBlock.java
index ed927a12c..309377720 100644
--- a/src/main/java/baritone/pathing/goals/GoalGetToBlock.java
+++ b/src/main/java/baritone/pathing/goals/GoalGetToBlock.java
@@ -47,8 +47,8 @@ public class GoalGetToBlock implements Goal {
int xDiff = pos.getX() - this.x;
int yDiff = pos.getY() - this.y;
int zDiff = pos.getZ() - this.z;
- if (yDiff == -2 && xDiff == 0 && zDiff == 0) {
- return true;
+ if (yDiff < 0) {
+ yDiff++;
}
return Math.abs(xDiff) + Math.abs(yDiff) + Math.abs(zDiff) <= 1;
}
diff --git a/src/main/java/baritone/pathing/movement/CalculationContext.java b/src/main/java/baritone/pathing/movement/CalculationContext.java
index 2aca1f821..bd05ec5eb 100644
--- a/src/main/java/baritone/pathing/movement/CalculationContext.java
+++ b/src/main/java/baritone/pathing/movement/CalculationContext.java
@@ -46,7 +46,6 @@ public class CalculationContext implements Helper {
}
public CalculationContext(ToolSet toolSet) {
- player().setSprinting(true);
this.toolSet = toolSet;
this.hasThrowaway = Baritone.settings().allowPlace.get() && MovementHelper.throwaway(false);
this.hasWaterBucket = Baritone.settings().allowWaterBucketFall.get() && InventoryPlayer.isHotbar(player().inventory.getSlotFor(STACK_BUCKET_WATER)) && !world().provider.isNether();
diff --git a/src/main/java/baritone/pathing/movement/Movement.java b/src/main/java/baritone/pathing/movement/Movement.java
index 9d2f5869f..5eba39aba 100644
--- a/src/main/java/baritone/pathing/movement/Movement.java
+++ b/src/main/java/baritone/pathing/movement/Movement.java
@@ -149,7 +149,7 @@ public abstract class Movement implements Helper, MovementHelper {
somethingInTheWay = true;
Optional reachable = LookBehaviorUtils.reachable(blockPos);
if (reachable.isPresent()) {
- player().inventory.currentItem = new ToolSet().getBestSlot(BlockStateInterface.get(blockPos));
+ MovementHelper.switchToBestToolFor(BlockStateInterface.get(blockPos));
state.setTarget(new MovementState.MovementTarget(reachable.get(), true)).setInput(Input.CLICK_LEFT, true);
return false;
}
diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java
index 82b20c417..49fc5968c 100644
--- a/src/main/java/baritone/pathing/movement/MovementHelper.java
+++ b/src/main/java/baritone/pathing/movement/MovementHelper.java
@@ -55,9 +55,7 @@ public interface MovementHelper extends ActionCosts, Helper {
|| BlockStateInterface.isLiquid(new BlockPos(pos.getX() + 1, pos.getY(), pos.getZ()))
|| BlockStateInterface.isLiquid(new BlockPos(pos.getX() - 1, pos.getY(), pos.getZ()))
|| BlockStateInterface.isLiquid(new BlockPos(pos.getX(), pos.getY(), pos.getZ() + 1))
- || BlockStateInterface.isLiquid(new BlockPos(pos.getX(), pos.getY(), pos.getZ() - 1))
- || (!(b instanceof BlockLilyPad && BlockStateInterface.isWater(below)) && below instanceof BlockLiquid);//if it's a lilypad above water, it's ok to break, otherwise don't break if its liquid
- // TODO revisit this. why is it not okay to break non-lilypads that are right above water?
+ || BlockStateInterface.isLiquid(new BlockPos(pos.getX(), pos.getY(), pos.getZ() - 1));
}
/**
@@ -261,7 +259,11 @@ public interface MovementHelper extends ActionCosts, Helper {
return COST_INF;
}
double m = Blocks.CRAFTING_TABLE.equals(block) ? 10 : 1; // TODO see if this is still necessary. it's from MineBot when we wanted to penalize breaking its crafting table
- double result = m / context.getToolSet().getStrVsBlock(state, position);
+ double strVsBlock = context.getToolSet().getStrVsBlock(state);
+ if (strVsBlock < 0)
+ return COST_INF;
+
+ double result = m / strVsBlock;
if (includeFalling) {
BlockPos up = position.up();
IBlockState above = BlockStateInterface.get(up);
diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java b/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java
index 2bf8bdf13..b71909d1b 100644
--- a/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java
+++ b/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java
@@ -50,29 +50,6 @@ public class MovementDiagonal extends Movement {
super(start, end, new BlockPos[]{dir1, dir1.up(), dir2, dir2.up(), end, end.up()});
}
- @Override
- public MovementState updateState(MovementState state) {
- super.updateState(state);
- switch (state.getStatus()) {
- case WAITING:
- state.setStatus(MovementState.MovementStatus.RUNNING);
- case RUNNING:
- break;
- default:
- return state;
- }
-
- if (playerFeet().equals(dest)) {
- state.setStatus(MovementState.MovementStatus.SUCCESS);
- return state;
- }
- if (!BlockStateInterface.isLiquid(playerFeet())) {
- state.setInput(InputOverrideHandler.Input.SPRINT, true);
- }
- MovementHelper.moveTowards(state, dest);
- return state;
- }
-
@Override
protected double calculateCost(CalculationContext context) {
Block fromDown = BlockStateInterface.get(src.down()).getBlock();
@@ -139,6 +116,29 @@ public class MovementDiagonal extends Movement {
return multiplier * SQRT_2;
}
+ @Override
+ public MovementState updateState(MovementState state) {
+ super.updateState(state);
+ switch (state.getStatus()) {
+ case WAITING:
+ state.setStatus(MovementState.MovementStatus.RUNNING);
+ case RUNNING:
+ break;
+ default:
+ return state;
+ }
+
+ if (playerFeet().equals(dest)) {
+ state.setStatus(MovementState.MovementStatus.SUCCESS);
+ return state;
+ }
+ if (!BlockStateInterface.isLiquid(playerFeet())) {
+ state.setInput(InputOverrideHandler.Input.SPRINT, true);
+ }
+ MovementHelper.moveTowards(state, dest);
+ return state;
+ }
+
@Override
protected boolean prepared(MovementState state) {
return true;
diff --git a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java
index af0b7b27a..12eda4312 100644
--- a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java
+++ b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java
@@ -57,15 +57,16 @@ public class MovementTraverse extends Movement {
IBlockState pb0 = BlockStateInterface.get(positionsToBreak[0]);
IBlockState pb1 = BlockStateInterface.get(positionsToBreak[1]);
IBlockState destOn = BlockStateInterface.get(positionToPlace);
+ Block srcDown = BlockStateInterface.getBlock(src.down());
if (MovementHelper.canWalkOn(positionToPlace, destOn)) {//this is a walk, not a bridge
double WC = WALK_ONE_BLOCK_COST;
if (BlockStateInterface.isWater(pb0.getBlock()) || BlockStateInterface.isWater(pb1.getBlock())) {
WC = WALK_ONE_IN_WATER_COST;
} else {
- if (Blocks.SOUL_SAND.equals(destOn.getBlock())) {
+ if (destOn.getBlock() == Blocks.SOUL_SAND) {
WC += (WALK_ONE_OVER_SOUL_SAND_COST - WALK_ONE_BLOCK_COST) / 2;
}
- if (Blocks.SOUL_SAND.equals(BlockStateInterface.get(src.down()).getBlock())) {
+ if (srcDown == Blocks.SOUL_SAND) {
WC += (WALK_ONE_OVER_SOUL_SAND_COST - WALK_ONE_BLOCK_COST) / 2;
}
}
@@ -82,9 +83,12 @@ public class MovementTraverse extends Movement {
}
return WC;
}
+ if (srcDown == Blocks.LADDER || srcDown == Blocks.VINE) {
+ hardness1 *= 5;
+ hardness2 *= 5;
+ }
return WC + hardness1 + hardness2;
} else {//this is a bridge, so we need to place a block
- Block srcDown = BlockStateInterface.get(src.down()).getBlock();
if (srcDown == Blocks.LADDER || srcDown == Blocks.VINE) {
return COST_INF;
}
@@ -130,6 +134,8 @@ public class MovementTraverse extends Movement {
return state;
}
+ state.setInput(InputOverrideHandler.Input.SNEAK, false);
+
Block fd = BlockStateInterface.get(src.down()).getBlock();
boolean ladder = fd instanceof BlockLadder || fd instanceof BlockVine;
IBlockState pb0 = BlockStateInterface.get(positionsToBreak[0]);
@@ -186,7 +192,7 @@ public class MovementTraverse extends Movement {
state.setInput(InputOverrideHandler.Input.SPRINT, true);
}
Block destDown = BlockStateInterface.get(dest.down()).getBlock();
- if (ladder && (destDown instanceof BlockVine || destDown instanceof BlockLadder)) {
+ if (whereAmI.getY() != dest.getY() && ladder && (destDown instanceof BlockVine || destDown instanceof BlockLadder)) {
new MovementPillar(dest.down(), dest).updateState(state); // i'm sorry
return state;
}
@@ -264,4 +270,15 @@ public class MovementTraverse extends Movement {
}
}
}
+
+ @Override
+ protected boolean prepared(MovementState state) {
+ if (playerFeet().equals(src) || playerFeet().equals(src.down())) {
+ Block block = BlockStateInterface.getBlock(src.down());
+ if (block == Blocks.LADDER || block == Blocks.VINE) {
+ state.setInput(InputOverrideHandler.Input.SNEAK, true);
+ }
+ }
+ return super.prepared(state);
+ }
}
diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java
index 16dabf4f0..9c28f058a 100644
--- a/src/main/java/baritone/utils/ExampleBaritoneControl.java
+++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java
@@ -105,7 +105,11 @@ public class ExampleBaritoneControl extends Behavior {
}
if (msg.equals("path")) {
if (!PathingBehavior.INSTANCE.path()) {
- displayChatMessageRaw("Currently executing a path. Please cancel it first.");
+ if (PathingBehavior.INSTANCE.getGoal() == null) {
+ displayChatMessageRaw("No goal.");
+ } else {
+ displayChatMessageRaw("Currently executing a path. Please cancel it first.");
+ }
}
event.cancel();
return;
diff --git a/src/main/java/baritone/utils/ToolSet.java b/src/main/java/baritone/utils/ToolSet.java
index e8243ba6a..e31fe09e9 100644
--- a/src/main/java/baritone/utils/ToolSet.java
+++ b/src/main/java/baritone/utils/ToolSet.java
@@ -17,55 +17,24 @@
package baritone.utils;
-import baritone.api.event.events.ItemSlotEvent;
-import baritone.api.event.listener.AbstractGameEventListener;
+import baritone.Baritone;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.entity.EntityPlayerSP;
-import net.minecraft.item.Item;
-import net.minecraft.item.ItemAir;
+import net.minecraft.enchantment.EnchantmentHelper;
+import net.minecraft.init.Enchantments;
+import net.minecraft.init.MobEffects;
import net.minecraft.item.ItemStack;
-import net.minecraft.item.ItemTool;
-import net.minecraft.util.NonNullList;
-import net.minecraft.util.math.BlockPos;
-import java.util.ArrayList;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
/**
* A cached list of the best tools on the hotbar for any block
*
- * @author avecowa, Brady
+ * @author avecowa, Brady, leijurv
*/
public class ToolSet implements Helper {
- /**
- * Instance of the internal event listener used to hook into Baritone's event bus
- */
- public static final InternalEventListener INTERNAL_EVENT_LISTENER = new InternalEventListener();
-
- /**
- * A list of tools on the hotbar that should be considered.
- * Note that if there are no tools on the hotbar this list will still have one (null) entry.
- */
- private List tools;
-
- /**
- * A mapping from the tools array to what hotbar slots the tool is actually in.
- * tools.get(i) will be on your hotbar in slot slots.get(i)
- */
- private List slots;
-
- /**
- * A mapping from a block to which tool index is best for it.
- * The values in this map are *not* hotbar slots indexes, they need to be looked up in slots
- * in order to be converted into hotbar slots.
- */
- private Map slotCache = new HashMap<>();
-
/**
* A cache mapping a {@link Block} to how long it will take to break
* with this toolset, given the optimum tool is used.
@@ -75,30 +44,7 @@ public class ToolSet implements Helper {
/**
* Create a toolset from the current player's inventory (but don't calculate any hardness values just yet)
*/
- public ToolSet() {
- EntityPlayerSP p = Minecraft.getMinecraft().player;
- NonNullList inv = p.inventory.mainInventory;
- tools = new ArrayList<>();
- slots = new ArrayList<>();
- boolean fnull = false;
- for (byte i = 0; i < 9; i++) {
- if (!fnull || ((!(inv.get(i).getItem() instanceof ItemAir)) && inv.get(i).getItem() instanceof ItemTool)) {
- tools.add(inv.get(i).getItem() instanceof ItemTool ? (ItemTool) inv.get(i).getItem() : null);
- slots.add(i);
- fnull |= (inv.get(i).getItem() instanceof ItemAir) || (!inv.get(i).getItem().isDamageable());
- }
- }
- }
-
- /**
- * A caching wrapper around getBestToolIndex
- *
- * @param state the blockstate to be mined
- * @return get which tool on the hotbar is best for mining it
- */
- public Item getBestTool(IBlockState state) {
- return tools.get(slotCache.computeIfAbsent(state.getBlock(), block -> getBestToolIndex(state)));
- }
+ public ToolSet() {}
/**
* Calculate which tool on the hotbar is best for mining
@@ -106,15 +52,11 @@ public class ToolSet implements Helper {
* @param b the blockstate to be mined
* @return a byte indicating the index in the tools array that worked best
*/
- private byte getBestToolIndex(IBlockState b) {
+ public byte getBestSlot(IBlockState b) {
byte best = 0;
- float value = -1;
- for (byte i = 0; i < tools.size(); i++) {
- Item item = tools.get(i);
- if (item == null)
- continue;
-
- float v = item.getDestroySpeed(new ItemStack(item), b);
+ double value = -1;
+ for (byte i = 0; i < 9; i++) {
+ double v = calculateStrVsBlock(i, b);
if (v > value || value == -1) {
value = v;
best = i;
@@ -123,62 +65,65 @@ public class ToolSet implements Helper {
return best;
}
- /**
- * Get which hotbar slot should be selected for fastest mining
- *
- * @param state the blockstate to be mined
- * @return a byte indicating which hotbar slot worked best
- */
- public byte getBestSlot(IBlockState state) {
- return slots.get(slotCache.computeIfAbsent(state.getBlock(), block -> getBestToolIndex(state)));
- }
-
/**
* Using the best tool on the hotbar, how long would it take to mine this block
*
* @param state the blockstate to be mined
- * @param pos the blockpos to be mined
* @return how long it would take in ticks
*/
- public double getStrVsBlock(IBlockState state, BlockPos pos) {
- return this.breakStrengthCache.computeIfAbsent(state.getBlock(), b -> calculateStrVsBlock(state, pos));
+ public double getStrVsBlock(IBlockState state) {
+ return this.breakStrengthCache.computeIfAbsent(state.getBlock(), b -> calculateStrVsBlock(getBestSlot(state), state));
}
/**
* Calculates how long would it take to mine the specified block given the best tool
- * in this toolset is used.
+ * in this toolset is used. A negative value is returned if the specified block is unbreakable.
*
* @param state the blockstate to be mined
- * @param pos the blockpos to be mined
* @return how long it would take in ticks
*/
- private double calculateStrVsBlock(IBlockState state, BlockPos pos) {
+ private double calculateStrVsBlock(byte slot, IBlockState state) {
// Calculate the slot with the best item
- byte slot = this.getBestSlot(state);
+ ItemStack contents = player().inventory.getStackInSlot(slot);
- INTERNAL_EVENT_LISTENER.setOverrideSlot(slot);
+ float blockHard = state.getBlockHardness(null, null);
+ if (blockHard < 0)
+ return -1;
- // Calculate the relative hardness of the block to the player
- float hardness = state.getPlayerRelativeBlockHardness(player(), world(), pos);
-
- // Restore the old slot
- INTERNAL_EVENT_LISTENER.setOverrideSlot(-1);
-
- return hardness;
- }
-
- private static final class InternalEventListener implements AbstractGameEventListener {
-
- private int overrideSlot;
-
- @Override
- public void onQueryItemSlotForBlocks(ItemSlotEvent event) {
- if (this.overrideSlot >= 0)
- event.setSlot(this.overrideSlot);
+ float speed = contents.getDestroySpeed(state);
+ if (speed > 1) {
+ int effLevel = EnchantmentHelper.getEnchantmentLevel(Enchantments.EFFICIENCY, contents);
+ if (effLevel > 0 && !contents.isEmpty()) {
+ speed += effLevel * effLevel + 1;
+ }
}
- final void setOverrideSlot(int overrideSlot) {
- this.overrideSlot = overrideSlot;
+ if (Baritone.settings().considerPotionEffects.get()) {
+ if (player().isPotionActive(MobEffects.HASTE)) {
+ speed *= 1 + (player().getActivePotionEffect(MobEffects.HASTE).getAmplifier() + 1) * 0.2;
+ }
+ if (player().isPotionActive(MobEffects.MINING_FATIGUE)) {
+ switch (player().getActivePotionEffect(MobEffects.MINING_FATIGUE).getAmplifier()) {
+ case 0:
+ speed *= 0.3;
+ break;
+ case 1:
+ speed *= 0.09;
+ break;
+ case 2:
+ speed *= 0.0027;
+ break;
+ default:
+ speed *= 0.00081;
+ break;
+ }
+ }
+ }
+ speed /= blockHard;
+ if (state.getMaterial().isToolNotRequired() || (!contents.isEmpty() && contents.canHarvestBlock(state))) {
+ return speed / 30;
+ } else {
+ return speed / 100;
}
}
}
diff --git a/src/test/java/baritone/pathing/goals/GoalGetToBlockTest.java b/src/test/java/baritone/pathing/goals/GoalGetToBlockTest.java
index 3c3905aa9..a908a8dd5 100644
--- a/src/test/java/baritone/pathing/goals/GoalGetToBlockTest.java
+++ b/src/test/java/baritone/pathing/goals/GoalGetToBlockTest.java
@@ -30,7 +30,7 @@ public class GoalGetToBlockTest {
@Test
public void isInGoal() {
- List acceptableOffsets = new ArrayList<>(Arrays.asList("0,0,0", "0,0,1", "0,0,-1", "1,0,0", "-1,0,0", "0,1,0", "0,-1,0", "0,-2,0"));
+ List acceptableOffsets = new ArrayList<>(Arrays.asList("0,0,0", "0,0,1", "0,0,-1", "1,0,0", "-1,0,0", "0,-1,1", "0,-1,-1", "1,-1,0", "-1,-1,0", "0,1,0", "0,-1,0", "0,-2,0"));
for (int x = -10; x <= 10; x++) {
for (int y = -10; y <= 10; y++) {
for (int z = -10; z <= 10; z++) {