Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 59e0d6406e |
@@ -28,8 +28,6 @@ Baritone is the pathfinding system used in [Impact](https://impactdevelopment.gi
|
|||||||
This project is an updated version of [MineBot](https://github.com/leijurv/MineBot/),
|
This project is an updated version of [MineBot](https://github.com/leijurv/MineBot/),
|
||||||
the original version of the bot for Minecraft 1.8, rebuilt for 1.12.2. Baritone focuses on reliability and particularly performance (it's over [30x faster](https://github.com/cabaletta/baritone/pull/180#issuecomment-423822928) than MineBot at calculating paths).
|
the original version of the bot for Minecraft 1.8, rebuilt for 1.12.2. Baritone focuses on reliability and particularly performance (it's over [30x faster](https://github.com/cabaletta/baritone/pull/180#issuecomment-423822928) than MineBot at calculating paths).
|
||||||
|
|
||||||
Have committed at least once a day for the last 6 months =D 🦀
|
|
||||||
|
|
||||||
Here are some links to help to get started:
|
Here are some links to help to get started:
|
||||||
|
|
||||||
- [Features](FEATURES.md)
|
- [Features](FEATURES.md)
|
||||||
@@ -45,12 +43,6 @@ Here are some links to help to get started:
|
|||||||
|
|
||||||
Quick start example: `thisway 1000` or `goal 70` to set the goal, `path` to actually start pathing. Also try `mine diamond_ore`. `cancel` to cancel.
|
Quick start example: `thisway 1000` or `goal 70` to set the goal, `path` to actually start pathing. Also try `mine diamond_ore`. `cancel` to cancel.
|
||||||
|
|
||||||
On v1.1.0 and newer: Put a `#` in front so that if you make a typo it doesn't go into public chat (anything beginning with `#` isn't sent).
|
|
||||||
|
|
||||||
For older than v1.1.0, `#` must be enabled by toggling on the `prefix` setting.
|
|
||||||
|
|
||||||
**Only** in Impact is `.b` also a valid prefix
|
|
||||||
|
|
||||||
# API example
|
# API example
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,15 +1,5 @@
|
|||||||
# Setup
|
# Setup
|
||||||
|
|
||||||
## Prebuilt
|
|
||||||
[Releases](https://github.com/cabaletta/baritone/releases)
|
|
||||||
|
|
||||||
Not always completely up to date with latest features.
|
|
||||||
|
|
||||||
The forge release (currently `baritone-forge-1.1.3.jar`) can simply be added as a Forge mod.
|
|
||||||
|
|
||||||
Previously (Baritone v1.1.2 and below), it was not fully compatible with the latest version of Forge. `freeLook` was broken in Forge 14.23.4.2744. Forge 14.23.4.2743 or **older** worked with Baritone v1.1.2 and lower. Newer versions of Forge "worked", sort of, but Baritone's movement became unreliable and `freeLook` must be off.
|
|
||||||
|
|
||||||
## Build it yourself
|
|
||||||
- Clone or download Baritone
|
- Clone or download Baritone
|
||||||
|
|
||||||

|

|
||||||
@@ -75,13 +65,12 @@ $ gradlew build
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
- Double click on **build** to run it
|
- Right click on **build** and press **Run**
|
||||||
|
|
||||||
## Artifacts
|
## Artifacts
|
||||||
|
|
||||||
Building Baritone will result in 4 artifacts created in the ``dist`` directory.
|
Building Baritone will result in 3 artifacts created in the ``dist`` directory.
|
||||||
|
|
||||||
- **Forge**: Forge mod
|
|
||||||
- **API**: Only the non-api packages are obfuscated. This should be used in environments where other mods would like to use Baritone's features.
|
- **API**: Only the non-api packages are obfuscated. This should be used in environments where other mods would like to use Baritone's features.
|
||||||
- **Standalone**: Everything is obfuscated. This should be used in environments where there are no other mods present that would like to use Baritone's features.
|
- **Standalone**: Everything is obfuscated. This should be used in environments where there are no other mods present that would like to use Baritone's features.
|
||||||
- **Unoptimized**: Nothing is obfuscated. This shouldn't be used ever in production.
|
- **Unoptimized**: Nothing is obfuscated. This shouldn't be used ever in production.
|
||||||
|
|||||||
+2
-10
@@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
group 'baritone'
|
group 'baritone'
|
||||||
version '1.1.3'
|
version '1.0.0-hotfix-2'
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
repositories {
|
repositories {
|
||||||
@@ -95,7 +95,7 @@ dependencies {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mixin {
|
mixin {
|
||||||
defaultObfuscationEnv searge
|
defaultObfuscationEnv notch
|
||||||
add sourceSets.launch, 'mixins.baritone.refmap.json'
|
add sourceSets.launch, 'mixins.baritone.refmap.json'
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,14 +113,6 @@ jar {
|
|||||||
reproducibleFileOrder = true
|
reproducibleFileOrder = true
|
||||||
}
|
}
|
||||||
|
|
||||||
jar {
|
|
||||||
manifest {
|
|
||||||
attributes(
|
|
||||||
'MixinConfigs': 'mixins.baritone.json'
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
task proguard(type: ProguardTask) {
|
task proguard(type: ProguardTask) {
|
||||||
url 'https://downloads.sourceforge.net/project/proguard/proguard/6.0/proguard6.0.3.zip'
|
url 'https://downloads.sourceforge.net/project/proguard/proguard/6.0/proguard6.0.3.zip'
|
||||||
extract 'proguard6.0.3/lib/proguard.jar'
|
extract 'proguard6.0.3/lib/proguard.jar'
|
||||||
|
|||||||
@@ -52,11 +52,10 @@ class BaritoneGradleTask extends DefaultTask {
|
|||||||
ARTIFACT_STANDARD = "%s-%s.jar",
|
ARTIFACT_STANDARD = "%s-%s.jar",
|
||||||
ARTIFACT_UNOPTIMIZED = "%s-unoptimized-%s.jar",
|
ARTIFACT_UNOPTIMIZED = "%s-unoptimized-%s.jar",
|
||||||
ARTIFACT_API = "%s-api-%s.jar",
|
ARTIFACT_API = "%s-api-%s.jar",
|
||||||
ARTIFACT_STANDALONE = "%s-standalone-%s.jar",
|
ARTIFACT_STANDALONE = "%s-standalone-%s.jar";
|
||||||
ARTIFACT_FORGE = "%s-forge-%s.jar";
|
|
||||||
|
|
||||||
protected String artifactName, artifactVersion;
|
protected String artifactName, artifactVersion;
|
||||||
protected Path artifactPath, artifactUnoptimizedPath, artifactApiPath, artifactStandalonePath, artifactForgePath, proguardOut;
|
protected Path artifactPath, artifactUnoptimizedPath, artifactApiPath, artifactStandalonePath, proguardOut;
|
||||||
|
|
||||||
protected void verifyArtifacts() throws IllegalStateException {
|
protected void verifyArtifacts() throws IllegalStateException {
|
||||||
this.artifactName = getProject().getName();
|
this.artifactName = getProject().getName();
|
||||||
@@ -66,7 +65,6 @@ class BaritoneGradleTask extends DefaultTask {
|
|||||||
this.artifactUnoptimizedPath = this.getBuildFile(formatVersion(ARTIFACT_UNOPTIMIZED));
|
this.artifactUnoptimizedPath = this.getBuildFile(formatVersion(ARTIFACT_UNOPTIMIZED));
|
||||||
this.artifactApiPath = this.getBuildFile(formatVersion(ARTIFACT_API));
|
this.artifactApiPath = this.getBuildFile(formatVersion(ARTIFACT_API));
|
||||||
this.artifactStandalonePath = this.getBuildFile(formatVersion(ARTIFACT_STANDALONE));
|
this.artifactStandalonePath = this.getBuildFile(formatVersion(ARTIFACT_STANDALONE));
|
||||||
this.artifactForgePath = this.getBuildFile(formatVersion(ARTIFACT_FORGE));
|
|
||||||
|
|
||||||
this.proguardOut = this.getTemporaryFile(PROGUARD_EXPORT_PATH);
|
this.proguardOut = this.getTemporaryFile(PROGUARD_EXPORT_PATH);
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,6 @@ public class CreateDistTask extends BaritoneGradleTask {
|
|||||||
Path api = getRelativeFile("dist/" + formatVersion(ARTIFACT_API));
|
Path api = getRelativeFile("dist/" + formatVersion(ARTIFACT_API));
|
||||||
Path standalone = getRelativeFile("dist/" + formatVersion(ARTIFACT_STANDALONE));
|
Path standalone = getRelativeFile("dist/" + formatVersion(ARTIFACT_STANDALONE));
|
||||||
Path unoptimized = getRelativeFile("dist/" + formatVersion(ARTIFACT_UNOPTIMIZED));
|
Path unoptimized = getRelativeFile("dist/" + formatVersion(ARTIFACT_UNOPTIMIZED));
|
||||||
Path forge = getRelativeFile("dist/" + formatVersion(ARTIFACT_FORGE));
|
|
||||||
|
|
||||||
// NIO will not automatically create directories
|
// NIO will not automatically create directories
|
||||||
Path dir = getRelativeFile("dist/");
|
Path dir = getRelativeFile("dist/");
|
||||||
@@ -57,10 +56,9 @@ public class CreateDistTask extends BaritoneGradleTask {
|
|||||||
Files.copy(this.artifactApiPath, api, REPLACE_EXISTING);
|
Files.copy(this.artifactApiPath, api, REPLACE_EXISTING);
|
||||||
Files.copy(this.artifactStandalonePath, standalone, REPLACE_EXISTING);
|
Files.copy(this.artifactStandalonePath, standalone, REPLACE_EXISTING);
|
||||||
Files.copy(this.artifactUnoptimizedPath, unoptimized, REPLACE_EXISTING);
|
Files.copy(this.artifactUnoptimizedPath, unoptimized, REPLACE_EXISTING);
|
||||||
Files.copy(this.artifactForgePath, forge, REPLACE_EXISTING);
|
|
||||||
|
|
||||||
// Calculate all checksums and format them like "shasum"
|
// Calculate all checksums and format them like "shasum"
|
||||||
List<String> shasum = Stream.of(api, standalone, unoptimized, forge)
|
List<String> shasum = Stream.of(api, standalone, unoptimized)
|
||||||
.map(path -> sha1(path) + " " + path.getFileName().toString())
|
.map(path -> sha1(path) + " " + path.getFileName().toString())
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
|||||||
@@ -59,8 +59,6 @@ public class ProguardTask extends BaritoneGradleTask {
|
|||||||
|
|
||||||
private List<String> requiredLibraries;
|
private List<String> requiredLibraries;
|
||||||
|
|
||||||
private File mixin;
|
|
||||||
|
|
||||||
@TaskAction
|
@TaskAction
|
||||||
protected void exec() throws Exception {
|
protected void exec() throws Exception {
|
||||||
super.verifyArtifacts();
|
super.verifyArtifacts();
|
||||||
@@ -73,7 +71,6 @@ public class ProguardTask extends BaritoneGradleTask {
|
|||||||
acquireDependencies();
|
acquireDependencies();
|
||||||
proguardApi();
|
proguardApi();
|
||||||
proguardStandalone();
|
proguardStandalone();
|
||||||
createForge();
|
|
||||||
cleanup();
|
cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,7 +79,7 @@ public class ProguardTask extends BaritoneGradleTask {
|
|||||||
Files.delete(this.artifactUnoptimizedPath);
|
Files.delete(this.artifactUnoptimizedPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
Determinizer.determinize(this.artifactPath.toString(), this.artifactUnoptimizedPath.toString(), Optional.empty());
|
Determinizer.determinize(this.artifactPath.toString(), this.artifactUnoptimizedPath.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void downloadProguard() throws Exception {
|
private void downloadProguard() throws Exception {
|
||||||
@@ -176,16 +173,10 @@ public class ProguardTask extends BaritoneGradleTask {
|
|||||||
// Find the library jar file, and copy it to tempLibraries
|
// Find the library jar file, and copy it to tempLibraries
|
||||||
for (File file : pair.getLeft().files(pair.getRight())) {
|
for (File file : pair.getLeft().files(pair.getRight())) {
|
||||||
if (file.getName().startsWith(lib)) {
|
if (file.getName().startsWith(lib)) {
|
||||||
if (lib.contains("mixin")) {
|
|
||||||
mixin = file;
|
|
||||||
}
|
|
||||||
Files.copy(file.toPath(), getTemporaryFile("tempLibraries/" + lib + ".jar"), REPLACE_EXISTING);
|
Files.copy(file.toPath(), getTemporaryFile("tempLibraries/" + lib + ".jar"), REPLACE_EXISTING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mixin == null) {
|
|
||||||
throw new IllegalStateException("Unable to find mixin jar");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// a bunch of epic stuff to get the path to the cached jar
|
// a bunch of epic stuff to get the path to the cached jar
|
||||||
@@ -273,16 +264,12 @@ public class ProguardTask extends BaritoneGradleTask {
|
|||||||
|
|
||||||
private void proguardApi() throws Exception {
|
private void proguardApi() throws Exception {
|
||||||
runProguard(getTemporaryFile(PROGUARD_API_CONFIG));
|
runProguard(getTemporaryFile(PROGUARD_API_CONFIG));
|
||||||
Determinizer.determinize(this.proguardOut.toString(), this.artifactApiPath.toString(), Optional.empty());
|
Determinizer.determinize(this.proguardOut.toString(), this.artifactApiPath.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void proguardStandalone() throws Exception {
|
private void proguardStandalone() throws Exception {
|
||||||
runProguard(getTemporaryFile(PROGUARD_STANDALONE_CONFIG));
|
runProguard(getTemporaryFile(PROGUARD_STANDALONE_CONFIG));
|
||||||
Determinizer.determinize(this.proguardOut.toString(), this.artifactStandalonePath.toString(), Optional.empty());
|
Determinizer.determinize(this.proguardOut.toString(), this.artifactStandalonePath.toString());
|
||||||
}
|
|
||||||
|
|
||||||
private void createForge() throws Exception {
|
|
||||||
Determinizer.determinize(this.proguardOut.toString(), this.artifactForgePath.toString(), Optional.of(mixin));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cleanup() {
|
private void cleanup() {
|
||||||
@@ -311,8 +298,8 @@ public class ProguardTask extends BaritoneGradleTask {
|
|||||||
.start();
|
.start();
|
||||||
|
|
||||||
// We can't do output inherit process I/O with gradle for some reason and have it work, so we have to do this
|
// We can't do output inherit process I/O with gradle for some reason and have it work, so we have to do this
|
||||||
this.printOutputLog(p.getInputStream(), System.out);
|
this.printOutputLog(p.getInputStream());
|
||||||
this.printOutputLog(p.getErrorStream(), System.err);
|
this.printOutputLog(p.getErrorStream());
|
||||||
|
|
||||||
// Halt the current thread until the process is complete, if the exit code isn't 0, throw an exception
|
// Halt the current thread until the process is complete, if the exit code isn't 0, throw an exception
|
||||||
int exitCode = p.waitFor();
|
int exitCode = p.waitFor();
|
||||||
@@ -321,12 +308,12 @@ public class ProguardTask extends BaritoneGradleTask {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void printOutputLog(InputStream stream, PrintStream outerr) {
|
private void printOutputLog(InputStream stream) {
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(stream))) {
|
try (BufferedReader reader = new BufferedReader(new InputStreamReader(stream))) {
|
||||||
String line;
|
String line;
|
||||||
while ((line = reader.readLine()) != null) {
|
while ((line = reader.readLine()) != null) {
|
||||||
outerr.println(line);
|
System.out.println(line);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|||||||
@@ -22,7 +22,10 @@ import com.google.gson.stream.JsonReader;
|
|||||||
import com.google.gson.stream.JsonWriter;
|
import com.google.gson.stream.JsonWriter;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.jar.JarEntry;
|
import java.util.jar.JarEntry;
|
||||||
import java.util.jar.JarFile;
|
import java.util.jar.JarFile;
|
||||||
import java.util.jar.JarOutputStream;
|
import java.util.jar.JarOutputStream;
|
||||||
@@ -36,7 +39,7 @@ import java.util.stream.Collectors;
|
|||||||
*/
|
*/
|
||||||
public class Determinizer {
|
public class Determinizer {
|
||||||
|
|
||||||
public static void determinize(String inputPath, String outputPath, Optional<File> toInclude) throws IOException {
|
public static void determinize(String inputPath, String outputPath) throws IOException {
|
||||||
System.out.println("Running Determinizer");
|
System.out.println("Running Determinizer");
|
||||||
System.out.println(" Input path: " + inputPath);
|
System.out.println(" Input path: " + inputPath);
|
||||||
System.out.println(" Output path: " + outputPath);
|
System.out.println(" Output path: " + outputPath);
|
||||||
@@ -63,30 +66,10 @@ public class Determinizer {
|
|||||||
if (entry.getName().endsWith(".refmap.json")) {
|
if (entry.getName().endsWith(".refmap.json")) {
|
||||||
JsonObject object = new JsonParser().parse(new InputStreamReader(jarFile.getInputStream(entry))).getAsJsonObject();
|
JsonObject object = new JsonParser().parse(new InputStreamReader(jarFile.getInputStream(entry))).getAsJsonObject();
|
||||||
jos.write(writeSorted(object).getBytes());
|
jos.write(writeSorted(object).getBytes());
|
||||||
} else if (entry.getName().equals("META-INF/MANIFEST.MF") && toInclude.isPresent()) { // only replace for forge jar
|
|
||||||
ByteArrayOutputStream cancer = new ByteArrayOutputStream();
|
|
||||||
copy(jarFile.getInputStream(entry), cancer);
|
|
||||||
String manifest = new String(cancer.toByteArray());
|
|
||||||
if (!manifest.contains("baritone.launch.BaritoneTweaker")) {
|
|
||||||
throw new IllegalStateException("unable to replace");
|
|
||||||
}
|
|
||||||
manifest = manifest.replace("baritone.launch.BaritoneTweaker", "org.spongepowered.asm.launch.MixinTweaker");
|
|
||||||
jos.write(manifest.getBytes());
|
|
||||||
} else {
|
} else {
|
||||||
copy(jarFile.getInputStream(entry), jos);
|
copy(jarFile.getInputStream(entry), jos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (toInclude.isPresent()) {
|
|
||||||
try (JarFile mixin = new JarFile(toInclude.get())) {
|
|
||||||
for (JarEntry entry : mixin.stream().sorted(Comparator.comparing(JarEntry::getName)).collect(Collectors.toList())) {
|
|
||||||
if (entry.getName().startsWith("META-INF") && !entry.getName().startsWith("META-INF/services")) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
jos.putNextEntry(entry);
|
|
||||||
copy(mixin.getInputStream(entry), jos);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
jos.finish();
|
jos.finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
-3
@@ -12,9 +12,6 @@
|
|||||||
-flattenpackagehierarchy
|
-flattenpackagehierarchy
|
||||||
-repackageclasses 'baritone'
|
-repackageclasses 'baritone'
|
||||||
|
|
||||||
# lwjgl is weird
|
|
||||||
-dontwarn org.lwjgl.opengl.GL14
|
|
||||||
|
|
||||||
-keep class baritone.api.** { *; } # this is the keep api
|
-keep class baritone.api.** { *; } # this is the keep api
|
||||||
|
|
||||||
# service provider needs these class names
|
# service provider needs these class names
|
||||||
|
|||||||
@@ -459,34 +459,10 @@ public final class Settings {
|
|||||||
*/
|
*/
|
||||||
public final Setting<Boolean> pathThroughCachedOnly = new Setting<>(false);
|
public final Setting<Boolean> pathThroughCachedOnly = new Setting<>(false);
|
||||||
|
|
||||||
/**
|
|
||||||
* 😎 Render cached chunks as semitransparent.
|
|
||||||
* <p>
|
|
||||||
* Can be very useful on servers with low render distance. After enabling, you may need to reload the world in order for it to have an effect
|
|
||||||
* (e.g. disconnect and reconnect, enter then exit the nether, die and respawn, etc). This may literally kill your FPS and CPU because
|
|
||||||
* every chunk gets recompiled twice as much as normal, since the cached version comes into range, then the normal one comes from the server for real.
|
|
||||||
* <p>
|
|
||||||
* Note that flowing water is cached as AVOID, which is rendered as lava. As you get closer, you may therefore see lava falls being replaced with water falls.
|
|
||||||
* <p>
|
|
||||||
* SOLID is rendered as stone in the overworld, netherrack in the nether, and end stone in the end
|
|
||||||
*/
|
|
||||||
public Setting<Boolean> renderCachedChunks = new Setting<>(false);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 0.0f = not visible, fully transparent
|
|
||||||
* 1.0f = fully opaque
|
|
||||||
*/
|
|
||||||
public Setting<Float> cachedChunksOpacity = new Setting<>(0.5f);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* If true, Baritone will not allow you to left or right click while pathing
|
|
||||||
*/
|
|
||||||
public Setting<Boolean> suppressClicks = new Setting<>(false);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether or not to use the "#" command prefix
|
* Whether or not to use the "#" command prefix
|
||||||
*/
|
*/
|
||||||
public final Setting<Boolean> prefixControl = new Setting<>(true);
|
public final Setting<Boolean> prefix = new Setting<>(false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Don't stop walking forward when you need to break blocks in your way
|
* Don't stop walking forward when you need to break blocks in your way
|
||||||
@@ -509,11 +485,6 @@ public final class Settings {
|
|||||||
*/
|
*/
|
||||||
public final Setting<Integer> mineGoalUpdateInterval = new Setting<>(5);
|
public final Setting<Integer> mineGoalUpdateInterval = new Setting<>(5);
|
||||||
|
|
||||||
/**
|
|
||||||
* When GetToBlock doesn't know any locations for the desired block, explore randomly instead of giving up.
|
|
||||||
*/
|
|
||||||
public final Setting<Boolean> exploreForBlocks = new Setting<>(true);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* While mining, should it also consider dropped items of the correct type as a pathing destination (as well as ore blocks)?
|
* While mining, should it also consider dropped items of the correct type as a pathing destination (as well as ore blocks)?
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -38,24 +38,11 @@ public interface IPathingBehavior extends IBehavior {
|
|||||||
* @return The estimated remaining ticks in the current segment.
|
* @return The estimated remaining ticks in the current segment.
|
||||||
*/
|
*/
|
||||||
default Optional<Double> ticksRemainingInSegment() {
|
default Optional<Double> ticksRemainingInSegment() {
|
||||||
return ticksRemainingInSegment(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the estimated remaining ticks in the current pathing
|
|
||||||
* segment. Given that the return type is an optional, {@link Optional#empty()}
|
|
||||||
* will be returned in the case that there is no current segment being pathed.
|
|
||||||
*
|
|
||||||
* @param includeCurrentMovement whether or not to include the entirety of the cost of the currently executing movement in the total
|
|
||||||
* @return The estimated remaining ticks in the current segment.
|
|
||||||
*/
|
|
||||||
default Optional<Double> ticksRemainingInSegment(boolean includeCurrentMovement) {
|
|
||||||
IPathExecutor current = getCurrent();
|
IPathExecutor current = getCurrent();
|
||||||
if (current == null) {
|
if (current == null) {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
int start = includeCurrentMovement ? current.getPosition() : current.getPosition() + 1;
|
return Optional.of(current.getPath().ticksRemainingFrom(current.getPosition()));
|
||||||
return Optional.of(current.getPath().ticksRemainingFrom(start));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,48 +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 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 <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package baritone.launch.mixins;
|
|
||||||
|
|
||||||
import baritone.Baritone;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.renderer.ChunkRenderContainer;
|
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
|
||||||
import net.minecraft.client.renderer.chunk.RenderChunk;
|
|
||||||
import org.lwjgl.opengl.GL14;
|
|
||||||
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.CallbackInfo;
|
|
||||||
|
|
||||||
import static org.lwjgl.opengl.GL11.*;
|
|
||||||
|
|
||||||
@Mixin(ChunkRenderContainer.class)
|
|
||||||
public class MixinChunkRenderContainer {
|
|
||||||
|
|
||||||
@Inject(
|
|
||||||
method = "preRenderChunk",
|
|
||||||
at = @At("HEAD")
|
|
||||||
)
|
|
||||||
private void preRenderChunk(RenderChunk renderChunkIn, CallbackInfo ci) {
|
|
||||||
if (Baritone.settings().renderCachedChunks.get() && Minecraft.getMinecraft().world.getChunk(renderChunkIn.getPosition()).isEmpty()) {
|
|
||||||
GlStateManager.enableAlpha();
|
|
||||||
GlStateManager.enableBlend();
|
|
||||||
GL14.glBlendColor(0, 0, 0, Baritone.settings().cachedChunksOpacity.get());
|
|
||||||
GlStateManager.tryBlendFuncSeparate(GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA, GL_ONE, GL_ZERO);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,56 +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 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 <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package baritone.launch.mixins;
|
|
||||||
|
|
||||||
import baritone.Baritone;
|
|
||||||
import baritone.api.BaritoneAPI;
|
|
||||||
import baritone.api.utils.IPlayerContext;
|
|
||||||
import net.minecraft.client.renderer.chunk.ChunkRenderWorker;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
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.Redirect;
|
|
||||||
|
|
||||||
@Mixin(ChunkRenderWorker.class)
|
|
||||||
public abstract class MixinChunkRenderWorker {
|
|
||||||
|
|
||||||
@Shadow
|
|
||||||
protected abstract boolean isChunkExisting(BlockPos pos, World worldIn);
|
|
||||||
|
|
||||||
@Redirect(
|
|
||||||
method = "processTask",
|
|
||||||
at = @At(
|
|
||||||
value = "INVOKE",
|
|
||||||
target = "net/minecraft/client/renderer/chunk/ChunkRenderWorker.isChunkExisting(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/world/World;)Z"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
private boolean isChunkExisting(ChunkRenderWorker worker, BlockPos pos, World world) {
|
|
||||||
if (Baritone.settings().renderCachedChunks.get()) {
|
|
||||||
Baritone baritone = (Baritone) BaritoneAPI.getProvider().getPrimaryBaritone();
|
|
||||||
IPlayerContext ctx = baritone.getPlayerContext();
|
|
||||||
if (ctx.player() != null && ctx.world() != null && baritone.bsi != null) {
|
|
||||||
return baritone.bsi.isLoaded(pos.getX(), pos.getZ()) || this.isChunkExisting(pos, world);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.isChunkExisting(pos, world);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
/*
|
||||||
|
* 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 <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package baritone.launch.mixins;
|
||||||
|
|
||||||
|
import baritone.api.BaritoneAPI;
|
||||||
|
import baritone.api.event.events.RotationMoveEvent;
|
||||||
|
import net.minecraft.client.entity.EntityPlayerSP;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
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 static org.spongepowered.asm.lib.Opcodes.GETFIELD;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Brady
|
||||||
|
* @since 8/21/2018
|
||||||
|
*/
|
||||||
|
@Mixin(Entity.class)
|
||||||
|
public class MixinEntity {
|
||||||
|
|
||||||
|
@Shadow
|
||||||
|
public float rotationYaw;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event called to override the movement direction when walking
|
||||||
|
*/
|
||||||
|
private RotationMoveEvent motionUpdateRotationEvent;
|
||||||
|
|
||||||
|
@Inject(
|
||||||
|
method = "moveRelative",
|
||||||
|
at = @At("HEAD")
|
||||||
|
)
|
||||||
|
private void preMoveRelative(float strafe, float up, float forward, float friction, CallbackInfo ci) {
|
||||||
|
// noinspection ConstantConditions
|
||||||
|
if (EntityPlayerSP.class.isInstance(this)) {
|
||||||
|
this.motionUpdateRotationEvent = new RotationMoveEvent(RotationMoveEvent.Type.MOTION_UPDATE, this.rotationYaw);
|
||||||
|
BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this).getGameEventHandler().onPlayerRotationMove(this.motionUpdateRotationEvent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Redirect(
|
||||||
|
method = "moveRelative",
|
||||||
|
at = @At(
|
||||||
|
value = "FIELD",
|
||||||
|
opcode = GETFIELD,
|
||||||
|
target = "net/minecraft/entity/Entity.rotationYaw:F"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
private float overrideYaw(Entity self) {
|
||||||
|
if (self instanceof EntityPlayerSP) {
|
||||||
|
return this.motionUpdateRotationEvent.getYaw();
|
||||||
|
}
|
||||||
|
return self.rotationYaw;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -74,25 +74,4 @@ public abstract class MixinEntityLivingBase extends Entity {
|
|||||||
}
|
}
|
||||||
return self.rotationYaw;
|
return self.rotationYaw;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Redirect(
|
|
||||||
method = "travel",
|
|
||||||
at = @At(
|
|
||||||
value = "INVOKE",
|
|
||||||
target = "net/minecraft/entity/EntityLivingBase.moveRelative(FFFF)V"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
private void travel(EntityLivingBase self, float strafe, float up, float forward, float friction) {
|
|
||||||
// noinspection ConstantConditions
|
|
||||||
if (!EntityPlayerSP.class.isInstance(this)) {
|
|
||||||
moveRelative(strafe, up, forward, friction);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
RotationMoveEvent motionUpdateRotationEvent = new RotationMoveEvent(RotationMoveEvent.Type.MOTION_UPDATE, this.rotationYaw);
|
|
||||||
BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this).getGameEventHandler().onPlayerRotationMove(motionUpdateRotationEvent);
|
|
||||||
float originalYaw = this.rotationYaw;
|
|
||||||
this.rotationYaw = motionUpdateRotationEvent.getYaw();
|
|
||||||
this.moveRelative(strafe, up, forward, friction);
|
|
||||||
this.rotationYaw = originalYaw;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
package baritone.launch.mixins;
|
package baritone.launch.mixins;
|
||||||
|
|
||||||
import baritone.api.BaritoneAPI;
|
import baritone.api.BaritoneAPI;
|
||||||
import baritone.api.IBaritone;
|
|
||||||
import baritone.api.behavior.IPathingBehavior;
|
import baritone.api.behavior.IPathingBehavior;
|
||||||
import baritone.api.event.events.ChatEvent;
|
import baritone.api.event.events.ChatEvent;
|
||||||
import baritone.api.event.events.PlayerUpdateEvent;
|
import baritone.api.event.events.PlayerUpdateEvent;
|
||||||
@@ -101,16 +100,8 @@ public class MixinEntityPlayerSP {
|
|||||||
)
|
)
|
||||||
private boolean isKeyDown(KeyBinding keyBinding) {
|
private boolean isKeyDown(KeyBinding keyBinding) {
|
||||||
SprintStateEvent event = new SprintStateEvent();
|
SprintStateEvent event = new SprintStateEvent();
|
||||||
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this);
|
BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this).getGameEventHandler().onPlayerSprintState(event);
|
||||||
baritone.getGameEventHandler().onPlayerSprintState(event);
|
return event.getState() == null ? keyBinding.isKeyDown() : event.getState();
|
||||||
if (event.getState() != null) {
|
|
||||||
return event.getState();
|
|
||||||
}
|
|
||||||
if (baritone != BaritoneAPI.getProvider().getPrimaryBaritone()) {
|
|
||||||
// hitting control shouldn't make all bots sprint
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return keyBinding.isKeyDown();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(
|
@Inject(
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
|
|
||||||
package baritone.launch.mixins;
|
package baritone.launch.mixins;
|
||||||
|
|
||||||
import baritone.Baritone;
|
|
||||||
import baritone.api.BaritoneAPI;
|
import baritone.api.BaritoneAPI;
|
||||||
import baritone.utils.Helper;
|
import baritone.utils.Helper;
|
||||||
import net.minecraft.client.settings.KeyBinding;
|
import net.minecraft.client.settings.KeyBinding;
|
||||||
@@ -46,9 +45,6 @@ public class MixinKeyBinding {
|
|||||||
// only the primary baritone forces keys
|
// only the primary baritone forces keys
|
||||||
Boolean force = BaritoneAPI.getProvider().getPrimaryBaritone().getInputOverrideHandler().isInputForcedDown((KeyBinding) (Object) this);
|
Boolean force = BaritoneAPI.getProvider().getPrimaryBaritone().getInputOverrideHandler().isInputForcedDown((KeyBinding) (Object) this);
|
||||||
if (force != null) {
|
if (force != null) {
|
||||||
if (!force && !Baritone.settings().suppressClicks.get()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
cir.setReturnValue(force); // :sunglasses:
|
cir.setReturnValue(force); // :sunglasses:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -61,10 +57,9 @@ public class MixinKeyBinding {
|
|||||||
private void isPressed(CallbackInfoReturnable<Boolean> cir) {
|
private void isPressed(CallbackInfoReturnable<Boolean> cir) {
|
||||||
// only the primary baritone forces keys
|
// only the primary baritone forces keys
|
||||||
Boolean force = BaritoneAPI.getProvider().getPrimaryBaritone().getInputOverrideHandler().isInputForcedDown((KeyBinding) (Object) this);
|
Boolean force = BaritoneAPI.getProvider().getPrimaryBaritone().getInputOverrideHandler().isInputForcedDown((KeyBinding) (Object) this);
|
||||||
if (force != null && !force && Baritone.settings().suppressClicks.get()) { // <-- cursed
|
if (force != null && !force) { // <-- cursed
|
||||||
if (pressTime > 0) {
|
if (pressTime > 0) {
|
||||||
Helper.HELPER.logDirect("You're trying to press this mouse button but I won't let you.");
|
Helper.HELPER.logDirect("You're trying to press this mouse button but I won't let you");
|
||||||
Helper.HELPER.logDirect("Turn off the suppressClicks setting to allow clicking while pathing.");
|
|
||||||
pressTime--;
|
pressTime--;
|
||||||
}
|
}
|
||||||
cir.setReturnValue(force); // :sunglasses:
|
cir.setReturnValue(force); // :sunglasses:
|
||||||
|
|||||||
@@ -1,88 +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 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 <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package baritone.launch.mixins;
|
|
||||||
|
|
||||||
import baritone.Baritone;
|
|
||||||
import baritone.api.BaritoneAPI;
|
|
||||||
import baritone.api.utils.IPlayerContext;
|
|
||||||
import net.minecraft.block.state.IBlockState;
|
|
||||||
import net.minecraft.client.renderer.chunk.RenderChunk;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.world.ChunkCache;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Brady
|
|
||||||
* @since 1/29/2019
|
|
||||||
*/
|
|
||||||
@Mixin(RenderChunk.class)
|
|
||||||
public class MixinRenderChunk {
|
|
||||||
|
|
||||||
@Redirect(
|
|
||||||
method = "rebuildChunk",
|
|
||||||
at = @At(
|
|
||||||
value = "INVOKE",
|
|
||||||
target = "net/minecraft/world/ChunkCache.isEmpty()Z"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
private boolean isEmpty(ChunkCache chunkCache) {
|
|
||||||
if (!chunkCache.isEmpty()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (Baritone.settings().renderCachedChunks.get()) {
|
|
||||||
Baritone baritone = (Baritone) BaritoneAPI.getProvider().getPrimaryBaritone();
|
|
||||||
IPlayerContext ctx = baritone.getPlayerContext();
|
|
||||||
if (ctx.player() != null && ctx.world() != null && baritone.bsi != null) {
|
|
||||||
BlockPos position = ((RenderChunk) (Object) this).getPosition();
|
|
||||||
// RenderChunk extends from -1,-1,-1 to +16,+16,+16
|
|
||||||
// then the constructor of ChunkCache extends it one more (presumably to get things like the connected status of fences? idk)
|
|
||||||
// so if ANY of the adjacent chunks are loaded, we are unempty
|
|
||||||
for (int dx = -1; dx <= 1; dx++) {
|
|
||||||
for (int dz = -1; dz <= 1; dz++) {
|
|
||||||
if (baritone.bsi.isLoaded(16 * dx + position.getX(), 16 * dz + position.getZ())) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Redirect(
|
|
||||||
method = "rebuildChunk",
|
|
||||||
at = @At(
|
|
||||||
value = "INVOKE",
|
|
||||||
target = "net/minecraft/world/ChunkCache.getBlockState(Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/block/state/IBlockState;"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
private IBlockState getBlockState(ChunkCache chunkCache, BlockPos pos) {
|
|
||||||
if (Baritone.settings().renderCachedChunks.get()) {
|
|
||||||
Baritone baritone = (Baritone) BaritoneAPI.getProvider().getPrimaryBaritone();
|
|
||||||
IPlayerContext ctx = baritone.getPlayerContext();
|
|
||||||
if (ctx.player() != null && ctx.world() != null && baritone.bsi != null) {
|
|
||||||
return baritone.bsi.get0(pos);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return chunkCache.getBlockState(pos);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,46 +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 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 <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package baritone.launch.mixins;
|
|
||||||
|
|
||||||
import baritone.Baritone;
|
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
|
||||||
import net.minecraft.client.renderer.RenderList;
|
|
||||||
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.CallbackInfo;
|
|
||||||
|
|
||||||
import static org.lwjgl.opengl.GL11.*;
|
|
||||||
|
|
||||||
@Mixin(RenderList.class)
|
|
||||||
public class MixinRenderList {
|
|
||||||
|
|
||||||
@Inject(
|
|
||||||
method = "renderChunkLayer",
|
|
||||||
at = @At(
|
|
||||||
value = "INVOKE",
|
|
||||||
target = "net/minecraft/client/renderer/GlStateManager.popMatrix()V"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
private void renderChunkLayer(CallbackInfo info) {
|
|
||||||
if (Baritone.settings().renderCachedChunks.get()) {
|
|
||||||
// reset the blend func to normal (not dependent on constant alpha)
|
|
||||||
GlStateManager.tryBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,46 +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 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 <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package baritone.launch.mixins;
|
|
||||||
|
|
||||||
import baritone.Baritone;
|
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
|
||||||
import net.minecraft.client.renderer.VboRenderList;
|
|
||||||
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.CallbackInfo;
|
|
||||||
|
|
||||||
import static org.lwjgl.opengl.GL11.*;
|
|
||||||
|
|
||||||
@Mixin(VboRenderList.class)
|
|
||||||
public class MixinVboRenderList {
|
|
||||||
|
|
||||||
@Inject(
|
|
||||||
method = "renderChunkLayer",
|
|
||||||
at = @At(
|
|
||||||
value = "INVOKE",
|
|
||||||
target = "net/minecraft/client/renderer/GlStateManager.popMatrix()V"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
private void renderChunkLayer(CallbackInfo info) {
|
|
||||||
if (Baritone.settings().renderCachedChunks.get()) {
|
|
||||||
// reset the blend func to normal (not dependent on constant alpha)
|
|
||||||
GlStateManager.tryBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -12,8 +12,7 @@
|
|||||||
"MixinBlockPos",
|
"MixinBlockPos",
|
||||||
"MixinChunkProviderClient",
|
"MixinChunkProviderClient",
|
||||||
"MixinChunkProviderServer",
|
"MixinChunkProviderServer",
|
||||||
"MixinChunkRenderContainer",
|
"MixinEntity",
|
||||||
"MixinChunkRenderWorker",
|
|
||||||
"MixinEntityLivingBase",
|
"MixinEntityLivingBase",
|
||||||
"MixinEntityPlayerSP",
|
"MixinEntityPlayerSP",
|
||||||
"MixinEntityRenderer",
|
"MixinEntityRenderer",
|
||||||
@@ -21,9 +20,6 @@
|
|||||||
"MixinMinecraft",
|
"MixinMinecraft",
|
||||||
"MixinNetHandlerPlayClient",
|
"MixinNetHandlerPlayClient",
|
||||||
"MixinNetworkManager",
|
"MixinNetworkManager",
|
||||||
"MixinRenderChunk",
|
|
||||||
"MixinRenderList",
|
|
||||||
"MixinVboRenderList",
|
|
||||||
"MixinWorldClient"
|
"MixinWorldClient"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -29,7 +29,10 @@ import baritone.process.CustomGoalProcess;
|
|||||||
import baritone.process.FollowProcess;
|
import baritone.process.FollowProcess;
|
||||||
import baritone.process.GetToBlockProcess;
|
import baritone.process.GetToBlockProcess;
|
||||||
import baritone.process.MineProcess;
|
import baritone.process.MineProcess;
|
||||||
import baritone.utils.*;
|
import baritone.utils.BaritoneAutoTest;
|
||||||
|
import baritone.utils.ExampleBaritoneControl;
|
||||||
|
import baritone.utils.InputOverrideHandler;
|
||||||
|
import baritone.utils.PathingControlManager;
|
||||||
import baritone.utils.player.PrimaryPlayerContext;
|
import baritone.utils.player.PrimaryPlayerContext;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
|
||||||
@@ -86,8 +89,6 @@ public class Baritone implements IBaritone {
|
|||||||
private IPlayerContext playerContext;
|
private IPlayerContext playerContext;
|
||||||
private WorldProvider worldProvider;
|
private WorldProvider worldProvider;
|
||||||
|
|
||||||
public BlockStateInterface bsi;
|
|
||||||
|
|
||||||
Baritone() {
|
Baritone() {
|
||||||
this.gameEventHandler = new GameEventHandler(this);
|
this.gameEventHandler = new GameEventHandler(this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -193,10 +193,8 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
|
|||||||
// and this path doesn't get us all the way there
|
// and this path doesn't get us all the way there
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (ticksRemainingInSegment(false).get() < Baritone.settings().planningTickLookAhead.get()) {
|
if (ticksRemainingInSegment().get() < Baritone.settings().planningTickLookAhead.get()) {
|
||||||
// and this path has 7.5 seconds or less left
|
// and this path has 7.5 seconds or less left
|
||||||
// don't include the current movement so a very long last movement (e.g. descend) doesn't trip it up
|
|
||||||
// if we actually included current, it wouldn't start planning ahead until the last movement was done, if the last movement took more than 7.5 seconds on its own
|
|
||||||
logDebug("Path almost over. Planning ahead...");
|
logDebug("Path almost over. Planning ahead...");
|
||||||
queuePathEvent(PathEvent.NEXT_SEGMENT_CALC_STARTED);
|
queuePathEvent(PathEvent.NEXT_SEGMENT_CALC_STARTED);
|
||||||
findPathInNewThread(current.getPath().getDest(), false);
|
findPathInNewThread(current.getPath().getDest(), false);
|
||||||
|
|||||||
+2
-3
@@ -124,13 +124,12 @@ public final class ChunkPacker {
|
|||||||
|
|
||||||
private static PathingBlockType getPathingBlockType(IBlockState state) {
|
private static PathingBlockType getPathingBlockType(IBlockState state) {
|
||||||
Block block = state.getBlock();
|
Block block = state.getBlock();
|
||||||
if ((block == Blocks.WATER || block == Blocks.FLOWING_WATER) && !MovementHelper.isFlowing(state)) {
|
if (block == Blocks.WATER && !MovementHelper.isFlowing(state)) {
|
||||||
// only water source blocks are plausibly usable, flowing water should be avoid
|
// only water source blocks are plausibly usable, flowing water should be avoid
|
||||||
// FLOWING_WATER is a waterfall, it doesn't really matter and caching it as AVOID just makes it look wrong
|
|
||||||
return PathingBlockType.WATER;
|
return PathingBlockType.WATER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MovementHelper.avoidWalkingInto(block) || MovementHelper.isBottomSlab(state)) {
|
if (MovementHelper.avoidWalkingInto(block) || block == Blocks.FLOWING_WATER || MovementHelper.isBottomSlab(state)) {
|
||||||
return PathingBlockType.AVOID;
|
return PathingBlockType.AVOID;
|
||||||
}
|
}
|
||||||
// We used to do an AABB check here
|
// We used to do an AABB check here
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ import baritone.api.event.events.type.EventState;
|
|||||||
import baritone.api.event.listener.IEventBus;
|
import baritone.api.event.listener.IEventBus;
|
||||||
import baritone.api.event.listener.IGameEventListener;
|
import baritone.api.event.listener.IGameEventListener;
|
||||||
import baritone.cache.WorldProvider;
|
import baritone.cache.WorldProvider;
|
||||||
import baritone.utils.BlockStateInterface;
|
|
||||||
import baritone.utils.Helper;
|
import baritone.utils.Helper;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.chunk.Chunk;
|
import net.minecraft.world.chunk.Chunk;
|
||||||
@@ -47,13 +46,6 @@ public final class GameEventHandler implements IEventBus, Helper {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void onTick(TickEvent event) {
|
public final void onTick(TickEvent event) {
|
||||||
if (event.getType() == TickEvent.Type.IN) {
|
|
||||||
try {
|
|
||||||
baritone.bsi = new BlockStateInterface(baritone.getPlayerContext(), true);
|
|
||||||
} catch (Exception ex) {}
|
|
||||||
} else {
|
|
||||||
baritone.bsi = null;
|
|
||||||
}
|
|
||||||
listeners.forEach(l -> l.onTick(event));
|
listeners.forEach(l -> l.onTick(event));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ public final class AStarPathFinder extends AbstractNodeCostSearch {
|
|||||||
if (bestHeuristicSoFar[i] - heuristic > minimumImprovement) {
|
if (bestHeuristicSoFar[i] - heuristic > minimumImprovement) {
|
||||||
bestHeuristicSoFar[i] = heuristic;
|
bestHeuristicSoFar[i] = heuristic;
|
||||||
bestSoFar[i] = neighbor;
|
bestSoFar[i] = neighbor;
|
||||||
if (failing && getDistFromStartSq(neighbor) > MIN_DIST_PATH * MIN_DIST_PATH) {
|
if (getDistFromStartSq(neighbor) > MIN_DIST_PATH * MIN_DIST_PATH) {
|
||||||
failing = false;
|
failing = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ public final class BinaryHeapOpenSet implements IOpenSet {
|
|||||||
int index = val.heapPosition;
|
int index = val.heapPosition;
|
||||||
int parentInd = index >>> 1;
|
int parentInd = index >>> 1;
|
||||||
double cost = val.combinedCost;
|
double cost = val.combinedCost;
|
||||||
|
PathNode[] array = this.array;
|
||||||
PathNode parentNode = array[parentInd];
|
PathNode parentNode = array[parentInd];
|
||||||
while (index > 1 && parentNode.combinedCost > cost) {
|
while (index > 1 && parentNode.combinedCost > cost) {
|
||||||
array[index] = parentNode;
|
array[index] = parentNode;
|
||||||
@@ -94,40 +95,50 @@ public final class BinaryHeapOpenSet implements IOpenSet {
|
|||||||
if (size == 0) {
|
if (size == 0) {
|
||||||
throw new IllegalStateException();
|
throw new IllegalStateException();
|
||||||
}
|
}
|
||||||
|
PathNode[] array = this.array;
|
||||||
PathNode result = array[1];
|
PathNode result = array[1];
|
||||||
PathNode val = array[size];
|
PathNode val = array[size];
|
||||||
array[1] = val;
|
array[1] = val;
|
||||||
val.heapPosition = 1;
|
val.heapPosition = 1;
|
||||||
array[size] = null;
|
array[size] = null;
|
||||||
size--;
|
int size = --this.size;
|
||||||
result.heapPosition = -1;
|
result.heapPosition = -1;
|
||||||
if (size < 2) {
|
if (size < 2) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
int index = 1;
|
int index = 1;
|
||||||
int smallerChild = 2;
|
int smallerChild = 1;
|
||||||
double cost = val.combinedCost;
|
double cost = val.combinedCost;
|
||||||
do {
|
while ((smallerChild <<= 1) < size) {
|
||||||
PathNode smallerChildNode = array[smallerChild];
|
PathNode smallerChildNode = array[smallerChild];
|
||||||
|
PathNode otherChildNode = array[smallerChild + 1];
|
||||||
double smallerChildCost = smallerChildNode.combinedCost;
|
double smallerChildCost = smallerChildNode.combinedCost;
|
||||||
if (smallerChild < size) {
|
double rightChildCost = otherChildNode.combinedCost;
|
||||||
PathNode rightChildNode = array[smallerChild + 1];
|
if (smallerChildCost > rightChildCost) {
|
||||||
double rightChildCost = rightChildNode.combinedCost;
|
smallerChild++;
|
||||||
if (smallerChildCost > rightChildCost) {
|
smallerChildCost = rightChildCost;
|
||||||
smallerChild++;
|
smallerChildNode = otherChildNode;
|
||||||
smallerChildCost = rightChildCost;
|
|
||||||
smallerChildNode = rightChildNode;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (cost <= smallerChildCost) {
|
if (cost <= smallerChildCost) {
|
||||||
break;
|
return result;
|
||||||
}
|
}
|
||||||
array[index] = smallerChildNode;
|
array[index] = smallerChildNode;
|
||||||
array[smallerChild] = val;
|
array[smallerChild] = val;
|
||||||
val.heapPosition = smallerChild;
|
val.heapPosition = smallerChild;
|
||||||
smallerChildNode.heapPosition = index;
|
smallerChildNode.heapPosition = index;
|
||||||
index = smallerChild;
|
index = smallerChild;
|
||||||
} while ((smallerChild <<= 1) <= size);
|
}
|
||||||
|
// if we get here, then smallerChild >= size
|
||||||
|
// one last swap to check
|
||||||
|
if (smallerChild == size) {
|
||||||
|
PathNode onlyChildNode = array[smallerChild];
|
||||||
|
if (cost > onlyChildNode.combinedCost) {
|
||||||
|
array[index] = onlyChildNode;
|
||||||
|
array[smallerChild] = val;
|
||||||
|
val.heapPosition = smallerChild;
|
||||||
|
onlyChildNode.heapPosition = index;
|
||||||
|
}
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ public class MovementDiagonal extends Movement {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
IBlockState pb3 = context.get(destX, y + 1, z);
|
IBlockState pb3 = context.get(destX, y + 1, z);
|
||||||
if (optionA == 0 && ((MovementHelper.avoidWalkingInto(pb2.getBlock()) && pb2.getBlock() != Blocks.WATER) || MovementHelper.avoidWalkingInto(pb3.getBlock()))) {
|
if (optionA == 0 && ((MovementHelper.avoidWalkingInto(pb2.getBlock()) && pb2.getBlock() != Blocks.WATER) || (MovementHelper.avoidWalkingInto(pb3.getBlock()) && pb3.getBlock() != Blocks.WATER))) {
|
||||||
// at this point we're done calculating optionA, so we can check if it's actually possible to edge around in that direction
|
// at this point we're done calculating optionA, so we can check if it's actually possible to edge around in that direction
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -123,7 +123,7 @@ public class MovementDiagonal extends Movement {
|
|||||||
// and finally, if the cost is nonzero for both ways to approach this diagonal, it's not possible
|
// and finally, if the cost is nonzero for both ways to approach this diagonal, it's not possible
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (optionB == 0 && ((MovementHelper.avoidWalkingInto(pb0.getBlock()) && pb0.getBlock() != Blocks.WATER) || MovementHelper.avoidWalkingInto(pb1.getBlock()))) {
|
if (optionB == 0 && ((MovementHelper.avoidWalkingInto(pb0.getBlock()) && pb0.getBlock() != Blocks.WATER) || (MovementHelper.avoidWalkingInto(pb1.getBlock()) && pb1.getBlock() != Blocks.WATER))) {
|
||||||
// and now that option B is fully calculated, see if we can edge around that way
|
// and now that option B is fully calculated, see if we can edge around that way
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -187,11 +187,6 @@ public class MovementParkour extends Movement {
|
|||||||
logDebug("Pausing parkour since hand is active");
|
logDebug("Pausing parkour since hand is active");
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
if (ctx.playerFeet().y < src.y) {
|
|
||||||
// we have fallen
|
|
||||||
logDebug("sorry");
|
|
||||||
return state.setStatus(MovementStatus.UNREACHABLE);
|
|
||||||
}
|
|
||||||
if (dist >= 4) {
|
if (dist >= 4) {
|
||||||
state.setInput(Input.SPRINT, true);
|
state.setInput(Input.SPRINT, true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -281,8 +281,6 @@ public class MovementTraverse extends Movement {
|
|||||||
}
|
}
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
if (whereAmI.equals(dest)) {
|
if (whereAmI.equals(dest)) {
|
||||||
// If we are in the block that we are trying to get to, we are sneaking over air and we need to place a block beneath us against the one we just walked off of
|
// If we are in the block that we are trying to get to, we are sneaking over air and we need to place a block beneath us against the one we just walked off of
|
||||||
|
|||||||
@@ -249,8 +249,6 @@ public class PathExecutor implements IPathExecutor, Helper {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!movement.calculatedWhileLoaded() && currentCost - currentMovementOriginalCostEstimate > Baritone.settings().maxCostIncrease.get() && canCancel) {
|
if (!movement.calculatedWhileLoaded() && currentCost - currentMovementOriginalCostEstimate > Baritone.settings().maxCostIncrease.get() && canCancel) {
|
||||||
// don't do this if the movement was calculated while loaded
|
|
||||||
// that means that this isn't a cache error, it's just part of the path interfering with a later part
|
|
||||||
logDebug("Original cost " + currentMovementOriginalCostEstimate + " current cost " + currentCost + ". Cancelling.");
|
logDebug("Original cost " + currentMovementOriginalCostEstimate + " current cost " + currentCost + ". Cancelling.");
|
||||||
cancel();
|
cancel();
|
||||||
return true;
|
return true;
|
||||||
@@ -379,21 +377,21 @@ public class PathExecutor implements IPathExecutor, Helper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean shouldSprintNextTick() {
|
private boolean shouldSprintNextTick() {
|
||||||
boolean requested = behavior.baritone.getInputOverrideHandler().isInputForcedDown(Input.SPRINT);
|
|
||||||
|
|
||||||
// we'll take it from here, no need for minecraft to see we're holding down control and sprint for us
|
|
||||||
behavior.baritone.getInputOverrideHandler().setInputForceState(Input.SPRINT, false);
|
|
||||||
|
|
||||||
// first and foremost, if allowSprint is off, or if we don't have enough hunger, don't try and sprint
|
// first and foremost, if allowSprint is off, or if we don't have enough hunger, don't try and sprint
|
||||||
if (!new CalculationContext(behavior.baritone).canSprint) {
|
if (!new CalculationContext(behavior.baritone).canSprint) {
|
||||||
|
behavior.baritone.getInputOverrideHandler().setInputForceState(Input.SPRINT, false);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the movement requested sprinting, then we're done
|
// if the movement requested sprinting, then we're done
|
||||||
if (requested) {
|
if (behavior.baritone.getInputOverrideHandler().isInputForcedDown(Input.SPRINT)) {
|
||||||
|
behavior.baritone.getInputOverrideHandler().setInputForceState(Input.SPRINT, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// we'll take it from here, no need for minecraft to see we're holding down control and sprint for us
|
||||||
|
behavior.baritone.getInputOverrideHandler().setInputForceState(Input.SPRINT, false);
|
||||||
|
|
||||||
// however, descend doesn't request sprinting, beceause it doesn't know the context of what movement comes after it
|
// however, descend doesn't request sprinting, beceause it doesn't know the context of what movement comes after it
|
||||||
IMovement current = path.movements().get(pathPosition);
|
IMovement current = path.movements().get(pathPosition);
|
||||||
if (current instanceof MovementDescend) {
|
if (current instanceof MovementDescend) {
|
||||||
|
|||||||
@@ -18,7 +18,10 @@
|
|||||||
package baritone.process;
|
package baritone.process;
|
||||||
|
|
||||||
import baritone.Baritone;
|
import baritone.Baritone;
|
||||||
import baritone.api.pathing.goals.*;
|
import baritone.api.pathing.goals.Goal;
|
||||||
|
import baritone.api.pathing.goals.GoalComposite;
|
||||||
|
import baritone.api.pathing.goals.GoalGetToBlock;
|
||||||
|
import baritone.api.pathing.goals.GoalTwoBlocks;
|
||||||
import baritone.api.process.IGetToBlockProcess;
|
import baritone.api.process.IGetToBlockProcess;
|
||||||
import baritone.api.process.PathingCommand;
|
import baritone.api.process.PathingCommand;
|
||||||
import baritone.api.process.PathingCommandType;
|
import baritone.api.process.PathingCommandType;
|
||||||
@@ -41,7 +44,6 @@ public class GetToBlockProcess extends BaritoneProcessHelper implements IGetToBl
|
|||||||
|
|
||||||
private Block gettingTo;
|
private Block gettingTo;
|
||||||
private List<BlockPos> knownLocations;
|
private List<BlockPos> knownLocations;
|
||||||
private BlockPos start;
|
|
||||||
|
|
||||||
private int tickCount = 0;
|
private int tickCount = 0;
|
||||||
|
|
||||||
@@ -53,7 +55,6 @@ public class GetToBlockProcess extends BaritoneProcessHelper implements IGetToBl
|
|||||||
public void getToBlock(Block block) {
|
public void getToBlock(Block block) {
|
||||||
onLostControl();
|
onLostControl();
|
||||||
gettingTo = block;
|
gettingTo = block;
|
||||||
start = ctx.playerFeet();
|
|
||||||
rescan(new ArrayList<>(), new CalculationContext(baritone));
|
rescan(new ArrayList<>(), new CalculationContext(baritone));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,14 +69,6 @@ public class GetToBlockProcess extends BaritoneProcessHelper implements IGetToBl
|
|||||||
rescan(new ArrayList<>(), new CalculationContext(baritone));
|
rescan(new ArrayList<>(), new CalculationContext(baritone));
|
||||||
}
|
}
|
||||||
if (knownLocations.isEmpty()) {
|
if (knownLocations.isEmpty()) {
|
||||||
if (Baritone.settings().exploreForBlocks.get()) {
|
|
||||||
return new PathingCommand(new GoalRunAway(1, start) {
|
|
||||||
@Override
|
|
||||||
public boolean isInGoal(int x, int y, int z) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}, PathingCommandType.FORCE_REVALIDATE_GOAL_AND_PATH);
|
|
||||||
}
|
|
||||||
logDirect("No known locations of " + gettingTo + ", canceling GetToBlock");
|
logDirect("No known locations of " + gettingTo + ", canceling GetToBlock");
|
||||||
if (isSafeToCancel) {
|
if (isSafeToCancel) {
|
||||||
onLostControl();
|
onLostControl();
|
||||||
@@ -113,7 +106,6 @@ public class GetToBlockProcess extends BaritoneProcessHelper implements IGetToBl
|
|||||||
public void onLostControl() {
|
public void onLostControl() {
|
||||||
gettingTo = null;
|
gettingTo = null;
|
||||||
knownLocations = null;
|
knownLocations = null;
|
||||||
start = null;
|
|
||||||
baritone.getInputOverrideHandler().clearAllKeys();
|
baritone.getInputOverrideHandler().clearAllKeys();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ import baritone.api.cache.IWaypoint;
|
|||||||
import baritone.api.event.events.ChatEvent;
|
import baritone.api.event.events.ChatEvent;
|
||||||
import baritone.api.pathing.goals.*;
|
import baritone.api.pathing.goals.*;
|
||||||
import baritone.api.pathing.movement.ActionCosts;
|
import baritone.api.pathing.movement.ActionCosts;
|
||||||
import baritone.api.utils.BetterBlockPos;
|
|
||||||
import baritone.api.utils.SettingsUtil;
|
import baritone.api.utils.SettingsUtil;
|
||||||
import baritone.behavior.Behavior;
|
import baritone.behavior.Behavior;
|
||||||
import baritone.behavior.PathingBehavior;
|
import baritone.behavior.PathingBehavior;
|
||||||
@@ -36,7 +35,6 @@ import baritone.pathing.movement.Moves;
|
|||||||
import baritone.process.CustomGoalProcess;
|
import baritone.process.CustomGoalProcess;
|
||||||
import baritone.utils.pathing.SegmentedCalculator;
|
import baritone.utils.pathing.SegmentedCalculator;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.multiplayer.ChunkProviderClient;
|
import net.minecraft.client.multiplayer.ChunkProviderClient;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
@@ -87,21 +85,21 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSendChatMessage(ChatEvent event) {
|
public void onSendChatMessage(ChatEvent event) {
|
||||||
|
if (!Baritone.settings().chatControl.get() && !Baritone.settings().removePrefix.get()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
String msg = event.getMessage();
|
String msg = event.getMessage();
|
||||||
if (Baritone.settings().prefixControl.get()) {
|
if (Baritone.settings().prefix.get()) {
|
||||||
if (msg.startsWith(COMMAND_PREFIX)) {
|
if (msg.startsWith(COMMAND_PREFIX)) {
|
||||||
if (!runCommand(msg.substring(COMMAND_PREFIX.length()))) {
|
if (!runCommand(msg.substring(COMMAND_PREFIX.length()))) {
|
||||||
logDirect("Invalid command");
|
logDirect("Invalid command");
|
||||||
}
|
}
|
||||||
event.cancel(); // always cancel if using prefixControl
|
event.cancel(); // always cancel if using prefix
|
||||||
return;
|
}
|
||||||
|
} else {
|
||||||
|
if (runCommand(msg)) {
|
||||||
|
event.cancel();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (!Baritone.settings().chatControl.get() && !Baritone.settings().removePrefix.get()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (runCommand(msg)) {
|
|
||||||
event.cancel();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -291,12 +289,6 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
|
|||||||
logDirect("Baritone settings reset");
|
logDirect("Baritone settings reset");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (msg.equals("render")) {
|
|
||||||
BetterBlockPos pf = ctx.playerFeet();
|
|
||||||
Minecraft.getMinecraft().renderGlobal.markBlockRangeForRenderUpdate(pf.x - 500, pf.y - 500, pf.z - 500, pf.x + 500, pf.y + 500, pf.z + 500);
|
|
||||||
logDirect("okay");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (msg.equals("echest")) {
|
if (msg.equals("echest")) {
|
||||||
Optional<List<ItemStack>> contents = baritone.getMemoryBehavior().echest();
|
Optional<List<ItemStack>> contents = baritone.getMemoryBehavior().echest();
|
||||||
if (contents.isPresent()) {
|
if (contents.isPresent()) {
|
||||||
|
|||||||
@@ -36,24 +36,39 @@ public class OpenSetsTest {
|
|||||||
this.size = size;
|
this.size = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final ArrayList<Long> insertions = new ArrayList<>();
|
||||||
|
private static final ArrayList<Long> removal1 = new ArrayList<>();
|
||||||
|
private static final ArrayList<Long> removal2 = new ArrayList<>();
|
||||||
|
|
||||||
@Parameterized.Parameters
|
@Parameterized.Parameters
|
||||||
public static Collection<Object[]> data() {
|
public static Collection<Object[]> data() {
|
||||||
ArrayList<Object[]> testSizes = new ArrayList<>();
|
ArrayList<Object[]> testSizes = new ArrayList<>();
|
||||||
for (int size = 1; size < 20; size++) {
|
/*for (int size = 1; size < 20; size++) {
|
||||||
testSizes.add(new Object[]{size});
|
testSizes.add(new Object[]{size});
|
||||||
}
|
}
|
||||||
for (int size = 100; size <= 1000; size += 100) {
|
for (int size = 100; size <= 1000; size += 100) {
|
||||||
testSizes.add(new Object[]{size});
|
testSizes.add(new Object[]{size});
|
||||||
}
|
}
|
||||||
testSizes.add(new Object[]{5000});
|
testSizes.add(new Object[]{5000});
|
||||||
testSizes.add(new Object[]{10000});
|
testSizes.add(new Object[]{10000});*/
|
||||||
|
testSizes.add(new Object[]{100000});
|
||||||
|
testSizes.add(new Object[]{100000});
|
||||||
|
testSizes.add(new Object[]{100000});
|
||||||
|
testSizes.add(new Object[]{100000});
|
||||||
|
testSizes.add(new Object[]{100000});
|
||||||
|
testSizes.add(new Object[]{100000});
|
||||||
|
testSizes.add(new Object[]{100000});
|
||||||
|
testSizes.add(new Object[]{100000});
|
||||||
|
testSizes.add(new Object[]{100000});
|
||||||
|
testSizes.add(new Object[]{100000});
|
||||||
|
testSizes.add(new Object[]{100000});
|
||||||
return testSizes;
|
return testSizes;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void removeAndTest(int amount, IOpenSet[] test, Optional<Collection<PathNode>> mustContain) {
|
private static void removeAndTest(int amount, IOpenSet[] test, Optional<Collection<PathNode>> mustContain) {
|
||||||
double[][] results = new double[test.length][amount];
|
double[][] results = new double[test.length][amount];
|
||||||
for (int i = 0; i < test.length; i++) {
|
for (int i = 0; i < test.length; i++) {
|
||||||
long before = System.nanoTime() / 1000000L;
|
long before = System.nanoTime();
|
||||||
for (int j = 0; j < amount; j++) {
|
for (int j = 0; j < amount; j++) {
|
||||||
PathNode pn = test[i].removeLowest();
|
PathNode pn = test[i].removeLowest();
|
||||||
if (mustContain.isPresent() && !mustContain.get().contains(pn)) {
|
if (mustContain.isPresent() && !mustContain.get().contains(pn)) {
|
||||||
@@ -61,7 +76,13 @@ public class OpenSetsTest {
|
|||||||
}
|
}
|
||||||
results[i][j] = pn.combinedCost;
|
results[i][j] = pn.combinedCost;
|
||||||
}
|
}
|
||||||
System.out.println(test[i].getClass() + " " + (System.nanoTime() / 1000000L - before));
|
long time = System.nanoTime() - before;
|
||||||
|
System.out.println(test[i].getClass() + " " + (time));
|
||||||
|
if (mustContain.isPresent()) {
|
||||||
|
removal1.add(time);
|
||||||
|
} else {
|
||||||
|
removal2.add(time);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for (int j = 0; j < amount; j++) {
|
for (int j = 0; j < amount; j++) {
|
||||||
for (int i = 1; i < test.length; i++) {
|
for (int i = 1; i < test.length; i++) {
|
||||||
@@ -75,10 +96,16 @@ public class OpenSetsTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSize() {
|
public void testSize() {
|
||||||
|
try {
|
||||||
|
System.gc();
|
||||||
|
Thread.sleep(1000L);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
System.out.println("Testing size " + size);
|
System.out.println("Testing size " + size);
|
||||||
// Include LinkedListOpenSet even though it's not performant because I absolutely trust that it behaves properly
|
// Include LinkedListOpenSet even though it's not performant because I absolutely trust that it behaves properly
|
||||||
// I'm really testing the heap implementations against it as the ground truth
|
// I'm really testing the heap implementations against it as the ground truth
|
||||||
IOpenSet[] test = new IOpenSet[]{new BinaryHeapOpenSet(), new LinkedListOpenSet()};
|
IOpenSet[] test = new IOpenSet[]{new BinaryHeapOpenSet()/*, new LinkedListOpenSet()*/};
|
||||||
for (IOpenSet set : test) {
|
for (IOpenSet set : test) {
|
||||||
assertTrue(set.isEmpty());
|
assertTrue(set.isEmpty());
|
||||||
}
|
}
|
||||||
@@ -116,10 +143,12 @@ public class OpenSetsTest {
|
|||||||
|
|
||||||
System.out.println("Insertion");
|
System.out.println("Insertion");
|
||||||
for (IOpenSet set : test) {
|
for (IOpenSet set : test) {
|
||||||
long before = System.nanoTime() / 1000000L;
|
long before = System.nanoTime();
|
||||||
for (int i = 0; i < size; i++)
|
for (int i = 0; i < size; i++)
|
||||||
set.insert(toInsert[i]);
|
set.insert(toInsert[i]);
|
||||||
System.out.println(set.getClass() + " " + (System.nanoTime() / 1000000L - before));
|
long time = System.nanoTime() - before;
|
||||||
|
System.out.println(set.getClass() + " " + (time));
|
||||||
|
insertions.add(time);
|
||||||
//all three take either 0 or 1ms to insert up to 10,000 nodes
|
//all three take either 0 or 1ms to insert up to 10,000 nodes
|
||||||
//linkedlist takes 0ms most often (because there's no array resizing or allocation there, just pointer shuffling)
|
//linkedlist takes 0ms most often (because there's no array resizing or allocation there, just pointer shuffling)
|
||||||
}
|
}
|
||||||
@@ -166,5 +195,18 @@ public class OpenSetsTest {
|
|||||||
for (IOpenSet set : test) {
|
for (IOpenSet set : test) {
|
||||||
assertTrue(set.isEmpty());
|
assertTrue(set.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
printo(insertions);
|
||||||
|
printo(removal1);
|
||||||
|
printo(removal2);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void printo(ArrayList<Long> data) {
|
||||||
|
if (data.size() < 3) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
System.out.println(data.subList(2, data.size()).stream().mapToLong(x -> x).average().getAsDouble() / 1000000D);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user