Compare commits
44 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2ee119fc64 | |||
| 83265fcb54 | |||
| e8b4f4d2b6 | |||
| 714c6773c3 | |||
| 2fac594315 | |||
| 4bec49de5b | |||
| 4eaa6e20c3 | |||
| 315cc26525 | |||
| 794a761243 | |||
| 5da14fcb3f | |||
| 1047d4ade9 | |||
| 0b8fa3ffe3 | |||
| 498e4e2d6c | |||
| 850c414e8f | |||
| d5a8ed5cb1 | |||
| dd8406c39a | |||
| 13469053b9 | |||
| c4c85b4f49 | |||
| af0c3bbd5c | |||
| 2fcf9ace64 | |||
| 47e1c67bd8 | |||
| 7e3aa6efdd | |||
| 7a2f26ef62 | |||
| b64154e3b3 | |||
| 26256e7155 | |||
| 6599736e00 | |||
| 343bb20bd8 | |||
| 518fa1c74d | |||
| 0b72a8b4b3 | |||
| c013d1e0d9 | |||
| fe51220e3c | |||
| 44d757347b | |||
| c136182e17 | |||
| a1a9b4e6b9 | |||
| f49df63183 | |||
| 96414b37f3 | |||
| 544168ff45 | |||
| e0a618a791 | |||
| 3333797144 | |||
| f7f003c0f9 | |||
| 236d02cb47 | |||
| 6e97fe2210 | |||
| 6741666c24 | |||
| f58b6b41cb |
@@ -11,8 +11,6 @@ build/
|
|||||||
classes/
|
classes/
|
||||||
*.class
|
*.class
|
||||||
|
|
||||||
/out
|
|
||||||
|
|
||||||
# IntelliJ Files
|
# IntelliJ Files
|
||||||
.idea/
|
.idea/
|
||||||
*.iml
|
*.iml
|
||||||
|
|||||||
+1
-1
@@ -10,7 +10,7 @@ install:
|
|||||||
|
|
||||||
script:
|
script:
|
||||||
- docker run --rm cabaletta/baritone ./gradlew javadoc
|
- docker run --rm cabaletta/baritone ./gradlew javadoc
|
||||||
- docker run --name baritone cabaletta/baritone /bin/sh -c "/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -screen 0 128x128x24 -ac +extension GLX +render; DISPLAY=:99 BARITONE_AUTO_TEST=true ./gradlew runAutoTest; cat /code/autotest/success"
|
- docker run --name baritone cabaletta/baritone /bin/sh -c "set -e; /sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -screen 0 128x128x24 -ac +extension GLX +render; DISPLAY=:99 BARITONE_AUTO_TEST=true ./gradlew runClient"
|
||||||
- docker cp baritone:/code/dist dist
|
- docker cp baritone:/code/dist dist
|
||||||
- ls dist
|
- ls dist
|
||||||
- cat dist/checksums.txt
|
- cat dist/checksums.txt
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||

|

|
||||||

|

|
||||||

|

|
||||||
[](https://minecraft.gamepedia.com/1.13.2)
|
[](https://minecraft.gamepedia.com/1.12.2)
|
||||||
[](https://github.com/cabaletta/baritone/graphs/contributors/)
|
[](https://github.com/cabaletta/baritone/graphs/contributors/)
|
||||||
[](https://github.com/cabaletta/baritone/commit/)
|
[](https://github.com/cabaletta/baritone/commit/)
|
||||||
[](https://impactdevelopment.github.io/)
|
[](https://impactdevelopment.github.io/)
|
||||||
|
|||||||
@@ -63,9 +63,6 @@ There are about a hundred settings, but here are some fun / interesting / import
|
|||||||
|
|
||||||
# Troubleshooting / common issues
|
# Troubleshooting / common issues
|
||||||
|
|
||||||
## Baritone highlights a block in green but gets completely stuck? Also I'm using Baritone with Future?
|
|
||||||
Baritone is trying to right click to place a block there, but it can't since there's a conflicting mixin. Baritone can't force click right click when Future is also installed. Left click **does work** on recent Baritone even with Future, however. For now, turn off `allowPlace` and Baritone will only search for paths that don't require placing blocks to complete. `allowBreak` can remain on.
|
|
||||||
|
|
||||||
## Why doesn't Baritone respond to any of my chat commands?
|
## Why doesn't Baritone respond to any of my chat commands?
|
||||||
This could be one of many things.
|
This could be one of many things.
|
||||||
|
|
||||||
|
|||||||
+14
-69
@@ -16,33 +16,33 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
group 'baritone'
|
group 'baritone'
|
||||||
version '1.3.1'
|
version '1.2.6'
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
repositories {
|
repositories {
|
||||||
jcenter()
|
|
||||||
maven {
|
maven {
|
||||||
name = 'forge'
|
name = 'forge'
|
||||||
url = 'http://files.minecraftforge.net/maven'
|
url = 'http://files.minecraftforge.net/maven'
|
||||||
}
|
}
|
||||||
maven {
|
maven {
|
||||||
name = 'impactdevelopment-repo'
|
name = 'SpongePowered'
|
||||||
url = 'https://impactdevelopment.github.io/maven/'
|
url = 'http://repo.spongepowered.org/maven'
|
||||||
}
|
}
|
||||||
|
jcenter()
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath group: 'com.github.ImpactDevelopment', name: 'ForgeGradle', version: '3.0.115'
|
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
|
||||||
classpath group: 'com.github.ImpactDevelopment', name: 'MixinGradle', version: '0.6.2'
|
classpath 'org.spongepowered:mixingradle:0.6-SNAPSHOT'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
import baritone.gradle.task.CreateDistTask
|
import baritone.gradle.task.CreateDistTask
|
||||||
import baritone.gradle.task.ProguardTask
|
import baritone.gradle.task.ProguardTask
|
||||||
import org.apache.tools.ant.taskdefs.condition.Os
|
|
||||||
|
|
||||||
apply plugin: 'java'
|
apply plugin: 'java'
|
||||||
apply plugin: 'net.minecraftforge.gradle'
|
apply plugin: 'net.minecraftforge.gradle.tweaker-client'
|
||||||
apply plugin: 'org.spongepowered.mixin'
|
apply plugin: 'org.spongepowered.mixin'
|
||||||
|
|
||||||
sourceCompatibility = targetCompatibility = '1.8'
|
sourceCompatibility = targetCompatibility = '1.8'
|
||||||
@@ -52,67 +52,19 @@ compileJava {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
api {
|
|
||||||
compileClasspath += main.compileClasspath
|
|
||||||
}
|
|
||||||
main {
|
|
||||||
compileClasspath += api.output
|
|
||||||
}
|
|
||||||
test {
|
|
||||||
compileClasspath += main.compileClasspath + main.runtimeClasspath + main.output
|
|
||||||
runtimeClasspath += main.compileClasspath + main.runtimeClasspath + main.output
|
|
||||||
}
|
|
||||||
launch {
|
launch {
|
||||||
compileClasspath += main.compileClasspath + main.runtimeClasspath + main.output
|
compileClasspath += main.compileClasspath + main.runtimeClasspath + main.output
|
||||||
runtimeClasspath += main.compileClasspath + main.runtimeClasspath + main.output
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
task sourceJar(type: Jar, dependsOn: classes) {
|
|
||||||
classifier = 'sources'
|
|
||||||
from sourceSets.api.allSource
|
|
||||||
}
|
|
||||||
|
|
||||||
minecraft {
|
minecraft {
|
||||||
mappings channel: 'snapshot', version: '20190307-1.13.1'
|
version = '1.12.2'
|
||||||
reobfMappings 'notch'
|
mappings = 'stable_39'
|
||||||
|
tweakClass = 'baritone.launch.BaritoneTweaker'
|
||||||
|
runDir = 'run'
|
||||||
|
|
||||||
runs {
|
// The sources jar should use SRG names not MCP to ensure compatibility with all mappings
|
||||||
client {
|
makeObfSourceJar = true
|
||||||
workingDirectory project.file('run')
|
|
||||||
source sourceSets.launch
|
|
||||||
|
|
||||||
main 'baritone.launch.LaunchTesting'
|
|
||||||
|
|
||||||
environment 'assetIndex', '{asset_index}'
|
|
||||||
environment 'assetDirectory', downloadAssets.output
|
|
||||||
environment 'nativesDirectory', extractNatives.output
|
|
||||||
|
|
||||||
environment 'tweakClass', 'baritone.launch.BaritoneTweaker'
|
|
||||||
|
|
||||||
if (Os.isFamily(Os.FAMILY_MAC)) {
|
|
||||||
jvmArgs "-XstartOnFirstThread"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
autoTest {
|
|
||||||
workingDirectory project.file('autotest')
|
|
||||||
source sourceSets.launch
|
|
||||||
|
|
||||||
main 'baritone.launch.LaunchTesting'
|
|
||||||
|
|
||||||
environment 'assetIndex', '{asset_index}'
|
|
||||||
environment 'assetDirectory', downloadAssets.output
|
|
||||||
environment 'nativesDirectory', extractNatives.output
|
|
||||||
|
|
||||||
environment 'tweakClass', 'baritone.launch.BaritoneTweaker'
|
|
||||||
environment 'BARITONE_AUTO_TEST', 'true'
|
|
||||||
|
|
||||||
if (Os.isFamily(Os.FAMILY_MAC)) {
|
|
||||||
jvmArgs "-XstartOnFirstThread"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
@@ -130,12 +82,6 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
minecraft 'com.github.ImpactDevelopment:Vanilla:1.13.2'
|
|
||||||
|
|
||||||
runtime launchCompile('net.minecraft:launchwrapper:1.12') {
|
|
||||||
exclude module: 'lwjgl'
|
|
||||||
}
|
|
||||||
runtime launchCompile('org.ow2.asm:asm-debug-all:5.2')
|
|
||||||
runtime launchCompile('com.github.ImpactDevelopment:SimpleTweaker:1.2')
|
runtime launchCompile('com.github.ImpactDevelopment:SimpleTweaker:1.2')
|
||||||
runtime launchCompile('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
|
// Mixin includes a lot of dependencies that are too up-to-date
|
||||||
@@ -145,7 +91,6 @@ dependencies {
|
|||||||
exclude module: 'commons-io'
|
exclude module: 'commons-io'
|
||||||
exclude module: 'log4j-core'
|
exclude module: 'log4j-core'
|
||||||
}
|
}
|
||||||
|
|
||||||
testImplementation 'junit:junit:4.12'
|
testImplementation 'junit:junit:4.12'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,13 +40,17 @@ class BaritoneGradleTask extends DefaultTask {
|
|||||||
PROGUARD_STANDALONE_CONFIG = "standalone.pro",
|
PROGUARD_STANDALONE_CONFIG = "standalone.pro",
|
||||||
PROGUARD_EXPORT_PATH = "proguard_out.jar",
|
PROGUARD_EXPORT_PATH = "proguard_out.jar",
|
||||||
|
|
||||||
|
TEMP_LIBRARY_DIR = "tempLibraries/",
|
||||||
|
|
||||||
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_API = "%s-api-forge-%s.jar",
|
||||||
|
ARTIFACT_FORGE_STANDALONE = "%s-standalone-forge-%s.jar";
|
||||||
|
|
||||||
protected String artifactName, artifactVersion;
|
protected String artifactName, artifactVersion;
|
||||||
protected Path artifactPath, artifactUnoptimizedPath, artifactApiPath, artifactStandalonePath, proguardOut;
|
protected Path artifactPath, artifactUnoptimizedPath, artifactApiPath, artifactStandalonePath, artifactForgeApiPath, artifactForgeStandalonePath, proguardOut;
|
||||||
|
|
||||||
protected void verifyArtifacts() throws IllegalStateException {
|
protected void verifyArtifacts() throws IllegalStateException {
|
||||||
this.artifactName = getProject().getName();
|
this.artifactName = getProject().getName();
|
||||||
@@ -56,6 +60,8 @@ 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.artifactForgeApiPath = this.getBuildFile(formatVersion(ARTIFACT_FORGE_API));
|
||||||
|
this.artifactForgeStandalonePath = this.getBuildFile(formatVersion(ARTIFACT_FORGE_STANDALONE));
|
||||||
|
|
||||||
this.proguardOut = this.getTemporaryFile(PROGUARD_EXPORT_PATH);
|
this.proguardOut = this.getTemporaryFile(PROGUARD_EXPORT_PATH);
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,8 @@ 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 forgeApi = getRelativeFile("dist/" + formatVersion(ARTIFACT_FORGE_API));
|
||||||
|
Path forgeStandalone = getRelativeFile("dist/" + formatVersion(ARTIFACT_FORGE_STANDALONE));
|
||||||
|
|
||||||
// NIO will not automatically create directories
|
// NIO will not automatically create directories
|
||||||
Path dir = getRelativeFile("dist/");
|
Path dir = getRelativeFile("dist/");
|
||||||
@@ -56,9 +58,11 @@ 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.artifactForgeApiPath, forgeApi, REPLACE_EXISTING);
|
||||||
|
Files.copy(this.artifactForgeStandalonePath, forgeStandalone, 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)
|
List<String> shasum = Stream.of(api, forgeApi, standalone, forgeStandalone, unoptimized)
|
||||||
.map(path -> sha1(path) + " " + path.getFileName().toString())
|
.map(path -> sha1(path) + " " + path.getFileName().toString())
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
|||||||
@@ -18,18 +18,26 @@
|
|||||||
package baritone.gradle.task;
|
package baritone.gradle.task;
|
||||||
|
|
||||||
import baritone.gradle.util.Determinizer;
|
import baritone.gradle.util.Determinizer;
|
||||||
|
import baritone.gradle.util.MappingType;
|
||||||
|
import baritone.gradle.util.ReobfWrapper;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.gradle.api.plugins.JavaPluginConvention;
|
import org.gradle.api.NamedDomainObjectContainer;
|
||||||
|
import org.gradle.api.artifacts.Configuration;
|
||||||
|
import org.gradle.api.artifacts.Dependency;
|
||||||
|
import org.gradle.api.internal.plugins.DefaultConvention;
|
||||||
import org.gradle.api.tasks.Input;
|
import org.gradle.api.tasks.Input;
|
||||||
import org.gradle.api.tasks.TaskAction;
|
import org.gradle.api.tasks.TaskAction;
|
||||||
|
import org.gradle.internal.Pair;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.List;
|
import java.util.regex.Matcher;
|
||||||
import java.util.stream.Stream;
|
import java.util.regex.Pattern;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipFile;
|
import java.util.zip.ZipFile;
|
||||||
|
|
||||||
@@ -41,12 +49,18 @@ import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
|
|||||||
*/
|
*/
|
||||||
public class ProguardTask extends BaritoneGradleTask {
|
public class ProguardTask extends BaritoneGradleTask {
|
||||||
|
|
||||||
|
private static final Pattern TEMP_LIBRARY_PATTERN = Pattern.compile("-libraryjars 'tempLibraries\\/([a-zA-Z0-9/_\\-\\.]+)\\.jar'");
|
||||||
|
|
||||||
@Input
|
@Input
|
||||||
private String url;
|
private String url;
|
||||||
|
|
||||||
@Input
|
@Input
|
||||||
private String extract;
|
private String extract;
|
||||||
|
|
||||||
|
private List<String> requiredLibraries;
|
||||||
|
|
||||||
|
private File mixin;
|
||||||
|
|
||||||
@TaskAction
|
@TaskAction
|
||||||
protected void exec() throws Exception {
|
protected void exec() throws Exception {
|
||||||
super.verifyArtifacts();
|
super.verifyArtifacts();
|
||||||
@@ -56,6 +70,7 @@ public class ProguardTask extends BaritoneGradleTask {
|
|||||||
downloadProguard();
|
downloadProguard();
|
||||||
extractProguard();
|
extractProguard();
|
||||||
generateConfigs();
|
generateConfigs();
|
||||||
|
acquireDependencies();
|
||||||
proguardApi();
|
proguardApi();
|
||||||
proguardStandalone();
|
proguardStandalone();
|
||||||
cleanup();
|
cleanup();
|
||||||
@@ -66,7 +81,7 @@ public class ProguardTask extends BaritoneGradleTask {
|
|||||||
Files.delete(this.artifactUnoptimizedPath);
|
Files.delete(this.artifactUnoptimizedPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
Determinizer.determinize(this.artifactPath.toString(), this.artifactUnoptimizedPath.toString());
|
Determinizer.determinize(this.artifactPath.toString(), this.artifactUnoptimizedPath.toString(), Optional.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void downloadProguard() throws Exception {
|
private void downloadProguard() throws Exception {
|
||||||
@@ -99,19 +114,6 @@ public class ProguardTask extends BaritoneGradleTask {
|
|||||||
String out = IOUtils.toString(p.getInputStream(), "UTF-8").split("\n")[0].split("Opened ")[1].replace("]", "");
|
String out = IOUtils.toString(p.getInputStream(), "UTF-8").split("\n")[0].split("Opened ")[1].replace("]", "");
|
||||||
template.add(2, "-libraryjars '" + out + "'");
|
template.add(2, "-libraryjars '" + out + "'");
|
||||||
|
|
||||||
// Discover all of the libraries that we will need to acquire from gradle
|
|
||||||
acquireDependencies().forEach(f -> {
|
|
||||||
if (f.toString().endsWith("-recomp.jar")) {
|
|
||||||
// remove MCP mapped jar
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (f.toString().endsWith("client-extra.jar")) {
|
|
||||||
// go from the extra to the original downloaded client
|
|
||||||
f = new File(f.getParentFile(), "client.jar");
|
|
||||||
}
|
|
||||||
template.add(2, "-libraryjars '" + f + "'");
|
|
||||||
});
|
|
||||||
|
|
||||||
// API config doesn't require any changes from the changes that we made to the template
|
// API config doesn't require any changes from the changes that we made to the template
|
||||||
Files.write(getTemporaryFile(PROGUARD_API_CONFIG), template);
|
Files.write(getTemporaryFile(PROGUARD_API_CONFIG), template);
|
||||||
|
|
||||||
@@ -119,20 +121,165 @@ public class ProguardTask extends BaritoneGradleTask {
|
|||||||
List<String> standalone = new ArrayList<>(template);
|
List<String> standalone = new ArrayList<>(template);
|
||||||
standalone.removeIf(s -> s.contains("# this is the keep api"));
|
standalone.removeIf(s -> s.contains("# this is the keep api"));
|
||||||
Files.write(getTemporaryFile(PROGUARD_STANDALONE_CONFIG), standalone);
|
Files.write(getTemporaryFile(PROGUARD_STANDALONE_CONFIG), standalone);
|
||||||
|
|
||||||
|
// Discover all of the libraries that we will need to acquire from gradle
|
||||||
|
this.requiredLibraries = new ArrayList<>();
|
||||||
|
template.forEach(line -> {
|
||||||
|
if (!line.startsWith("#")) {
|
||||||
|
Matcher m = TEMP_LIBRARY_PATTERN.matcher(line);
|
||||||
|
if (m.find()) {
|
||||||
|
this.requiredLibraries.add(m.group(1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private Stream<File> acquireDependencies() {
|
private void acquireDependencies() throws Exception {
|
||||||
return getProject().getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().findByName("launch").getRuntimeClasspath().getFiles().stream().filter(File::isFile);
|
|
||||||
|
// Create a map of all of the dependencies that we are able to access in this project
|
||||||
|
// Likely a better way to do this, I just pair the dependency with the first valid configuration
|
||||||
|
Map<String, Pair<Configuration, Dependency>> dependencyLookupMap = new HashMap<>();
|
||||||
|
getProject().getConfigurations().stream().filter(Configuration::isCanBeResolved).forEach(config ->
|
||||||
|
config.getAllDependencies().forEach(dependency ->
|
||||||
|
dependencyLookupMap.putIfAbsent(dependency.getName() + "-" + dependency.getVersion(), Pair.of(config, dependency))));
|
||||||
|
|
||||||
|
// Create the directory if it doesn't already exist
|
||||||
|
Path tempLibraries = getTemporaryFile(TEMP_LIBRARY_DIR);
|
||||||
|
if (!Files.exists(tempLibraries)) {
|
||||||
|
Files.createDirectory(tempLibraries);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Iterate the required libraries to copy them to tempLibraries
|
||||||
|
for (String lib : this.requiredLibraries) {
|
||||||
|
// copy from the forgegradle cache
|
||||||
|
if (lib.equals("minecraft")) {
|
||||||
|
Path cachedJar = getMinecraftJar();
|
||||||
|
Path inTempDir = getTemporaryFile("tempLibraries/minecraft.jar");
|
||||||
|
// TODO: maybe try not to copy every time
|
||||||
|
Files.copy(cachedJar, inTempDir, REPLACE_EXISTING);
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find a configuration/dependency pair that matches the desired library
|
||||||
|
Pair<Configuration, Dependency> pair = null;
|
||||||
|
for (Map.Entry<String, Pair<Configuration, Dependency>> entry : dependencyLookupMap.entrySet()) {
|
||||||
|
if (entry.getKey().startsWith(lib)) {
|
||||||
|
pair = entry.getValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// The pair must be non-null
|
||||||
|
Objects.requireNonNull(pair);
|
||||||
|
|
||||||
|
// Find the library jar file, and copy it to tempLibraries
|
||||||
|
for (File file : pair.getLeft().files(pair.getRight())) {
|
||||||
|
if (file.getName().startsWith(lib)) {
|
||||||
|
if (lib.contains("mixin")) {
|
||||||
|
mixin = file;
|
||||||
|
}
|
||||||
|
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
|
||||||
|
private Path getMinecraftJar() throws Exception {
|
||||||
|
MappingType mappingType;
|
||||||
|
try {
|
||||||
|
mappingType = getMappingType();
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.err.println("Failed to get mapping type, assuming NOTCH.");
|
||||||
|
mappingType = MappingType.NOTCH;
|
||||||
|
}
|
||||||
|
|
||||||
|
String suffix;
|
||||||
|
switch (mappingType) {
|
||||||
|
case NOTCH:
|
||||||
|
suffix = "";
|
||||||
|
break;
|
||||||
|
case SEARGE:
|
||||||
|
suffix = "-srgBin";
|
||||||
|
break;
|
||||||
|
case CUSTOM:
|
||||||
|
throw new IllegalStateException("Custom mappings not supported!");
|
||||||
|
default:
|
||||||
|
throw new IllegalStateException("Unknown mapping type: " + mappingType);
|
||||||
|
}
|
||||||
|
|
||||||
|
DefaultConvention convention = (DefaultConvention) this.getProject().getConvention();
|
||||||
|
Object extension = convention.getAsMap().get("minecraft");
|
||||||
|
Objects.requireNonNull(extension);
|
||||||
|
|
||||||
|
// for some reason cant use Class.forName
|
||||||
|
Class<?> class_baseExtension = extension.getClass().getSuperclass().getSuperclass().getSuperclass(); // <-- cursed
|
||||||
|
Field f_replacer = class_baseExtension.getDeclaredField("replacer");
|
||||||
|
f_replacer.setAccessible(true);
|
||||||
|
Object replacer = f_replacer.get(extension);
|
||||||
|
Class<?> class_replacementProvider = replacer.getClass();
|
||||||
|
Field replacement_replaceMap = class_replacementProvider.getDeclaredField("replaceMap");
|
||||||
|
replacement_replaceMap.setAccessible(true);
|
||||||
|
|
||||||
|
Map<String, Object> replacements = (Map) replacement_replaceMap.get(replacer);
|
||||||
|
String cacheDir = replacements.get("CACHE_DIR").toString() + "/net/minecraft";
|
||||||
|
String mcVersion = replacements.get("MC_VERSION").toString();
|
||||||
|
String mcpInsert = replacements.get("MAPPING_CHANNEL").toString() + "/" + replacements.get("MAPPING_VERSION").toString();
|
||||||
|
String fullJarName = "minecraft-" + mcVersion + suffix + ".jar";
|
||||||
|
|
||||||
|
String baseDir = String.format("%s/minecraft/%s/", cacheDir, mcVersion);
|
||||||
|
|
||||||
|
String jarPath;
|
||||||
|
if (mappingType == MappingType.SEARGE) {
|
||||||
|
jarPath = String.format("%s/%s/%s", baseDir, mcpInsert, fullJarName);
|
||||||
|
} else {
|
||||||
|
jarPath = baseDir + fullJarName;
|
||||||
|
}
|
||||||
|
jarPath = jarPath
|
||||||
|
.replace("/", File.separator)
|
||||||
|
.replace("\\", File.separator); // hecking regex
|
||||||
|
|
||||||
|
return new File(jarPath).toPath();
|
||||||
|
}
|
||||||
|
|
||||||
|
// throws IllegalStateException if mapping type is ambiguous or it fails to find it
|
||||||
|
private MappingType getMappingType() {
|
||||||
|
// if it fails to find this then its probably a forgegradle version problem
|
||||||
|
Set<Object> reobf = (NamedDomainObjectContainer<Object>) this.getProject().getExtensions().getByName("reobf");
|
||||||
|
|
||||||
|
List<MappingType> mappingTypes = getUsedMappingTypes(reobf);
|
||||||
|
long mappingTypesUsed = mappingTypes.size();
|
||||||
|
if (mappingTypesUsed == 0) {
|
||||||
|
throw new IllegalStateException("Failed to find mapping type (no jar task?)");
|
||||||
|
}
|
||||||
|
if (mappingTypesUsed > 1) {
|
||||||
|
throw new IllegalStateException("Ambiguous mapping type (multiple jars with different mapping types?)");
|
||||||
|
}
|
||||||
|
|
||||||
|
return mappingTypes.get(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<MappingType> getUsedMappingTypes(Set<Object> reobf) {
|
||||||
|
return reobf.stream()
|
||||||
|
.map(ReobfWrapper::new)
|
||||||
|
.map(ReobfWrapper::getMappingType)
|
||||||
|
.distinct()
|
||||||
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
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());
|
Determinizer.determinize(this.proguardOut.toString(), this.artifactApiPath.toString(), Optional.empty());
|
||||||
|
Determinizer.determinize(this.proguardOut.toString(), this.artifactForgeApiPath.toString(), Optional.of(mixin));
|
||||||
}
|
}
|
||||||
|
|
||||||
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());
|
Determinizer.determinize(this.proguardOut.toString(), this.artifactStandalonePath.toString(), Optional.empty());
|
||||||
|
Determinizer.determinize(this.proguardOut.toString(), this.artifactForgeStandalonePath.toString(), Optional.of(mixin));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cleanup() {
|
private void cleanup() {
|
||||||
|
|||||||
@@ -22,10 +22,7 @@ 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.ArrayList;
|
import java.util.*;
|
||||||
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;
|
||||||
@@ -39,7 +36,7 @@ import java.util.stream.Collectors;
|
|||||||
*/
|
*/
|
||||||
public class Determinizer {
|
public class Determinizer {
|
||||||
|
|
||||||
public static void determinize(String inputPath, String outputPath) throws IOException {
|
public static void determinize(String inputPath, String outputPath, Optional<File> toInclude) 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);
|
||||||
@@ -66,10 +63,30 @@ 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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* 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.gradle.util;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* All credits go to AsmLibGradle and its contributors.
|
||||||
|
*
|
||||||
|
* @see <a href="https://github.com/pozzed/AsmLibGradle/blob/8f917dbc3939eab7a3d9daf54d9d285fdf34f4b2/src/main/java/net/futureclient/asmlib/forgegradle/MappingType.java">Original Source</a>
|
||||||
|
*/
|
||||||
|
public enum MappingType {
|
||||||
|
SEARGE,
|
||||||
|
NOTCH,
|
||||||
|
CUSTOM // forgegradle
|
||||||
|
}
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
/*
|
||||||
|
* 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.gradle.util;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* All credits go to AsmLibGradle and its contributors.
|
||||||
|
*
|
||||||
|
* @see <a href="https://github.com/pozzed/AsmLibGradle/blob/8f917dbc3939eab7a3d9daf54d9d285fdf34f4b2/src/main/java/net/futureclient/asmlib/forgegradle/ReobfWrapper.java">Original Source</a>
|
||||||
|
*/
|
||||||
|
public class ReobfWrapper {
|
||||||
|
|
||||||
|
private final Object instance;
|
||||||
|
private final Class<?> type;
|
||||||
|
|
||||||
|
public ReobfWrapper(Object instance) {
|
||||||
|
this.instance = instance;
|
||||||
|
Objects.requireNonNull(instance);
|
||||||
|
this.type = instance.getClass();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
try {
|
||||||
|
Field nameField = type.getDeclaredField("name");
|
||||||
|
nameField.setAccessible(true);
|
||||||
|
return (String) nameField.get(this.instance);
|
||||||
|
} catch (ReflectiveOperationException ex) {
|
||||||
|
throw new IllegalStateException(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public MappingType getMappingType() {
|
||||||
|
try {
|
||||||
|
Field enumField = type.getDeclaredField("mappingType");
|
||||||
|
enumField.setAccessible(true);
|
||||||
|
Enum<?> aEnum = (Enum<?>) enumField.get(this.instance);
|
||||||
|
MappingType mappingType = MappingType.values()[aEnum.ordinal()];
|
||||||
|
if (!aEnum.name().equals(mappingType.name())) {
|
||||||
|
throw new IllegalStateException("ForgeGradle ReobfMappingType is not equivalent to MappingType (version error?)");
|
||||||
|
}
|
||||||
|
return mappingType;
|
||||||
|
} catch (ReflectiveOperationException ex) {
|
||||||
|
throw new IllegalStateException(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Vendored
+52
-2
@@ -14,8 +14,6 @@
|
|||||||
|
|
||||||
# lwjgl is weird
|
# lwjgl is weird
|
||||||
-dontwarn org.lwjgl.**
|
-dontwarn org.lwjgl.**
|
||||||
# also lwjgl lol
|
|
||||||
-dontwarn module-info
|
|
||||||
|
|
||||||
-keep class baritone.api.** { *; } # this is the keep api
|
-keep class baritone.api.** { *; } # this is the keep api
|
||||||
|
|
||||||
@@ -23,6 +21,8 @@
|
|||||||
-keep class baritone.BaritoneProvider
|
-keep class baritone.BaritoneProvider
|
||||||
-keep class baritone.api.IBaritoneProvider
|
-keep class baritone.api.IBaritoneProvider
|
||||||
|
|
||||||
|
-keep class baritone.api.utils.MyChunkPos { *; } # even in standalone we need to keep this for gson reflect
|
||||||
|
|
||||||
# setting names are reflected from field names, so keep field names
|
# setting names are reflected from field names, so keep field names
|
||||||
-keepclassmembers class baritone.api.Settings {
|
-keepclassmembers class baritone.api.Settings {
|
||||||
public <fields>;
|
public <fields>;
|
||||||
@@ -31,6 +31,56 @@
|
|||||||
# need to keep mixin names
|
# need to keep mixin names
|
||||||
-keep class baritone.launch.** { *; }
|
-keep class baritone.launch.** { *; }
|
||||||
|
|
||||||
|
# copy all necessary libraries into tempLibraries to build
|
||||||
|
|
||||||
|
# The correct jar will be copied from the forgegradle cache based on the mapping type being compiled with
|
||||||
|
-libraryjars 'tempLibraries/minecraft.jar'
|
||||||
|
|
||||||
|
-libraryjars 'tempLibraries/SimpleTweaker-1.2.jar'
|
||||||
|
|
||||||
|
-libraryjars 'tempLibraries/authlib-1.5.25.jar'
|
||||||
|
-libraryjars 'tempLibraries/codecjorbis-20101023.jar'
|
||||||
|
-libraryjars 'tempLibraries/codecwav-20101023.jar'
|
||||||
|
-libraryjars 'tempLibraries/commons-codec-1.10.jar'
|
||||||
|
-libraryjars 'tempLibraries/commons-compress-1.8.1.jar'
|
||||||
|
-libraryjars 'tempLibraries/commons-io-2.5.jar'
|
||||||
|
-libraryjars 'tempLibraries/commons-lang3-3.5.jar'
|
||||||
|
-libraryjars 'tempLibraries/commons-logging-1.1.3.jar'
|
||||||
|
-libraryjars 'tempLibraries/fastutil-7.1.0.jar'
|
||||||
|
-libraryjars 'tempLibraries/gson-2.8.0.jar'
|
||||||
|
-libraryjars 'tempLibraries/guava-21.0.jar'
|
||||||
|
-libraryjars 'tempLibraries/httpclient-4.3.3.jar'
|
||||||
|
-libraryjars 'tempLibraries/httpcore-4.3.2.jar'
|
||||||
|
-libraryjars 'tempLibraries/icu4j-core-mojang-51.2.jar'
|
||||||
|
-libraryjars 'tempLibraries/jinput-2.0.5.jar'
|
||||||
|
-libraryjars 'tempLibraries/jna-4.4.0.jar'
|
||||||
|
-libraryjars 'tempLibraries/jopt-simple-5.0.3.jar'
|
||||||
|
-libraryjars 'tempLibraries/jsr305-3.0.1.jar'
|
||||||
|
-libraryjars 'tempLibraries/jutils-1.0.0.jar'
|
||||||
|
-libraryjars 'tempLibraries/libraryjavasound-20101123.jar'
|
||||||
|
-libraryjars 'tempLibraries/librarylwjglopenal-20100824.jar'
|
||||||
|
-libraryjars 'tempLibraries/log4j-api-2.8.1.jar'
|
||||||
|
-libraryjars 'tempLibraries/log4j-core-2.8.1.jar'
|
||||||
|
|
||||||
|
# startsWith is used to check the library, and mac/linux differ in which version they use
|
||||||
|
# this is FINE
|
||||||
|
-libraryjars 'tempLibraries/lwjgl-.jar'
|
||||||
|
-libraryjars 'tempLibraries/lwjgl_util-.jar'
|
||||||
|
|
||||||
|
-libraryjars 'tempLibraries/netty-all-4.1.9.Final.jar'
|
||||||
|
-libraryjars 'tempLibraries/oshi-core-1.1.jar'
|
||||||
|
-libraryjars 'tempLibraries/patchy-1.1.jar'
|
||||||
|
-libraryjars 'tempLibraries/platform-3.4.0.jar'
|
||||||
|
-libraryjars 'tempLibraries/realms-1.10.22.jar'
|
||||||
|
-libraryjars 'tempLibraries/soundsystem-20120107.jar'
|
||||||
|
-libraryjars 'tempLibraries/text2speech-1.10.3.jar'
|
||||||
|
|
||||||
|
-libraryjars 'tempLibraries/mixin-0.7.11-SNAPSHOT.jar'
|
||||||
|
-libraryjars 'tempLibraries/launchwrapper-1.11.jar' # TODO why does only 1.11.jar exist?
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Keep - Applications. Keep all application classes, along with their 'main'
|
# Keep - Applications. Keep all application classes, along with their 'main'
|
||||||
# methods.
|
# methods.
|
||||||
-keepclasseswithmembers public class * {
|
-keepclasseswithmembers public class * {
|
||||||
|
|||||||
@@ -71,6 +71,18 @@ public interface IBaritone {
|
|||||||
*/
|
*/
|
||||||
IBuilderProcess getBuilderProcess();
|
IBuilderProcess getBuilderProcess();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The {@link IExploreProcess} instance
|
||||||
|
* @see IExploreProcess
|
||||||
|
*/
|
||||||
|
IExploreProcess getExploreProcess();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The {@link IFarmProcess} instance
|
||||||
|
* @see IFarmProcess
|
||||||
|
*/
|
||||||
|
IFarmProcess getFarmProcess();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The {@link ICustomGoalProcess} instance
|
* @return The {@link ICustomGoalProcess} instance
|
||||||
* @see ICustomGoalProcess
|
* @see ICustomGoalProcess
|
||||||
@@ -115,4 +127,6 @@ public interface IBaritone {
|
|||||||
* @see IEventBus
|
* @see IEventBus
|
||||||
*/
|
*/
|
||||||
IEventBus getGameEventHandler();
|
IEventBus getGameEventHandler();
|
||||||
|
|
||||||
|
void openClick();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,8 @@
|
|||||||
package baritone.api;
|
package baritone.api;
|
||||||
|
|
||||||
import baritone.api.utils.SettingsUtil;
|
import baritone.api.utils.SettingsUtil;
|
||||||
|
import baritone.api.utils.TypeUtils;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
@@ -26,6 +28,8 @@ import net.minecraft.util.text.ITextComponent;
|
|||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.ParameterizedType;
|
||||||
|
import java.lang.reflect.Type;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
@@ -140,11 +144,26 @@ public final class Settings {
|
|||||||
* Blocks that Baritone is allowed to place (as throwaway, for sneak bridging, pillaring, etc.)
|
* Blocks that Baritone is allowed to place (as throwaway, for sneak bridging, pillaring, etc.)
|
||||||
*/
|
*/
|
||||||
public final Setting<List<Item>> acceptableThrowawayItems = new Setting<>(new ArrayList<>(Arrays.asList(
|
public final Setting<List<Item>> acceptableThrowawayItems = new Setting<>(new ArrayList<>(Arrays.asList(
|
||||||
Blocks.DIRT.asItem(),
|
Item.getItemFromBlock(Blocks.DIRT),
|
||||||
Blocks.COBBLESTONE.asItem(),
|
Item.getItemFromBlock(Blocks.COBBLESTONE),
|
||||||
Blocks.NETHERRACK.asItem()
|
Item.getItemFromBlock(Blocks.NETHERRACK),
|
||||||
|
Item.getItemFromBlock(Blocks.STONE)
|
||||||
)));
|
)));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Blocks that Baritone will attempt to avoid (Used in avoidance)
|
||||||
|
*/
|
||||||
|
public final Setting<List<Block>> blocksToAvoid = new Setting<>(new ArrayList<>(
|
||||||
|
// Leave Empty by Default
|
||||||
|
));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Blocks that Baritone is not allowed to break
|
||||||
|
*/
|
||||||
|
public final Setting<List<Block>> blocksToAvoidBreaking = new Setting<>(new ArrayList<>(
|
||||||
|
// e.g. crafting table, beds
|
||||||
|
));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enables some more advanced vine features. They're honestly just gimmicks and won't ever be needed in real
|
* Enables some more advanced vine features. They're honestly just gimmicks and won't ever be needed in real
|
||||||
* pathing scenarios. And they can cause Baritone to get trapped indefinitely in a strange scenario.
|
* pathing scenarios. And they can cause Baritone to get trapped indefinitely in a strange scenario.
|
||||||
@@ -401,10 +420,12 @@ public final class Settings {
|
|||||||
* On save, delete from RAM any cached regions that are more than 1024 blocks away from the player
|
* On save, delete from RAM any cached regions that are more than 1024 blocks away from the player
|
||||||
* <p>
|
* <p>
|
||||||
* Temporarily disabled
|
* Temporarily disabled
|
||||||
|
* <p>
|
||||||
|
* Temporarily reenabled
|
||||||
*
|
*
|
||||||
* @see <a href="https://github.com/cabaletta/baritone/issues/248">Issue #248</a>
|
* @see <a href="https://github.com/cabaletta/baritone/issues/248">Issue #248</a>
|
||||||
*/
|
*/
|
||||||
public final Setting<Boolean> pruneRegionsFromRAM = new Setting<>(false);
|
public final Setting<Boolean> pruneRegionsFromRAM = new Setting<>(true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remember the contents of containers (chests, echests, furnaces)
|
* Remember the contents of containers (chests, echests, furnaces)
|
||||||
@@ -413,6 +434,11 @@ public final class Settings {
|
|||||||
*/
|
*/
|
||||||
public final Setting<Boolean> containerMemory = new Setting<>(false);
|
public final Setting<Boolean> containerMemory = new Setting<>(false);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fill in blocks behind you
|
||||||
|
*/
|
||||||
|
public final Setting<Boolean> backfill = new Setting<>(false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Print all the debug messages to chat
|
* Print all the debug messages to chat
|
||||||
*/
|
*/
|
||||||
@@ -567,6 +593,30 @@ public final class Settings {
|
|||||||
*/
|
*/
|
||||||
public final Setting<Boolean> exploreForBlocks = new Setting<>(true);
|
public final Setting<Boolean> exploreForBlocks = new Setting<>(true);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* While exploring the world, offset the closest unloaded chunk by this much in both axes.
|
||||||
|
* <p>
|
||||||
|
* This can result in more efficient loading, if you set this to the render distance.
|
||||||
|
*/
|
||||||
|
public final Setting<Integer> worldExploringChunkOffset = new Setting<>(0);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Take the 10 closest chunks, even if they aren't strictly tied for distance metric from origin.
|
||||||
|
*/
|
||||||
|
public final Setting<Integer> exploreChunkSetMinimumSize = new Setting<>(10);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replant nether wart
|
||||||
|
*/
|
||||||
|
public final Setting<Boolean> replantNetherWart = new Setting<>(false);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When the cache scan gives less blocks than the maximum threshold (but still above zero), scan the main world too.
|
||||||
|
* <p>
|
||||||
|
* Only if you have a beefy CPU and automatically mine blocks that are in cache
|
||||||
|
*/
|
||||||
|
public final Setting<Boolean> extendCacheOnThreshold = new Setting<>(false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Don't consider the next layer in builder until the current one is done
|
* Don't consider the next layer in builder until the current one is done
|
||||||
*/
|
*/
|
||||||
@@ -575,10 +625,10 @@ public final class Settings {
|
|||||||
/**
|
/**
|
||||||
* How far to move before repeating the build. -1 for the size of the build in that axis. 0 to disable
|
* How far to move before repeating the build. -1 for the size of the build in that axis. 0 to disable
|
||||||
*/
|
*/
|
||||||
public final Setting<Integer> buildRepeatDistance=new Setting<>(0);
|
public final Setting<Integer> buildRepeatDistance = new Setting<>(0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* What direction te repeat the build in
|
* What direction to repeat the build in
|
||||||
*/
|
*/
|
||||||
public final Setting<EnumFacing> buildRepeatDirection = new Setting<>(EnumFacing.NORTH);
|
public final Setting<EnumFacing> buildRepeatDirection = new Setting<>(EnumFacing.NORTH);
|
||||||
|
|
||||||
@@ -674,6 +724,12 @@ public final class Settings {
|
|||||||
*/
|
*/
|
||||||
public final Setting<Boolean> exploreUsePythagorean = new Setting<>(false);
|
public final Setting<Boolean> exploreUsePythagorean = new Setting<>(false);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Turn this on if your exploration filter is enormous, you don't want it to check if it's done,
|
||||||
|
* and you are just fine with it just hanging on completion
|
||||||
|
*/
|
||||||
|
public final Setting<Boolean> disableCompletionCheck = new Setting<>(false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cached chunks (regardless of if they're in RAM or saved to disk) expire and are deleted after this number of seconds
|
* Cached chunks (regardless of if they're in RAM or saved to disk) expire and are deleted after this number of seconds
|
||||||
* -1 to disable
|
* -1 to disable
|
||||||
@@ -701,7 +757,7 @@ public final class Settings {
|
|||||||
* via {@link Consumer#andThen(Consumer)} or it can completely be overriden via setting
|
* via {@link Consumer#andThen(Consumer)} or it can completely be overriden via setting
|
||||||
* {@link Setting#value};
|
* {@link Setting#value};
|
||||||
*/
|
*/
|
||||||
public final Setting<Consumer<ITextComponent>> logger = new Setting<>(Minecraft.getInstance().ingameGUI.getChatGUI()::printChatMessage);
|
public final Setting<Consumer<ITextComponent>> logger = new Setting<>(Minecraft.getMinecraft().ingameGUI.getChatGUI()::printChatMessage);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The color of the current path
|
* The color of the current path
|
||||||
@@ -754,11 +810,12 @@ public final class Settings {
|
|||||||
*/
|
*/
|
||||||
public final List<Setting<?>> allSettings;
|
public final List<Setting<?>> allSettings;
|
||||||
|
|
||||||
|
public final Map<Setting<?>, Type> settingTypes;
|
||||||
|
|
||||||
public final class Setting<T> {
|
public final class Setting<T> {
|
||||||
public T value;
|
public T value;
|
||||||
public final T defaultValue;
|
public final T defaultValue;
|
||||||
private String name;
|
private String name;
|
||||||
private final Class<T> klass;
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private Setting(T value) {
|
private Setting(T value) {
|
||||||
@@ -767,7 +824,6 @@ public final class Settings {
|
|||||||
}
|
}
|
||||||
this.value = value;
|
this.value = value;
|
||||||
this.defaultValue = value;
|
this.defaultValue = value;
|
||||||
this.klass = (Class<T>) value.getClass();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -785,7 +841,8 @@ public final class Settings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Class<T> getValueClass() {
|
public Class<T> getValueClass() {
|
||||||
return klass;
|
// noinspection unchecked
|
||||||
|
return (Class<T>) TypeUtils.resolveBaseClass(getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -799,14 +856,21 @@ public final class Settings {
|
|||||||
public void reset() {
|
public void reset() {
|
||||||
value = defaultValue;
|
value = defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final Type getType() {
|
||||||
|
return settingTypes.get(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// here be dragons
|
// here be dragons
|
||||||
|
|
||||||
Settings() {
|
Settings() {
|
||||||
Field[] temp = getClass().getFields();
|
Field[] temp = getClass().getFields();
|
||||||
HashMap<String, Setting<?>> tmpByName = new HashMap<>();
|
|
||||||
|
Map<String, Setting<?>> tmpByName = new HashMap<>();
|
||||||
List<Setting<?>> tmpAll = new ArrayList<>();
|
List<Setting<?>> tmpAll = new ArrayList<>();
|
||||||
|
Map<Setting<?>, Type> tmpSettingTypes = new HashMap<>();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (Field field : temp) {
|
for (Field field : temp) {
|
||||||
if (field.getType().equals(Setting.class)) {
|
if (field.getType().equals(Setting.class)) {
|
||||||
@@ -819,6 +883,7 @@ public final class Settings {
|
|||||||
}
|
}
|
||||||
tmpByName.put(name, setting);
|
tmpByName.put(name, setting);
|
||||||
tmpAll.add(setting);
|
tmpAll.add(setting);
|
||||||
|
tmpSettingTypes.put(setting, ((ParameterizedType) field.getGenericType()).getActualTypeArguments()[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
@@ -826,6 +891,7 @@ public final class Settings {
|
|||||||
}
|
}
|
||||||
byLowerName = Collections.unmodifiableMap(tmpByName);
|
byLowerName = Collections.unmodifiableMap(tmpByName);
|
||||||
allSettings = Collections.unmodifiableList(tmpAll);
|
allSettings = Collections.unmodifiableList(tmpAll);
|
||||||
|
settingTypes = Collections.unmodifiableMap(tmpSettingTypes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
|||||||
@@ -23,9 +23,8 @@ import baritone.api.event.listener.IGameEventListener;
|
|||||||
/**
|
/**
|
||||||
* A behavior is simply a type that is able to listen to events.
|
* A behavior is simply a type that is able to listen to events.
|
||||||
*
|
*
|
||||||
* @see IGameEventListener
|
|
||||||
*
|
|
||||||
* @author Brady
|
* @author Brady
|
||||||
|
* @see IGameEventListener
|
||||||
* @since 9/23/2018
|
* @since 9/23/2018
|
||||||
*/
|
*/
|
||||||
public interface IBehavior extends AbstractGameEventListener {}
|
public interface IBehavior extends AbstractGameEventListener {}
|
||||||
|
|||||||
@@ -80,6 +80,13 @@ public interface IPathingBehavior extends IBehavior {
|
|||||||
*/
|
*/
|
||||||
boolean cancelEverything();
|
boolean cancelEverything();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PLEASE never call this
|
||||||
|
* <p>
|
||||||
|
* If cancelEverything was like "kill" this is "sudo kill -9". Or shutting off your computer.
|
||||||
|
*/
|
||||||
|
void forceCancel();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the current path, from the current path executor, if there is one.
|
* Returns the current path, from the current path executor, if there is one.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -81,4 +81,6 @@ public interface ICachedWorld {
|
|||||||
* in a new thread by default.
|
* in a new thread by default.
|
||||||
*/
|
*/
|
||||||
void save();
|
void save();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-3
@@ -15,9 +15,8 @@
|
|||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package baritone.cache;
|
package baritone.api.cache;
|
||||||
|
|
||||||
import baritone.api.cache.IWaypoint;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@@ -47,7 +46,7 @@ public class Waypoint implements IWaypoint {
|
|||||||
* @param location The waypoint location
|
* @param location The waypoint location
|
||||||
* @param creationTimestamp When the waypoint was created
|
* @param creationTimestamp When the waypoint was created
|
||||||
*/
|
*/
|
||||||
Waypoint(String name, Tag tag, BlockPos location, long creationTimestamp) {
|
public Waypoint(String name, Tag tag, BlockPos location, long creationTimestamp) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.tag = tag;
|
this.tag = tag;
|
||||||
this.location = location;
|
this.location = location;
|
||||||
@@ -18,11 +18,12 @@
|
|||||||
package baritone.api.event.listener;
|
package baritone.api.event.listener;
|
||||||
|
|
||||||
import baritone.api.event.events.*;
|
import baritone.api.event.events.*;
|
||||||
|
import io.netty.util.concurrent.GenericFutureListener;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.entity.EntityPlayerSP;
|
import net.minecraft.client.entity.EntityPlayerSP;
|
||||||
import net.minecraft.client.gui.GuiGameOver;
|
import net.minecraft.client.gui.GuiGameOver;
|
||||||
import net.minecraft.client.gui.GuiScreen;
|
|
||||||
import net.minecraft.client.multiplayer.WorldClient;
|
import net.minecraft.client.multiplayer.WorldClient;
|
||||||
|
import net.minecraft.client.settings.GameSettings;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.network.Packet;
|
import net.minecraft.network.Packet;
|
||||||
|
|
||||||
@@ -44,7 +45,7 @@ public interface IGameEventListener {
|
|||||||
* Run once per game tick from before and after the player rotation is sent to the server.
|
* Run once per game tick from before and after the player rotation is sent to the server.
|
||||||
*
|
*
|
||||||
* @param event The event
|
* @param event The event
|
||||||
* @see EntityPlayerSP#tick()
|
* @see EntityPlayerSP#onUpdate()
|
||||||
*/
|
*/
|
||||||
void onPlayerUpdate(PlayerUpdateEvent event);
|
void onPlayerUpdate(PlayerUpdateEvent event);
|
||||||
|
|
||||||
@@ -60,11 +61,14 @@ public interface IGameEventListener {
|
|||||||
* Runs before and after whenever a chunk is either loaded, unloaded, or populated.
|
* Runs before and after whenever a chunk is either loaded, unloaded, or populated.
|
||||||
*
|
*
|
||||||
* @param event The event
|
* @param event The event
|
||||||
|
* @see WorldClient#doPreChunk(int, int, boolean)
|
||||||
*/
|
*/
|
||||||
void onChunkEvent(ChunkEvent event);
|
void onChunkEvent(ChunkEvent event);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Runs once per world render pass.
|
* Runs once per world render pass. Two passes are made when {@link GameSettings#anaglyph} is on.
|
||||||
|
* <p>
|
||||||
|
* <b>Note:</b> {@link GameSettings#anaglyph} has been removed in Minecraft 1.13
|
||||||
*
|
*
|
||||||
* @param event The event
|
* @param event The event
|
||||||
*/
|
*/
|
||||||
@@ -74,7 +78,7 @@ public interface IGameEventListener {
|
|||||||
* Runs before and after whenever a new world is loaded
|
* Runs before and after whenever a new world is loaded
|
||||||
*
|
*
|
||||||
* @param event The event
|
* @param event The event
|
||||||
* @see Minecraft#loadWorld(WorldClient, GuiScreen)
|
* @see Minecraft#loadWorld(WorldClient, String)
|
||||||
*/
|
*/
|
||||||
void onWorldEvent(WorldEvent event);
|
void onWorldEvent(WorldEvent event);
|
||||||
|
|
||||||
@@ -83,6 +87,7 @@ public interface IGameEventListener {
|
|||||||
*
|
*
|
||||||
* @param event The event
|
* @param event The event
|
||||||
* @see Packet
|
* @see Packet
|
||||||
|
* @see GenericFutureListener
|
||||||
*/
|
*/
|
||||||
void onSendPacket(PacketEvent event);
|
void onSendPacket(PacketEvent event);
|
||||||
|
|
||||||
@@ -91,6 +96,7 @@ public interface IGameEventListener {
|
|||||||
*
|
*
|
||||||
* @param event The event
|
* @param event The event
|
||||||
* @see Packet
|
* @see Packet
|
||||||
|
* @see GenericFutureListener
|
||||||
*/
|
*/
|
||||||
void onReceivePacket(PacketEvent event);
|
void onReceivePacket(PacketEvent event);
|
||||||
|
|
||||||
@@ -104,10 +110,10 @@ public interface IGameEventListener {
|
|||||||
void onPlayerRotationMove(RotationMoveEvent event);
|
void onPlayerRotationMove(RotationMoveEvent event);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called whenever the sprint keybind state is checked in {@link EntityPlayerSP#livingTick}
|
* Called whenever the sprint keybind state is checked in {@link EntityPlayerSP#onLivingUpdate}
|
||||||
*
|
*
|
||||||
* @param event The event
|
* @param event The event
|
||||||
* @see EntityPlayerSP#livingTick()
|
* @see EntityPlayerSP#onLivingUpdate()
|
||||||
*/
|
*/
|
||||||
void onPlayerSprintState(SprintStateEvent event);
|
void onPlayerSprintState(SprintStateEvent event);
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
|
|
||||||
package baritone.api.pathing.goals;
|
package baritone.api.pathing.goals;
|
||||||
|
|
||||||
import baritone.api.BaritoneAPI;
|
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
|
|||||||
@@ -31,17 +31,17 @@ public class GoalTwoBlocks implements Goal, IGoalRenderPos {
|
|||||||
/**
|
/**
|
||||||
* The X block position of this goal
|
* The X block position of this goal
|
||||||
*/
|
*/
|
||||||
private final int x;
|
protected final int x;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Y block position of this goal
|
* The Y block position of this goal
|
||||||
*/
|
*/
|
||||||
private final int y;
|
protected final int y;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Z block position of this goal
|
* The Z block position of this goal
|
||||||
*/
|
*/
|
||||||
private final int z;
|
protected final int z;
|
||||||
|
|
||||||
public GoalTwoBlocks(BlockPos pos) {
|
public GoalTwoBlocks(BlockPos pos) {
|
||||||
this(pos.getX(), pos.getY(), pos.getZ());
|
this(pos.getX(), pos.getY(), pos.getZ());
|
||||||
|
|||||||
@@ -18,6 +18,8 @@
|
|||||||
package baritone.api.process;
|
package baritone.api.process;
|
||||||
|
|
||||||
import baritone.api.utils.ISchematic;
|
import baritone.api.utils.ISchematic;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Vec3i;
|
import net.minecraft.util.math.Vec3i;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -46,4 +48,15 @@ public interface IBuilderProcess extends IBaritoneProcess {
|
|||||||
* @return Whether or not the schematic was able to load from file
|
* @return Whether or not the schematic was able to load from file
|
||||||
*/
|
*/
|
||||||
boolean build(String name, File schematic, Vec3i origin);
|
boolean build(String name, File schematic, Vec3i origin);
|
||||||
|
|
||||||
|
default boolean build(String schematicFile, BlockPos origin) {
|
||||||
|
File file = new File(new File(Minecraft.getMinecraft().gameDir, "schematics"), schematicFile);
|
||||||
|
return build(schematicFile, file, origin);
|
||||||
|
}
|
||||||
|
|
||||||
|
void pause();
|
||||||
|
|
||||||
|
void resume();
|
||||||
|
|
||||||
|
void clearArea(BlockPos corner1, BlockPos corner2);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* 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.api.process;
|
||||||
|
|
||||||
|
import java.nio.file.Path;
|
||||||
|
|
||||||
|
public interface IExploreProcess extends IBaritoneProcess {
|
||||||
|
void explore(int centerX, int centerZ);
|
||||||
|
|
||||||
|
void applyJsonFilter(Path path, boolean invert) throws Exception;
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* 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.api.process;
|
||||||
|
|
||||||
|
public interface IFarmProcess extends IBaritoneProcess {
|
||||||
|
void farm();
|
||||||
|
}
|
||||||
@@ -25,4 +25,6 @@ import net.minecraft.block.Block;
|
|||||||
public interface IGetToBlockProcess extends IBaritoneProcess {
|
public interface IGetToBlockProcess extends IBaritoneProcess {
|
||||||
|
|
||||||
void getToBlock(Block block);
|
void getToBlock(Block block);
|
||||||
|
|
||||||
|
boolean blacklistClosest();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,5 +51,10 @@ public enum PathingCommandType {
|
|||||||
* <p>
|
* <p>
|
||||||
* Cancel the current path if the goals are not equal
|
* Cancel the current path if the goals are not equal
|
||||||
*/
|
*/
|
||||||
FORCE_REVALIDATE_GOAL_AND_PATH
|
FORCE_REVALIDATE_GOAL_AND_PATH,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Go and ask the next process what to do
|
||||||
|
*/
|
||||||
|
DEFER
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,63 @@
|
|||||||
|
/*
|
||||||
|
* 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.api.utils;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class BlockUtils {
|
||||||
|
private static transient Map<String, Block> resourceCache = new HashMap<>();
|
||||||
|
|
||||||
|
public static String blockToString(Block block) {
|
||||||
|
ResourceLocation loc = Block.REGISTRY.getNameForObject(block);
|
||||||
|
String name = loc.getPath(); // normally, only write the part after the minecraft:
|
||||||
|
if (!loc.getNamespace().equals("minecraft")) {
|
||||||
|
// Baritone is running on top of forge with mods installed, perhaps?
|
||||||
|
name = loc.toString(); // include the namespace with the colon
|
||||||
|
}
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Block stringToBlockRequired(String name) {
|
||||||
|
Block block = stringToBlockNullable(name);
|
||||||
|
Objects.requireNonNull(block);
|
||||||
|
return block;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Block stringToBlockNullable(String name) {
|
||||||
|
// do NOT just replace this with a computeWithAbsent, it isn't thread safe
|
||||||
|
Block block = resourceCache.get(name); // map is never mutated in place so this is safe
|
||||||
|
if (block != null) {
|
||||||
|
return block;
|
||||||
|
}
|
||||||
|
if (resourceCache.containsKey(name)) {
|
||||||
|
return null; // cached as null
|
||||||
|
}
|
||||||
|
block = Block.getBlockFromName(name.contains(":") ? name : "minecraft:" + name);
|
||||||
|
Map<String, Block> copy = new HashMap<>(resourceCache); // read only copy is safe, wont throw concurrentmodification
|
||||||
|
copy.put(name, block);
|
||||||
|
resourceCache = copy;
|
||||||
|
return block;
|
||||||
|
}
|
||||||
|
|
||||||
|
private BlockUtils() {}
|
||||||
|
}
|
||||||
+110
-79
@@ -15,27 +15,21 @@
|
|||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package baritone.utils;
|
package baritone.api.utils;
|
||||||
|
|
||||||
import baritone.Baritone;
|
import baritone.api.BaritoneAPI;
|
||||||
|
import baritone.api.IBaritone;
|
||||||
import baritone.api.Settings;
|
import baritone.api.Settings;
|
||||||
|
import baritone.api.behavior.IPathingBehavior;
|
||||||
import baritone.api.cache.IRememberedInventory;
|
import baritone.api.cache.IRememberedInventory;
|
||||||
import baritone.api.cache.IWaypoint;
|
import baritone.api.cache.IWaypoint;
|
||||||
|
import baritone.api.cache.Waypoint;
|
||||||
import baritone.api.event.events.ChatEvent;
|
import baritone.api.event.events.ChatEvent;
|
||||||
|
import baritone.api.event.listener.AbstractGameEventListener;
|
||||||
import baritone.api.pathing.goals.*;
|
import baritone.api.pathing.goals.*;
|
||||||
import baritone.api.pathing.movement.ActionCosts;
|
|
||||||
import baritone.api.process.IBaritoneProcess;
|
import baritone.api.process.IBaritoneProcess;
|
||||||
import baritone.api.utils.BetterBlockPos;
|
import baritone.api.process.ICustomGoalProcess;
|
||||||
import baritone.api.utils.SettingsUtil;
|
import baritone.api.process.IGetToBlockProcess;
|
||||||
import baritone.behavior.Behavior;
|
|
||||||
import baritone.behavior.PathingBehavior;
|
|
||||||
import baritone.cache.ChunkPacker;
|
|
||||||
import baritone.cache.Waypoint;
|
|
||||||
import baritone.pathing.movement.CalculationContext;
|
|
||||||
import baritone.pathing.movement.Movement;
|
|
||||||
import baritone.pathing.movement.Moves;
|
|
||||||
import baritone.process.CustomGoalProcess;
|
|
||||||
import baritone.utils.pathing.SegmentedCalculator;
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.multiplayer.ChunkProviderClient;
|
import net.minecraft.client.multiplayer.ChunkProviderClient;
|
||||||
@@ -45,11 +39,10 @@ import net.minecraft.item.ItemStack;
|
|||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.chunk.Chunk;
|
import net.minecraft.world.chunk.Chunk;
|
||||||
|
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
public class ExampleBaritoneControl extends Behavior implements Helper {
|
public class ExampleBaritoneControl implements Helper, AbstractGameEventListener {
|
||||||
|
|
||||||
private static final String HELP_MSG =
|
private static final String HELP_MSG =
|
||||||
"baritone - Output settings into chat\n" +
|
"baritone - Output settings into chat\n" +
|
||||||
@@ -83,21 +76,26 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
|
|||||||
|
|
||||||
private static final String COMMAND_PREFIX = "#";
|
private static final String COMMAND_PREFIX = "#";
|
||||||
|
|
||||||
public ExampleBaritoneControl(Baritone baritone) {
|
public final IBaritone baritone;
|
||||||
super(baritone);
|
public final IPlayerContext ctx;
|
||||||
|
|
||||||
|
public ExampleBaritoneControl(IBaritone baritone) {
|
||||||
|
this.baritone = baritone;
|
||||||
|
this.ctx = baritone.getPlayerContext();
|
||||||
|
baritone.getGameEventHandler().registerEventListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSendChatMessage(ChatEvent event) {
|
public void onSendChatMessage(ChatEvent event) {
|
||||||
String msg = event.getMessage();
|
String msg = event.getMessage();
|
||||||
if (Baritone.settings().prefixControl.value && msg.startsWith(COMMAND_PREFIX)) {
|
if (BaritoneAPI.getSettings().prefixControl.value && 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 prefixControl
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!Baritone.settings().chatControl.value && !Baritone.settings().removePrefix.value) {
|
if (!BaritoneAPI.getSettings().chatControl.value && !BaritoneAPI.getSettings().removePrefix.value) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (runCommand(msg)) {
|
if (runCommand(msg)) {
|
||||||
@@ -107,20 +105,20 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
|
|||||||
|
|
||||||
public boolean runCommand(String msg0) { // you may think this can be private, but impcat calls it from .b =)
|
public boolean runCommand(String msg0) { // you may think this can be private, but impcat calls it from .b =)
|
||||||
String msg = msg0.toLowerCase(Locale.US).trim(); // don't reassign the argument LOL
|
String msg = msg0.toLowerCase(Locale.US).trim(); // don't reassign the argument LOL
|
||||||
PathingBehavior pathingBehavior = baritone.getPathingBehavior();
|
IPathingBehavior pathingBehavior = baritone.getPathingBehavior();
|
||||||
CustomGoalProcess customGoalProcess = baritone.getCustomGoalProcess();
|
ICustomGoalProcess customGoalProcess = baritone.getCustomGoalProcess();
|
||||||
List<Settings.Setting<Boolean>> toggleable = Baritone.settings().getAllValuesByType(Boolean.class);
|
List<Settings.Setting<Boolean>> toggleable = BaritoneAPI.getSettings().getAllValuesByType(Boolean.class);
|
||||||
for (Settings.Setting<Boolean> setting : toggleable) {
|
for (Settings.Setting<Boolean> setting : toggleable) {
|
||||||
if (msg.equalsIgnoreCase(setting.getName())) {
|
if (msg.equalsIgnoreCase(setting.getName())) {
|
||||||
setting.value ^= true;
|
setting.value ^= true;
|
||||||
logDirect("Toggled " + setting.getName() + " to " + setting.value);
|
logDirect("Toggled " + setting.getName() + " to " + setting.value);
|
||||||
SettingsUtil.save(Baritone.settings());
|
SettingsUtil.save(BaritoneAPI.getSettings());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (msg.equals("baritone") || msg.equals("modifiedsettings") || msg.startsWith("settings m") || msg.equals("modified")) {
|
if (msg.equals("baritone") || msg.equals("modifiedsettings") || msg.startsWith("settings m") || msg.equals("modified")) {
|
||||||
logDirect("All settings that have been modified from their default values:");
|
logDirect("All settings that have been modified from their default values:");
|
||||||
for (Settings.Setting<?> setting : SettingsUtil.modifiedSettings(Baritone.settings())) {
|
for (Settings.Setting<?> setting : SettingsUtil.modifiedSettings(BaritoneAPI.getSettings())) {
|
||||||
logDirect(setting.toString());
|
logDirect(setting.toString());
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -130,15 +128,15 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
|
|||||||
try {
|
try {
|
||||||
int page = Integer.parseInt(rest.trim());
|
int page = Integer.parseInt(rest.trim());
|
||||||
int min = page * 10;
|
int min = page * 10;
|
||||||
int max = Math.min(Baritone.settings().allSettings.size(), (page + 1) * 10);
|
int max = Math.min(BaritoneAPI.getSettings().allSettings.size(), (page + 1) * 10);
|
||||||
logDirect("Settings " + min + " to " + (max - 1) + ":");
|
logDirect("Settings " + min + " to " + (max - 1) + ":");
|
||||||
for (int i = min; i < max; i++) {
|
for (int i = min; i < max; i++) {
|
||||||
logDirect(Baritone.settings().allSettings.get(i).toString());
|
logDirect(BaritoneAPI.getSettings().allSettings.get(i).toString());
|
||||||
}
|
}
|
||||||
} catch (Exception ex) { // NumberFormatException | ArrayIndexOutOfBoundsException and probably some others I'm forgetting lol
|
} catch (Exception ex) { // NumberFormatException | ArrayIndexOutOfBoundsException and probably some others I'm forgetting lol
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
logDirect("All settings:");
|
logDirect("All settings:");
|
||||||
for (Settings.Setting<?> setting : Baritone.settings().allSettings) {
|
for (Settings.Setting<?> setting : BaritoneAPI.getSettings().allSettings) {
|
||||||
logDirect(setting.toString());
|
logDirect(setting.toString());
|
||||||
}
|
}
|
||||||
logDirect("To get one page of ten settings at a time, do settings <num>");
|
logDirect("To get one page of ten settings at a time, do settings <num>");
|
||||||
@@ -154,26 +152,26 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
|
|||||||
if (msg.contains(" ")) {
|
if (msg.contains(" ")) {
|
||||||
String settingName = msg.substring(0, msg.indexOf(' '));
|
String settingName = msg.substring(0, msg.indexOf(' '));
|
||||||
String settingValue = msg.substring(msg.indexOf(' ') + 1);
|
String settingValue = msg.substring(msg.indexOf(' ') + 1);
|
||||||
Settings.Setting setting = Baritone.settings().byLowerName.get(settingName);
|
Settings.Setting setting = BaritoneAPI.getSettings().byLowerName.get(settingName);
|
||||||
if (setting != null) {
|
if (setting != null) {
|
||||||
if (settingValue.equals("reset")) {
|
if (settingValue.equals("reset")) {
|
||||||
logDirect("Resetting setting " + settingName + " to default value.");
|
logDirect("Resetting setting " + settingName + " to default value.");
|
||||||
setting.reset();
|
setting.reset();
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
SettingsUtil.parseAndApply(Baritone.settings(), settingName, settingValue);
|
SettingsUtil.parseAndApply(BaritoneAPI.getSettings(), settingName, settingValue);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
logDirect("Unable to parse setting");
|
logDirect("Unable to parse setting");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SettingsUtil.save(Baritone.settings());
|
SettingsUtil.save(BaritoneAPI.getSettings());
|
||||||
logDirect(setting.toString());
|
logDirect(setting.toString());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Baritone.settings().byLowerName.containsKey(msg)) {
|
if (BaritoneAPI.getSettings().byLowerName.containsKey(msg)) {
|
||||||
Settings.Setting<?> setting = Baritone.settings().byLowerName.get(msg);
|
Settings.Setting<?> setting = BaritoneAPI.getSettings().byLowerName.get(msg);
|
||||||
logDirect(setting.toString());
|
logDirect(setting.toString());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -209,7 +207,7 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (msg.equals("fullpath")) {
|
/*if (msg.equals("fullpath")) {
|
||||||
if (pathingBehavior.getGoal() == null) {
|
if (pathingBehavior.getGoal() == null) {
|
||||||
logDirect("No goal.");
|
logDirect("No goal.");
|
||||||
} else {
|
} else {
|
||||||
@@ -225,7 +223,7 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}*/
|
||||||
if (msg.equals("proc")) {
|
if (msg.equals("proc")) {
|
||||||
Optional<IBaritoneProcess> proc = baritone.getPathingControlManager().mostRecentInControl();
|
Optional<IBaritoneProcess> proc = baritone.getPathingControlManager().mostRecentInControl();
|
||||||
if (!proc.isPresent()) {
|
if (!proc.isPresent()) {
|
||||||
@@ -256,7 +254,7 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
|
|||||||
int count = 0;
|
int count = 0;
|
||||||
for (int x = playerChunkX - 40; x <= playerChunkX + 40; x++) {
|
for (int x = playerChunkX - 40; x <= playerChunkX + 40; x++) {
|
||||||
for (int z = playerChunkZ - 40; z <= playerChunkZ + 40; z++) {
|
for (int z = playerChunkZ - 40; z <= playerChunkZ + 40; z++) {
|
||||||
Chunk chunk = cli.getChunk(x, z, false, false);
|
Chunk chunk = cli.getLoadedChunk(x, z);
|
||||||
if (chunk != null) {
|
if (chunk != null) {
|
||||||
count++;
|
count++;
|
||||||
baritone.getWorldProvider().getCurrentWorld().getCachedWorld().queueForPacking(chunk);
|
baritone.getWorldProvider().getCurrentWorld().getCachedWorld().queueForPacking(chunk);
|
||||||
@@ -283,7 +281,7 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (msg.equals("come")) {
|
if (msg.equals("come")) {
|
||||||
customGoalProcess.setGoalAndPath(new GoalBlock(new BlockPos(mc.getRenderViewEntity())));
|
customGoalProcess.setGoalAndPath(new GoalBlock(new BlockPos(Helper.mc.getRenderViewEntity())));
|
||||||
logDirect("Coming");
|
logDirect("Coming");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -358,11 +356,16 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
|
|||||||
logDirect("resumed");
|
logDirect("resumed");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if (msg.equals("pause")) {
|
||||||
|
baritone.getBuilderProcess().pause();
|
||||||
|
logDirect("paused");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (msg.equals("reset")) {
|
if (msg.equals("reset")) {
|
||||||
for (Settings.Setting setting : Baritone.settings().allSettings) {
|
for (Settings.Setting setting : BaritoneAPI.getSettings().allSettings) {
|
||||||
setting.reset();
|
setting.reset();
|
||||||
}
|
}
|
||||||
SettingsUtil.save(Baritone.settings());
|
SettingsUtil.save(BaritoneAPI.getSettings());
|
||||||
logDirect("Baritone settings reset");
|
logDirect("Baritone settings reset");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -373,11 +376,17 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
|
|||||||
}
|
}
|
||||||
if (msg.equals("render")) {
|
if (msg.equals("render")) {
|
||||||
BetterBlockPos pf = ctx.playerFeet();
|
BetterBlockPos pf = ctx.playerFeet();
|
||||||
Minecraft.getInstance().worldRenderer.markBlockRangeForRenderUpdate(pf.x - 500, pf.y - 500, pf.z - 500, pf.x + 500, pf.y + 500, pf.z + 500);
|
Minecraft.getMinecraft().renderGlobal.markBlockRangeForRenderUpdate(pf.x - 500, pf.y - 500, pf.z - 500, pf.x + 500, pf.y + 500, pf.z + 500);
|
||||||
logDirect("okay");
|
logDirect("okay");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (msg.equals("echest")) {
|
if (msg.equals("farm")) {
|
||||||
|
baritone.getFarmProcess().farm();
|
||||||
|
logDirect("farming");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// this literally doesn't work, memory is disabled lol
|
||||||
|
/*if (msg.equals("echest")) {
|
||||||
Optional<List<ItemStack>> contents = baritone.getMemoryBehavior().echest();
|
Optional<List<ItemStack>> contents = baritone.getMemoryBehavior().echest();
|
||||||
if (contents.isPresent()) {
|
if (contents.isPresent()) {
|
||||||
logDirect("echest contents:");
|
logDirect("echest contents:");
|
||||||
@@ -386,18 +395,8 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
|
|||||||
logDirect("echest contents unknown");
|
logDirect("echest contents unknown");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}*/
|
||||||
if (msg.equals("chests")) {
|
if (msg.equals("chests")) {
|
||||||
System.out.println(baritone.getWorldProvider());
|
|
||||||
System.out.println(baritone.getWorldProvider().getCurrentWorld());
|
|
||||||
|
|
||||||
System.out.println(baritone.getWorldProvider().getCurrentWorld().getContainerMemory());
|
|
||||||
|
|
||||||
System.out.println(baritone.getWorldProvider().getCurrentWorld().getContainerMemory().getRememberedInventories());
|
|
||||||
|
|
||||||
System.out.println(baritone.getWorldProvider().getCurrentWorld().getContainerMemory().getRememberedInventories().entrySet());
|
|
||||||
|
|
||||||
System.out.println(baritone.getWorldProvider().getCurrentWorld().getContainerMemory().getRememberedInventories().entrySet());
|
|
||||||
for (Map.Entry<BlockPos, IRememberedInventory> entry : baritone.getWorldProvider().getCurrentWorld().getContainerMemory().getRememberedInventories().entrySet()) {
|
for (Map.Entry<BlockPos, IRememberedInventory> entry : baritone.getWorldProvider().getCurrentWorld().getContainerMemory().getRememberedInventories().entrySet()) {
|
||||||
logDirect(entry.getKey() + "");
|
logDirect(entry.getKey() + "");
|
||||||
log(entry.getValue().getContents());
|
log(entry.getValue().getContents());
|
||||||
@@ -416,8 +415,8 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
|
|||||||
toFollow = ctx.getSelectedEntity();
|
toFollow = ctx.getSelectedEntity();
|
||||||
} else {
|
} else {
|
||||||
for (EntityPlayer pl : ctx.world().playerEntities) {
|
for (EntityPlayer pl : ctx.world().playerEntities) {
|
||||||
String theirName = pl.getName().getString().trim().toLowerCase();
|
String theirName = pl.getName().trim().toLowerCase();
|
||||||
if (!theirName.equals(ctx.player().getName().getString().trim().toLowerCase()) && (theirName.contains(name) || name.contains(theirName))) { // don't follow ourselves lol
|
if (!theirName.equals(ctx.player().getName().trim().toLowerCase()) && (theirName.contains(name) || name.contains(theirName))) { // don't follow ourselves lol
|
||||||
toFollow = Optional.of(pl);
|
toFollow = Optional.of(pl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -431,6 +430,29 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
|
|||||||
logDirect("Following " + toFollow.get());
|
logDirect("Following " + toFollow.get());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if (msg.startsWith("explorefilter")) {
|
||||||
|
// explorefilter blah.json
|
||||||
|
// means that entries in blah.json are already explored
|
||||||
|
// explorefilter blah.json invert
|
||||||
|
// means that entries in blah.json are NOT already explored
|
||||||
|
String path = msg.substring("explorefilter".length()).trim();
|
||||||
|
String[] parts = path.split(" ");
|
||||||
|
Path path1 = Minecraft.getMinecraft().gameDir.toPath().resolve(parts[0]);
|
||||||
|
boolean invert = parts.length > 1;
|
||||||
|
try {
|
||||||
|
baritone.getExploreProcess().applyJsonFilter(path1, invert);
|
||||||
|
logDirect("Loaded filter. Inverted: " + invert);
|
||||||
|
if (invert) {
|
||||||
|
logDirect("Chunks on this list will be treated as possibly unexplored, all others will be treated as certainly explored");
|
||||||
|
} else {
|
||||||
|
logDirect("Chunks on this list will be treated as certainly explored, all others will be treated as possibly unexplored");
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
logDirect("Unable to load " + path1);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (msg.equals("reloadall")) {
|
if (msg.equals("reloadall")) {
|
||||||
baritone.getWorldProvider().getCurrentWorld().getCachedWorld().reloadAllFromDisk();
|
baritone.getWorldProvider().getCurrentWorld().getCachedWorld().reloadAllFromDisk();
|
||||||
logDirect("ok");
|
logDirect("ok");
|
||||||
@@ -456,14 +478,27 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
|
|||||||
logDirect("Exploring from " + centerX + "," + centerZ);
|
logDirect("Exploring from " + centerX + "," + centerZ);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if (msg.equals("blacklist")) {
|
||||||
|
IGetToBlockProcess proc = baritone.getGetToBlockProcess();
|
||||||
|
if (!proc.isActive()) {
|
||||||
|
logDirect("GetToBlockProcess is not currently active");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (proc.blacklistClosest()) {
|
||||||
|
logDirect("Blacklisted closest instances");
|
||||||
|
} else {
|
||||||
|
logDirect("No known locations, unable to blacklist");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (msg.startsWith("find")) {
|
if (msg.startsWith("find")) {
|
||||||
String blockType = msg.substring(4).trim();
|
String blockType = msg.substring(4).trim();
|
||||||
ArrayList<BlockPos> locs = baritone.getWorldProvider().getCurrentWorld().getCachedWorld().getLocationsOf(blockType, 1, ctx.playerFeet().getX(), ctx.playerFeet().getZ(), 4);
|
ArrayList<BlockPos> locs = baritone.getWorldProvider().getCurrentWorld().getCachedWorld().getLocationsOf(blockType, 1, ctx.playerFeet().getX(), ctx.playerFeet().getZ(), 4);
|
||||||
logDirect("Have " + locs.size() + " locations");
|
logDirect("Have " + locs.size() + " locations");
|
||||||
for (BlockPos pos : locs) {
|
for (BlockPos pos : locs) {
|
||||||
Block actually = BlockStateInterface.get(ctx, pos).getBlock();
|
Block actually = ctx.world().getBlockState(pos).getBlock();
|
||||||
if (!ChunkPacker.blockToString(actually).equalsIgnoreCase(blockType)) {
|
if (!BlockUtils.blockToString(actually).equalsIgnoreCase(blockType)) {
|
||||||
System.out.println("Was looking for " + blockType + " but actually found " + actually + " " + ChunkPacker.blockToString(actually));
|
logDebug("Was looking for " + blockType + " but actually found " + actually + " " + BlockUtils.blockToString(actually));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -472,13 +507,13 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
|
|||||||
String[] blockTypes = msg.substring(4).trim().split(" ");
|
String[] blockTypes = msg.substring(4).trim().split(" ");
|
||||||
try {
|
try {
|
||||||
int quantity = Integer.parseInt(blockTypes[1]);
|
int quantity = Integer.parseInt(blockTypes[1]);
|
||||||
Block block = ChunkPacker.stringToBlockRequired(blockTypes[0]);
|
Block block = BlockUtils.stringToBlockRequired(blockTypes[0]);
|
||||||
baritone.getMineProcess().mine(quantity, block);
|
baritone.getMineProcess().mine(quantity, block);
|
||||||
logDirect("Will mine " + quantity + " " + blockTypes[0]);
|
logDirect("Will mine " + quantity + " " + blockTypes[0]);
|
||||||
return true;
|
return true;
|
||||||
} catch (NumberFormatException | ArrayIndexOutOfBoundsException | NullPointerException ex) {}
|
} catch (NumberFormatException | ArrayIndexOutOfBoundsException | NullPointerException ex) {}
|
||||||
for (String s : blockTypes) {
|
for (String s : blockTypes) {
|
||||||
if (ChunkPacker.stringToBlockNullable(s) == null) {
|
if (BlockUtils.stringToBlockNullable(s) == null) {
|
||||||
logDirect(s + " isn't a valid block name");
|
logDirect(s + " isn't a valid block name");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -489,12 +524,7 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (msg.equals("click")) {
|
if (msg.equals("click")) {
|
||||||
new Thread(() -> {
|
baritone.openClick();
|
||||||
try {
|
|
||||||
Thread.sleep(100);
|
|
||||||
mc.addScheduledTask(() -> mc.displayGuiScreen(new GuiClick()));
|
|
||||||
} catch (Exception ignored) {}
|
|
||||||
}).start();
|
|
||||||
logDirect("aight dude");
|
logDirect("aight dude");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -514,9 +544,9 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
|
|||||||
// for example, "show deaths"
|
// for example, "show deaths"
|
||||||
waypointType = waypointType.substring(0, waypointType.length() - 1);
|
waypointType = waypointType.substring(0, waypointType.length() - 1);
|
||||||
}
|
}
|
||||||
Waypoint.Tag tag = Waypoint.Tag.fromString(waypointType);
|
IWaypoint.Tag tag = IWaypoint.Tag.fromString(waypointType);
|
||||||
if (tag == null) {
|
if (tag == null) {
|
||||||
logDirect("Not a valid tag. Tags are: " + Arrays.asList(Waypoint.Tag.values()).toString().toLowerCase());
|
logDirect("Not a valid tag. Tags are: " + Arrays.asList(IWaypoint.Tag.values()).toString().toLowerCase());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Set<IWaypoint> waypoints = baritone.getWorldProvider().getCurrentWorld().getWaypoints().getByTag(tag);
|
Set<IWaypoint> waypoints = baritone.getWorldProvider().getCurrentWorld().getWaypoints().getByTag(tag);
|
||||||
@@ -547,21 +577,21 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
|
|||||||
}
|
}
|
||||||
name = parts[0];
|
name = parts[0];
|
||||||
}
|
}
|
||||||
baritone.getWorldProvider().getCurrentWorld().getWaypoints().addWaypoint(new Waypoint(name, Waypoint.Tag.USER, pos));
|
baritone.getWorldProvider().getCurrentWorld().getWaypoints().addWaypoint(new Waypoint(name, IWaypoint.Tag.USER, pos));
|
||||||
logDirect("Saved user defined position " + pos + " under name '" + name + "'. Say 'goto " + name + "' to set goal, say 'list user' to list custom waypoints.");
|
logDirect("Saved user defined position " + pos + " under name '" + name + "'. Say 'goto " + name + "' to set goal, say 'list user' to list custom waypoints.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (msg.startsWith("goto")) {
|
if (msg.startsWith("goto")) {
|
||||||
String waypointType = msg.substring(4).trim();
|
String waypointType = msg.substring(4).trim();
|
||||||
if (waypointType.endsWith("s") && Waypoint.Tag.fromString(waypointType.substring(0, waypointType.length() - 1)) != null) {
|
if (waypointType.endsWith("s") && IWaypoint.Tag.fromString(waypointType.substring(0, waypointType.length() - 1)) != null) {
|
||||||
// for example, "show deaths"
|
// for example, "show deaths"
|
||||||
waypointType = waypointType.substring(0, waypointType.length() - 1);
|
waypointType = waypointType.substring(0, waypointType.length() - 1);
|
||||||
}
|
}
|
||||||
Waypoint.Tag tag = Waypoint.Tag.fromString(waypointType);
|
IWaypoint.Tag tag = IWaypoint.Tag.fromString(waypointType);
|
||||||
IWaypoint waypoint;
|
IWaypoint waypoint;
|
||||||
if (tag == null) {
|
if (tag == null) {
|
||||||
String mining = waypointType;
|
String mining = waypointType;
|
||||||
Block block = ChunkPacker.stringToBlockNullable(mining);
|
Block block = BlockUtils.stringToBlockNullable(mining);
|
||||||
//logDirect("Not a valid tag. Tags are: " + Arrays.asList(Waypoint.Tag.values()).toString().toLowerCase());
|
//logDirect("Not a valid tag. Tags are: " + Arrays.asList(Waypoint.Tag.values()).toString().toLowerCase());
|
||||||
if (block == null) {
|
if (block == null) {
|
||||||
waypoint = baritone.getWorldProvider().getCurrentWorld().getWaypoints().getAllWaypoints().stream().filter(w -> w.getName().equalsIgnoreCase(mining)).max(Comparator.comparingLong(IWaypoint::getCreationTimestamp)).orElse(null);
|
waypoint = baritone.getWorldProvider().getCurrentWorld().getWaypoints().getAllWaypoints().stream().filter(w -> w.getName().equalsIgnoreCase(mining)).max(Comparator.comparingLong(IWaypoint::getCreationTimestamp)).orElse(null);
|
||||||
@@ -584,12 +614,12 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Goal goal = waypoint.getTag() == Waypoint.Tag.BED ? new GoalGetToBlock(waypoint.getLocation()) : new GoalBlock(waypoint.getLocation());
|
Goal goal = waypoint.getTag() == IWaypoint.Tag.BED ? new GoalGetToBlock(waypoint.getLocation()) : new GoalBlock(waypoint.getLocation());
|
||||||
customGoalProcess.setGoalAndPath(goal);
|
customGoalProcess.setGoalAndPath(goal);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (msg.equals("spawn") || msg.equals("bed")) {
|
if (msg.equals("spawn") || msg.equals("bed")) {
|
||||||
IWaypoint waypoint = baritone.getWorldProvider().getCurrentWorld().getWaypoints().getMostRecentByTag(Waypoint.Tag.BED);
|
IWaypoint waypoint = baritone.getWorldProvider().getCurrentWorld().getWaypoints().getMostRecentByTag(IWaypoint.Tag.BED);
|
||||||
if (waypoint == null) {
|
if (waypoint == null) {
|
||||||
BlockPos spawnPoint = ctx.player().getBedLocation();
|
BlockPos spawnPoint = ctx.player().getBedLocation();
|
||||||
// for some reason the default spawnpoint is underground sometimes
|
// for some reason the default spawnpoint is underground sometimes
|
||||||
@@ -604,12 +634,12 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (msg.equals("sethome")) {
|
if (msg.equals("sethome")) {
|
||||||
baritone.getWorldProvider().getCurrentWorld().getWaypoints().addWaypoint(new Waypoint("", Waypoint.Tag.HOME, ctx.playerFeet()));
|
baritone.getWorldProvider().getCurrentWorld().getWaypoints().addWaypoint(new Waypoint("", IWaypoint.Tag.HOME, ctx.playerFeet()));
|
||||||
logDirect("Saved. Say home to set goal.");
|
logDirect("Saved. Say home to set goal.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (msg.equals("home")) {
|
if (msg.equals("home")) {
|
||||||
IWaypoint waypoint = baritone.getWorldProvider().getCurrentWorld().getWaypoints().getMostRecentByTag(Waypoint.Tag.HOME);
|
IWaypoint waypoint = baritone.getWorldProvider().getCurrentWorld().getWaypoints().getMostRecentByTag(IWaypoint.Tag.HOME);
|
||||||
if (waypoint == null) {
|
if (waypoint == null) {
|
||||||
logDirect("home not saved");
|
logDirect("home not saved");
|
||||||
} else {
|
} else {
|
||||||
@@ -619,7 +649,8 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (msg.equals("costs")) {
|
// this is completely impossible from api
|
||||||
|
/*if (msg.equals("costs")) {
|
||||||
List<Movement> moves = Stream.of(Moves.values()).map(x -> x.apply0(new CalculationContext(baritone), ctx.playerFeet())).collect(Collectors.toCollection(ArrayList::new));
|
List<Movement> moves = Stream.of(Moves.values()).map(x -> x.apply0(new CalculationContext(baritone), ctx.playerFeet())).collect(Collectors.toCollection(ArrayList::new));
|
||||||
while (moves.contains(null)) {
|
while (moves.contains(null)) {
|
||||||
moves.remove(null);
|
moves.remove(null);
|
||||||
@@ -635,7 +666,7 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
|
|||||||
logDirect(parts[parts.length - 1] + " " + move.getDest().getX() + "," + move.getDest().getY() + "," + move.getDest().getZ() + " " + strCost);
|
logDirect(parts[parts.length - 1] + " " + move.getDest().getX() + "," + move.getDest().getY() + "," + move.getDest().getZ() + " " + strCost);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}*/
|
||||||
if (msg.equals("damn")) {
|
if (msg.equals("damn")) {
|
||||||
logDirect("daniel");
|
logDirect("daniel");
|
||||||
}
|
}
|
||||||
@@ -649,7 +680,7 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
|
|||||||
private void log(List<ItemStack> stacks) {
|
private void log(List<ItemStack> stacks) {
|
||||||
for (ItemStack stack : stacks) {
|
for (ItemStack stack : stacks) {
|
||||||
if (!stack.isEmpty()) {
|
if (!stack.isEmpty()) {
|
||||||
logDirect(stack.getCount() + "x " + stack.getDisplayName() + "@" + stack.getDamage());
|
logDirect(stack.getCount() + "x " + stack.getDisplayName() + "@" + stack.getItemDamage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+6
-6
@@ -15,9 +15,9 @@
|
|||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package baritone.utils;
|
package baritone.api.utils;
|
||||||
|
|
||||||
import baritone.Baritone;
|
import baritone.api.BaritoneAPI;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.util.text.ITextComponent;
|
import net.minecraft.util.text.ITextComponent;
|
||||||
import net.minecraft.util.text.TextComponentString;
|
import net.minecraft.util.text.TextComponentString;
|
||||||
@@ -42,7 +42,7 @@ public interface Helper {
|
|||||||
TextFormatting.GRAY
|
TextFormatting.GRAY
|
||||||
));
|
));
|
||||||
|
|
||||||
Minecraft mc = Minecraft.getInstance();
|
Minecraft mc = Minecraft.getMinecraft();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a message to chat only if chatDebug is on
|
* Send a message to chat only if chatDebug is on
|
||||||
@@ -50,7 +50,7 @@ public interface Helper {
|
|||||||
* @param message The message to display in chat
|
* @param message The message to display in chat
|
||||||
*/
|
*/
|
||||||
default void logDebug(String message) {
|
default void logDebug(String message) {
|
||||||
if (!Baritone.settings().chatDebug.value) {
|
if (!BaritoneAPI.getSettings().chatDebug.value) {
|
||||||
//System.out.println("Suppressed debug message:");
|
//System.out.println("Suppressed debug message:");
|
||||||
//System.out.println(message);
|
//System.out.println(message);
|
||||||
return;
|
return;
|
||||||
@@ -64,9 +64,9 @@ public interface Helper {
|
|||||||
* @param message The message to display in chat
|
* @param message The message to display in chat
|
||||||
*/
|
*/
|
||||||
default void logDirect(String message) {
|
default void logDirect(String message) {
|
||||||
ITextComponent component = MESSAGE_PREFIX.shallowCopy();
|
ITextComponent component = MESSAGE_PREFIX.createCopy();
|
||||||
component.getStyle().setColor(TextFormatting.GRAY);
|
component.getStyle().setColor(TextFormatting.GRAY);
|
||||||
component.appendSibling(new TextComponentString(" " + message));
|
component.appendSibling(new TextComponentString(" " + message));
|
||||||
Minecraft.getInstance().addScheduledTask(() -> Baritone.settings().logger.value.accept(component));
|
Minecraft.getMinecraft().addScheduledTask(() -> BaritoneAPI.getSettings().logger.value.accept(component));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -71,20 +71,26 @@ public interface IPlayerContext {
|
|||||||
* @return The position of the highlighted block
|
* @return The position of the highlighted block
|
||||||
*/
|
*/
|
||||||
default Optional<BlockPos> getSelectedBlock() {
|
default Optional<BlockPos> getSelectedBlock() {
|
||||||
if (objectMouseOver() != null && objectMouseOver().type == RayTraceResult.Type.BLOCK) {
|
RayTraceResult result = objectMouseOver();
|
||||||
return Optional.of(objectMouseOver().getBlockPos());
|
if (result != null && result.typeOfHit == RayTraceResult.Type.BLOCK) {
|
||||||
|
return Optional.of(result.getBlockPos());
|
||||||
}
|
}
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default boolean isLookingAt(BlockPos pos) {
|
||||||
|
return getSelectedBlock().equals(Optional.of(pos));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the entity that the crosshair is currently placed over. Updated once per tick.
|
* Returns the entity that the crosshair is currently placed over. Updated once per tick.
|
||||||
*
|
*
|
||||||
* @return The entity
|
* @return The entity
|
||||||
*/
|
*/
|
||||||
default Optional<Entity> getSelectedEntity() {
|
default Optional<Entity> getSelectedEntity() {
|
||||||
if (objectMouseOver() != null && objectMouseOver().type == RayTraceResult.Type.ENTITY) {
|
RayTraceResult result = objectMouseOver();
|
||||||
return Optional.of(objectMouseOver().entity);
|
if (result != null && result.typeOfHit == RayTraceResult.Type.ENTITY) {
|
||||||
|
return Optional.of(result.entityHit);
|
||||||
}
|
}
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* 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.api.utils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Need a non obfed chunkpos that we can load using GSON
|
||||||
|
*/
|
||||||
|
public class MyChunkPos {
|
||||||
|
public int x;
|
||||||
|
public int z;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return x + ", " + z;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,7 +18,6 @@
|
|||||||
package baritone.api.utils;
|
package baritone.api.utils;
|
||||||
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.util.math.RayTraceFluidMode;
|
|
||||||
import net.minecraft.util.math.RayTraceResult;
|
import net.minecraft.util.math.RayTraceResult;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
|
|
||||||
@@ -41,13 +40,13 @@ public final class RayTraceUtils {
|
|||||||
* @return The calculated raytrace result
|
* @return The calculated raytrace result
|
||||||
*/
|
*/
|
||||||
public static RayTraceResult rayTraceTowards(Entity entity, Rotation rotation, double blockReachDistance) {
|
public static RayTraceResult rayTraceTowards(Entity entity, Rotation rotation, double blockReachDistance) {
|
||||||
Vec3d start = entity.getEyePosition(1.0F);
|
Vec3d start = entity.getPositionEyes(1.0F);
|
||||||
Vec3d direction = RotationUtils.calcVec3dFromRotation(rotation);
|
Vec3d direction = RotationUtils.calcVec3dFromRotation(rotation);
|
||||||
Vec3d end = start.add(
|
Vec3d end = start.add(
|
||||||
direction.x * blockReachDistance,
|
direction.x * blockReachDistance,
|
||||||
direction.y * blockReachDistance,
|
direction.y * blockReachDistance,
|
||||||
direction.z * blockReachDistance
|
direction.z * blockReachDistance
|
||||||
);
|
);
|
||||||
return entity.world.rayTraceBlocks(start, end, RayTraceFluidMode.NEVER, false, true);
|
return entity.world.rayTraceBlocks(start, end, false, false, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,9 +36,6 @@ public class Rotation {
|
|||||||
public Rotation(float yaw, float pitch) {
|
public Rotation(float yaw, float pitch) {
|
||||||
this.yaw = yaw;
|
this.yaw = yaw;
|
||||||
this.pitch = pitch;
|
this.pitch = pitch;
|
||||||
if (Float.isInfinite(yaw) || Float.isNaN(yaw) || Float.isInfinite(pitch) || Float.isNaN(pitch)) {
|
|
||||||
throw new IllegalStateException(yaw + " " + pitch);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -23,13 +23,7 @@ import net.minecraft.block.BlockFire;
|
|||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.client.entity.EntityPlayerSP;
|
import net.minecraft.client.entity.EntityPlayerSP;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.math.*;
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.util.math.MathHelper;
|
|
||||||
import net.minecraft.util.math.RayTraceResult;
|
|
||||||
import net.minecraft.util.math.Vec3d;
|
|
||||||
import net.minecraft.util.math.shapes.VoxelShape;
|
|
||||||
import net.minecraft.util.math.shapes.VoxelShapes;
|
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@@ -180,14 +174,11 @@ public final class RotationUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
IBlockState state = entity.world.getBlockState(pos);
|
IBlockState state = entity.world.getBlockState(pos);
|
||||||
VoxelShape shape = state.getShape(entity.world, pos);
|
AxisAlignedBB aabb = state.getBoundingBox(entity.world, pos);
|
||||||
if (shape.isEmpty()) {
|
|
||||||
shape = VoxelShapes.fullCube();
|
|
||||||
}
|
|
||||||
for (Vec3d sideOffset : BLOCK_SIDE_MULTIPLIERS) {
|
for (Vec3d sideOffset : BLOCK_SIDE_MULTIPLIERS) {
|
||||||
double xDiff = shape.getStart(EnumFacing.Axis.X) * sideOffset.x + shape.getEnd(EnumFacing.Axis.X) * (1 - sideOffset.x);
|
double xDiff = aabb.minX * sideOffset.x + aabb.maxX * (1 - sideOffset.x);
|
||||||
double yDiff = shape.getStart(EnumFacing.Axis.Y) * sideOffset.y + shape.getEnd(EnumFacing.Axis.Y) * (1 - sideOffset.y);
|
double yDiff = aabb.minY * sideOffset.y + aabb.maxY * (1 - sideOffset.y);
|
||||||
double zDiff = shape.getStart(EnumFacing.Axis.Z) * sideOffset.z + shape.getEnd(EnumFacing.Axis.Z) * (1 - sideOffset.z);
|
double zDiff = aabb.minZ * sideOffset.z + aabb.maxZ * (1 - sideOffset.z);
|
||||||
possibleRotation = reachableOffset(entity, pos, new Vec3d(pos).add(xDiff, yDiff, zDiff), blockReachDistance);
|
possibleRotation = reachableOffset(entity, pos, new Vec3d(pos).add(xDiff, yDiff, zDiff), blockReachDistance);
|
||||||
if (possibleRotation.isPresent()) {
|
if (possibleRotation.isPresent()) {
|
||||||
return possibleRotation;
|
return possibleRotation;
|
||||||
@@ -208,10 +199,10 @@ public final class RotationUtils {
|
|||||||
* @return The optional rotation
|
* @return The optional rotation
|
||||||
*/
|
*/
|
||||||
public static Optional<Rotation> reachableOffset(Entity entity, BlockPos pos, Vec3d offsetPos, double blockReachDistance) {
|
public static Optional<Rotation> reachableOffset(Entity entity, BlockPos pos, Vec3d offsetPos, double blockReachDistance) {
|
||||||
Rotation rotation = calcRotationFromVec3d(entity.getEyePosition(1.0F), offsetPos, new Rotation(entity.rotationYaw, entity.rotationPitch));
|
Rotation rotation = calcRotationFromVec3d(entity.getPositionEyes(1.0F), offsetPos, new Rotation(entity.rotationYaw, entity.rotationPitch));
|
||||||
RayTraceResult result = RayTraceUtils.rayTraceTowards(entity, rotation, blockReachDistance);
|
RayTraceResult result = RayTraceUtils.rayTraceTowards(entity, rotation, blockReachDistance);
|
||||||
//System.out.println(result);
|
//System.out.println(result);
|
||||||
if (result != null && result.type == RayTraceResult.Type.BLOCK) {
|
if (result != null && result.typeOfHit == RayTraceResult.Type.BLOCK) {
|
||||||
if (result.getBlockPos().equals(pos)) {
|
if (result.getBlockPos().equals(pos)) {
|
||||||
return Optional.of(rotation);
|
return Optional.of(rotation);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,33 +18,33 @@
|
|||||||
package baritone.api.utils;
|
package baritone.api.utils;
|
||||||
|
|
||||||
import baritone.api.Settings;
|
import baritone.api.Settings;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
import net.minecraft.util.registry.IRegistry;
|
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.BufferedWriter;
|
import java.io.BufferedWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.lang.reflect.ParameterizedType;
|
||||||
|
import java.lang.reflect.Type;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
import static net.minecraft.client.Minecraft.getMinecraft;
|
||||||
|
|
||||||
public class SettingsUtil {
|
public class SettingsUtil {
|
||||||
|
|
||||||
private static final Path SETTINGS_PATH = Minecraft.getInstance().gameDir.toPath().resolve("baritone").resolve("settings.txt");
|
private static final Path SETTINGS_PATH = getMinecraft().gameDir.toPath().resolve("baritone").resolve("settings.txt");
|
||||||
private static final Pattern SETTING_PATTERN = Pattern.compile("^(?<setting>[^ ]+) +(?<value>[^ ]+)"); // 2 words separated by spaces
|
private static final Pattern SETTING_PATTERN = Pattern.compile("^(?<setting>[^ ]+) +(?<value>.+)"); // key and value split by the first space
|
||||||
|
|
||||||
private static final Map<Class<?>, SettingsIO> map;
|
|
||||||
|
|
||||||
private static boolean isComment(String line) {
|
private static boolean isComment(String line) {
|
||||||
return line.startsWith("#") || line.startsWith("//");
|
return line.startsWith("#") || line.startsWith("//");
|
||||||
@@ -119,11 +119,11 @@ public class SettingsUtil {
|
|||||||
if (setting.getName().equals("logger")) {
|
if (setting.getName().equals("logger")) {
|
||||||
return "logger";
|
return "logger";
|
||||||
}
|
}
|
||||||
SettingsIO io = map.get(setting.getValueClass());
|
Parser io = Parser.getParser(setting.getType());
|
||||||
if (io == null) {
|
if (io == null) {
|
||||||
throw new IllegalStateException("Missing " + setting.getValueClass() + " " + setting.getName());
|
throw new IllegalStateException("Missing " + setting.getValueClass() + " " + setting.getName());
|
||||||
}
|
}
|
||||||
return setting.getName() + " " + io.toString.apply(setting.value);
|
return setting.getName() + " " + io.toString(new ParserContext(setting), setting.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void parseAndApply(Settings settings, String settingName, String settingValue) throws IllegalStateException, NumberFormatException {
|
public static void parseAndApply(Settings settings, String settingName, String settingValue) throws IllegalStateException, NumberFormatException {
|
||||||
@@ -132,46 +132,125 @@ public class SettingsUtil {
|
|||||||
throw new IllegalStateException("No setting by that name");
|
throw new IllegalStateException("No setting by that name");
|
||||||
}
|
}
|
||||||
Class intendedType = setting.getValueClass();
|
Class intendedType = setting.getValueClass();
|
||||||
SettingsIO ioMethod = map.get(intendedType);
|
ISettingParser ioMethod = Parser.getParser(setting.getType());
|
||||||
Object parsed = ioMethod.parser.apply(settingValue);
|
Object parsed = ioMethod.parse(new ParserContext(setting), settingValue);
|
||||||
if (!intendedType.isInstance(parsed)) {
|
if (!intendedType.isInstance(parsed)) {
|
||||||
throw new IllegalStateException(ioMethod + " parser returned incorrect type, expected " + intendedType + " got " + parsed + " which is " + parsed.getClass());
|
throw new IllegalStateException(ioMethod + " parser returned incorrect type, expected " + intendedType + " got " + parsed + " which is " + parsed.getClass());
|
||||||
}
|
}
|
||||||
setting.value = parsed;
|
setting.value = parsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
private enum SettingsIO {
|
private interface ISettingParser<T> {
|
||||||
|
|
||||||
|
T parse(ParserContext context, String raw);
|
||||||
|
|
||||||
|
String toString(ParserContext context, T value);
|
||||||
|
|
||||||
|
boolean accepts(Type type);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class ParserContext {
|
||||||
|
|
||||||
|
private final Settings.Setting<?> setting;
|
||||||
|
|
||||||
|
public ParserContext(Settings.Setting<?> setting) {
|
||||||
|
this.setting = setting;
|
||||||
|
}
|
||||||
|
|
||||||
|
final Settings.Setting<?> getSetting() {
|
||||||
|
return this.setting;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private enum Parser implements ISettingParser {
|
||||||
|
|
||||||
DOUBLE(Double.class, Double::parseDouble),
|
DOUBLE(Double.class, Double::parseDouble),
|
||||||
BOOLEAN(Boolean.class, Boolean::parseBoolean),
|
BOOLEAN(Boolean.class, Boolean::parseBoolean),
|
||||||
INTEGER(Integer.class, Integer::parseInt),
|
INTEGER(Integer.class, Integer::parseInt),
|
||||||
FLOAT(Float.class, Float::parseFloat),
|
FLOAT(Float.class, Float::parseFloat),
|
||||||
LONG(Long.class, Long::parseLong),
|
LONG(Long.class, Long::parseLong),
|
||||||
|
ENUMFACING(EnumFacing.class, EnumFacing::byName),
|
||||||
|
COLOR(
|
||||||
|
Color.class,
|
||||||
|
str -> new Color(Integer.parseInt(str.split(",")[0]), Integer.parseInt(str.split(",")[1]), Integer.parseInt(str.split(",")[2])),
|
||||||
|
color -> color.getRed() + "," + color.getGreen() + "," + color.getBlue()
|
||||||
|
),
|
||||||
|
BLOCK(
|
||||||
|
Block.class,
|
||||||
|
str -> BlockUtils.stringToBlockRequired(str.trim()),
|
||||||
|
BlockUtils::blockToString
|
||||||
|
),
|
||||||
|
ITEM(
|
||||||
|
Item.class,
|
||||||
|
str -> Item.getByNameOrId(str.trim()),
|
||||||
|
item -> Item.REGISTRY.getNameForObject(item).toString()
|
||||||
|
),
|
||||||
|
LIST() {
|
||||||
|
@Override
|
||||||
|
public Object parse(ParserContext context, String raw) {
|
||||||
|
Type type = ((ParameterizedType) context.getSetting().getType()).getActualTypeArguments()[0];
|
||||||
|
Parser parser = Parser.getParser(type);
|
||||||
|
|
||||||
ITEM_LIST(ArrayList.class, str -> Stream.of(str.split(",")).map(ResourceLocation::new).map(IRegistry.ITEM::get).collect(Collectors.toCollection(ArrayList::new)), list -> ((ArrayList<Item>) list).stream().map(IRegistry.ITEM::getKey).map(ResourceLocation::toString).collect(Collectors.joining(","))),
|
return Arrays.stream(raw.split(","))
|
||||||
COLOR(Color.class, str -> new Color(Integer.parseInt(str.split(",")[0]), Integer.parseInt(str.split(",")[1]), Integer.parseInt(str.split(",")[2])), color -> color.getRed() + "," + color.getGreen() + "," + color.getBlue()),
|
.map(s -> parser.parse(context, s))
|
||||||
ENUMFACING(EnumFacing.class, EnumFacing::byName);
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString(ParserContext context, Object value) {
|
||||||
|
Type type = ((ParameterizedType) context.getSetting().getType()).getActualTypeArguments()[0];
|
||||||
|
Parser parser = Parser.getParser(type);
|
||||||
|
|
||||||
Class<?> klass;
|
return ((List<?>) value).stream()
|
||||||
Function<String, Object> parser;
|
.map(o -> parser.toString(context, o))
|
||||||
Function<Object, String> toString;
|
.collect(Collectors.joining(","));
|
||||||
|
}
|
||||||
|
|
||||||
<T> SettingsIO(Class<T> klass, Function<String, T> parser) {
|
@Override
|
||||||
|
public boolean accepts(Type type) {
|
||||||
|
return List.class.isAssignableFrom(TypeUtils.resolveBaseClass(type));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
private final Class<?> klass;
|
||||||
|
private final Function<String, Object> parser;
|
||||||
|
private final Function<Object, String> toString;
|
||||||
|
|
||||||
|
Parser() {
|
||||||
|
this.klass = null;
|
||||||
|
this.parser = null;
|
||||||
|
this.toString = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
<T> Parser(Class<T> klass, Function<String, T> parser) {
|
||||||
this(klass, parser, Object::toString);
|
this(klass, parser, Object::toString);
|
||||||
}
|
}
|
||||||
|
|
||||||
<T> SettingsIO(Class<T> klass, Function<String, T> parser, Function<T, String> toString) {
|
<T> Parser(Class<T> klass, Function<String, T> parser, Function<T, String> toString) {
|
||||||
this.klass = klass;
|
this.klass = klass;
|
||||||
this.parser = parser::apply;
|
this.parser = parser::apply;
|
||||||
this.toString = x -> toString.apply((T) x);
|
this.toString = x -> toString.apply((T) x);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
static {
|
@Override
|
||||||
HashMap<Class<?>, SettingsIO> tempMap = new HashMap<>();
|
public Object parse(ParserContext context, String raw) {
|
||||||
for (SettingsIO type : SettingsIO.values()) {
|
return this.parser.apply(raw);
|
||||||
tempMap.put(type.klass, type);
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString(ParserContext context, Object value) {
|
||||||
|
return this.toString.apply(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean accepts(Type type) {
|
||||||
|
return type instanceof Class && this.klass.isAssignableFrom((Class) type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Parser getParser(Type type) {
|
||||||
|
return Arrays.stream(values())
|
||||||
|
.filter(parser -> parser.accepts(type))
|
||||||
|
.findFirst().orElse(null);
|
||||||
}
|
}
|
||||||
map = Collections.unmodifiableMap(tempMap);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +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 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.api.utils;
|
||||||
|
|
||||||
|
import java.lang.reflect.ParameterizedType;
|
||||||
|
import java.lang.reflect.Type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Brady
|
||||||
|
* @since 4/20/2019
|
||||||
|
*/
|
||||||
|
public final class TypeUtils {
|
||||||
|
|
||||||
|
private TypeUtils() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resolves the "base type" for the specified type. For example, if the specified
|
||||||
|
* type is {@code List<String>}, then {@code List.class} will be returned. If the
|
||||||
|
* specified type is already a class, then it is directly returned.
|
||||||
|
*
|
||||||
|
* @param type The type to resolve
|
||||||
|
* @return The base class
|
||||||
|
*/
|
||||||
|
public static Class<?> resolveBaseClass(Type type) {
|
||||||
|
return type instanceof Class ? (Class<?>) type
|
||||||
|
: type instanceof ParameterizedType ? (Class<?>) ((ParameterizedType) type).getRawType()
|
||||||
|
: null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,10 +20,9 @@ package baritone.api.utils;
|
|||||||
import net.minecraft.block.BlockFire;
|
import net.minecraft.block.BlockFire;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.util.math.shapes.VoxelShape;
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -44,16 +43,10 @@ public final class VecUtils {
|
|||||||
*/
|
*/
|
||||||
public static Vec3d calculateBlockCenter(World world, BlockPos pos) {
|
public static Vec3d calculateBlockCenter(World world, BlockPos pos) {
|
||||||
IBlockState b = world.getBlockState(pos);
|
IBlockState b = world.getBlockState(pos);
|
||||||
VoxelShape shape = b.getCollisionShape(world, pos);
|
AxisAlignedBB bbox = b.getBoundingBox(world, pos);
|
||||||
if (shape.isEmpty()) {
|
double xDiff = (bbox.minX + bbox.maxX) / 2;
|
||||||
return getBlockPosCenter(pos);
|
double yDiff = (bbox.minY + bbox.maxY) / 2;
|
||||||
}
|
double zDiff = (bbox.minZ + bbox.maxZ) / 2;
|
||||||
double xDiff = (shape.getStart(EnumFacing.Axis.X) + shape.getEnd(EnumFacing.Axis.X)) / 2;
|
|
||||||
double yDiff = (shape.getStart(EnumFacing.Axis.Y) + shape.getEnd(EnumFacing.Axis.Y)) / 2;
|
|
||||||
double zDiff = (shape.getStart(EnumFacing.Axis.Z) + shape.getEnd(EnumFacing.Axis.Z)) / 2;
|
|
||||||
if (Double.isNaN(xDiff) || Double.isNaN(yDiff) || Double.isNaN(zDiff)) {
|
|
||||||
throw new IllegalStateException(b + " " + pos + " " + shape);
|
|
||||||
}
|
|
||||||
if (b.getBlock() instanceof BlockFire) {//look at bottom of fire when putting it out
|
if (b.getBlock() instanceof BlockFire) {//look at bottom of fire when putting it out
|
||||||
yDiff = 0;
|
yDiff = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,105 +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;
|
|
||||||
|
|
||||||
import com.google.common.base.Strings;
|
|
||||||
import com.google.gson.GsonBuilder;
|
|
||||||
import com.mojang.authlib.Agent;
|
|
||||||
import com.mojang.authlib.exceptions.AuthenticationException;
|
|
||||||
import com.mojang.authlib.properties.PropertyMap;
|
|
||||||
import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService;
|
|
||||||
import com.mojang.authlib.yggdrasil.YggdrasilUserAuthentication;
|
|
||||||
import net.minecraft.launchwrapper.Launch;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.net.Proxy;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Based on GradleStart from ForgeGradle 2.3
|
|
||||||
*
|
|
||||||
* @author Brady
|
|
||||||
* @since 3/11/2019
|
|
||||||
*/
|
|
||||||
public class LaunchTesting {
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
Map<String, String> arguments = new HashMap<>();
|
|
||||||
|
|
||||||
hackNatives();
|
|
||||||
arguments.put("version", "BaritownedDeveloperEnvironment");
|
|
||||||
arguments.put("assetIndex", System.getenv("assetIndex"));
|
|
||||||
arguments.put("assetsDir", System.getenv().getOrDefault("assetDirectory", "assets"));
|
|
||||||
arguments.put("accessToken", "FML");
|
|
||||||
arguments.put("userProperties", "{}");
|
|
||||||
arguments.put("tweakClass", System.getenv("tweakClass"));
|
|
||||||
String password = System.getenv("password");
|
|
||||||
if (password != null && !password.isEmpty()) {
|
|
||||||
attemptLogin(arguments, System.getenv("username"), System.getenv("password"));
|
|
||||||
}
|
|
||||||
|
|
||||||
List<String> argsArray = new ArrayList<>();
|
|
||||||
arguments.forEach((k, v) -> {
|
|
||||||
argsArray.add("--" + k);
|
|
||||||
argsArray.add(v);
|
|
||||||
});
|
|
||||||
|
|
||||||
Launch.main(argsArray.toArray(new String[0]));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void hackNatives() {
|
|
||||||
String paths = System.getProperty("java.library.path");
|
|
||||||
String nativesDir = System.getenv().get("nativesDirectory");
|
|
||||||
|
|
||||||
if (Strings.isNullOrEmpty(paths))
|
|
||||||
paths = nativesDir;
|
|
||||||
else
|
|
||||||
paths += File.pathSeparator + nativesDir;
|
|
||||||
|
|
||||||
System.setProperty("java.library.path", paths);
|
|
||||||
|
|
||||||
// hack the classloader now.
|
|
||||||
try {
|
|
||||||
final Field sysPathsField = ClassLoader.class.getDeclaredField("sys_paths");
|
|
||||||
sysPathsField.setAccessible(true);
|
|
||||||
sysPathsField.set(null, null);
|
|
||||||
} catch (Throwable ignored) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void attemptLogin(Map<String, String> argMap, String username, String password) {
|
|
||||||
YggdrasilUserAuthentication auth = (YggdrasilUserAuthentication) (new YggdrasilAuthenticationService(Proxy.NO_PROXY, "1")).createUserAuthentication(Agent.MINECRAFT);
|
|
||||||
auth.setUsername(username);
|
|
||||||
auth.setPassword(password);
|
|
||||||
|
|
||||||
try {
|
|
||||||
auth.logIn();
|
|
||||||
} catch (AuthenticationException var4) {
|
|
||||||
throw new RuntimeException(var4);
|
|
||||||
}
|
|
||||||
|
|
||||||
argMap.put("accessToken", auth.getAuthenticatedToken());
|
|
||||||
argMap.put("uuid", auth.getSelectedProfile().getId().toString().replace("-", ""));
|
|
||||||
argMap.put("username", auth.getSelectedProfile().getName());
|
|
||||||
argMap.put("userType", auth.getUserType().getName());
|
|
||||||
argMap.put("userProperties", (new GsonBuilder()).registerTypeAdapter(PropertyMap.class, new PropertyMap.Serializer()).create().toJson(auth.getUserProperties()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -29,7 +29,6 @@ import org.spongepowered.asm.mixin.injection.At;
|
|||||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
|
|
||||||
import static org.lwjgl.opengl.GL11.*;
|
import static org.lwjgl.opengl.GL11.*;
|
||||||
import static org.lwjgl.opengl.GL14.*;
|
|
||||||
|
|
||||||
@Mixin(ChunkRenderContainer.class)
|
@Mixin(ChunkRenderContainer.class)
|
||||||
public class MixinChunkRenderContainer {
|
public class MixinChunkRenderContainer {
|
||||||
@@ -42,11 +41,11 @@ public class MixinChunkRenderContainer {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
private BlockPos getPosition(RenderChunk renderChunkIn) {
|
private BlockPos getPosition(RenderChunk renderChunkIn) {
|
||||||
if (Baritone.settings().renderCachedChunks.value && Minecraft.getInstance().getIntegratedServer() == null && Minecraft.getInstance().world.getChunk(renderChunkIn.getPosition()).isEmpty()) {
|
if (Baritone.settings().renderCachedChunks.value && Minecraft.getMinecraft().getIntegratedServer() == null && Minecraft.getMinecraft().world.getChunk(renderChunkIn.getPosition()).isEmpty()) {
|
||||||
GlStateManager.enableAlphaTest();
|
GlStateManager.enableAlpha();
|
||||||
GlStateManager.enableBlend();
|
GlStateManager.enableBlend();
|
||||||
GL14.glBlendColor(0, 0, 0, Baritone.settings().cachedChunksOpacity.value);
|
GL14.glBlendColor(0, 0, 0, Baritone.settings().cachedChunksOpacity.value);
|
||||||
GlStateManager.blendFuncSeparate(GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA, GL_ONE, GL_ZERO);
|
GlStateManager.tryBlendFuncSeparate(GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA, GL_ONE, GL_ZERO);
|
||||||
}
|
}
|
||||||
return renderChunkIn.getPosition();
|
return renderChunkIn.getPosition();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ public abstract class MixinChunkRenderWorker {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
private boolean isChunkExisting(ChunkRenderWorker worker, BlockPos pos, World world) {
|
private boolean isChunkExisting(ChunkRenderWorker worker, BlockPos pos, World world) {
|
||||||
if (Baritone.settings().renderCachedChunks.value && Minecraft.getInstance().getIntegratedServer() == null) {
|
if (Baritone.settings().renderCachedChunks.value && Minecraft.getMinecraft().getIntegratedServer() == null) {
|
||||||
Baritone baritone = (Baritone) BaritoneAPI.getProvider().getPrimaryBaritone();
|
Baritone baritone = (Baritone) BaritoneAPI.getProvider().getPrimaryBaritone();
|
||||||
IPlayerContext ctx = baritone.getPlayerContext();
|
IPlayerContext ctx = baritone.getPlayerContext();
|
||||||
if (ctx.player() != null && ctx.world() != null && baritone.bsi != null) {
|
if (ctx.player() != null && ctx.world() != null && baritone.bsi != null) {
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ import baritone.api.event.events.RotationMoveEvent;
|
|||||||
import net.minecraft.client.entity.EntityPlayerSP;
|
import net.minecraft.client.entity.EntityPlayerSP;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
import net.minecraft.entity.EntityType;
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
@@ -45,8 +44,9 @@ public abstract class MixinEntityLivingBase extends Entity {
|
|||||||
*/
|
*/
|
||||||
private RotationMoveEvent jumpRotationEvent;
|
private RotationMoveEvent jumpRotationEvent;
|
||||||
|
|
||||||
public MixinEntityLivingBase(EntityType<?> entityTypeIn, World worldIn) {
|
public MixinEntityLivingBase(World worldIn, RotationMoveEvent jumpRotationEvent) {
|
||||||
super(entityTypeIn, worldIn);
|
super(worldIn);
|
||||||
|
this.jumpRotationEvent = jumpRotationEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(
|
@Inject(
|
||||||
|
|||||||
@@ -58,10 +58,10 @@ public class MixinEntityPlayerSP {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Inject(
|
@Inject(
|
||||||
method = "tick",
|
method = "onUpdate",
|
||||||
at = @At(
|
at = @At(
|
||||||
value = "INVOKE",
|
value = "INVOKE",
|
||||||
target = "net/minecraft/client/entity/EntityPlayerSP.isPassenger()Z",
|
target = "net/minecraft/client/entity/EntityPlayerSP.isRiding()Z",
|
||||||
shift = At.Shift.BY,
|
shift = At.Shift.BY,
|
||||||
by = -3
|
by = -3
|
||||||
)
|
)
|
||||||
@@ -74,7 +74,7 @@ public class MixinEntityPlayerSP {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Inject(
|
@Inject(
|
||||||
method = "tick",
|
method = "onUpdate",
|
||||||
at = @At(
|
at = @At(
|
||||||
value = "INVOKE",
|
value = "INVOKE",
|
||||||
target = "net/minecraft/client/entity/EntityPlayerSP.onUpdateWalkingPlayer()V",
|
target = "net/minecraft/client/entity/EntityPlayerSP.onUpdateWalkingPlayer()V",
|
||||||
@@ -90,7 +90,7 @@ public class MixinEntityPlayerSP {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Redirect(
|
@Redirect(
|
||||||
method = "livingTick",
|
method = "onLivingUpdate",
|
||||||
at = @At(
|
at = @At(
|
||||||
value = "FIELD",
|
value = "FIELD",
|
||||||
target = "net/minecraft/entity/player/PlayerCapabilities.allowFlying:Z"
|
target = "net/minecraft/entity/player/PlayerCapabilities.allowFlying:Z"
|
||||||
@@ -105,7 +105,7 @@ public class MixinEntityPlayerSP {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Redirect(
|
@Redirect(
|
||||||
method = "livingTick",
|
method = "onLivingUpdate",
|
||||||
at = @At(
|
at = @At(
|
||||||
value = "INVOKE",
|
value = "INVOKE",
|
||||||
target = "net/minecraft/client/settings/KeyBinding.isKeyDown()Z"
|
target = "net/minecraft/client/settings/KeyBinding.isKeyDown()Z"
|
||||||
|
|||||||
+5
-5
@@ -20,24 +20,24 @@ package baritone.launch.mixins;
|
|||||||
import baritone.api.BaritoneAPI;
|
import baritone.api.BaritoneAPI;
|
||||||
import baritone.api.IBaritone;
|
import baritone.api.IBaritone;
|
||||||
import baritone.api.event.events.RenderEvent;
|
import baritone.api.event.events.RenderEvent;
|
||||||
import net.minecraft.client.renderer.GameRenderer;
|
import net.minecraft.client.renderer.EntityRenderer;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
@Mixin(GameRenderer.class)
|
@Mixin(EntityRenderer.class)
|
||||||
public class MixinGameRenderer {
|
public class MixinEntityRenderer {
|
||||||
|
|
||||||
@Inject(
|
@Inject(
|
||||||
method = "updateCameraAndRender(FJ)V",
|
method = "renderWorldPass",
|
||||||
at = @At(
|
at = @At(
|
||||||
value = "INVOKE_STRING",
|
value = "INVOKE_STRING",
|
||||||
target = "Lnet/minecraft/profiler/Profiler;endStartSection(Ljava/lang/String;)V",
|
target = "Lnet/minecraft/profiler/Profiler;endStartSection(Ljava/lang/String;)V",
|
||||||
args = {"ldc=hand"}
|
args = {"ldc=hand"}
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
private void renderWorldPass(float partialTicks, long finishTimeNano, CallbackInfo ci) {
|
private void renderWorldPass(int pass, float partialTicks, long finishTimeNano, CallbackInfo ci) {
|
||||||
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
|
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
|
||||||
ibaritone.getGameEventHandler().onRenderPass(new RenderEvent(partialTicks));
|
ibaritone.getGameEventHandler().onRenderPass(new RenderEvent(partialTicks));
|
||||||
}
|
}
|
||||||
@@ -97,10 +97,10 @@ public class MixinMinecraft {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Inject(
|
@Inject(
|
||||||
method = "loadWorld(Lnet/minecraft/client/multiplayer/WorldClient;Lnet/minecraft/client/gui/GuiScreen;)V",
|
method = "loadWorld(Lnet/minecraft/client/multiplayer/WorldClient;Ljava/lang/String;)V",
|
||||||
at = @At("HEAD")
|
at = @At("HEAD")
|
||||||
)
|
)
|
||||||
private void preLoadWorld(WorldClient world, GuiScreen loadingScreen, CallbackInfo ci) {
|
private void preLoadWorld(WorldClient world, String loadingMessage, CallbackInfo ci) {
|
||||||
// If we're unloading the world but one doesn't exist, ignore it
|
// If we're unloading the world but one doesn't exist, ignore it
|
||||||
if (this.world == null && world == null) {
|
if (this.world == null && world == null) {
|
||||||
return;
|
return;
|
||||||
@@ -117,10 +117,10 @@ public class MixinMinecraft {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Inject(
|
@Inject(
|
||||||
method = "loadWorld(Lnet/minecraft/client/multiplayer/WorldClient;Lnet/minecraft/client/gui/GuiScreen;)V",
|
method = "loadWorld(Lnet/minecraft/client/multiplayer/WorldClient;Ljava/lang/String;)V",
|
||||||
at = @At("RETURN")
|
at = @At("RETURN")
|
||||||
)
|
)
|
||||||
private void postLoadWorld(WorldClient world, GuiScreen loadingScreen, CallbackInfo ci) {
|
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
|
// still fire event for both null, as that means we've just finished exiting a world
|
||||||
|
|
||||||
// mc.world changing is only the primary baritone
|
// mc.world changing is only the primary baritone
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ import baritone.api.event.events.type.EventState;
|
|||||||
import net.minecraft.client.network.NetHandlerPlayClient;
|
import net.minecraft.client.network.NetHandlerPlayClient;
|
||||||
import net.minecraft.network.play.server.SPacketChunkData;
|
import net.minecraft.network.play.server.SPacketChunkData;
|
||||||
import net.minecraft.network.play.server.SPacketCombatEvent;
|
import net.minecraft.network.play.server.SPacketCombatEvent;
|
||||||
import net.minecraft.network.play.server.SPacketUnloadChunk;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
@@ -41,7 +40,7 @@ public class MixinNetHandlerPlayClient {
|
|||||||
method = "handleChunkData",
|
method = "handleChunkData",
|
||||||
at = @At(
|
at = @At(
|
||||||
value = "INVOKE",
|
value = "INVOKE",
|
||||||
target = "net/minecraft/client/multiplayer/ChunkProviderClient.func_212474_a(IILnet/minecraft/network/PacketBuffer;IZ)Lnet/minecraft/world/chunk/Chunk;"
|
target = "net/minecraft/world/chunk/Chunk.read(Lnet/minecraft/network/PacketBuffer;IZ)V"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
private void preRead(SPacketChunkData packetIn, CallbackInfo ci) {
|
private void preRead(SPacketChunkData packetIn, CallbackInfo ci) {
|
||||||
@@ -78,34 +77,6 @@ public class MixinNetHandlerPlayClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(
|
|
||||||
method = "processChunkUnload",
|
|
||||||
at = @At("HEAD")
|
|
||||||
)
|
|
||||||
private void preChunkUnload(SPacketUnloadChunk packet, CallbackInfo ci) {
|
|
||||||
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
|
|
||||||
if (ibaritone.getPlayerContext().player().connection == (NetHandlerPlayClient) (Object) this) {
|
|
||||||
ibaritone.getGameEventHandler().onChunkEvent(
|
|
||||||
new ChunkEvent(EventState.PRE, ChunkEvent.Type.UNLOAD, packet.getX(), packet.getZ())
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(
|
|
||||||
method = "processChunkUnload",
|
|
||||||
at = @At("RETURN")
|
|
||||||
)
|
|
||||||
private void postChunkUnload(SPacketUnloadChunk packet, CallbackInfo ci) {
|
|
||||||
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
|
|
||||||
if (ibaritone.getPlayerContext().player().connection == (NetHandlerPlayClient) (Object) this) {
|
|
||||||
ibaritone.getGameEventHandler().onChunkEvent(
|
|
||||||
new ChunkEvent(EventState.POST, ChunkEvent.Type.UNLOAD, packet.getX(), packet.getZ())
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(
|
@Inject(
|
||||||
method = "handleCombatEvent",
|
method = "handleCombatEvent",
|
||||||
at = @At(
|
at = @At(
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public class MixinNetworkManager {
|
|||||||
method = "dispatchPacket",
|
method = "dispatchPacket",
|
||||||
at = @At("HEAD")
|
at = @At("HEAD")
|
||||||
)
|
)
|
||||||
private void preDispatchPacket(Packet<?> inPacket, final GenericFutureListener<? extends Future<? super Void>> futureListeners, CallbackInfo ci) {
|
private void preDispatchPacket(Packet<?> inPacket, final GenericFutureListener<? extends Future<? super Void>>[] futureListeners, CallbackInfo ci) {
|
||||||
if (this.direction != EnumPacketDirection.CLIENTBOUND) {
|
if (this.direction != EnumPacketDirection.CLIENTBOUND) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -69,7 +69,7 @@ public class MixinNetworkManager {
|
|||||||
method = "dispatchPacket",
|
method = "dispatchPacket",
|
||||||
at = @At("RETURN")
|
at = @At("RETURN")
|
||||||
)
|
)
|
||||||
private void postDispatchPacket(Packet<?> inPacket, final GenericFutureListener<? extends Future<? super Void>> futureListeners, CallbackInfo ci) {
|
private void postDispatchPacket(Packet<?> inPacket, final GenericFutureListener<? extends Future<? super Void>>[] futureListeners, CallbackInfo ci) {
|
||||||
if (this.direction != EnumPacketDirection.CLIENTBOUND) {
|
if (this.direction != EnumPacketDirection.CLIENTBOUND) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -85,7 +85,7 @@ public class MixinNetworkManager {
|
|||||||
method = "channelRead0",
|
method = "channelRead0",
|
||||||
at = @At(
|
at = @At(
|
||||||
value = "INVOKE",
|
value = "INVOKE",
|
||||||
target = "net/minecraft/network/NetworkManager.processPacket(Lnet/minecraft/network/Packet;Lnet/minecraft/network/INetHandler;)V"
|
target = "net/minecraft/network/Packet.processPacket(Lnet/minecraft/network/INetHandler;)V"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
private void preProcessPacket(ChannelHandlerContext context, Packet<?> packet, CallbackInfo ci) {
|
private void preProcessPacket(ChannelHandlerContext context, Packet<?> packet, CallbackInfo ci) {
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ import baritone.api.utils.IPlayerContext;
|
|||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.chunk.RenderChunk;
|
import net.minecraft.client.renderer.chunk.RenderChunk;
|
||||||
import net.minecraft.client.renderer.chunk.RenderChunkCache;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.ChunkCache;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
@@ -40,11 +40,43 @@ public class MixinRenderChunk {
|
|||||||
method = "rebuildChunk",
|
method = "rebuildChunk",
|
||||||
at = @At(
|
at = @At(
|
||||||
value = "INVOKE",
|
value = "INVOKE",
|
||||||
target = "net/minecraft/client/renderer/chunk/RenderChunkCache.getBlockState(Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/block/state/IBlockState;"
|
target = "net/minecraft/world/ChunkCache.isEmpty()Z"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
private IBlockState getBlockState(RenderChunkCache chunkCache, BlockPos pos) {
|
private boolean isEmpty(ChunkCache chunkCache) {
|
||||||
if (Baritone.settings().renderCachedChunks.value && Minecraft.getInstance().getIntegratedServer() == null) {
|
if (!chunkCache.isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (Baritone.settings().renderCachedChunks.value && Minecraft.getMinecraft().getIntegratedServer() == null) {
|
||||||
|
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.value && Minecraft.getMinecraft().getIntegratedServer() == null) {
|
||||||
Baritone baritone = (Baritone) BaritoneAPI.getProvider().getPrimaryBaritone();
|
Baritone baritone = (Baritone) BaritoneAPI.getProvider().getPrimaryBaritone();
|
||||||
IPlayerContext ctx = baritone.getPlayerContext();
|
IPlayerContext ctx = baritone.getPlayerContext();
|
||||||
if (ctx.player() != null && ctx.world() != null && baritone.bsi != null) {
|
if (ctx.player() != null && ctx.world() != null && baritone.bsi != null) {
|
||||||
|
|||||||
@@ -1,47 +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.chunk.RenderChunkCache;
|
|
||||||
import net.minecraft.world.chunk.Chunk;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
|
||||||
|
|
||||||
@Mixin(RenderChunkCache.class)
|
|
||||||
public class MixinRenderChunkCache {
|
|
||||||
|
|
||||||
@Redirect(
|
|
||||||
method = "generateCache",
|
|
||||||
at = @At(
|
|
||||||
value = "INVOKE",
|
|
||||||
target = "net/minecraft/world/chunk/Chunk.isEmptyBetween(II)Z"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
private static boolean isEmpty(Chunk chunk, int yStart, int yEnd) {
|
|
||||||
if (!chunk.isEmptyBetween(yStart, yEnd)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (chunk.isEmpty() && Baritone.settings().renderCachedChunks.value && Minecraft.getInstance().getIntegratedServer() == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -38,9 +38,9 @@ public class MixinRenderList {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
private void popMatrix() {
|
private void popMatrix() {
|
||||||
if (Baritone.settings().renderCachedChunks.value && Minecraft.getInstance().getIntegratedServer() == null) {
|
if (Baritone.settings().renderCachedChunks.value && Minecraft.getMinecraft().getIntegratedServer() == null) {
|
||||||
// reset the blend func to normal (not dependent on constant alpha)
|
// reset the blend func to normal (not dependent on constant alpha)
|
||||||
GlStateManager.blendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO);
|
GlStateManager.tryBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO);
|
||||||
}
|
}
|
||||||
GlStateManager.popMatrix();
|
GlStateManager.popMatrix();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,9 +38,9 @@ public class MixinVboRenderList {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
private void popMatrix() {
|
private void popMatrix() {
|
||||||
if (Baritone.settings().renderCachedChunks.value && Minecraft.getInstance().getIntegratedServer() == null) {
|
if (Baritone.settings().renderCachedChunks.value && Minecraft.getMinecraft().getIntegratedServer() == null) {
|
||||||
// reset the blend func to normal (not dependent on constant alpha)
|
// reset the blend func to normal (not dependent on constant alpha)
|
||||||
GlStateManager.blendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO);
|
GlStateManager.tryBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO);
|
||||||
}
|
}
|
||||||
GlStateManager.popMatrix();
|
GlStateManager.popMatrix();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,75 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of Baritone.
|
||||||
|
*
|
||||||
|
* Baritone is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Baritone is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package baritone.launch.mixins;
|
||||||
|
|
||||||
|
import baritone.api.BaritoneAPI;
|
||||||
|
import baritone.api.IBaritone;
|
||||||
|
import baritone.api.event.events.ChunkEvent;
|
||||||
|
import baritone.api.event.events.type.EventState;
|
||||||
|
import net.minecraft.client.multiplayer.WorldClient;
|
||||||
|
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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Brady
|
||||||
|
* @since 8/2/2018
|
||||||
|
*/
|
||||||
|
@Mixin(WorldClient.class)
|
||||||
|
public class MixinWorldClient {
|
||||||
|
|
||||||
|
@Inject(
|
||||||
|
method = "doPreChunk",
|
||||||
|
at = @At("HEAD")
|
||||||
|
)
|
||||||
|
private void preDoPreChunk(int chunkX, int chunkZ, boolean loadChunk, CallbackInfo ci) {
|
||||||
|
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
|
||||||
|
if (ibaritone.getPlayerContext().world() == (WorldClient) (Object) this) {
|
||||||
|
ibaritone.getGameEventHandler().onChunkEvent(
|
||||||
|
new ChunkEvent(
|
||||||
|
EventState.PRE,
|
||||||
|
loadChunk ? ChunkEvent.Type.LOAD : ChunkEvent.Type.UNLOAD,
|
||||||
|
chunkX,
|
||||||
|
chunkZ
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(
|
||||||
|
method = "doPreChunk",
|
||||||
|
at = @At("RETURN")
|
||||||
|
)
|
||||||
|
private void postDoPreChunk(int chunkX, int chunkZ, boolean loadChunk, CallbackInfo ci) {
|
||||||
|
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
|
||||||
|
if (ibaritone.getPlayerContext().world() == (WorldClient) (Object) this) {
|
||||||
|
ibaritone.getGameEventHandler().onChunkEvent(
|
||||||
|
new ChunkEvent(
|
||||||
|
EventState.POST,
|
||||||
|
loadChunk ? ChunkEvent.Type.LOAD : ChunkEvent.Type.UNLOAD,
|
||||||
|
chunkX,
|
||||||
|
chunkZ
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,13 +16,13 @@
|
|||||||
"MixinChunkRenderWorker",
|
"MixinChunkRenderWorker",
|
||||||
"MixinEntityLivingBase",
|
"MixinEntityLivingBase",
|
||||||
"MixinEntityPlayerSP",
|
"MixinEntityPlayerSP",
|
||||||
"MixinGameRenderer",
|
"MixinEntityRenderer",
|
||||||
"MixinMinecraft",
|
"MixinMinecraft",
|
||||||
"MixinNetHandlerPlayClient",
|
"MixinNetHandlerPlayClient",
|
||||||
"MixinNetworkManager",
|
"MixinNetworkManager",
|
||||||
"MixinRenderChunk",
|
"MixinRenderChunk",
|
||||||
"MixinRenderChunkCache",
|
|
||||||
"MixinRenderList",
|
"MixinRenderList",
|
||||||
"MixinVboRenderList"
|
"MixinVboRenderList",
|
||||||
|
"MixinWorldClient"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -21,6 +21,8 @@ import baritone.api.BaritoneAPI;
|
|||||||
import baritone.api.IBaritone;
|
import baritone.api.IBaritone;
|
||||||
import baritone.api.Settings;
|
import baritone.api.Settings;
|
||||||
import baritone.api.event.listener.IEventBus;
|
import baritone.api.event.listener.IEventBus;
|
||||||
|
import baritone.api.utils.ExampleBaritoneControl;
|
||||||
|
import baritone.api.utils.Helper;
|
||||||
import baritone.api.utils.IPlayerContext;
|
import baritone.api.utils.IPlayerContext;
|
||||||
import baritone.behavior.*;
|
import baritone.behavior.*;
|
||||||
import baritone.cache.WorldProvider;
|
import baritone.cache.WorldProvider;
|
||||||
@@ -33,8 +35,6 @@ import net.minecraft.client.Minecraft;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
import java.util.concurrent.SynchronousQueue;
|
import java.util.concurrent.SynchronousQueue;
|
||||||
import java.util.concurrent.ThreadPoolExecutor;
|
import java.util.concurrent.ThreadPoolExecutor;
|
||||||
@@ -52,7 +52,7 @@ public class Baritone implements IBaritone {
|
|||||||
static {
|
static {
|
||||||
threadPool = new ThreadPoolExecutor(4, Integer.MAX_VALUE, 60L, TimeUnit.SECONDS, new SynchronousQueue<>());
|
threadPool = new ThreadPoolExecutor(4, Integer.MAX_VALUE, 60L, TimeUnit.SECONDS, new SynchronousQueue<>());
|
||||||
|
|
||||||
dir = new File(Minecraft.getInstance().gameDir, "baritone");
|
dir = new File(Minecraft.getMinecraft().gameDir, "baritone");
|
||||||
if (!Files.exists(dir.toPath())) {
|
if (!Files.exists(dir.toPath())) {
|
||||||
try {
|
try {
|
||||||
Files.createDirectories(dir.toPath());
|
Files.createDirectories(dir.toPath());
|
||||||
@@ -67,7 +67,6 @@ public class Baritone implements IBaritone {
|
|||||||
|
|
||||||
private GameEventHandler gameEventHandler;
|
private GameEventHandler gameEventHandler;
|
||||||
|
|
||||||
private List<Behavior> behaviors;
|
|
||||||
private PathingBehavior pathingBehavior;
|
private PathingBehavior pathingBehavior;
|
||||||
private LookBehavior lookBehavior;
|
private LookBehavior lookBehavior;
|
||||||
private MemoryBehavior memoryBehavior;
|
private MemoryBehavior memoryBehavior;
|
||||||
@@ -80,6 +79,8 @@ public class Baritone implements IBaritone {
|
|||||||
private CustomGoalProcess customGoalProcess;
|
private CustomGoalProcess customGoalProcess;
|
||||||
private BuilderProcess builderProcess;
|
private BuilderProcess builderProcess;
|
||||||
private ExploreProcess exploreProcess;
|
private ExploreProcess exploreProcess;
|
||||||
|
private BackfillProcess backfillProcess;
|
||||||
|
private FarmProcess farmProcess;
|
||||||
|
|
||||||
private PathingControlManager pathingControlManager;
|
private PathingControlManager pathingControlManager;
|
||||||
|
|
||||||
@@ -101,7 +102,6 @@ public class Baritone implements IBaritone {
|
|||||||
// Define this before behaviors try and get it, or else it will be null and the builds will fail!
|
// Define this before behaviors try and get it, or else it will be null and the builds will fail!
|
||||||
this.playerContext = PrimaryPlayerContext.INSTANCE;
|
this.playerContext = PrimaryPlayerContext.INSTANCE;
|
||||||
|
|
||||||
this.behaviors = new ArrayList<>();
|
|
||||||
{
|
{
|
||||||
// the Behavior constructor calls baritone.registerBehavior(this) so this populates the behaviors arraylist
|
// the Behavior constructor calls baritone.registerBehavior(this) so this populates the behaviors arraylist
|
||||||
pathingBehavior = new PathingBehavior(this);
|
pathingBehavior = new PathingBehavior(this);
|
||||||
@@ -120,6 +120,8 @@ public class Baritone implements IBaritone {
|
|||||||
getToBlockProcess = new GetToBlockProcess(this);
|
getToBlockProcess = new GetToBlockProcess(this);
|
||||||
builderProcess = new BuilderProcess(this);
|
builderProcess = new BuilderProcess(this);
|
||||||
exploreProcess = new ExploreProcess(this);
|
exploreProcess = new ExploreProcess(this);
|
||||||
|
backfillProcess = new BackfillProcess(this);
|
||||||
|
farmProcess = new FarmProcess(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.worldProvider = new WorldProvider();
|
this.worldProvider = new WorldProvider();
|
||||||
@@ -136,12 +138,7 @@ public class Baritone implements IBaritone {
|
|||||||
return this.pathingControlManager;
|
return this.pathingControlManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Behavior> getBehaviors() {
|
|
||||||
return this.behaviors;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void registerBehavior(Behavior behavior) {
|
public void registerBehavior(Behavior behavior) {
|
||||||
this.behaviors.add(behavior);
|
|
||||||
this.gameEventHandler.registerEventListener(behavior);
|
this.gameEventHandler.registerEventListener(behavior);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -197,6 +194,10 @@ public class Baritone implements IBaritone {
|
|||||||
return this.mineProcess;
|
return this.mineProcess;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public FarmProcess getFarmProcess() {
|
||||||
|
return this.farmProcess;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PathingBehavior getPathingBehavior() {
|
public PathingBehavior getPathingBehavior() {
|
||||||
return this.pathingBehavior;
|
return this.pathingBehavior;
|
||||||
@@ -212,6 +213,16 @@ public class Baritone implements IBaritone {
|
|||||||
return this.gameEventHandler;
|
return this.gameEventHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void openClick() {
|
||||||
|
new Thread(() -> {
|
||||||
|
try {
|
||||||
|
Thread.sleep(100);
|
||||||
|
Helper.mc.addScheduledTask(() -> Helper.mc.displayGuiScreen(new GuiClick()));
|
||||||
|
} catch (Exception ignored) {}
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
|
||||||
public static Settings settings() {
|
public static Settings settings() {
|
||||||
return BaritoneAPI.getSettings();
|
return BaritoneAPI.getSettings();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -123,27 +123,27 @@ public class InventoryBehavior extends Behavior {
|
|||||||
|
|
||||||
public boolean hasGenericThrowaway() {
|
public boolean hasGenericThrowaway() {
|
||||||
for (Item item : Baritone.settings().acceptableThrowawayItems.value) {
|
for (Item item : Baritone.settings().acceptableThrowawayItems.value) {
|
||||||
if (throwaway(false, item::equals)) {
|
if (throwaway(false, stack -> item.equals(stack.getItem()))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean selectThrowawayForLocation(int x, int y, int z) {
|
public boolean selectThrowawayForLocation(boolean select, int x, int y, int z) {
|
||||||
IBlockState maybe = baritone.getBuilderProcess().placeAt(x, y, z);
|
IBlockState maybe = baritone.getBuilderProcess().placeAt(x, y, z);
|
||||||
if (maybe != null && throwaway(true, item -> item instanceof ItemBlock && ((ItemBlock) item).getBlock().equals(maybe.getBlock()))) {
|
if (maybe != null && throwaway(select, stack -> stack.getItem() instanceof ItemBlock && ((ItemBlock) stack.getItem()).getBlock().equals(maybe.getBlock()))) {
|
||||||
return true; // gotem
|
return true; // gotem
|
||||||
}
|
}
|
||||||
for (Item item : Baritone.settings().acceptableThrowawayItems.value) {
|
for (Item item : Baritone.settings().acceptableThrowawayItems.value) {
|
||||||
if (throwaway(true, item::equals)) {
|
if (throwaway(select, stack -> item.equals(stack.getItem()))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean throwaway(boolean select, Predicate<? super Item> desired) {
|
public boolean throwaway(boolean select, Predicate<? super ItemStack> desired) {
|
||||||
EntityPlayerSP p = ctx.player();
|
EntityPlayerSP p = ctx.player();
|
||||||
NonNullList<ItemStack> inv = p.inventory.mainInventory;
|
NonNullList<ItemStack> inv = p.inventory.mainInventory;
|
||||||
for (byte i = 0; i < 9; i++) {
|
for (byte i = 0; i < 9; i++) {
|
||||||
@@ -153,14 +153,14 @@ public class InventoryBehavior extends Behavior {
|
|||||||
// and then it's called during execution
|
// and then it's called during execution
|
||||||
// since this function is never called during cost calculation, we don't need to migrate
|
// since this function is never called during cost calculation, we don't need to migrate
|
||||||
// acceptableThrowawayItems to the CalculationContext
|
// acceptableThrowawayItems to the CalculationContext
|
||||||
if (desired.test(item.getItem())) {
|
if (desired.test(item)) {
|
||||||
if (select) {
|
if (select) {
|
||||||
p.inventory.currentItem = i;
|
p.inventory.currentItem = i;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (desired.test(p.inventory.offHandInventory.get(0).getItem())) {
|
if (desired.test(p.inventory.offHandInventory.get(0))) {
|
||||||
// main hand takes precedence over off hand
|
// main hand takes precedence over off hand
|
||||||
// that means that if we have block A selected in main hand and block B in off hand, right clicking places block B
|
// that means that if we have block A selected in main hand and block B in off hand, right clicking places block B
|
||||||
// we've already checked above ^ and the main hand can't possible have an acceptablethrowawayitem
|
// we've already checked above ^ and the main hand can't possible have an acceptablethrowawayitem
|
||||||
|
|||||||
@@ -28,6 +28,9 @@ public final class LookBehavior extends Behavior implements ILookBehavior {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Target's values are as follows:
|
* Target's values are as follows:
|
||||||
|
* <p>
|
||||||
|
* getFirst() -> yaw
|
||||||
|
* getSecond() -> pitch
|
||||||
*/
|
*/
|
||||||
private Rotation target;
|
private Rotation target;
|
||||||
|
|
||||||
|
|||||||
@@ -18,13 +18,13 @@
|
|||||||
package baritone.behavior;
|
package baritone.behavior;
|
||||||
|
|
||||||
import baritone.Baritone;
|
import baritone.Baritone;
|
||||||
|
import baritone.api.cache.Waypoint;
|
||||||
import baritone.api.event.events.BlockInteractEvent;
|
import baritone.api.event.events.BlockInteractEvent;
|
||||||
import baritone.api.event.events.PacketEvent;
|
import baritone.api.event.events.PacketEvent;
|
||||||
import baritone.api.event.events.PlayerUpdateEvent;
|
import baritone.api.event.events.PlayerUpdateEvent;
|
||||||
import baritone.api.event.events.TickEvent;
|
import baritone.api.event.events.TickEvent;
|
||||||
import baritone.api.event.events.type.EventState;
|
import baritone.api.event.events.type.EventState;
|
||||||
import baritone.cache.ContainerMemory;
|
import baritone.cache.ContainerMemory;
|
||||||
import baritone.cache.Waypoint;
|
|
||||||
import baritone.utils.BlockStateInterface;
|
import baritone.utils.BlockStateInterface;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockBed;
|
import net.minecraft.block.BlockBed;
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import baritone.api.pathing.goals.Goal;
|
|||||||
import baritone.api.pathing.goals.GoalXZ;
|
import baritone.api.pathing.goals.GoalXZ;
|
||||||
import baritone.api.process.PathingCommand;
|
import baritone.api.process.PathingCommand;
|
||||||
import baritone.api.utils.BetterBlockPos;
|
import baritone.api.utils.BetterBlockPos;
|
||||||
|
import baritone.api.utils.Helper;
|
||||||
import baritone.api.utils.PathCalculationResult;
|
import baritone.api.utils.PathCalculationResult;
|
||||||
import baritone.api.utils.interfaces.IGoalRenderPos;
|
import baritone.api.utils.interfaces.IGoalRenderPos;
|
||||||
import baritone.pathing.calc.AStarPathFinder;
|
import baritone.pathing.calc.AStarPathFinder;
|
||||||
@@ -32,7 +33,6 @@ import baritone.pathing.calc.AbstractNodeCostSearch;
|
|||||||
import baritone.pathing.movement.CalculationContext;
|
import baritone.pathing.movement.CalculationContext;
|
||||||
import baritone.pathing.movement.MovementHelper;
|
import baritone.pathing.movement.MovementHelper;
|
||||||
import baritone.pathing.path.PathExecutor;
|
import baritone.pathing.path.PathExecutor;
|
||||||
import baritone.utils.Helper;
|
|
||||||
import baritone.utils.PathRenderer;
|
import baritone.utils.PathRenderer;
|
||||||
import baritone.utils.PathingCommandContext;
|
import baritone.utils.PathingCommandContext;
|
||||||
import baritone.utils.pathing.Favoring;
|
import baritone.utils.pathing.Favoring;
|
||||||
@@ -350,7 +350,8 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void forceCancel() { // NOT exposed on public api
|
@Override
|
||||||
|
public void forceCancel() { // exposed on public api because :sob:
|
||||||
cancelEverything();
|
cancelEverything();
|
||||||
secretInternalSegmentCancel();
|
secretInternalSegmentCancel();
|
||||||
synchronized (pathCalcLock) {
|
synchronized (pathCalcLock) {
|
||||||
@@ -358,11 +359,11 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void secretCursedFunctionDoNotCall(IPath path) {
|
/*public void secretCursedFunctionDoNotCall(IPath path) {
|
||||||
synchronized (pathPlanLock) {
|
synchronized (pathPlanLock) {
|
||||||
current = new PathExecutor(this, path);
|
current = new PathExecutor(this, path);
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
public CalculationContext secretInternalGetCalculationContext() {
|
public CalculationContext secretInternalGetCalculationContext() {
|
||||||
return context;
|
return context;
|
||||||
|
|||||||
+11
-45
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
package baritone.cache;
|
package baritone.cache;
|
||||||
|
|
||||||
|
import baritone.api.utils.BlockUtils;
|
||||||
import baritone.utils.pathing.PathingBlockType;
|
import baritone.utils.pathing.PathingBlockType;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
@@ -53,10 +54,9 @@ public final class CachedChunk {
|
|||||||
temp.add(Blocks.TRAPPED_CHEST);
|
temp.add(Blocks.TRAPPED_CHEST);
|
||||||
temp.add(Blocks.END_PORTAL);
|
temp.add(Blocks.END_PORTAL);
|
||||||
temp.add(Blocks.END_PORTAL_FRAME);
|
temp.add(Blocks.END_PORTAL_FRAME);
|
||||||
temp.add(Blocks.SPAWNER);
|
temp.add(Blocks.MOB_SPAWNER);
|
||||||
temp.add(Blocks.BARRIER);
|
temp.add(Blocks.BARRIER);
|
||||||
temp.add(Blocks.OBSERVER);
|
temp.add(Blocks.OBSERVER);
|
||||||
|
|
||||||
temp.add(Blocks.WHITE_SHULKER_BOX);
|
temp.add(Blocks.WHITE_SHULKER_BOX);
|
||||||
temp.add(Blocks.ORANGE_SHULKER_BOX);
|
temp.add(Blocks.ORANGE_SHULKER_BOX);
|
||||||
temp.add(Blocks.MAGENTA_SHULKER_BOX);
|
temp.add(Blocks.MAGENTA_SHULKER_BOX);
|
||||||
@@ -65,7 +65,7 @@ public final class CachedChunk {
|
|||||||
temp.add(Blocks.LIME_SHULKER_BOX);
|
temp.add(Blocks.LIME_SHULKER_BOX);
|
||||||
temp.add(Blocks.PINK_SHULKER_BOX);
|
temp.add(Blocks.PINK_SHULKER_BOX);
|
||||||
temp.add(Blocks.GRAY_SHULKER_BOX);
|
temp.add(Blocks.GRAY_SHULKER_BOX);
|
||||||
temp.add(Blocks.LIGHT_GRAY_SHULKER_BOX);
|
temp.add(Blocks.SILVER_SHULKER_BOX);
|
||||||
temp.add(Blocks.CYAN_SHULKER_BOX);
|
temp.add(Blocks.CYAN_SHULKER_BOX);
|
||||||
temp.add(Blocks.PURPLE_SHULKER_BOX);
|
temp.add(Blocks.PURPLE_SHULKER_BOX);
|
||||||
temp.add(Blocks.BLUE_SHULKER_BOX);
|
temp.add(Blocks.BLUE_SHULKER_BOX);
|
||||||
@@ -73,57 +73,23 @@ public final class CachedChunk {
|
|||||||
temp.add(Blocks.GREEN_SHULKER_BOX);
|
temp.add(Blocks.GREEN_SHULKER_BOX);
|
||||||
temp.add(Blocks.RED_SHULKER_BOX);
|
temp.add(Blocks.RED_SHULKER_BOX);
|
||||||
temp.add(Blocks.BLACK_SHULKER_BOX);
|
temp.add(Blocks.BLACK_SHULKER_BOX);
|
||||||
|
temp.add(Blocks.PORTAL);
|
||||||
temp.add(Blocks.NETHER_PORTAL);
|
|
||||||
temp.add(Blocks.HOPPER);
|
temp.add(Blocks.HOPPER);
|
||||||
temp.add(Blocks.BEACON);
|
temp.add(Blocks.BEACON);
|
||||||
temp.add(Blocks.BREWING_STAND);
|
temp.add(Blocks.BREWING_STAND);
|
||||||
|
temp.add(Blocks.SKULL);
|
||||||
// TODO: Maybe add a predicate for blocks to keep track of?
|
|
||||||
// This should really not need to happen
|
|
||||||
temp.add(Blocks.CREEPER_HEAD);
|
|
||||||
temp.add(Blocks.CREEPER_WALL_HEAD);
|
|
||||||
temp.add(Blocks.DRAGON_HEAD);
|
|
||||||
temp.add(Blocks.DRAGON_WALL_HEAD);
|
|
||||||
temp.add(Blocks.PLAYER_HEAD);
|
|
||||||
temp.add(Blocks.PLAYER_WALL_HEAD);
|
|
||||||
temp.add(Blocks.ZOMBIE_HEAD);
|
|
||||||
temp.add(Blocks.ZOMBIE_WALL_HEAD);
|
|
||||||
temp.add(Blocks.SKELETON_SKULL);
|
|
||||||
temp.add(Blocks.SKELETON_WALL_SKULL);
|
|
||||||
temp.add(Blocks.WITHER_SKELETON_SKULL);
|
|
||||||
temp.add(Blocks.WITHER_SKELETON_WALL_SKULL);
|
|
||||||
|
|
||||||
temp.add(Blocks.ENCHANTING_TABLE);
|
temp.add(Blocks.ENCHANTING_TABLE);
|
||||||
temp.add(Blocks.ANVIL);
|
temp.add(Blocks.ANVIL);
|
||||||
|
temp.add(Blocks.LIT_FURNACE);
|
||||||
temp.add(Blocks.WHITE_BED);
|
temp.add(Blocks.BED);
|
||||||
temp.add(Blocks.ORANGE_BED);
|
|
||||||
temp.add(Blocks.MAGENTA_BED);
|
|
||||||
temp.add(Blocks.LIGHT_BLUE_BED);
|
|
||||||
temp.add(Blocks.YELLOW_BED);
|
|
||||||
temp.add(Blocks.LIME_BED);
|
|
||||||
temp.add(Blocks.PINK_BED);
|
|
||||||
temp.add(Blocks.GRAY_BED);
|
|
||||||
temp.add(Blocks.LIGHT_GRAY_BED);
|
|
||||||
temp.add(Blocks.CYAN_BED);
|
|
||||||
temp.add(Blocks.PURPLE_BED);
|
|
||||||
temp.add(Blocks.BLUE_BED);
|
|
||||||
temp.add(Blocks.BROWN_BED);
|
|
||||||
temp.add(Blocks.GREEN_BED);
|
|
||||||
temp.add(Blocks.RED_BED);
|
|
||||||
temp.add(Blocks.BLACK_BED);
|
|
||||||
|
|
||||||
temp.add(Blocks.DRAGON_EGG);
|
temp.add(Blocks.DRAGON_EGG);
|
||||||
temp.add(Blocks.JUKEBOX);
|
temp.add(Blocks.JUKEBOX);
|
||||||
temp.add(Blocks.END_GATEWAY);
|
temp.add(Blocks.END_GATEWAY);
|
||||||
temp.add(Blocks.COBWEB);
|
temp.add(Blocks.WEB);
|
||||||
temp.add(Blocks.NETHER_WART);
|
temp.add(Blocks.NETHER_WART);
|
||||||
temp.add(Blocks.LADDER);
|
temp.add(Blocks.LADDER);
|
||||||
temp.add(Blocks.VINE);
|
temp.add(Blocks.VINE);
|
||||||
BLOCKS_TO_KEEP_TRACK_OF = Collections.unmodifiableSet(temp);
|
BLOCKS_TO_KEEP_TRACK_OF = Collections.unmodifiableSet(temp);
|
||||||
|
|
||||||
// TODO: Lit Furnaces
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -204,15 +170,15 @@ public final class CachedChunk {
|
|||||||
|
|
||||||
// we have this exact block, it's a surface block
|
// we have this exact block, it's a surface block
|
||||||
/*System.out.println("Saying that " + x + "," + y + "," + z + " is " + state);
|
/*System.out.println("Saying that " + x + "," + y + "," + z + " is " + state);
|
||||||
if (!Minecraft.getInstance().world.getBlockState(new BlockPos(x + this.x * 16, y, z + this.z * 16)).getBlock().equals(state.getBlock())) {
|
if (!Minecraft.getMinecraft().world.getBlockState(new BlockPos(x + this.x * 16, y, z + this.z * 16)).getBlock().equals(state.getBlock())) {
|
||||||
throw new IllegalStateException("failed " + Minecraft.getInstance().world.getBlockState(new BlockPos(x + this.x * 16, y, z + this.z * 16)).getBlock() + " " + state.getBlock() + " " + (x + this.x * 16) + " " + y + " " + (z + this.z * 16));
|
throw new IllegalStateException("failed " + Minecraft.getMinecraft().world.getBlockState(new BlockPos(x + this.x * 16, y, z + this.z * 16)).getBlock() + " " + state.getBlock() + " " + (x + this.x * 16) + " " + y + " " + (z + this.z * 16));
|
||||||
}*/
|
}*/
|
||||||
return overview[internalPos];
|
return overview[internalPos];
|
||||||
}
|
}
|
||||||
if (special != null) {
|
if (special != null) {
|
||||||
String str = special.get(index);
|
String str = special.get(index);
|
||||||
if (str != null) {
|
if (str != null) {
|
||||||
return ChunkPacker.stringToBlockRequired(str).getDefaultState();
|
return BlockUtils.stringToBlockRequired(str).getDefaultState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-3
@@ -19,6 +19,7 @@ package baritone.cache;
|
|||||||
|
|
||||||
import baritone.Baritone;
|
import baritone.Baritone;
|
||||||
import baritone.api.cache.ICachedRegion;
|
import baritone.api.cache.ICachedRegion;
|
||||||
|
import baritone.api.utils.BlockUtils;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
@@ -149,7 +150,7 @@ public final class CachedRegion implements ICachedRegion {
|
|||||||
for (int z = 0; z < 32; z++) {
|
for (int z = 0; z < 32; z++) {
|
||||||
if (chunks[x][z] != null) {
|
if (chunks[x][z] != null) {
|
||||||
for (int i = 0; i < 256; i++) {
|
for (int i = 0; i < 256; i++) {
|
||||||
out.writeUTF(ChunkPacker.blockToString(chunks[x][z].getOverview()[i].getBlock()));
|
out.writeUTF(BlockUtils.blockToString(chunks[x][z].getOverview()[i].getBlock()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -240,7 +241,7 @@ public final class CachedRegion implements ICachedRegion {
|
|||||||
for (int z = 0; z < 32; z++) {
|
for (int z = 0; z < 32; z++) {
|
||||||
if (present[x][z]) {
|
if (present[x][z]) {
|
||||||
for (int i = 0; i < 256; i++) {
|
for (int i = 0; i < 256; i++) {
|
||||||
overview[x][z][i] = ChunkPacker.stringToBlockRequired(in.readUTF()).getDefaultState();
|
overview[x][z][i] = BlockUtils.stringToBlockRequired(in.readUTF()).getDefaultState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -255,7 +256,7 @@ public final class CachedRegion implements ICachedRegion {
|
|||||||
int numSpecialBlockTypes = in.readShort() & 0xffff;
|
int numSpecialBlockTypes = in.readShort() & 0xffff;
|
||||||
for (int i = 0; i < numSpecialBlockTypes; i++) {
|
for (int i = 0; i < numSpecialBlockTypes; i++) {
|
||||||
String blockName = in.readUTF();
|
String blockName = in.readUTF();
|
||||||
ChunkPacker.stringToBlockRequired(blockName);
|
BlockUtils.stringToBlockRequired(blockName);
|
||||||
List<BlockPos> locs = new ArrayList<>();
|
List<BlockPos> locs = new ArrayList<>();
|
||||||
location[x][z].put(blockName, locs);
|
location[x][z].put(blockName, locs);
|
||||||
int numLocations = in.readShort() & 0xffff;
|
int numLocations = in.readShort() & 0xffff;
|
||||||
|
|||||||
+4
-4
@@ -22,7 +22,7 @@ import baritone.api.BaritoneAPI;
|
|||||||
import baritone.api.IBaritone;
|
import baritone.api.IBaritone;
|
||||||
import baritone.api.cache.ICachedWorld;
|
import baritone.api.cache.ICachedWorld;
|
||||||
import baritone.api.cache.IWorldData;
|
import baritone.api.cache.IWorldData;
|
||||||
import baritone.utils.Helper;
|
import baritone.api.utils.Helper;
|
||||||
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
|
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
|
||||||
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
@@ -180,8 +180,8 @@ public final class CachedWorld implements ICachedWorld, Helper {
|
|||||||
if (region == null) {
|
if (region == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int distX = (region.getX() << 9 + 256) - pruneCenter.getX();
|
int distX = ((region.getX() << 9) + 256) - pruneCenter.getX();
|
||||||
int distZ = (region.getZ() << 9 + 256) - pruneCenter.getZ();
|
int distZ = ((region.getZ() << 9) + 256) - pruneCenter.getZ();
|
||||||
double dist = Math.sqrt(distX * distX + distZ * distZ);
|
double dist = Math.sqrt(distX * distX + distZ * distZ);
|
||||||
if (dist > 1024) {
|
if (dist > 1024) {
|
||||||
logDebug("Deleting cached region " + region.getX() + "," + region.getZ() + " from ram");
|
logDebug("Deleting cached region " + region.getX() + "," + region.getZ() + " from ram");
|
||||||
@@ -216,7 +216,7 @@ public final class CachedWorld implements ICachedWorld, Helper {
|
|||||||
if (mostRecentlyModified == null) {
|
if (mostRecentlyModified == null) {
|
||||||
return new BlockPos(0, 0, 0);
|
return new BlockPos(0, 0, 0);
|
||||||
}
|
}
|
||||||
return new BlockPos(mostRecentlyModified.x << 4 + 8, 0, mostRecentlyModified.z << 4 + 8);
|
return new BlockPos((mostRecentlyModified.x << 4) + 8, 0, (mostRecentlyModified.z << 4) + 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized List<CachedRegion> allRegions() {
|
private synchronized List<CachedRegion> allRegions() {
|
||||||
|
|||||||
+20
-43
@@ -17,18 +17,16 @@
|
|||||||
|
|
||||||
package baritone.cache;
|
package baritone.cache;
|
||||||
|
|
||||||
|
import baritone.api.utils.BlockUtils;
|
||||||
import baritone.pathing.movement.MovementHelper;
|
import baritone.pathing.movement.MovementHelper;
|
||||||
import baritone.utils.pathing.PathingBlockType;
|
import baritone.utils.pathing.PathingBlockType;
|
||||||
import net.minecraft.block.*;
|
import net.minecraft.block.*;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Vec3d;
|
|
||||||
import net.minecraft.util.registry.IRegistry;
|
|
||||||
import net.minecraft.world.chunk.BlockStateContainer;
|
import net.minecraft.world.chunk.BlockStateContainer;
|
||||||
import net.minecraft.world.chunk.Chunk;
|
import net.minecraft.world.chunk.Chunk;
|
||||||
import net.minecraft.world.chunk.ChunkSection;
|
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@@ -38,8 +36,6 @@ import java.util.*;
|
|||||||
*/
|
*/
|
||||||
public final class ChunkPacker {
|
public final class ChunkPacker {
|
||||||
|
|
||||||
private static final Map<String, Block> resourceCache = new HashMap<>();
|
|
||||||
|
|
||||||
private ChunkPacker() {}
|
private ChunkPacker() {}
|
||||||
|
|
||||||
public static CachedChunk pack(Chunk chunk) {
|
public static CachedChunk pack(Chunk chunk) {
|
||||||
@@ -48,9 +44,9 @@ public final class ChunkPacker {
|
|||||||
Map<String, List<BlockPos>> specialBlocks = new HashMap<>();
|
Map<String, List<BlockPos>> specialBlocks = new HashMap<>();
|
||||||
BitSet bitSet = new BitSet(CachedChunk.SIZE);
|
BitSet bitSet = new BitSet(CachedChunk.SIZE);
|
||||||
try {
|
try {
|
||||||
ChunkSection[] chunkInternalStorageArray = chunk.getSections();
|
ExtendedBlockStorage[] chunkInternalStorageArray = chunk.getBlockStorageArray();
|
||||||
for (int y0 = 0; y0 < 16; y0++) {
|
for (int y0 = 0; y0 < 16; y0++) {
|
||||||
ChunkSection extendedblockstorage = chunkInternalStorageArray[y0];
|
ExtendedBlockStorage extendedblockstorage = chunkInternalStorageArray[y0];
|
||||||
if (extendedblockstorage == null) {
|
if (extendedblockstorage == null) {
|
||||||
// any 16x16x16 area that's all air will have null storage
|
// any 16x16x16 area that's all air will have null storage
|
||||||
// for example, in an ocean biome, with air from y=64 to y=256
|
// for example, in an ocean biome, with air from y=64 to y=256
|
||||||
@@ -62,7 +58,7 @@ public final class ChunkPacker {
|
|||||||
// since a bitset is initialized to all zero, and air is saved as zeros
|
// since a bitset is initialized to all zero, and air is saved as zeros
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
BlockStateContainer<IBlockState> bsc = extendedblockstorage.getData();
|
BlockStateContainer bsc = extendedblockstorage.getData();
|
||||||
int yReal = y0 << 4;
|
int yReal = y0 << 4;
|
||||||
// the mapping of BlockStateContainer.getIndex from xyz to index is y << 8 | z << 4 | x;
|
// the mapping of BlockStateContainer.getIndex from xyz to index is y << 8 | z << 4 | x;
|
||||||
// for better cache locality, iterate in that order
|
// for better cache locality, iterate in that order
|
||||||
@@ -77,7 +73,7 @@ public final class ChunkPacker {
|
|||||||
bitSet.set(index + 1, bits[1]);
|
bitSet.set(index + 1, bits[1]);
|
||||||
Block block = state.getBlock();
|
Block block = state.getBlock();
|
||||||
if (CachedChunk.BLOCKS_TO_KEEP_TRACK_OF.contains(block)) {
|
if (CachedChunk.BLOCKS_TO_KEEP_TRACK_OF.contains(block)) {
|
||||||
String name = blockToString(block);
|
String name = BlockUtils.blockToString(block);
|
||||||
specialBlocks.computeIfAbsent(name, b -> new ArrayList<>()).add(new BlockPos(x, y, z));
|
specialBlocks.computeIfAbsent(name, b -> new ArrayList<>()).add(new BlockPos(x, y, z));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -92,8 +88,7 @@ public final class ChunkPacker {
|
|||||||
IBlockState[] blocks = new IBlockState[256];
|
IBlockState[] blocks = new IBlockState[256];
|
||||||
|
|
||||||
for (int z = 0; z < 16; z++) {
|
for (int z = 0; z < 16; z++) {
|
||||||
https:
|
https://www.ibm.com/developerworks/library/j-perry-writing-good-java-code/index.html
|
||||||
//www.ibm.com/developerworks/library/j-perry-writing-good-java-code/index.html
|
|
||||||
for (int x = 0; x < 16; x++) {
|
for (int x = 0; x < 16; x++) {
|
||||||
for (int y = 255; y >= 0; y--) {
|
for (int y = 255; y >= 0; y--) {
|
||||||
int index = CachedChunk.getPositionIndex(x, y, z);
|
int index = CachedChunk.getPositionIndex(x, y, z);
|
||||||
@@ -108,58 +103,40 @@ public final class ChunkPacker {
|
|||||||
return new CachedChunk(chunk.x, chunk.z, bitSet, blocks, specialBlocks, System.currentTimeMillis());
|
return new CachedChunk(chunk.x, chunk.z, bitSet, blocks, specialBlocks, System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String blockToString(Block block) {
|
|
||||||
ResourceLocation loc = IRegistry.BLOCK.getKey(block);
|
|
||||||
String name = loc.getPath(); // normally, only write the part after the minecraft:
|
|
||||||
if (!loc.getNamespace().equals("minecraft")) {
|
|
||||||
// Baritone is running on top of forge with mods installed, perhaps?
|
|
||||||
name = loc.toString(); // include the namespace with the colon
|
|
||||||
}
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Block stringToBlockRequired(String name) {
|
|
||||||
if (name.equals("lit_redstone_ore")) {
|
|
||||||
return stringToBlockRequired("redstone_ore");
|
|
||||||
}
|
|
||||||
Block block = stringToBlockNullable(name);
|
|
||||||
Objects.requireNonNull(block);
|
|
||||||
return block;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Block stringToBlockNullable(String name) {
|
|
||||||
return resourceCache.computeIfAbsent(name, n -> IRegistry.BLOCK.get(new ResourceLocation(n.contains(":") ? n : "minecraft:" + n)));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static PathingBlockType getPathingBlockType(IBlockState state, Chunk chunk, int x, int y, int z) {
|
private static PathingBlockType getPathingBlockType(IBlockState state, Chunk chunk, int x, int y, int z) {
|
||||||
Block block = state.getBlock();
|
Block block = state.getBlock();
|
||||||
if (MovementHelper.isWater(state)) {
|
if (block == Blocks.WATER || block == Blocks.FLOWING_WATER) {
|
||||||
// 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
|
// FLOWING_WATER is a waterfall, it doesn't really matter and caching it as AVOID just makes it look wrong
|
||||||
if (MovementHelper.possiblyFlowing(state)) {
|
if (MovementHelper.possiblyFlowing(state)) {
|
||||||
return PathingBlockType.AVOID;
|
return PathingBlockType.AVOID;
|
||||||
}
|
}
|
||||||
if (x == 0 || x == 15 || z == 0 || z == 15) {
|
if (
|
||||||
Vec3d flow = state.getFluidState().getFlow(chunk.getWorld(), new BlockPos(x + chunk.x << 4, y, z + chunk.z << 4));
|
(x != 15 && MovementHelper.possiblyFlowing(chunk.getBlockState(x + 1, y, z)))
|
||||||
if (flow.x != 0.0 || flow.z != 0.0) {
|
|| (x != 0 && MovementHelper.possiblyFlowing(chunk.getBlockState(x - 1, y, z)))
|
||||||
return PathingBlockType.WATER;
|
|| (z != 15 && MovementHelper.possiblyFlowing(chunk.getBlockState(x, y, z + 1)))
|
||||||
}
|
|| (z != 0 && MovementHelper.possiblyFlowing(chunk.getBlockState(x, y, z - 1)))
|
||||||
|
) {
|
||||||
return PathingBlockType.AVOID;
|
return PathingBlockType.AVOID;
|
||||||
}
|
}
|
||||||
if (MovementHelper.possiblyFlowing(chunk.getBlockState(x + 1, y, z)) || MovementHelper.possiblyFlowing(chunk.getBlockState(x - 1, y, z)) || MovementHelper.possiblyFlowing(chunk.getBlockState(x, y, z + 1)) || MovementHelper.possiblyFlowing(chunk.getBlockState(x, y, z - 1))) {
|
if (x == 0 || x == 15 || z == 0 || z == 15) {
|
||||||
|
if (BlockLiquid.getSlopeAngle(chunk.getWorld(), new BlockPos(x + chunk.x << 4, y, z + chunk.z << 4), state.getMaterial(), state) == -1000.0F) {
|
||||||
|
return PathingBlockType.WATER;
|
||||||
|
}
|
||||||
return PathingBlockType.AVOID;
|
return PathingBlockType.AVOID;
|
||||||
}
|
}
|
||||||
return PathingBlockType.WATER;
|
return PathingBlockType.WATER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MovementHelper.avoidWalkingInto(state) || MovementHelper.isBottomSlab(state)) {
|
if (MovementHelper.avoidWalkingInto(block) || 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
|
||||||
// however, this failed in the nether when you were near a nether fortress
|
// however, this failed in the nether when you were near a nether fortress
|
||||||
// because fences check their adjacent blocks in the world for their fence connection status to determine AABB shape
|
// because fences check their adjacent blocks in the world for their fence connection status to determine AABB shape
|
||||||
// this caused a nullpointerexception when we saved chunks on unload, because they were unable to check their neighbors
|
// this caused a nullpointerexception when we saved chunks on unload, because they were unable to check their neighbors
|
||||||
if (block instanceof BlockAir || block instanceof BlockTallGrass || block instanceof BlockDoublePlant || block instanceof BlockFlower) {
|
if (block == Blocks.AIR || block instanceof BlockTallGrass || block instanceof BlockDoublePlant || block instanceof BlockFlower) {
|
||||||
return PathingBlockType.AIR;
|
return PathingBlockType.AIR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ package baritone.cache;
|
|||||||
|
|
||||||
import baritone.api.cache.IWaypoint;
|
import baritone.api.cache.IWaypoint;
|
||||||
import baritone.api.cache.IWaypointCollection;
|
import baritone.api.cache.IWaypointCollection;
|
||||||
|
import baritone.api.cache.Waypoint;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
|||||||
+4
-5
@@ -19,12 +19,11 @@ package baritone.cache;
|
|||||||
|
|
||||||
import baritone.Baritone;
|
import baritone.Baritone;
|
||||||
import baritone.api.cache.IWorldProvider;
|
import baritone.api.cache.IWorldProvider;
|
||||||
import baritone.utils.Helper;
|
import baritone.api.utils.Helper;
|
||||||
import baritone.utils.accessor.IAnvilChunkLoader;
|
import baritone.utils.accessor.IAnvilChunkLoader;
|
||||||
import baritone.utils.accessor.IChunkProviderServer;
|
import baritone.utils.accessor.IChunkProviderServer;
|
||||||
import net.minecraft.server.integrated.IntegratedServer;
|
import net.minecraft.server.integrated.IntegratedServer;
|
||||||
import net.minecraft.world.WorldServer;
|
import net.minecraft.world.WorldServer;
|
||||||
import net.minecraft.world.dimension.DimensionType;
|
|
||||||
import org.apache.commons.lang3.SystemUtils;
|
import org.apache.commons.lang3.SystemUtils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -56,7 +55,7 @@ public class WorldProvider implements IWorldProvider, Helper {
|
|||||||
*
|
*
|
||||||
* @param dimension The ID of the world's dimension
|
* @param dimension The ID of the world's dimension
|
||||||
*/
|
*/
|
||||||
public final void initWorld(DimensionType dimension) {
|
public final void initWorld(int dimension) {
|
||||||
File directory;
|
File directory;
|
||||||
File readme;
|
File readme;
|
||||||
|
|
||||||
@@ -93,7 +92,7 @@ public class WorldProvider implements IWorldProvider, Helper {
|
|||||||
} catch (IOException ignored) {}
|
} catch (IOException ignored) {}
|
||||||
|
|
||||||
// We will actually store the world data in a subfolder: "DIM<id>"
|
// We will actually store the world data in a subfolder: "DIM<id>"
|
||||||
Path dir = new File(directory, "DIM" + dimension.getId()).toPath();
|
Path dir = new File(directory, "DIM" + dimension).toPath();
|
||||||
if (!Files.exists(dir)) {
|
if (!Files.exists(dir)) {
|
||||||
try {
|
try {
|
||||||
Files.createDirectories(dir);
|
Files.createDirectories(dir);
|
||||||
@@ -102,7 +101,7 @@ public class WorldProvider implements IWorldProvider, Helper {
|
|||||||
|
|
||||||
System.out.println("Baritone world data dir: " + dir);
|
System.out.println("Baritone world data dir: " + dir);
|
||||||
synchronized (worldCache) {
|
synchronized (worldCache) {
|
||||||
this.currentWorld = worldCache.computeIfAbsent(dir, d -> new WorldData(d, dimension.getId()));
|
this.currentWorld = worldCache.computeIfAbsent(dir, d -> new WorldData(d, dimension));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+6
-6
@@ -26,7 +26,7 @@ import net.minecraft.util.math.BlockPos;
|
|||||||
import net.minecraft.util.math.ChunkPos;
|
import net.minecraft.util.math.ChunkPos;
|
||||||
import net.minecraft.world.chunk.BlockStateContainer;
|
import net.minecraft.world.chunk.BlockStateContainer;
|
||||||
import net.minecraft.world.chunk.Chunk;
|
import net.minecraft.world.chunk.Chunk;
|
||||||
import net.minecraft.world.chunk.ChunkSection;
|
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.IntStream;
|
import java.util.stream.IntStream;
|
||||||
@@ -70,7 +70,7 @@ public enum WorldScanner implements IWorldScanner {
|
|||||||
foundChunks = true;
|
foundChunks = true;
|
||||||
int chunkX = xoff + playerChunkX;
|
int chunkX = xoff + playerChunkX;
|
||||||
int chunkZ = zoff + playerChunkZ;
|
int chunkZ = zoff + playerChunkZ;
|
||||||
Chunk chunk = chunkProvider.getChunk(chunkX, chunkZ, false, false);
|
Chunk chunk = chunkProvider.getLoadedChunk(chunkX, chunkZ);
|
||||||
if (chunk == null) {
|
if (chunk == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -97,7 +97,7 @@ public enum WorldScanner implements IWorldScanner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ChunkProviderClient chunkProvider = (ChunkProviderClient) ctx.world().getChunkProvider();
|
ChunkProviderClient chunkProvider = (ChunkProviderClient) ctx.world().getChunkProvider();
|
||||||
Chunk chunk = chunkProvider.getChunk(pos.x, pos.z, false, false);
|
Chunk chunk = chunkProvider.getLoadedChunk(pos.x, pos.z);
|
||||||
int playerY = ctx.playerFeet().getY();
|
int playerY = ctx.playerFeet().getY();
|
||||||
|
|
||||||
if (chunk == null || chunk.isEmpty()) {
|
if (chunk == null || chunk.isEmpty()) {
|
||||||
@@ -110,16 +110,16 @@ public enum WorldScanner implements IWorldScanner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean scanChunkInto(int chunkX, int chunkZ, Chunk chunk, List<Block> search, Collection<BlockPos> result, int max, int yLevelThreshold, int playerY, int[] coordinateIterationOrder) {
|
private boolean scanChunkInto(int chunkX, int chunkZ, Chunk chunk, List<Block> search, Collection<BlockPos> result, int max, int yLevelThreshold, int playerY, int[] coordinateIterationOrder) {
|
||||||
ChunkSection[] chunkInternalStorageArray = chunk.getSections();
|
ExtendedBlockStorage[] chunkInternalStorageArray = chunk.getBlockStorageArray();
|
||||||
boolean foundWithinY = false;
|
boolean foundWithinY = false;
|
||||||
for (int yIndex = 0; yIndex < 16; yIndex++) {
|
for (int yIndex = 0; yIndex < 16; yIndex++) {
|
||||||
int y0 = coordinateIterationOrder[yIndex];
|
int y0 = coordinateIterationOrder[yIndex];
|
||||||
ChunkSection extendedblockstorage = chunkInternalStorageArray[y0];
|
ExtendedBlockStorage extendedblockstorage = chunkInternalStorageArray[y0];
|
||||||
if (extendedblockstorage == null) {
|
if (extendedblockstorage == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int yReal = y0 << 4;
|
int yReal = y0 << 4;
|
||||||
BlockStateContainer<IBlockState> bsc = extendedblockstorage.getData();
|
BlockStateContainer bsc = extendedblockstorage.getData();
|
||||||
// the mapping of BlockStateContainer.getIndex from xyz to index is y << 8 | z << 4 | x;
|
// the mapping of BlockStateContainer.getIndex from xyz to index is y << 8 | z << 4 | x;
|
||||||
// for better cache locality, iterate in that order
|
// for better cache locality, iterate in that order
|
||||||
for (int y = 0; y < 16; y++) {
|
for (int y = 0; y < 16; y++) {
|
||||||
|
|||||||
@@ -22,9 +22,9 @@ import baritone.api.event.events.*;
|
|||||||
import baritone.api.event.events.type.EventState;
|
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.api.utils.Helper;
|
||||||
import baritone.cache.WorldProvider;
|
import baritone.cache.WorldProvider;
|
||||||
import baritone.utils.BlockStateInterface;
|
import baritone.utils.BlockStateInterface;
|
||||||
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;
|
||||||
|
|
||||||
@@ -84,7 +84,7 @@ public final class GameEventHandler implements IEventBus, Helper {
|
|||||||
// to make sure the chunk being unloaded is already loaded.
|
// to make sure the chunk being unloaded is already loaded.
|
||||||
boolean isPreUnload = state == EventState.PRE
|
boolean isPreUnload = state == EventState.PRE
|
||||||
&& type == ChunkEvent.Type.UNLOAD
|
&& type == ChunkEvent.Type.UNLOAD
|
||||||
&& world.getChunkProvider().getChunk(event.getX(), event.getZ(), false, false) != null;
|
&& world.getChunkProvider().isChunkGeneratedAt(event.getX(), event.getZ());
|
||||||
|
|
||||||
if (isPostPopulate || isPreUnload) {
|
if (isPostPopulate || isPreUnload) {
|
||||||
baritone.getWorldProvider().ifWorldLoaded(worldData -> {
|
baritone.getWorldProvider().ifWorldLoaded(worldData -> {
|
||||||
@@ -109,7 +109,7 @@ public final class GameEventHandler implements IEventBus, Helper {
|
|||||||
if (event.getState() == EventState.POST) {
|
if (event.getState() == EventState.POST) {
|
||||||
cache.closeWorld();
|
cache.closeWorld();
|
||||||
if (event.getWorld() != null) {
|
if (event.getWorld() != null) {
|
||||||
cache.initWorld(event.getWorld().getDimension().getType());
|
cache.initWorld(event.getWorld().provider.getDimensionType().getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,9 +22,9 @@ import baritone.api.pathing.calc.IPath;
|
|||||||
import baritone.api.pathing.calc.IPathFinder;
|
import baritone.api.pathing.calc.IPathFinder;
|
||||||
import baritone.api.pathing.goals.Goal;
|
import baritone.api.pathing.goals.Goal;
|
||||||
import baritone.api.utils.BetterBlockPos;
|
import baritone.api.utils.BetterBlockPos;
|
||||||
|
import baritone.api.utils.Helper;
|
||||||
import baritone.api.utils.PathCalculationResult;
|
import baritone.api.utils.PathCalculationResult;
|
||||||
import baritone.pathing.movement.CalculationContext;
|
import baritone.pathing.movement.CalculationContext;
|
||||||
import baritone.utils.Helper;
|
|
||||||
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@@ -186,7 +186,7 @@ public abstract class AbstractNodeCostSearch implements IPathFinder, Helper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected Optional<IPath> bestSoFar(boolean logInfo, int numNodes) {
|
protected Optional<IPath> bestSoFar(boolean logInfo, int numNodes) {
|
||||||
if (startNode == null || bestSoFar == null) {
|
if (startNode == null) {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
double bestDist = 0;
|
double bestDist = 0;
|
||||||
|
|||||||
@@ -21,11 +21,11 @@ import baritone.api.pathing.calc.IPath;
|
|||||||
import baritone.api.pathing.goals.Goal;
|
import baritone.api.pathing.goals.Goal;
|
||||||
import baritone.api.pathing.movement.IMovement;
|
import baritone.api.pathing.movement.IMovement;
|
||||||
import baritone.api.utils.BetterBlockPos;
|
import baritone.api.utils.BetterBlockPos;
|
||||||
|
import baritone.api.utils.Helper;
|
||||||
import baritone.pathing.movement.CalculationContext;
|
import baritone.pathing.movement.CalculationContext;
|
||||||
import baritone.pathing.movement.Movement;
|
import baritone.pathing.movement.Movement;
|
||||||
import baritone.pathing.movement.Moves;
|
import baritone.pathing.movement.Moves;
|
||||||
import baritone.pathing.path.CutoffPath;
|
import baritone.pathing.path.CutoffPath;
|
||||||
import baritone.utils.Helper;
|
|
||||||
import baritone.utils.pathing.PathBase;
|
import baritone.utils.pathing.PathBase;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ public class CalculationContext {
|
|||||||
this.bsi = new BlockStateInterface(world, worldData, forUseOnAnotherThread);
|
this.bsi = new BlockStateInterface(world, worldData, forUseOnAnotherThread);
|
||||||
this.toolSet = new ToolSet(player);
|
this.toolSet = new ToolSet(player);
|
||||||
this.hasThrowaway = Baritone.settings().allowPlace.value && ((Baritone) baritone).getInventoryBehavior().hasGenericThrowaway();
|
this.hasThrowaway = Baritone.settings().allowPlace.value && ((Baritone) baritone).getInventoryBehavior().hasGenericThrowaway();
|
||||||
this.hasWaterBucket = Baritone.settings().allowWaterBucketFall.value && InventoryPlayer.isHotbar(player.inventory.getSlotFor(STACK_BUCKET_WATER)) && !world.getDimension().isNether();
|
this.hasWaterBucket = Baritone.settings().allowWaterBucketFall.value && InventoryPlayer.isHotbar(player.inventory.getSlotFor(STACK_BUCKET_WATER)) && !world.provider.isNether();
|
||||||
this.canSprint = Baritone.settings().allowSprint.value && player.getFoodStats().getFoodLevel() > 6;
|
this.canSprint = Baritone.settings().allowSprint.value && player.getFoodStats().getFoodLevel() > 6;
|
||||||
this.placeBlockCost = Baritone.settings().blockPlacementPenalty.value;
|
this.placeBlockCost = Baritone.settings().blockPlacementPenalty.value;
|
||||||
this.allowBreak = Baritone.settings().allowBreak.value;
|
this.allowBreak = Baritone.settings().allowBreak.value;
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import baritone.api.pathing.movement.MovementStatus;
|
|||||||
import baritone.api.utils.*;
|
import baritone.api.utils.*;
|
||||||
import baritone.api.utils.input.Input;
|
import baritone.api.utils.input.Input;
|
||||||
import baritone.utils.BlockStateInterface;
|
import baritone.utils.BlockStateInterface;
|
||||||
|
import net.minecraft.block.BlockLiquid;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
@@ -105,7 +106,7 @@ public abstract class Movement implements IMovement, MovementHelper {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public MovementStatus update() {
|
public MovementStatus update() {
|
||||||
ctx.player().abilities.isFlying = false;
|
ctx.player().capabilities.isFlying = false;
|
||||||
currentState = updateState(currentState);
|
currentState = updateState(currentState);
|
||||||
if (MovementHelper.isLiquid(ctx, ctx.playerFeet())) {
|
if (MovementHelper.isLiquid(ctx, ctx.playerFeet())) {
|
||||||
currentState.setInput(Input.JUMP, true);
|
currentState.setInput(Input.JUMP, true);
|
||||||
@@ -139,7 +140,7 @@ public abstract class Movement implements IMovement, MovementHelper {
|
|||||||
}
|
}
|
||||||
boolean somethingInTheWay = false;
|
boolean somethingInTheWay = false;
|
||||||
for (BetterBlockPos blockPos : positionsToBreak) {
|
for (BetterBlockPos blockPos : positionsToBreak) {
|
||||||
if (!MovementHelper.canWalkThrough(ctx, blockPos)) { // can't break air, so don't try
|
if (!MovementHelper.canWalkThrough(ctx, blockPos) && !(BlockStateInterface.getBlock(ctx, blockPos) instanceof BlockLiquid)) { // can't break liquid, so don't try
|
||||||
somethingInTheWay = true;
|
somethingInTheWay = true;
|
||||||
Optional<Rotation> reachable = RotationUtils.reachable(ctx.player(), blockPos, ctx.playerController().getBlockReachDistance());
|
Optional<Rotation> reachable = RotationUtils.reachable(ctx.player(), blockPos, ctx.playerController().getBlockReachDistance());
|
||||||
if (reachable.isPresent()) {
|
if (reachable.isPresent()) {
|
||||||
@@ -155,7 +156,7 @@ public abstract class Movement implements IMovement, MovementHelper {
|
|||||||
//i'm doing it anyway
|
//i'm doing it anyway
|
||||||
//i dont care if theres snow in the way!!!!!!!
|
//i dont care if theres snow in the way!!!!!!!
|
||||||
//you dont own me!!!!
|
//you dont own me!!!!
|
||||||
state.setTarget(new MovementState.MovementTarget(RotationUtils.calcRotationFromVec3d(ctx.player().getEyePosition(1.0F),
|
state.setTarget(new MovementState.MovementTarget(RotationUtils.calcRotationFromVec3d(ctx.player().getPositionEyes(1.0F),
|
||||||
VecUtils.getBlockPosCenter(blockPos), ctx.playerRotations()), true)
|
VecUtils.getBlockPosCenter(blockPos), ctx.playerRotations()), true)
|
||||||
);
|
);
|
||||||
// don't check selectedblock on this one, this is a fallback when we can't see any face directly, it's intended to be breaking the "incorrect" block
|
// don't check selectedblock on this one, this is a fallback when we can't see any face directly, it's intended to be breaking the "incorrect" block
|
||||||
@@ -269,4 +270,8 @@ public abstract class Movement implements IMovement, MovementHelper {
|
|||||||
}
|
}
|
||||||
return toWalkIntoCached;
|
return toWalkIntoCached;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BlockPos[] toBreakAll() {
|
||||||
|
return positionsToBreak;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,19 +25,11 @@ import baritone.api.utils.*;
|
|||||||
import baritone.api.utils.input.Input;
|
import baritone.api.utils.input.Input;
|
||||||
import baritone.pathing.movement.MovementState.MovementTarget;
|
import baritone.pathing.movement.MovementState.MovementTarget;
|
||||||
import baritone.utils.BlockStateInterface;
|
import baritone.utils.BlockStateInterface;
|
||||||
import baritone.utils.Helper;
|
|
||||||
import baritone.utils.ToolSet;
|
import baritone.utils.ToolSet;
|
||||||
import net.minecraft.block.*;
|
import net.minecraft.block.*;
|
||||||
|
import net.minecraft.block.properties.PropertyBool;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.fluid.FlowingFluid;
|
|
||||||
import net.minecraft.fluid.Fluid;
|
|
||||||
import net.minecraft.fluid.IFluidState;
|
|
||||||
import net.minecraft.fluid.WaterFluid;
|
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.init.Fluids;
|
|
||||||
import net.minecraft.pathfinding.PathType;
|
|
||||||
import net.minecraft.state.BooleanProperty;
|
|
||||||
import net.minecraft.state.properties.SlabType;
|
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.RayTraceResult;
|
import net.minecraft.util.math.RayTraceResult;
|
||||||
@@ -59,11 +51,12 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
return b == Blocks.ICE // ice becomes water, and water can mess up the path
|
return b == Blocks.ICE // ice becomes water, and water can mess up the path
|
||||||
|| b instanceof BlockSilverfish // obvious reasons
|
|| b instanceof BlockSilverfish // obvious reasons
|
||||||
// call context.get directly with x,y,z. no need to make 5 new BlockPos for no reason
|
// call context.get directly with x,y,z. no need to make 5 new BlockPos for no reason
|
||||||
|| !bsi.get0(x, y + 1, z).getFluidState().isEmpty()//don't break anything touching liquid on any side
|
|| bsi.get0(x, y + 1, z).getBlock() instanceof BlockLiquid//don't break anything touching liquid on any side
|
||||||
|| !bsi.get0(x + 1, y, z).getFluidState().isEmpty()
|
|| bsi.get0(x + 1, y, z).getBlock() instanceof BlockLiquid
|
||||||
|| !bsi.get0(x - 1, y, z).getFluidState().isEmpty()
|
|| bsi.get0(x - 1, y, z).getBlock() instanceof BlockLiquid
|
||||||
|| !bsi.get0(x, y, z + 1).getFluidState().isEmpty()
|
|| bsi.get0(x, y, z + 1).getBlock() instanceof BlockLiquid
|
||||||
|| !bsi.get0(x, y, z - 1).getFluidState().isEmpty();
|
|| bsi.get0(x, y, z - 1).getBlock() instanceof BlockLiquid
|
||||||
|
|| Baritone.settings().blocksToAvoidBreaking.value.contains(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean canWalkThrough(IPlayerContext ctx, BetterBlockPos pos) {
|
static boolean canWalkThrough(IPlayerContext ctx, BetterBlockPos pos) {
|
||||||
@@ -76,10 +69,13 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
|
|
||||||
static boolean canWalkThrough(BlockStateInterface bsi, int x, int y, int z, IBlockState state) {
|
static boolean canWalkThrough(BlockStateInterface bsi, int x, int y, int z, IBlockState state) {
|
||||||
Block block = state.getBlock();
|
Block block = state.getBlock();
|
||||||
if (block instanceof BlockAir) { // early return for most common case
|
if (block == Blocks.AIR) { // early return for most common case
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (block == Blocks.FIRE || block == Blocks.TRIPWIRE || block == Blocks.COBWEB || block == Blocks.END_PORTAL || block == Blocks.COCOA || block instanceof BlockSkull || block == Blocks.BUBBLE_COLUMN || block instanceof BlockShulkerBox || block instanceof BlockSlab || block instanceof BlockTrapDoor) {
|
if (block == Blocks.FIRE || block == Blocks.TRIPWIRE || block == Blocks.WEB || block == Blocks.END_PORTAL || block == Blocks.COCOA || block instanceof BlockSkull || block instanceof BlockTrapDoor) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (Baritone.settings().blocksToAvoid.value.contains(block)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (block instanceof BlockDoor || block instanceof BlockFenceGate) {
|
if (block instanceof BlockDoor || block instanceof BlockFenceGate) {
|
||||||
@@ -88,10 +84,10 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
// be opened by just interacting.
|
// be opened by just interacting.
|
||||||
return block != Blocks.IRON_DOOR;
|
return block != Blocks.IRON_DOOR;
|
||||||
}
|
}
|
||||||
if (block instanceof BlockCarpet) {
|
if (block == Blocks.CARPET) {
|
||||||
return canWalkOn(bsi, x, y - 1, z);
|
return canWalkOn(bsi, x, y - 1, z);
|
||||||
}
|
}
|
||||||
if (block instanceof BlockSnowLayer) {
|
if (block instanceof BlockSnow) {
|
||||||
// we've already checked doors and fence gates
|
// we've already checked doors and fence gates
|
||||||
// so the only remaining dynamic isPassables are snow and trapdoor
|
// so the only remaining dynamic isPassables are snow and trapdoor
|
||||||
// if they're cached as a top block, we don't know their metadata
|
// if they're cached as a top block, we don't know their metadata
|
||||||
@@ -101,7 +97,7 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
}
|
}
|
||||||
// the check in BlockSnow.isPassable is layers < 5
|
// the check in BlockSnow.isPassable is layers < 5
|
||||||
// while actually, we want < 3 because 3 or greater makes it impassable in a 2 high ceiling
|
// while actually, we want < 3 because 3 or greater makes it impassable in a 2 high ceiling
|
||||||
if (state.get(BlockSnowLayer.LAYERS) >= 3) {
|
if (state.getValue(BlockSnow.LAYERS) >= 3) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// ok, it's low enough we could walk through it, but is it supported?
|
// ok, it's low enough we could walk through it, but is it supported?
|
||||||
@@ -110,21 +106,20 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
if (isFlowing(x, y, z, state, bsi)) {
|
if (isFlowing(x, y, z, state, bsi)) {
|
||||||
return false; // Don't walk through flowing liquids
|
return false; // Don't walk through flowing liquids
|
||||||
}
|
}
|
||||||
IFluidState fluidState = state.getFluidState();
|
if (block instanceof BlockLiquid) {
|
||||||
if (fluidState.getFluid() instanceof WaterFluid) {
|
|
||||||
if (Baritone.settings().assumeWalkOnWater.value) {
|
if (Baritone.settings().assumeWalkOnWater.value) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
IBlockState up = bsi.get0(x, y + 1, z);
|
IBlockState up = bsi.get0(x, y + 1, z);
|
||||||
if (!up.getFluidState().isEmpty() || up.getBlock() instanceof BlockLilyPad) {
|
if (up.getBlock() instanceof BlockLiquid || up.getBlock() instanceof BlockLilyPad) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return block == Blocks.WATER || block == Blocks.FLOWING_WATER;
|
||||||
}
|
}
|
||||||
// every block that overrides isPassable with anything more complicated than a "return true;" or "return false;"
|
// every block that overrides isPassable with anything more complicated than a "return true;" or "return false;"
|
||||||
// has already been accounted for above
|
// has already been accounted for above
|
||||||
// therefore it's safe to not construct a blockpos from our x, y, z ints and instead just pass null
|
// therefore it's safe to not construct a blockpos from our x, y, z ints and instead just pass null
|
||||||
return state.allowsMovement(null, null, PathType.LAND);
|
return block.isPassable(null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -143,28 +138,27 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
|
|
||||||
static boolean fullyPassable(IBlockState state) {
|
static boolean fullyPassable(IBlockState state) {
|
||||||
Block block = state.getBlock();
|
Block block = state.getBlock();
|
||||||
if (block instanceof BlockAir) { // early return for most common case
|
if (block == Blocks.AIR) { // early return for most common case
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// exceptions - blocks that are isPassable true, but we can't actually jump through
|
// exceptions - blocks that are isPassable true, but we can't actually jump through
|
||||||
if (block == Blocks.FIRE
|
if (block == Blocks.FIRE
|
||||||
|| block == Blocks.TRIPWIRE
|
|| block == Blocks.TRIPWIRE
|
||||||
|| block == Blocks.COBWEB
|
|| block == Blocks.WEB
|
||||||
|| block == Blocks.VINE
|
|| block == Blocks.VINE
|
||||||
|| block == Blocks.LADDER
|
|| block == Blocks.LADDER
|
||||||
|| block == Blocks.COCOA
|
|| block == Blocks.COCOA
|
||||||
|| block instanceof BlockDoor
|
|| block instanceof BlockDoor
|
||||||
|| block instanceof BlockFenceGate
|
|| block instanceof BlockFenceGate
|
||||||
|| block instanceof BlockSnow
|
|| block instanceof BlockSnow
|
||||||
|| !state.getFluidState().isEmpty()
|
|| block instanceof BlockLiquid
|
||||||
|| block instanceof BlockTrapDoor
|
|| block instanceof BlockTrapDoor
|
||||||
|| block instanceof BlockEndPortal
|
|| block instanceof BlockEndPortal
|
||||||
|| block instanceof BlockSkull
|
|| block instanceof BlockSkull) {
|
||||||
|| block instanceof BlockShulkerBox) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// door, fence gate, liquid, trapdoor have been accounted for, nothing else uses the world or pos parameters
|
// door, fence gate, liquid, trapdoor have been accounted for, nothing else uses the world or pos parameters
|
||||||
return state.allowsMovement(null, null, PathType.LAND);
|
return block.isPassable(null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean isReplacable(int x, int y, int z, IBlockState state, BlockStateInterface bsi) {
|
static boolean isReplacable(int x, int y, int z, IBlockState state, BlockStateInterface bsi) {
|
||||||
@@ -179,19 +173,20 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
Block block = state.getBlock();
|
Block block = state.getBlock();
|
||||||
if (block instanceof BlockAir) {
|
if (block == Blocks.AIR || isWater(block)) {
|
||||||
// early return for common cases hehe
|
// early return for common cases hehe
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (block instanceof BlockSnowLayer) {
|
if (block instanceof BlockSnow) {
|
||||||
// as before, default to true (mostly because it would otherwise make long distance pathing through snowy biomes impossible)
|
// as before, default to true (mostly because it would otherwise make long distance pathing through snowy biomes impossible)
|
||||||
if (!bsi.worldContainsLoadedChunk(x, z)) {
|
if (!bsi.worldContainsLoadedChunk(x, z)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return state.get(BlockSnowLayer.LAYERS) == 1;
|
return state.getValue(BlockSnow.LAYERS) == 1;
|
||||||
}
|
}
|
||||||
if (block == Blocks.LARGE_FERN || block == Blocks.TALL_GRASS) {
|
if (block instanceof BlockDoublePlant) {
|
||||||
return true;
|
BlockDoublePlant.EnumPlantType kek = state.getValue(BlockDoublePlant.VARIANT);
|
||||||
|
return kek == BlockDoublePlant.EnumPlantType.FERN || kek == BlockDoublePlant.EnumPlantType.GRASS;
|
||||||
}
|
}
|
||||||
return state.getMaterial().isReplaceable();
|
return state.getMaterial().isReplaceable();
|
||||||
}
|
}
|
||||||
@@ -219,16 +214,16 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return state.get(BlockFenceGate.OPEN);
|
return state.getValue(BlockFenceGate.OPEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean isHorizontalBlockPassable(BlockPos blockPos, IBlockState blockState, BlockPos playerPos, BooleanProperty propertyOpen) {
|
static boolean isHorizontalBlockPassable(BlockPos blockPos, IBlockState blockState, BlockPos playerPos, PropertyBool propertyOpen) {
|
||||||
if (playerPos.equals(blockPos)) {
|
if (playerPos.equals(blockPos)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
EnumFacing.Axis facing = blockState.get(BlockHorizontal.HORIZONTAL_FACING).getAxis();
|
EnumFacing.Axis facing = blockState.getValue(BlockHorizontal.FACING).getAxis();
|
||||||
boolean open = blockState.get(propertyOpen);
|
boolean open = blockState.getValue(propertyOpen);
|
||||||
|
|
||||||
EnumFacing.Axis playerFacing;
|
EnumFacing.Axis playerFacing;
|
||||||
if (playerPos.north().equals(blockPos) || playerPos.south().equals(blockPos)) {
|
if (playerPos.north().equals(blockPos) || playerPos.south().equals(blockPos)) {
|
||||||
@@ -242,15 +237,14 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
return (facing == playerFacing) == open;
|
return (facing == playerFacing) == open;
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean avoidWalkingInto(IBlockState state) {
|
static boolean avoidWalkingInto(Block block) {
|
||||||
Block block = state.getBlock();
|
return block instanceof BlockLiquid
|
||||||
return !state.getFluidState().isEmpty()
|
|| block instanceof BlockDynamicLiquid
|
||||||
|| block == Blocks.MAGMA_BLOCK
|
|| block == Blocks.MAGMA
|
||||||
|| block == Blocks.CACTUS
|
|| block == Blocks.CACTUS
|
||||||
|| block == Blocks.FIRE
|
|| block == Blocks.FIRE
|
||||||
|| block == Blocks.END_PORTAL
|
|| block == Blocks.END_PORTAL
|
||||||
|| block == Blocks.COBWEB
|
|| block == Blocks.WEB;
|
||||||
|| block == Blocks.BUBBLE_COLUMN;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -267,7 +261,7 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
*/
|
*/
|
||||||
static boolean canWalkOn(BlockStateInterface bsi, int x, int y, int z, IBlockState state) {
|
static boolean canWalkOn(BlockStateInterface bsi, int x, int y, int z, IBlockState state) {
|
||||||
Block block = state.getBlock();
|
Block block = state.getBlock();
|
||||||
if (block instanceof BlockAir || block == Blocks.MAGMA_BLOCK || block == Blocks.BUBBLE_COLUMN) {
|
if (block == Blocks.AIR || block == Blocks.MAGMA) {
|
||||||
// early return for most common case (air)
|
// early return for most common case (air)
|
||||||
// plus magma, which is a normal cube but it hurts you
|
// plus magma, which is a normal cube but it hurts you
|
||||||
return false;
|
return false;
|
||||||
@@ -284,31 +278,33 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
if (block == Blocks.ENDER_CHEST || block == Blocks.CHEST) {
|
if (block == Blocks.ENDER_CHEST || block == Blocks.CHEST) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (isWater(state)) {
|
if (isWater(block)) {
|
||||||
// since this is called literally millions of times per second, the benefit of not allocating millions of useless "pos.up()"
|
// since this is called literally millions of times per second, the benefit of not allocating millions of useless "pos.up()"
|
||||||
// BlockPos s that we'd just garbage collect immediately is actually noticeable. I don't even think its a decrease in readability
|
// BlockPos s that we'd just garbage collect immediately is actually noticeable. I don't even think its a decrease in readability
|
||||||
IBlockState upState = bsi.get0(x, y + 1, z);
|
Block up = bsi.get0(x, y + 1, z).getBlock();
|
||||||
Block up = upState.getBlock();
|
if (up == Blocks.WATERLILY || up == Blocks.CARPET) {
|
||||||
if (up == Blocks.LILY_PAD || up instanceof BlockCarpet) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (isFlowing(x, y, z, state, bsi) || upState.getFluidState().getFluid() == Fluids.FLOWING_WATER) {
|
if (isFlowing(x, y, z, state, bsi) || block == Blocks.FLOWING_WATER) {
|
||||||
// the only scenario in which we can walk on flowing water is if it's under still water with jesus off
|
// the only scenario in which we can walk on flowing water is if it's under still water with jesus off
|
||||||
return isWater(upState) && !Baritone.settings().assumeWalkOnWater.value;
|
return isWater(up) && !Baritone.settings().assumeWalkOnWater.value;
|
||||||
}
|
}
|
||||||
// if assumeWalkOnWater is on, we can only walk on water if there isn't water above it
|
// if assumeWalkOnWater is on, we can only walk on water if there isn't water above it
|
||||||
// if assumeWalkOnWater is off, we can only walk on water if there is water above it
|
// if assumeWalkOnWater is off, we can only walk on water if there is water above it
|
||||||
return isWater(upState) ^ Baritone.settings().assumeWalkOnWater.value;
|
return isWater(up) ^ Baritone.settings().assumeWalkOnWater.value;
|
||||||
}
|
}
|
||||||
if (Baritone.settings().assumeWalkOnLava.value && isLava(state) && !isFlowing(x, y, z, state, bsi)) {
|
if (Baritone.settings().assumeWalkOnLava.value && isLava(block) && !isFlowing(x, y, z, state, bsi)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (block == Blocks.GLASS || block instanceof BlockStainedGlass) {
|
if (block == Blocks.GLASS || block == Blocks.STAINED_GLASS) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (block instanceof BlockSlab) {
|
if (block instanceof BlockSlab) {
|
||||||
if (!Baritone.settings().allowWalkOnBottomSlab.value) {
|
if (!Baritone.settings().allowWalkOnBottomSlab.value) {
|
||||||
return state.isTopSolid();
|
if (((BlockSlab) block).isDouble()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return state.getValue(BlockSlab.HALF) != BlockSlab.EnumBlockHalf.BOTTOM;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -319,6 +315,10 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
return canWalkOn(new BlockStateInterface(ctx), pos.x, pos.y, pos.z, state);
|
return canWalkOn(new BlockStateInterface(ctx), pos.x, pos.y, pos.z, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static boolean canWalkOn(IPlayerContext ctx, BlockPos pos) {
|
||||||
|
return canWalkOn(new BlockStateInterface(ctx), pos.getX(), pos.getY(), pos.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
static boolean canWalkOn(IPlayerContext ctx, BetterBlockPos pos) {
|
static boolean canWalkOn(IPlayerContext ctx, BetterBlockPos pos) {
|
||||||
return canWalkOn(new BlockStateInterface(ctx), pos.x, pos.y, pos.z);
|
return canWalkOn(new BlockStateInterface(ctx), pos.x, pos.y, pos.z);
|
||||||
}
|
}
|
||||||
@@ -343,7 +343,7 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
// can we look at the center of a side face of this block and likely be able to place?
|
// can we look at the center of a side face of this block and likely be able to place?
|
||||||
// (thats how this check is used)
|
// (thats how this check is used)
|
||||||
// therefore dont include weird things that we technically could place against (like carpet) but practically can't
|
// therefore dont include weird things that we technically could place against (like carpet) but practically can't
|
||||||
return state.isBlockNormalCube() || state.isFullCube() || state.getBlock() == Blocks.GLASS || state.getBlock() instanceof BlockStainedGlass;
|
return state.isBlockNormalCube() || state.isFullBlock() || state.getBlock() == Blocks.GLASS || state.getBlock() == Blocks.STAINED_GLASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static double getMiningDurationTicks(CalculationContext context, int x, int y, int z, boolean includeFalling) {
|
static double getMiningDurationTicks(CalculationContext context, int x, int y, int z, boolean includeFalling) {
|
||||||
@@ -360,7 +360,7 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
if (avoidBreaking(context.bsi, x, y, z, state)) {
|
if (avoidBreaking(context.bsi, x, y, z, state)) {
|
||||||
return COST_INF;
|
return COST_INF;
|
||||||
}
|
}
|
||||||
if (!state.getFluidState().isEmpty()) {
|
if (block instanceof BlockLiquid) {
|
||||||
return COST_INF;
|
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 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
|
||||||
@@ -385,7 +385,8 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
|
|
||||||
static boolean isBottomSlab(IBlockState state) {
|
static boolean isBottomSlab(IBlockState state) {
|
||||||
return state.getBlock() instanceof BlockSlab
|
return state.getBlock() instanceof BlockSlab
|
||||||
&& state.get(BlockSlab.TYPE) == SlabType.BOTTOM;
|
&& !((BlockSlab) state.getBlock()).isDouble()
|
||||||
|
&& state.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.BOTTOM;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -422,12 +423,11 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
* Returns whether or not the specified block is
|
* Returns whether or not the specified block is
|
||||||
* water, regardless of whether or not it is flowing.
|
* water, regardless of whether or not it is flowing.
|
||||||
*
|
*
|
||||||
* @param state The block state
|
* @param b The block
|
||||||
* @return Whether or not the block is water
|
* @return Whether or not the block is water
|
||||||
*/
|
*/
|
||||||
static boolean isWater(IBlockState state) {
|
static boolean isWater(Block b) {
|
||||||
Fluid f = state.getFluidState().getFluid();
|
return b == Blocks.FLOWING_WATER || b == Blocks.WATER;
|
||||||
return f == Fluids.WATER || f == Fluids.FLOWING_WATER;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -439,12 +439,11 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
* @return Whether or not the block is water
|
* @return Whether or not the block is water
|
||||||
*/
|
*/
|
||||||
static boolean isWater(IPlayerContext ctx, BlockPos bp) {
|
static boolean isWater(IPlayerContext ctx, BlockPos bp) {
|
||||||
return isWater(BlockStateInterface.get(ctx, bp));
|
return isWater(BlockStateInterface.getBlock(ctx, bp));
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean isLava(IBlockState state) {
|
static boolean isLava(Block b) {
|
||||||
Fluid f = state.getFluidState().getFluid();
|
return b == Blocks.FLOWING_LAVA || b == Blocks.LAVA;
|
||||||
return f == Fluids.LAVA || f == Fluids.FLOWING_LAVA;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -455,25 +454,20 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
* @return Whether or not the block is a liquid
|
* @return Whether or not the block is a liquid
|
||||||
*/
|
*/
|
||||||
static boolean isLiquid(IPlayerContext ctx, BlockPos p) {
|
static boolean isLiquid(IPlayerContext ctx, BlockPos p) {
|
||||||
return isLiquid(BlockStateInterface.get(ctx, p));
|
return BlockStateInterface.getBlock(ctx, p) instanceof BlockLiquid;
|
||||||
}
|
|
||||||
|
|
||||||
static boolean isLiquid(IBlockState blockState) {
|
|
||||||
return !blockState.getFluidState().isEmpty();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean possiblyFlowing(IBlockState state) {
|
static boolean possiblyFlowing(IBlockState state) {
|
||||||
IFluidState fluidState = state.getFluidState();
|
// Will be IFluidState in 1.13
|
||||||
return fluidState.getFluid() instanceof FlowingFluid
|
return state.getBlock() instanceof BlockLiquid
|
||||||
&& fluidState.getFluid().getLevel(fluidState) != 8;
|
&& state.getValue(BlockLiquid.LEVEL) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean isFlowing(int x, int y, int z, IBlockState state, BlockStateInterface bsi) {
|
static boolean isFlowing(int x, int y, int z, IBlockState state, BlockStateInterface bsi) {
|
||||||
IFluidState fluidState = state.getFluidState();
|
if (!(state.getBlock() instanceof BlockLiquid)) {
|
||||||
if (!(fluidState.getFluid() instanceof FlowingFluid)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (fluidState.getFluid().getLevel(fluidState) != 8) {
|
if (state.getValue(BlockLiquid.LEVEL) != 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return possiblyFlowing(bsi.get0(x + 1, y, z))
|
return possiblyFlowing(bsi.get0(x + 1, y, z))
|
||||||
@@ -494,8 +488,8 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
BlockPos against1 = placeAt.offset(HORIZONTALS_BUT_ALSO_DOWN____SO_EVERY_DIRECTION_EXCEPT_UP[i]);
|
BlockPos against1 = placeAt.offset(HORIZONTALS_BUT_ALSO_DOWN____SO_EVERY_DIRECTION_EXCEPT_UP[i]);
|
||||||
if (MovementHelper.canPlaceAgainst(ctx, against1)) {
|
if (MovementHelper.canPlaceAgainst(ctx, against1)) {
|
||||||
if (!((Baritone) baritone).getInventoryBehavior().selectThrowawayForLocation(placeAt.getX(), placeAt.getY(), placeAt.getZ())) { // get ready to place a throwaway block
|
if (!((Baritone) baritone).getInventoryBehavior().selectThrowawayForLocation(false, placeAt.getX(), placeAt.getY(), placeAt.getZ())) { // get ready to place a throwaway block
|
||||||
Helper.HELPER.logDebug("bb pls get me some blocks. dirt or cobble");
|
Helper.HELPER.logDebug("bb pls get me some blocks. dirt, netherrack, cobble");
|
||||||
state.setStatus(MovementStatus.UNREACHABLE);
|
state.setStatus(MovementStatus.UNREACHABLE);
|
||||||
return PlaceResult.NO_OPTION;
|
return PlaceResult.NO_OPTION;
|
||||||
}
|
}
|
||||||
@@ -504,7 +498,7 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
double faceZ = (placeAt.getZ() + against1.getZ() + 1.0D) * 0.5D;
|
double faceZ = (placeAt.getZ() + against1.getZ() + 1.0D) * 0.5D;
|
||||||
Rotation place = RotationUtils.calcRotationFromVec3d(ctx.playerHead(), new Vec3d(faceX, faceY, faceZ), ctx.playerRotations());
|
Rotation place = RotationUtils.calcRotationFromVec3d(ctx.playerHead(), new Vec3d(faceX, faceY, faceZ), ctx.playerRotations());
|
||||||
RayTraceResult res = RayTraceUtils.rayTraceTowards(ctx.player(), place, ctx.playerController().getBlockReachDistance());
|
RayTraceResult res = RayTraceUtils.rayTraceTowards(ctx.player(), place, ctx.playerController().getBlockReachDistance());
|
||||||
if (res != null && res.type == RayTraceResult.Type.BLOCK && res.getBlockPos().equals(against1) && res.getBlockPos().offset(res.sideHit).equals(placeAt)) {
|
if (res != null && res.typeOfHit == RayTraceResult.Type.BLOCK && res.getBlockPos().equals(against1) && res.getBlockPos().offset(res.sideHit).equals(placeAt)) {
|
||||||
state.setTarget(new MovementState.MovementTarget(place, true));
|
state.setTarget(new MovementState.MovementTarget(place, true));
|
||||||
found = true;
|
found = true;
|
||||||
|
|
||||||
@@ -521,10 +515,15 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
EnumFacing side = ctx.objectMouseOver().sideHit;
|
EnumFacing side = ctx.objectMouseOver().sideHit;
|
||||||
// only way for selectedBlock.equals(placeAt) to be true is if it's replacable
|
// only way for selectedBlock.equals(placeAt) to be true is if it's replacable
|
||||||
if (selectedBlock.equals(placeAt) || (MovementHelper.canPlaceAgainst(ctx, selectedBlock) && selectedBlock.offset(side).equals(placeAt))) {
|
if (selectedBlock.equals(placeAt) || (MovementHelper.canPlaceAgainst(ctx, selectedBlock) && selectedBlock.offset(side).equals(placeAt))) {
|
||||||
|
((Baritone) baritone).getInventoryBehavior().selectThrowawayForLocation(true, placeAt.getX(), placeAt.getY(), placeAt.getZ());
|
||||||
return PlaceResult.READY_TO_PLACE;
|
return PlaceResult.READY_TO_PLACE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return found ? PlaceResult.ATTEMPTING : PlaceResult.NO_OPTION;
|
if (found) {
|
||||||
|
((Baritone) baritone).getInventoryBehavior().selectThrowawayForLocation(true, placeAt.getX(), placeAt.getY(), placeAt.getZ());
|
||||||
|
return PlaceResult.ATTEMPTING;
|
||||||
|
}
|
||||||
|
return PlaceResult.NO_OPTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum PlaceResult {
|
enum PlaceResult {
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ public class MovementDescend extends Movement {
|
|||||||
IBlockState ontoBlock = context.get(destX, newY, destZ);
|
IBlockState ontoBlock = context.get(destX, newY, destZ);
|
||||||
int unprotectedFallHeight = fallHeight - (y - effectiveStartHeight); // equal to fallHeight - y + effectiveFallHeight, which is equal to -newY + effectiveFallHeight, which is equal to effectiveFallHeight - newY
|
int unprotectedFallHeight = fallHeight - (y - effectiveStartHeight); // equal to fallHeight - y + effectiveFallHeight, which is equal to -newY + effectiveFallHeight, which is equal to effectiveFallHeight - newY
|
||||||
double tentativeCost = WALK_OFF_BLOCK_COST + FALL_N_BLOCKS_COST[unprotectedFallHeight] + frontBreak + costSoFar;
|
double tentativeCost = WALK_OFF_BLOCK_COST + FALL_N_BLOCKS_COST[unprotectedFallHeight] + frontBreak + costSoFar;
|
||||||
if (MovementHelper.isWater(ontoBlock)) {
|
if (MovementHelper.isWater(ontoBlock.getBlock())) {
|
||||||
if (!MovementHelper.canWalkThrough(context.bsi, destX, newY, destZ, ontoBlock)) {
|
if (!MovementHelper.canWalkThrough(context.bsi, destX, newY, destZ, ontoBlock)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -216,7 +216,7 @@ public class MovementDescend extends Movement {
|
|||||||
double destZ = (src.getZ() + 0.5) * 0.17 + (dest.getZ() + 0.5) * 0.83;
|
double destZ = (src.getZ() + 0.5) * 0.17 + (dest.getZ() + 0.5) * 0.83;
|
||||||
EntityPlayerSP player = ctx.player();
|
EntityPlayerSP player = ctx.player();
|
||||||
state.setTarget(new MovementState.MovementTarget(
|
state.setTarget(new MovementState.MovementTarget(
|
||||||
new Rotation(RotationUtils.calcRotationFromVec3d(player.getEyePosition(1.0F),
|
new Rotation(RotationUtils.calcRotationFromVec3d(player.getPositionEyes(1.0F),
|
||||||
new Vec3d(destX, dest.getY(), destZ),
|
new Vec3d(destX, dest.getY(), destZ),
|
||||||
new Rotation(player.rotationYaw, player.rotationPitch)).getYaw(), player.rotationPitch),
|
new Rotation(player.rotationYaw, player.rotationPitch)).getYaw(), player.rotationPitch),
|
||||||
false
|
false
|
||||||
@@ -248,7 +248,7 @@ public class MovementDescend extends Movement {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
for (int y = 0; y <= 2; y++) { // we could hit any of the three blocks
|
for (int y = 0; y <= 2; y++) { // we could hit any of the three blocks
|
||||||
if (MovementHelper.avoidWalkingInto(BlockStateInterface.get(ctx, into.up(y)))) {
|
if (MovementHelper.avoidWalkingInto(BlockStateInterface.getBlock(ctx, into.up(y)))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -91,12 +91,12 @@ public class MovementDiagonal extends Movement {
|
|||||||
if (fromDown == Blocks.SOUL_SAND) {
|
if (fromDown == Blocks.SOUL_SAND) {
|
||||||
multiplier += (WALK_ONE_OVER_SOUL_SAND_COST - WALK_ONE_BLOCK_COST) / 2;
|
multiplier += (WALK_ONE_OVER_SOUL_SAND_COST - WALK_ONE_BLOCK_COST) / 2;
|
||||||
}
|
}
|
||||||
IBlockState cuttingOver1 = context.get(x, y - 1, destZ);
|
Block cuttingOver1 = context.get(x, y - 1, destZ).getBlock();
|
||||||
if (cuttingOver1.getBlock() == Blocks.MAGMA_BLOCK || MovementHelper.isLava(cuttingOver1)) {
|
if (cuttingOver1 == Blocks.MAGMA || MovementHelper.isLava(cuttingOver1)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
IBlockState cuttingOver2 = context.get(destX, y - 1, z);
|
Block cuttingOver2 = context.get(destX, y - 1, z).getBlock();
|
||||||
if (cuttingOver2.getBlock() == Blocks.MAGMA_BLOCK || MovementHelper.isLava(cuttingOver2)) {
|
if (cuttingOver2 == Blocks.MAGMA || MovementHelper.isLava(cuttingOver2)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
IBlockState pb0 = context.get(x, y, destZ);
|
IBlockState pb0 = context.get(x, y, destZ);
|
||||||
@@ -115,7 +115,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) && pb2.getBlock() != Blocks.WATER) || MovementHelper.avoidWalkingInto(pb3))) {
|
if (optionA == 0 && ((MovementHelper.avoidWalkingInto(pb2.getBlock()) && pb2.getBlock() != Blocks.WATER) || MovementHelper.avoidWalkingInto(pb3.getBlock()))) {
|
||||||
// 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;
|
||||||
}
|
}
|
||||||
@@ -124,14 +124,13 @@ 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) && pb0.getBlock() != Blocks.WATER) || MovementHelper.avoidWalkingInto(pb1))) {
|
if (optionB == 0 && ((MovementHelper.avoidWalkingInto(pb0.getBlock()) && pb0.getBlock() != Blocks.WATER) || MovementHelper.avoidWalkingInto(pb1.getBlock()))) {
|
||||||
// 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;
|
||||||
}
|
}
|
||||||
boolean water = false;
|
boolean water = false;
|
||||||
IBlockState startState = context.get(x, y, z);
|
Block startIn = context.getBlock(x, y, z);
|
||||||
Block startIn = startState.getBlock();
|
if (MovementHelper.isWater(startIn) || MovementHelper.isWater(destInto.getBlock())) {
|
||||||
if (MovementHelper.isWater(startState) || MovementHelper.isWater(destInto)) {
|
|
||||||
// Ignore previous multiplier
|
// Ignore previous multiplier
|
||||||
// Whatever we were walking on (possibly soul sand) doesn't matter as we're actually floating on water
|
// Whatever we were walking on (possibly soul sand) doesn't matter as we're actually floating on water
|
||||||
// Not even touching the blocks below
|
// Not even touching the blocks below
|
||||||
|
|||||||
@@ -34,13 +34,11 @@ import net.minecraft.block.Block;
|
|||||||
import net.minecraft.block.BlockLadder;
|
import net.minecraft.block.BlockLadder;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.entity.player.InventoryPlayer;
|
import net.minecraft.entity.player.InventoryPlayer;
|
||||||
import net.minecraft.fluid.WaterFluid;
|
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.init.Items;
|
import net.minecraft.init.Items;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.RayTraceResult;
|
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.util.math.Vec3i;
|
import net.minecraft.util.math.Vec3i;
|
||||||
|
|
||||||
@@ -81,11 +79,10 @@ public class MovementFall extends Movement {
|
|||||||
BlockPos playerFeet = ctx.playerFeet();
|
BlockPos playerFeet = ctx.playerFeet();
|
||||||
Rotation toDest = RotationUtils.calcRotationFromVec3d(ctx.playerHead(), VecUtils.getBlockPosCenter(dest), ctx.playerRotations());
|
Rotation toDest = RotationUtils.calcRotationFromVec3d(ctx.playerHead(), VecUtils.getBlockPosCenter(dest), ctx.playerRotations());
|
||||||
Rotation targetRotation = null;
|
Rotation targetRotation = null;
|
||||||
IBlockState destState = ctx.world().getBlockState(dest);
|
Block destBlock = ctx.world().getBlockState(dest).getBlock();
|
||||||
Block destBlock = destState.getBlock();
|
boolean isWater = destBlock == Blocks.WATER || destBlock == Blocks.FLOWING_WATER;
|
||||||
boolean isWater = destState.getFluidState().getFluid() instanceof WaterFluid;
|
|
||||||
if (!isWater && willPlaceBucket() && !playerFeet.equals(dest)) {
|
if (!isWater && willPlaceBucket() && !playerFeet.equals(dest)) {
|
||||||
if (!InventoryPlayer.isHotbar(ctx.player().inventory.getSlotFor(STACK_BUCKET_WATER)) || ctx.world().getDimension().isNether()) {
|
if (!InventoryPlayer.isHotbar(ctx.player().inventory.getSlotFor(STACK_BUCKET_WATER)) || ctx.world().provider.isNether()) {
|
||||||
return state.setStatus(MovementStatus.UNREACHABLE);
|
return state.setStatus(MovementStatus.UNREACHABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,8 +91,7 @@ public class MovementFall extends Movement {
|
|||||||
|
|
||||||
targetRotation = new Rotation(toDest.getYaw(), 90.0F);
|
targetRotation = new Rotation(toDest.getYaw(), 90.0F);
|
||||||
|
|
||||||
RayTraceResult trace = ctx.objectMouseOver();
|
if (ctx.isLookingAt(dest) || ctx.isLookingAt(dest.down())) {
|
||||||
if (trace != null && trace.type == RayTraceResult.Type.BLOCK && (trace.getBlockPos().equals(dest) || trace.getBlockPos().equals(dest.down()))) {
|
|
||||||
state.setInput(Input.CLICK_RIGHT, true);
|
state.setInput(Input.CLICK_RIGHT, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -152,7 +148,7 @@ public class MovementFall extends Movement {
|
|||||||
for (int i = 0; i < 15; i++) {
|
for (int i = 0; i < 15; i++) {
|
||||||
IBlockState state = ctx.world().getBlockState(ctx.playerFeet().down(i));
|
IBlockState state = ctx.world().getBlockState(ctx.playerFeet().down(i));
|
||||||
if (state.getBlock() == Blocks.LADDER) {
|
if (state.getBlock() == Blocks.LADDER) {
|
||||||
return state.get(BlockLadder.FACING);
|
return state.getValue(BlockLadder.FACING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -28,11 +28,10 @@ import baritone.pathing.movement.MovementState;
|
|||||||
import baritone.utils.BlockStateInterface;
|
import baritone.utils.BlockStateInterface;
|
||||||
import baritone.utils.pathing.MutableMoveResult;
|
import baritone.utils.pathing.MutableMoveResult;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.BlockLiquid;
|
||||||
import net.minecraft.block.BlockStairs;
|
import net.minecraft.block.BlockStairs;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.fluid.WaterFluid;
|
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.init.Fluids;
|
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
|
|
||||||
public class MovementParkour extends Movement {
|
public class MovementParkour extends Movement {
|
||||||
@@ -74,7 +73,7 @@ public class MovementParkour extends Movement {
|
|||||||
// second most common case -- we could just traverse not parkour
|
// second most common case -- we could just traverse not parkour
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (MovementHelper.avoidWalkingInto(adj) && !(adj.getFluidState().getFluid() instanceof WaterFluid)) { // magma sucks
|
if (MovementHelper.avoidWalkingInto(adj.getBlock()) && adj.getBlock() != Blocks.WATER && adj.getBlock() != Blocks.FLOWING_WATER) { // magma sucks
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!MovementHelper.fullyPassable(context, x + xDiff, y + 1, z + zDiff)) {
|
if (!MovementHelper.fullyPassable(context, x + xDiff, y + 1, z + zDiff)) {
|
||||||
@@ -87,7 +86,7 @@ public class MovementParkour extends Movement {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
IBlockState standingOn = context.get(x, y - 1, z);
|
IBlockState standingOn = context.get(x, y - 1, z);
|
||||||
if (standingOn.getBlock() == Blocks.VINE || standingOn.getBlock() == Blocks.LADDER || standingOn.getBlock() instanceof BlockStairs || MovementHelper.isBottomSlab(standingOn) || standingOn.getFluidState().getFluid() != Fluids.EMPTY) {
|
if (standingOn.getBlock() == Blocks.VINE || standingOn.getBlock() == Blocks.LADDER || standingOn.getBlock() instanceof BlockStairs || MovementHelper.isBottomSlab(standingOn) || standingOn.getBlock() instanceof BlockLiquid) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int maxJump;
|
int maxJump;
|
||||||
@@ -107,7 +106,9 @@ public class MovementParkour extends Movement {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (MovementHelper.canWalkOn(context.bsi, x + xDiff * i, y - 1, z + zDiff * i)) {
|
IBlockState landingOn = context.bsi.get0(x + xDiff * i, y - 1, z + zDiff * i);
|
||||||
|
// farmland needs to be canwalkon otherwise farm can never work at all, but we want to specifically disallow ending a jumy on farmland haha
|
||||||
|
if (landingOn.getBlock() != Blocks.FARMLAND && MovementHelper.canWalkOn(context.bsi, x + xDiff * i, y - 1, z + zDiff * i, landingOn)) {
|
||||||
res.x = x + xDiff * i;
|
res.x = x + xDiff * i;
|
||||||
res.y = y;
|
res.y = y;
|
||||||
res.z = z + zDiff * i;
|
res.z = z + zDiff * i;
|
||||||
|
|||||||
@@ -51,15 +51,14 @@ public class MovementPillar extends Movement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static double cost(CalculationContext context, int x, int y, int z) {
|
public static double cost(CalculationContext context, int x, int y, int z) {
|
||||||
IBlockState fromState = context.get(x, y, z);
|
Block from = context.get(x, y, z).getBlock();
|
||||||
Block from = fromState.getBlock();
|
|
||||||
boolean ladder = from == Blocks.LADDER || from == Blocks.VINE;
|
boolean ladder = from == Blocks.LADDER || from == Blocks.VINE;
|
||||||
IBlockState fromDown = context.get(x, y - 1, z);
|
IBlockState fromDown = context.get(x, y - 1, z);
|
||||||
if (!ladder) {
|
if (!ladder) {
|
||||||
if (fromDown.getBlock() == Blocks.LADDER || fromDown.getBlock() == Blocks.VINE) {
|
if (fromDown.getBlock() == Blocks.LADDER || fromDown.getBlock() == Blocks.VINE) {
|
||||||
return COST_INF; // can't pillar from a ladder or vine onto something that isn't also climbable
|
return COST_INF; // can't pillar from a ladder or vine onto something that isn't also climbable
|
||||||
}
|
}
|
||||||
if (fromDown.getBlock() instanceof BlockSlab && !fromDown.isTopSolid()) {
|
if (fromDown.getBlock() instanceof BlockSlab && !((BlockSlab) fromDown.getBlock()).isDouble() && fromDown.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.BOTTOM) {
|
||||||
return COST_INF; // can't pillar up from a bottom slab onto a non ladder
|
return COST_INF; // can't pillar up from a bottom slab onto a non ladder
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -71,9 +70,9 @@ public class MovementPillar extends Movement {
|
|||||||
if (toBreakBlock instanceof BlockFenceGate) { // see issue #172
|
if (toBreakBlock instanceof BlockFenceGate) { // see issue #172
|
||||||
return COST_INF;
|
return COST_INF;
|
||||||
}
|
}
|
||||||
IBlockState srcUp = null;
|
Block srcUp = null;
|
||||||
if (MovementHelper.isWater(toBreak) && MovementHelper.isWater(fromState)) { // TODO should this also be allowed if toBreakBlock is air?
|
if (MovementHelper.isWater(toBreakBlock) && MovementHelper.isWater(from)) { // TODO should this also be allowed if toBreakBlock is air?
|
||||||
srcUp = context.get(x, y + 1, z);
|
srcUp = context.get(x, y + 1, z).getBlock();
|
||||||
if (MovementHelper.isWater(srcUp)) {
|
if (MovementHelper.isWater(srcUp)) {
|
||||||
return LADDER_UP_ONE_COST; // allow ascending pillars of water, but only if we're already in one
|
return LADDER_UP_ONE_COST; // allow ascending pillars of water, but only if we're already in one
|
||||||
}
|
}
|
||||||
@@ -85,11 +84,11 @@ public class MovementPillar extends Movement {
|
|||||||
if (placeCost >= COST_INF) {
|
if (placeCost >= COST_INF) {
|
||||||
return COST_INF;
|
return COST_INF;
|
||||||
}
|
}
|
||||||
if (fromDown.getBlock() instanceof BlockAir) {
|
if (fromDown.getBlock() == Blocks.AIR) {
|
||||||
placeCost += 0.1; // slightly (1/200th of a second) penalize pillaring on what's currently air
|
placeCost += 0.1; // slightly (1/200th of a second) penalize pillaring on what's currently air
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((MovementHelper.isLiquid(fromState) && !MovementHelper.canPlaceAgainst(context.bsi, x, y - 1, z, fromDown)) || (MovementHelper.isLiquid(fromDown) && context.assumeWalkOnWater)) {
|
if (from instanceof BlockLiquid || (fromDown.getBlock() instanceof BlockLiquid && context.assumeWalkOnWater)) {
|
||||||
// otherwise, if we're standing in water, we cannot pillar
|
// otherwise, if we're standing in water, we cannot pillar
|
||||||
// if we're standing on water and assumeWalkOnWater is true, we cannot pillar
|
// if we're standing on water and assumeWalkOnWater is true, we cannot pillar
|
||||||
// if we're standing on water and assumeWalkOnWater is false, we must have ascended to here, or sneak backplaced, so it is possible to pillar again
|
// if we're standing on water and assumeWalkOnWater is false, we must have ascended to here, or sneak backplaced, so it is possible to pillar again
|
||||||
@@ -107,9 +106,9 @@ public class MovementPillar extends Movement {
|
|||||||
if (check.getBlock() instanceof BlockFalling) {
|
if (check.getBlock() instanceof BlockFalling) {
|
||||||
// see MovementAscend's identical check for breaking a falling block above our head
|
// see MovementAscend's identical check for breaking a falling block above our head
|
||||||
if (srcUp == null) {
|
if (srcUp == null) {
|
||||||
srcUp = context.get(x, y + 1, z);
|
srcUp = context.get(x, y + 1, z).getBlock();
|
||||||
}
|
}
|
||||||
if (!(toBreakBlock instanceof BlockFalling) || !(srcUp.getBlock() instanceof BlockFalling)) {
|
if (!(toBreakBlock instanceof BlockFalling) || !(srcUp instanceof BlockFalling)) {
|
||||||
return COST_INF;
|
return COST_INF;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -164,7 +163,7 @@ public class MovementPillar extends Movement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
IBlockState fromDown = BlockStateInterface.get(ctx, src);
|
IBlockState fromDown = BlockStateInterface.get(ctx, src);
|
||||||
if (MovementHelper.isWater(fromDown) && MovementHelper.isWater(ctx, dest)) {
|
if (MovementHelper.isWater(fromDown.getBlock()) && MovementHelper.isWater(ctx, dest)) {
|
||||||
// stay centered while swimming up a water column
|
// stay centered while swimming up a water column
|
||||||
state.setTarget(new MovementState.MovementTarget(RotationUtils.calcRotationFromVec3d(ctx.playerHead(), VecUtils.getBlockPosCenter(dest), ctx.playerRotations()), false));
|
state.setTarget(new MovementState.MovementTarget(RotationUtils.calcRotationFromVec3d(ctx.playerHead(), VecUtils.getBlockPosCenter(dest), ctx.playerRotations()), false));
|
||||||
Vec3d destCenter = VecUtils.getBlockPosCenter(dest);
|
Vec3d destCenter = VecUtils.getBlockPosCenter(dest);
|
||||||
@@ -178,7 +177,7 @@ public class MovementPillar extends Movement {
|
|||||||
}
|
}
|
||||||
boolean ladder = fromDown.getBlock() == Blocks.LADDER || fromDown.getBlock() == Blocks.VINE;
|
boolean ladder = fromDown.getBlock() == Blocks.LADDER || fromDown.getBlock() == Blocks.VINE;
|
||||||
boolean vine = fromDown.getBlock() == Blocks.VINE;
|
boolean vine = fromDown.getBlock() == Blocks.VINE;
|
||||||
Rotation rotation = RotationUtils.calcRotationFromVec3d(ctx.player().getEyePosition(1.0F),
|
Rotation rotation = RotationUtils.calcRotationFromVec3d(ctx.player().getPositionEyes(1.0F),
|
||||||
VecUtils.getBlockPosCenter(positionToPlace),
|
VecUtils.getBlockPosCenter(positionToPlace),
|
||||||
new Rotation(ctx.player().rotationYaw, ctx.player().rotationPitch));
|
new Rotation(ctx.player().rotationYaw, ctx.player().rotationPitch));
|
||||||
if (!ladder) {
|
if (!ladder) {
|
||||||
@@ -187,7 +186,7 @@ public class MovementPillar extends Movement {
|
|||||||
|
|
||||||
boolean blockIsThere = MovementHelper.canWalkOn(ctx, src) || ladder;
|
boolean blockIsThere = MovementHelper.canWalkOn(ctx, src) || ladder;
|
||||||
if (ladder) {
|
if (ladder) {
|
||||||
BlockPos against = vine ? getAgainst(new CalculationContext(baritone), src) : src.offset(fromDown.get(BlockLadder.FACING).getOpposite());
|
BlockPos against = vine ? getAgainst(new CalculationContext(baritone), src) : src.offset(fromDown.getValue(BlockLadder.FACING).getOpposite());
|
||||||
if (against == null) {
|
if (against == null) {
|
||||||
logDebug("Unable to climb vines");
|
logDebug("Unable to climb vines");
|
||||||
return state.setStatus(MovementStatus.UNREACHABLE);
|
return state.setStatus(MovementStatus.UNREACHABLE);
|
||||||
@@ -209,7 +208,7 @@ public class MovementPillar extends Movement {
|
|||||||
return state;
|
return state;
|
||||||
} else {
|
} else {
|
||||||
// Get ready to place a throwaway block
|
// Get ready to place a throwaway block
|
||||||
if (!((Baritone) baritone).getInventoryBehavior().selectThrowawayForLocation(src.x, src.y, src.z)) {
|
if (!((Baritone) baritone).getInventoryBehavior().selectThrowawayForLocation(true, src.x, src.y, src.z)) {
|
||||||
return state.setStatus(MovementStatus.UNREACHABLE);
|
return state.setStatus(MovementStatus.UNREACHABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,9 +32,7 @@ import baritone.pathing.movement.MovementState;
|
|||||||
import baritone.utils.BlockStateInterface;
|
import baritone.utils.BlockStateInterface;
|
||||||
import net.minecraft.block.*;
|
import net.minecraft.block.*;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.fluid.WaterFluid;
|
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.state.properties.SlabType;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
|
|
||||||
@@ -66,12 +64,11 @@ public class MovementTraverse extends Movement {
|
|||||||
IBlockState pb0 = context.get(destX, y + 1, destZ);
|
IBlockState pb0 = context.get(destX, y + 1, destZ);
|
||||||
IBlockState pb1 = context.get(destX, y, destZ);
|
IBlockState pb1 = context.get(destX, y, destZ);
|
||||||
IBlockState destOn = context.get(destX, y - 1, destZ);
|
IBlockState destOn = context.get(destX, y - 1, destZ);
|
||||||
IBlockState down = context.get(x, y - 1, z);
|
Block srcDown = context.getBlock(x, y - 1, z);
|
||||||
Block srcDown = down.getBlock();
|
|
||||||
if (MovementHelper.canWalkOn(context.bsi, destX, y - 1, destZ, destOn)) {//this is a walk, not a bridge
|
if (MovementHelper.canWalkOn(context.bsi, destX, y - 1, destZ, destOn)) {//this is a walk, not a bridge
|
||||||
double WC = WALK_ONE_BLOCK_COST;
|
double WC = WALK_ONE_BLOCK_COST;
|
||||||
boolean water = false;
|
boolean water = false;
|
||||||
if (MovementHelper.isWater(pb0) || MovementHelper.isWater(pb1)) {
|
if (MovementHelper.isWater(pb0.getBlock()) || MovementHelper.isWater(pb1.getBlock())) {
|
||||||
WC = context.waterWalkSpeed;
|
WC = context.waterWalkSpeed;
|
||||||
water = true;
|
water = true;
|
||||||
} else {
|
} else {
|
||||||
@@ -108,8 +105,8 @@ public class MovementTraverse extends Movement {
|
|||||||
return COST_INF;
|
return COST_INF;
|
||||||
}
|
}
|
||||||
if (MovementHelper.isReplacable(destX, y - 1, destZ, destOn, context.bsi)) {
|
if (MovementHelper.isReplacable(destX, y - 1, destZ, destOn, context.bsi)) {
|
||||||
boolean throughWater = MovementHelper.isWater(pb0) || MovementHelper.isWater(pb1);
|
boolean throughWater = MovementHelper.isWater(pb0.getBlock()) || MovementHelper.isWater(pb1.getBlock());
|
||||||
if (MovementHelper.isWater(destOn) && throughWater) {
|
if (MovementHelper.isWater(destOn.getBlock()) && throughWater) {
|
||||||
// this happens when assume walk on water is true and this is a traverse in water, which isn't allowed
|
// this happens when assume walk on water is true and this is a traverse in water, which isn't allowed
|
||||||
return COST_INF;
|
return COST_INF;
|
||||||
}
|
}
|
||||||
@@ -135,10 +132,10 @@ public class MovementTraverse extends Movement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// now that we've checked all possible directions to side place, we actually need to backplace
|
// now that we've checked all possible directions to side place, we actually need to backplace
|
||||||
if (srcDown == Blocks.SOUL_SAND || (srcDown instanceof BlockSlab && down.get(BlockSlab.TYPE) != SlabType.DOUBLE)) {
|
if (srcDown == Blocks.SOUL_SAND || (srcDown instanceof BlockSlab && !((BlockSlab) srcDown).isDouble())) {
|
||||||
return COST_INF; // can't sneak and backplace against soul sand or half slabs (regardless of whether it's top half or bottom half) =/
|
return COST_INF; // can't sneak and backplace against soul sand or half slabs (regardless of whether it's top half or bottom half) =/
|
||||||
}
|
}
|
||||||
if (down.getFluidState() instanceof WaterFluid) {
|
if (srcDown == Blocks.FLOWING_WATER || srcDown == Blocks.WATER) {
|
||||||
return COST_INF; // this is obviously impossible
|
return COST_INF; // this is obviously impossible
|
||||||
}
|
}
|
||||||
WC = WC * (SNEAK_ONE_BLOCK_COST / WALK_ONE_BLOCK_COST);//since we are sneak backplacing, we are sneaking lol
|
WC = WC * (SNEAK_ONE_BLOCK_COST / WALK_ONE_BLOCK_COST);//since we are sneak backplacing, we are sneaking lol
|
||||||
@@ -163,10 +160,10 @@ public class MovementTraverse extends Movement {
|
|||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
// and if it's fine to walk into the blocks in front
|
// and if it's fine to walk into the blocks in front
|
||||||
if (MovementHelper.avoidWalkingInto(pb0)) {
|
if (MovementHelper.avoidWalkingInto(pb0.getBlock())) {
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
if (MovementHelper.avoidWalkingInto(pb1)) {
|
if (MovementHelper.avoidWalkingInto(pb1.getBlock())) {
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
// and we aren't already pressed up against the block
|
// and we aren't already pressed up against the block
|
||||||
@@ -244,17 +241,18 @@ public class MovementTraverse extends Movement {
|
|||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
BlockPos into = dest.subtract(src).add(dest);
|
BlockPos into = dest.subtract(src).add(dest);
|
||||||
IBlockState intoBelow = BlockStateInterface.get(ctx, into);
|
Block intoBelow = BlockStateInterface.get(ctx, into).getBlock();
|
||||||
IBlockState intoAbove = BlockStateInterface.get(ctx, into.up());
|
Block intoAbove = BlockStateInterface.get(ctx, into.up()).getBlock();
|
||||||
if (wasTheBridgeBlockAlwaysThere && (!MovementHelper.isLiquid(ctx, ctx.playerFeet()) || Baritone.settings().sprintInWater.value) && (!MovementHelper.avoidWalkingInto(intoBelow) || MovementHelper.isWater(intoBelow)) && !MovementHelper.avoidWalkingInto(intoAbove)) {
|
if (wasTheBridgeBlockAlwaysThere && (!MovementHelper.isLiquid(ctx, ctx.playerFeet()) || Baritone.settings().sprintInWater.value) && (!MovementHelper.avoidWalkingInto(intoBelow) || MovementHelper.isWater(intoBelow)) && !MovementHelper.avoidWalkingInto(intoAbove)) {
|
||||||
state.setInput(Input.SPRINT, true);
|
state.setInput(Input.SPRINT, true);
|
||||||
}
|
}
|
||||||
Block destDown = BlockStateInterface.get(ctx, dest.down()).getBlock();
|
|
||||||
if (whereAmI.getY() != dest.getY() && ladder && (destDown == Blocks.VINE || destDown == Blocks.LADDER)) {
|
IBlockState destDown = BlockStateInterface.get(ctx, dest.down());
|
||||||
new MovementPillar(baritone, dest.down(), dest).updateState(state); // i'm sorry
|
BlockPos against = positionsToBreak[0];
|
||||||
return state;
|
if (whereAmI.getY() != dest.getY() && ladder && (destDown.getBlock() == Blocks.VINE || destDown.getBlock() == Blocks.LADDER)) {
|
||||||
|
against = destDown.getBlock() == Blocks.VINE ? MovementPillar.getAgainst(new CalculationContext(baritone), dest.down()) : dest.offset(destDown.getValue(BlockLadder.FACING).getOpposite());
|
||||||
}
|
}
|
||||||
MovementHelper.moveTowards(ctx, state, positionsToBreak[0]);
|
MovementHelper.moveTowards(ctx, state, against);
|
||||||
return state;
|
return state;
|
||||||
} else {
|
} else {
|
||||||
wasTheBridgeBlockAlwaysThere = false;
|
wasTheBridgeBlockAlwaysThere = false;
|
||||||
|
|||||||
@@ -23,10 +23,7 @@ import baritone.api.pathing.movement.ActionCosts;
|
|||||||
import baritone.api.pathing.movement.IMovement;
|
import baritone.api.pathing.movement.IMovement;
|
||||||
import baritone.api.pathing.movement.MovementStatus;
|
import baritone.api.pathing.movement.MovementStatus;
|
||||||
import baritone.api.pathing.path.IPathExecutor;
|
import baritone.api.pathing.path.IPathExecutor;
|
||||||
import baritone.api.utils.BetterBlockPos;
|
import baritone.api.utils.*;
|
||||||
import baritone.api.utils.IPlayerContext;
|
|
||||||
import baritone.api.utils.RotationUtils;
|
|
||||||
import baritone.api.utils.VecUtils;
|
|
||||||
import baritone.api.utils.input.Input;
|
import baritone.api.utils.input.Input;
|
||||||
import baritone.behavior.PathingBehavior;
|
import baritone.behavior.PathingBehavior;
|
||||||
import baritone.pathing.calc.AbstractNodeCostSearch;
|
import baritone.pathing.calc.AbstractNodeCostSearch;
|
||||||
@@ -35,9 +32,8 @@ import baritone.pathing.movement.Movement;
|
|||||||
import baritone.pathing.movement.MovementHelper;
|
import baritone.pathing.movement.MovementHelper;
|
||||||
import baritone.pathing.movement.movements.*;
|
import baritone.pathing.movement.movements.*;
|
||||||
import baritone.utils.BlockStateInterface;
|
import baritone.utils.BlockStateInterface;
|
||||||
import baritone.utils.Helper;
|
import net.minecraft.block.BlockLiquid;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.init.Fluids;
|
|
||||||
import net.minecraft.util.Tuple;
|
import net.minecraft.util.Tuple;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
@@ -137,7 +133,7 @@ public class PathExecutor implements IPathExecutor, Helper {
|
|||||||
Tuple<Double, BlockPos> status = closestPathPos(path);
|
Tuple<Double, BlockPos> status = closestPathPos(path);
|
||||||
if (possiblyOffPath(status, MAX_DIST_FROM_PATH)) {
|
if (possiblyOffPath(status, MAX_DIST_FROM_PATH)) {
|
||||||
ticksAway++;
|
ticksAway++;
|
||||||
System.out.println("FAR AWAY FROM PATH FOR " + ticksAway + " TICKS. Current distance: " + status.getA() + ". Threshold: " + MAX_DIST_FROM_PATH);
|
System.out.println("FAR AWAY FROM PATH FOR " + ticksAway + " TICKS. Current distance: " + status.getFirst() + ". Threshold: " + MAX_DIST_FROM_PATH);
|
||||||
if (ticksAway > MAX_TICKS_AWAY) {
|
if (ticksAway > MAX_TICKS_AWAY) {
|
||||||
logDebug("Too far away from path for too long, cancelling path");
|
logDebug("Too far away from path for too long, cancelling path");
|
||||||
cancel();
|
cancel();
|
||||||
@@ -333,7 +329,7 @@ public class PathExecutor implements IPathExecutor, Helper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean possiblyOffPath(Tuple<Double, BlockPos> status, double leniency) {
|
private boolean possiblyOffPath(Tuple<Double, BlockPos> status, double leniency) {
|
||||||
double distanceFromPath = status.getA();
|
double distanceFromPath = status.getFirst();
|
||||||
if (distanceFromPath > leniency) {
|
if (distanceFromPath > leniency) {
|
||||||
// when we're midair in the middle of a fall, we're very far from both the beginning and the end, but we aren't actually off path
|
// when we're midair in the middle of a fall, we're very far from both the beginning and the end, but we aren't actually off path
|
||||||
if (path.movements().get(pathPosition) instanceof MovementFall) {
|
if (path.movements().get(pathPosition) instanceof MovementFall) {
|
||||||
@@ -353,7 +349,7 @@ public class PathExecutor implements IPathExecutor, Helper {
|
|||||||
* @return Whether or not it was possible to snap to the current player feet
|
* @return Whether or not it was possible to snap to the current player feet
|
||||||
*/
|
*/
|
||||||
public boolean snipsnapifpossible() {
|
public boolean snipsnapifpossible() {
|
||||||
if (!ctx.player().onGround && ctx.world().getFluidState(ctx.playerFeet()).isEmpty()) {
|
if (!ctx.player().onGround && !(ctx.world().getBlockState(ctx.playerFeet()).getBlock() instanceof BlockLiquid)) {
|
||||||
// if we're falling in the air, and not in water, don't splice
|
// if we're falling in the air, and not in water, don't splice
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
@@ -441,7 +437,10 @@ public class PathExecutor implements IPathExecutor, Helper {
|
|||||||
IMovement prev = path.movements().get(pathPosition - 1);
|
IMovement prev = path.movements().get(pathPosition - 1);
|
||||||
if (prev instanceof MovementDescend && prev.getDirection().up().equals(current.getDirection().down())) {
|
if (prev instanceof MovementDescend && prev.getDirection().up().equals(current.getDirection().down())) {
|
||||||
BlockPos center = current.getSrc().up();
|
BlockPos center = current.getSrc().up();
|
||||||
if (ctx.player().posY >= center.getY()) { // playerFeet adds 0.1251 to account for soul sand
|
// playerFeet adds 0.1251 to account for soul sand
|
||||||
|
// farmland is 0.9375
|
||||||
|
// 0.07 is to account for farmland
|
||||||
|
if (ctx.player().posY >= center.getY() - 0.07) {
|
||||||
behavior.baritone.getInputOverrideHandler().setInputForceState(Input.JUMP, false);
|
behavior.baritone.getInputOverrideHandler().setInputForceState(Input.JUMP, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -453,7 +452,7 @@ public class PathExecutor implements IPathExecutor, Helper {
|
|||||||
if (current instanceof MovementFall) {
|
if (current instanceof MovementFall) {
|
||||||
Tuple<Vec3d, BlockPos> data = overrideFall((MovementFall) current);
|
Tuple<Vec3d, BlockPos> data = overrideFall((MovementFall) current);
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
BlockPos fallDest = data.getB();
|
BlockPos fallDest = data.getSecond();
|
||||||
if (!path.positions().contains(fallDest)) {
|
if (!path.positions().contains(fallDest)) {
|
||||||
throw new IllegalStateException();
|
throw new IllegalStateException();
|
||||||
}
|
}
|
||||||
@@ -464,7 +463,7 @@ public class PathExecutor implements IPathExecutor, Helper {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
clearKeys();
|
clearKeys();
|
||||||
behavior.baritone.getLookBehavior().updateTarget(RotationUtils.calcRotationFromVec3d(ctx.playerHead(), data.getA(), ctx.playerRotations()), false);
|
behavior.baritone.getLookBehavior().updateTarget(RotationUtils.calcRotationFromVec3d(ctx.playerHead(), data.getFirst(), ctx.playerRotations()), false);
|
||||||
behavior.baritone.getInputOverrideHandler().setInputForceState(Input.MOVE_FORWARD, true);
|
behavior.baritone.getInputOverrideHandler().setInputForceState(Input.MOVE_FORWARD, true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -556,17 +555,20 @@ public class PathExecutor implements IPathExecutor, Helper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (MovementHelper.avoidWalkingInto(ctx.world().getBlockState(current.getSrc().up(3)))) {
|
if (MovementHelper.avoidWalkingInto(ctx.world().getBlockState(current.getSrc().up(3)).getBlock())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return !MovementHelper.avoidWalkingInto(ctx.world().getBlockState(next.getDest().up(2))); // codacy smh my head
|
return !MovementHelper.avoidWalkingInto(ctx.world().getBlockState(next.getDest().up(2)).getBlock()); // codacy smh my head
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean canSprintFromDescendInto(IPlayerContext ctx, IMovement current, IMovement next) {
|
private static boolean canSprintFromDescendInto(IPlayerContext ctx, IMovement current, IMovement next) {
|
||||||
if (next instanceof MovementDescend && next.getDirection().equals(current.getDirection())) {
|
if (next instanceof MovementDescend && next.getDirection().equals(current.getDirection())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (next instanceof MovementTraverse && next.getDirection().down().equals(current.getDirection()) && MovementHelper.canWalkOn(ctx, next.getDest().down())) {
|
if (!MovementHelper.canWalkOn(ctx, current.getDest().add(current.getDirection()))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (next instanceof MovementTraverse && next.getDirection().down().equals(current.getDirection())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return next instanceof MovementDiagonal && Baritone.settings().allowOvershootDiagonalDescend.value;
|
return next instanceof MovementDiagonal && Baritone.settings().allowOvershootDiagonalDescend.value;
|
||||||
|
|||||||
@@ -0,0 +1,141 @@
|
|||||||
|
/*
|
||||||
|
* 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.process;
|
||||||
|
|
||||||
|
import baritone.Baritone;
|
||||||
|
import baritone.api.process.PathingCommand;
|
||||||
|
import baritone.api.process.PathingCommandType;
|
||||||
|
import baritone.api.utils.input.Input;
|
||||||
|
import baritone.pathing.movement.Movement;
|
||||||
|
import baritone.pathing.movement.MovementHelper;
|
||||||
|
import baritone.pathing.movement.MovementState;
|
||||||
|
import baritone.pathing.path.PathExecutor;
|
||||||
|
import baritone.utils.BaritoneProcessHelper;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.init.Blocks;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.chunk.EmptyChunk;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class BackfillProcess extends BaritoneProcessHelper {
|
||||||
|
|
||||||
|
public HashMap<BlockPos, IBlockState> blocksToReplace = new HashMap<>();
|
||||||
|
|
||||||
|
public BackfillProcess(Baritone baritone) {
|
||||||
|
super(baritone);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isActive() {
|
||||||
|
if (ctx.player() == null || ctx.world() == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!Baritone.settings().backfill.value) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (Baritone.settings().allowParkour.value) {
|
||||||
|
logDirect("Backfill cannot be used with allowParkour true");
|
||||||
|
Baritone.settings().backfill.value = false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
amIBreakingABlockHMMMMMMM();
|
||||||
|
for (BlockPos pos : new ArrayList<>(blocksToReplace.keySet())) {
|
||||||
|
if (ctx.world().getChunk(pos) instanceof EmptyChunk) {
|
||||||
|
blocksToReplace.remove(pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
baritone.getInputOverrideHandler().clearAllKeys();
|
||||||
|
|
||||||
|
return !toFillIn().isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PathingCommand onTick(boolean calcFailed, boolean isSafeToCancel) {
|
||||||
|
if (!isSafeToCancel) {
|
||||||
|
return new PathingCommand(null, PathingCommandType.REQUEST_PAUSE);
|
||||||
|
}
|
||||||
|
baritone.getInputOverrideHandler().clearAllKeys();
|
||||||
|
for (BlockPos toPlace : toFillIn()) {
|
||||||
|
MovementState fake = new MovementState();
|
||||||
|
switch (MovementHelper.attemptToPlaceABlock(fake, baritone, toPlace, false)) {
|
||||||
|
case NO_OPTION:
|
||||||
|
continue;
|
||||||
|
case READY_TO_PLACE:
|
||||||
|
baritone.getInputOverrideHandler().setInputForceState(Input.CLICK_RIGHT, true);
|
||||||
|
return new PathingCommand(null, PathingCommandType.REQUEST_PAUSE);
|
||||||
|
case ATTEMPTING:
|
||||||
|
// patience
|
||||||
|
baritone.getLookBehavior().updateTarget(fake.getTarget().getRotation().get(), true);
|
||||||
|
return new PathingCommand(null, PathingCommandType.REQUEST_PAUSE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new PathingCommand(null, PathingCommandType.DEFER); // cede to other process
|
||||||
|
}
|
||||||
|
|
||||||
|
public void amIBreakingABlockHMMMMMMM() {
|
||||||
|
if (!ctx.getSelectedBlock().isPresent()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
blocksToReplace.put(ctx.getSelectedBlock().get(), ctx.world().getBlockState(ctx.getSelectedBlock().get()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<BlockPos> toFillIn() {
|
||||||
|
return blocksToReplace
|
||||||
|
.keySet()
|
||||||
|
.stream()
|
||||||
|
.filter(pos -> ctx.world().getBlockState(pos).getBlock() == Blocks.AIR)
|
||||||
|
.filter(pos -> ctx.world().mayPlace(Blocks.DIRT, pos, false, EnumFacing.UP, null))
|
||||||
|
.filter(pos -> !partOfCurrentMovement(pos))
|
||||||
|
.sorted(Comparator.<BlockPos>comparingDouble(ctx.player()::getDistanceSq).reversed())
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean partOfCurrentMovement(BlockPos pos) {
|
||||||
|
PathExecutor exec = baritone.getPathingBehavior().getCurrent();
|
||||||
|
if (exec == null || exec.finished() || exec.failed()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Movement movement = (Movement) exec.getPath().movements().get(exec.getPosition());
|
||||||
|
return Arrays.asList(movement.toBreakAll()).contains(pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLostControl() {
|
||||||
|
if (blocksToReplace != null && !blocksToReplace.isEmpty()) {
|
||||||
|
blocksToReplace.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String displayName0() {
|
||||||
|
return "Backfill";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isTemporary() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double priority() {
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -35,20 +35,15 @@ import baritone.utils.BlockStateInterface;
|
|||||||
import baritone.utils.PathingCommandContext;
|
import baritone.utils.PathingCommandContext;
|
||||||
import baritone.utils.schematic.AirSchematic;
|
import baritone.utils.schematic.AirSchematic;
|
||||||
import baritone.utils.schematic.Schematic;
|
import baritone.utils.schematic.Schematic;
|
||||||
import net.minecraft.block.BlockAir;
|
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.item.BlockItemUseContext;
|
|
||||||
import net.minecraft.item.ItemBlock;
|
import net.minecraft.item.ItemBlock;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.ItemUseContext;
|
|
||||||
import net.minecraft.nbt.CompressedStreamTools;
|
import net.minecraft.nbt.CompressedStreamTools;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.Tuple;
|
import net.minecraft.util.Tuple;
|
||||||
import net.minecraft.util.math.*;
|
import net.minecraft.util.math.*;
|
||||||
import net.minecraft.util.math.shapes.VoxelShape;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
@@ -73,12 +68,6 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro
|
|||||||
super(baritone);
|
super(baritone);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean build(String schematicFile, BlockPos origin) {
|
|
||||||
File file = new File(new File(Minecraft.getInstance().gameDir, "schematics"), schematicFile);
|
|
||||||
System.out.println(file + " " + file.exists());
|
|
||||||
return build(schematicFile, file, origin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void build(String name, ISchematic schematic, Vec3i origin) {
|
public void build(String name, ISchematic schematic, Vec3i origin) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
@@ -93,6 +82,10 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro
|
|||||||
paused = false;
|
paused = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void pause() {
|
||||||
|
paused = true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean build(String name, File schematic, Vec3i origin) {
|
public boolean build(String name, File schematic, Vec3i origin) {
|
||||||
NBTTagCompound tag;
|
NBTTagCompound tag;
|
||||||
@@ -134,7 +127,7 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
IBlockState state = schematic.desiredState(x - origin.getX(), y - origin.getY(), z - origin.getZ());
|
IBlockState state = schematic.desiredState(x - origin.getX(), y - origin.getY(), z - origin.getZ());
|
||||||
if (state.getBlock() instanceof BlockAir) {
|
if (state.getBlock() == Blocks.AIR) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return state;
|
return state;
|
||||||
@@ -154,7 +147,7 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro
|
|||||||
continue; // irrelevant
|
continue; // irrelevant
|
||||||
}
|
}
|
||||||
IBlockState curr = bcc.bsi.get0(x, y, z);
|
IBlockState curr = bcc.bsi.get0(x, y, z);
|
||||||
if (!(curr.getBlock() instanceof BlockAir) && !valid(curr, desired)) {
|
if (curr.getBlock() != Blocks.AIR && !valid(curr, desired)) {
|
||||||
BetterBlockPos pos = new BetterBlockPos(x, y, z);
|
BetterBlockPos pos = new BetterBlockPos(x, y, z);
|
||||||
Optional<Rotation> rot = RotationUtils.reachable(ctx.player(), pos, ctx.playerController().getBlockReachDistance());
|
Optional<Rotation> rot = RotationUtils.reachable(ctx.player(), pos, ctx.playerController().getBlockReachDistance());
|
||||||
if (rot.isPresent()) {
|
if (rot.isPresent()) {
|
||||||
@@ -195,7 +188,7 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro
|
|||||||
}
|
}
|
||||||
IBlockState curr = bcc.bsi.get0(x, y, z);
|
IBlockState curr = bcc.bsi.get0(x, y, z);
|
||||||
if (MovementHelper.isReplacable(x, y, z, curr, bcc.bsi) && !valid(curr, desired)) {
|
if (MovementHelper.isReplacable(x, y, z, curr, bcc.bsi) && !valid(curr, desired)) {
|
||||||
if (dy == 1 && bcc.bsi.get0(x, y + 1, z).getBlock() instanceof BlockAir) {
|
if (dy == 1 && bcc.bsi.get0(x, y + 1, z).getBlock() == Blocks.AIR) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
desirableOnHotbar.add(desired);
|
desirableOnHotbar.add(desired);
|
||||||
@@ -210,11 +203,6 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro
|
|||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean placementPlausible(BlockPos pos, IBlockState state) {
|
|
||||||
VoxelShape voxelshape = state.getCollisionShape(ctx.world(), pos);
|
|
||||||
return voxelshape.isEmpty() || ctx.world().checkNoEntityCollision(null, voxelshape.withOffset(pos.getX(), pos.getY(), pos.getZ()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public Optional<Placement> possibleToPlace(IBlockState toPlace, int x, int y, int z, BlockStateInterface bsi) {
|
public Optional<Placement> possibleToPlace(IBlockState toPlace, int x, int y, int z, BlockStateInterface bsi) {
|
||||||
for (EnumFacing against : EnumFacing.values()) {
|
for (EnumFacing against : EnumFacing.values()) {
|
||||||
BetterBlockPos placeAgainstPos = new BetterBlockPos(x, y, z).offset(against);
|
BetterBlockPos placeAgainstPos = new BetterBlockPos(x, y, z).offset(against);
|
||||||
@@ -222,20 +210,17 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro
|
|||||||
if (MovementHelper.isReplacable(placeAgainstPos.x, placeAgainstPos.y, placeAgainstPos.z, placeAgainstState, bsi)) {
|
if (MovementHelper.isReplacable(placeAgainstPos.x, placeAgainstPos.y, placeAgainstPos.z, placeAgainstState, bsi)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!toPlace.isValidPosition(ctx.world(), new BetterBlockPos(x, y, z))) {
|
if (!ctx.world().mayPlace(toPlace.getBlock(), new BetterBlockPos(x, y, z), false, against, null)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!placementPlausible(new BetterBlockPos(x, y, z), toPlace)) {
|
AxisAlignedBB aabb = placeAgainstState.getBoundingBox(ctx.world(), placeAgainstPos);
|
||||||
continue;
|
|
||||||
}
|
|
||||||
AxisAlignedBB aabb = placeAgainstState.getShape(ctx.world(), placeAgainstPos).getBoundingBox();
|
|
||||||
for (Vec3d placementMultiplier : aabbSideMultipliers(against)) {
|
for (Vec3d placementMultiplier : aabbSideMultipliers(against)) {
|
||||||
double placeX = placeAgainstPos.x + aabb.minX * placementMultiplier.x + aabb.maxX * (1 - placementMultiplier.x);
|
double placeX = placeAgainstPos.x + aabb.minX * placementMultiplier.x + aabb.maxX * (1 - placementMultiplier.x);
|
||||||
double placeY = placeAgainstPos.y + aabb.minY * placementMultiplier.y + aabb.maxY * (1 - placementMultiplier.y);
|
double placeY = placeAgainstPos.y + aabb.minY * placementMultiplier.y + aabb.maxY * (1 - placementMultiplier.y);
|
||||||
double placeZ = placeAgainstPos.z + aabb.minZ * placementMultiplier.z + aabb.maxZ * (1 - placementMultiplier.z);
|
double placeZ = placeAgainstPos.z + aabb.minZ * placementMultiplier.z + aabb.maxZ * (1 - placementMultiplier.z);
|
||||||
Rotation rot = RotationUtils.calcRotationFromVec3d(ctx.playerHead(), new Vec3d(placeX, placeY, placeZ), ctx.playerRotations());
|
Rotation rot = RotationUtils.calcRotationFromVec3d(ctx.playerHead(), new Vec3d(placeX, placeY, placeZ), ctx.playerRotations());
|
||||||
RayTraceResult result = RayTraceUtils.rayTraceTowards(ctx.player(), rot, ctx.playerController().getBlockReachDistance());
|
RayTraceResult result = RayTraceUtils.rayTraceTowards(ctx.player(), rot, ctx.playerController().getBlockReachDistance());
|
||||||
if (result != null && result.type == RayTraceResult.Type.BLOCK && result.getBlockPos().equals(placeAgainstPos) && result.sideHit == against.getOpposite()) {
|
if (result != null && result.typeOfHit == RayTraceResult.Type.BLOCK && result.getBlockPos().equals(placeAgainstPos) && result.sideHit == against.getOpposite()) {
|
||||||
OptionalInt hotbar = hasAnyItemThatWouldPlace(toPlace, result, rot);
|
OptionalInt hotbar = hasAnyItemThatWouldPlace(toPlace, result, rot);
|
||||||
if (hotbar.isPresent()) {
|
if (hotbar.isPresent()) {
|
||||||
return Optional.of(new Placement(hotbar.getAsInt(), placeAgainstPos, against.getOpposite(), rot));
|
return Optional.of(new Placement(hotbar.getAsInt(), placeAgainstPos, against.getOpposite(), rot));
|
||||||
@@ -258,24 +243,18 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro
|
|||||||
// the state depends on the facing of the player sometimes
|
// the state depends on the facing of the player sometimes
|
||||||
ctx.player().rotationYaw = rot.getYaw();
|
ctx.player().rotationYaw = rot.getYaw();
|
||||||
ctx.player().rotationPitch = rot.getPitch();
|
ctx.player().rotationPitch = rot.getPitch();
|
||||||
BlockItemUseContext meme = new BlockItemUseContext(new ItemUseContext(
|
IBlockState wouldBePlaced = ((ItemBlock) stack.getItem()).getBlock().getStateForPlacement(
|
||||||
ctx.player(),
|
ctx.world(),
|
||||||
stack,
|
|
||||||
result.getBlockPos().offset(result.sideHit),
|
result.getBlockPos().offset(result.sideHit),
|
||||||
result.sideHit,
|
result.sideHit,
|
||||||
(float) result.hitVec.x - result.getBlockPos().getX(),
|
(float) result.hitVec.x - result.getBlockPos().getX(), // as in PlayerControllerMP
|
||||||
(float) result.hitVec.y - result.getBlockPos().getY(),
|
(float) result.hitVec.y - result.getBlockPos().getY(),
|
||||||
(float) result.hitVec.z - result.getBlockPos().getZ()
|
(float) result.hitVec.z - result.getBlockPos().getZ(),
|
||||||
));
|
stack.getItem().getMetadata(stack.getMetadata()),
|
||||||
IBlockState wouldBePlaced = ((ItemBlock) stack.getItem()).getBlock().getStateForPlacement(meme);
|
ctx.player()
|
||||||
|
);
|
||||||
ctx.player().rotationYaw = originalYaw;
|
ctx.player().rotationYaw = originalYaw;
|
||||||
ctx.player().rotationPitch = originalPitch;
|
ctx.player().rotationPitch = originalPitch;
|
||||||
if (wouldBePlaced == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (!meme.canPlace()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (valid(wouldBePlaced, desired)) {
|
if (valid(wouldBePlaced, desired)) {
|
||||||
return OptionalInt.of(i);
|
return OptionalInt.of(i);
|
||||||
}
|
}
|
||||||
@@ -310,7 +289,7 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro
|
|||||||
}
|
}
|
||||||
baritone.getInputOverrideHandler().clearAllKeys();
|
baritone.getInputOverrideHandler().clearAllKeys();
|
||||||
if (paused) {
|
if (paused) {
|
||||||
return new PathingCommand(null, PathingCommandType.REQUEST_PAUSE);
|
return new PathingCommand(null, PathingCommandType.CANCEL_AND_SET_GOAL);
|
||||||
}
|
}
|
||||||
if (Baritone.settings().buildInLayers.value) {
|
if (Baritone.settings().buildInLayers.value) {
|
||||||
if (realSchematic == null) {
|
if (realSchematic == null) {
|
||||||
@@ -366,8 +345,8 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro
|
|||||||
if (toBreak.isPresent() && isSafeToCancel && ctx.player().onGround) {
|
if (toBreak.isPresent() && isSafeToCancel && ctx.player().onGround) {
|
||||||
// we'd like to pause to break this block
|
// we'd like to pause to break this block
|
||||||
// only change look direction if it's safe (don't want to fuck up an in progress parkour for example
|
// only change look direction if it's safe (don't want to fuck up an in progress parkour for example
|
||||||
Rotation rot = toBreak.get().getB();
|
Rotation rot = toBreak.get().getSecond();
|
||||||
BetterBlockPos pos = toBreak.get().getA();
|
BetterBlockPos pos = toBreak.get().getFirst();
|
||||||
baritone.getLookBehavior().updateTarget(rot, true);
|
baritone.getLookBehavior().updateTarget(rot, true);
|
||||||
MovementHelper.switchToBestToolFor(ctx, bcc.get(pos));
|
MovementHelper.switchToBestToolFor(ctx, bcc.get(pos));
|
||||||
if (ctx.player().isSneaking()) {
|
if (ctx.player().isSneaking()) {
|
||||||
@@ -376,10 +355,10 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro
|
|||||||
// and is unable since it's unsneaked in the intermediary tick
|
// and is unable since it's unsneaked in the intermediary tick
|
||||||
baritone.getInputOverrideHandler().setInputForceState(Input.SNEAK, true);
|
baritone.getInputOverrideHandler().setInputForceState(Input.SNEAK, true);
|
||||||
}
|
}
|
||||||
if (Objects.equals(ctx.objectMouseOver().getBlockPos(), pos) || ctx.playerRotations().isReallyCloseTo(rot)) {
|
if (ctx.isLookingAt(pos) || ctx.playerRotations().isReallyCloseTo(rot)) {
|
||||||
baritone.getInputOverrideHandler().setInputForceState(Input.CLICK_LEFT, true);
|
baritone.getInputOverrideHandler().setInputForceState(Input.CLICK_LEFT, true);
|
||||||
}
|
}
|
||||||
return new PathingCommand(null, PathingCommandType.REQUEST_PAUSE);
|
return new PathingCommand(null, PathingCommandType.CANCEL_AND_SET_GOAL);
|
||||||
}
|
}
|
||||||
List<IBlockState> desirableOnHotbar = new ArrayList<>();
|
List<IBlockState> desirableOnHotbar = new ArrayList<>();
|
||||||
Optional<Placement> toPlace = searchForPlacables(bcc, desirableOnHotbar);
|
Optional<Placement> toPlace = searchForPlacables(bcc, desirableOnHotbar);
|
||||||
@@ -388,10 +367,10 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro
|
|||||||
baritone.getLookBehavior().updateTarget(rot, true);
|
baritone.getLookBehavior().updateTarget(rot, true);
|
||||||
ctx.player().inventory.currentItem = toPlace.get().hotbarSelection;
|
ctx.player().inventory.currentItem = toPlace.get().hotbarSelection;
|
||||||
baritone.getInputOverrideHandler().setInputForceState(Input.SNEAK, true);
|
baritone.getInputOverrideHandler().setInputForceState(Input.SNEAK, true);
|
||||||
if ((Objects.equals(ctx.objectMouseOver().getBlockPos(), toPlace.get().placeAgainst) && ctx.objectMouseOver().sideHit.equals(toPlace.get().side)) || ctx.playerRotations().isReallyCloseTo(rot)) {
|
if ((ctx.isLookingAt(toPlace.get().placeAgainst) && ctx.objectMouseOver().sideHit.equals(toPlace.get().side)) || ctx.playerRotations().isReallyCloseTo(rot)) {
|
||||||
baritone.getInputOverrideHandler().setInputForceState(Input.CLICK_RIGHT, true);
|
baritone.getInputOverrideHandler().setInputForceState(Input.CLICK_RIGHT, true);
|
||||||
}
|
}
|
||||||
return new PathingCommand(null, PathingCommandType.REQUEST_PAUSE);
|
return new PathingCommand(null, PathingCommandType.CANCEL_AND_SET_GOAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<IBlockState> approxPlacable = placable(36);
|
List<IBlockState> approxPlacable = placable(36);
|
||||||
@@ -492,8 +471,8 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Goal assemble(BuilderCalculationContext bcc, List<IBlockState> approxPlacable) {
|
private Goal assemble(BuilderCalculationContext bcc, List<IBlockState> approxPlacable) {
|
||||||
List<BetterBlockPos> placable = incorrectPositions.stream().filter(pos -> bcc.bsi.get0(pos).getBlock() instanceof BlockAir && approxPlacable.contains(bcc.getSchematic(pos.x, pos.y, pos.z))).collect(Collectors.toList());
|
List<BetterBlockPos> placable = incorrectPositions.stream().filter(pos -> bcc.bsi.get0(pos).getBlock() == Blocks.AIR && approxPlacable.contains(bcc.getSchematic(pos.x, pos.y, pos.z))).collect(Collectors.toList());
|
||||||
Goal[] toBreak = incorrectPositions.stream().filter(pos -> !(bcc.bsi.get0(pos).getBlock() instanceof BlockAir)).map(GoalBreak::new).toArray(Goal[]::new);
|
Goal[] toBreak = incorrectPositions.stream().filter(pos -> bcc.bsi.get0(pos).getBlock() != Blocks.AIR).map(GoalBreak::new).toArray(Goal[]::new);
|
||||||
Goal[] toPlace = placable.stream().filter(pos -> !placable.contains(pos.down()) && !placable.contains(pos.down(2))).map(pos -> placementgoal(pos, bcc)).toArray(Goal[]::new);
|
Goal[] toPlace = placable.stream().filter(pos -> !placable.contains(pos.down()) && !placable.contains(pos.down(2))).map(pos -> placementgoal(pos, bcc)).toArray(Goal[]::new);
|
||||||
|
|
||||||
if (toPlace.length != 0) {
|
if (toPlace.length != 0) {
|
||||||
@@ -549,12 +528,12 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Goal placementgoal(BlockPos pos, BuilderCalculationContext bcc) {
|
public Goal placementgoal(BlockPos pos, BuilderCalculationContext bcc) {
|
||||||
if (!(ctx.world().getBlockState(pos).getBlock() instanceof BlockAir)) {
|
if (ctx.world().getBlockState(pos).getBlock() != Blocks.AIR) {
|
||||||
return new GoalPlace(pos);
|
return new GoalPlace(pos);
|
||||||
}
|
}
|
||||||
boolean allowSameLevel = !(ctx.world().getBlockState(pos.up()).getBlock() instanceof BlockAir);
|
boolean allowSameLevel = ctx.world().getBlockState(pos.up()).getBlock() != Blocks.AIR;
|
||||||
for (EnumFacing facing : Movement.HORIZONTALS_BUT_ALSO_DOWN____SO_EVERY_DIRECTION_EXCEPT_UP) {
|
for (EnumFacing facing : Movement.HORIZONTALS_BUT_ALSO_DOWN____SO_EVERY_DIRECTION_EXCEPT_UP) {
|
||||||
if (MovementHelper.canPlaceAgainst(ctx, pos.offset(facing)) && placementPlausible(pos, bcc.getSchematic(pos.getX(), pos.getY(), pos.getZ()))) {
|
if (MovementHelper.canPlaceAgainst(ctx, pos.offset(facing)) && ctx.world().mayPlace(bcc.getSchematic(pos.getX(), pos.getY(), pos.getZ()).getBlock(), pos, false, facing, null)) {
|
||||||
return new GoalAdjacent(pos, allowSameLevel);
|
return new GoalAdjacent(pos, allowSameLevel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -623,21 +602,15 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// <toxic cloud>
|
// <toxic cloud>
|
||||||
result.add(((ItemBlock) stack.getItem()).getBlock().getStateForPlacement(new BlockItemUseContext(new ItemUseContext(ctx.player(), stack, ctx.playerFeet(), EnumFacing.UP, (float) ctx.player().posX, (float) ctx.player().posY, (float) ctx.player().posZ))));
|
result.add(((ItemBlock) stack.getItem()).getBlock().getStateForPlacement(ctx.world(), ctx.playerFeet(), EnumFacing.UP, (float) ctx.player().posX, (float) ctx.player().posY, (float) ctx.player().posZ, stack.getItem().getMetadata(stack.getMetadata()), ctx.player()));
|
||||||
// </toxic cloud>
|
// </toxic cloud>
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean valid(IBlockState current, IBlockState desired) {
|
public boolean valid(IBlockState current, IBlockState desired) {
|
||||||
if (desired == null) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (current.getBlock() instanceof BlockAir && desired.getBlock() instanceof BlockAir) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
// TODO more complicated comparison logic I guess
|
// TODO more complicated comparison logic I guess
|
||||||
return current.equals(desired);
|
return desired == null || current.equals(desired);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class BuilderCalculationContext extends CalculationContext {
|
public class BuilderCalculationContext extends CalculationContext {
|
||||||
@@ -675,7 +648,7 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro
|
|||||||
IBlockState sch = getSchematic(x, y, z);
|
IBlockState sch = getSchematic(x, y, z);
|
||||||
if (sch != null) {
|
if (sch != null) {
|
||||||
// TODO this can return true even when allowPlace is off.... is that an issue?
|
// TODO this can return true even when allowPlace is off.... is that an issue?
|
||||||
if (sch.getBlock() instanceof BlockAir) {
|
if (sch.getBlock() == Blocks.AIR) {
|
||||||
// we want this to be air, but they're asking if they can place here
|
// we want this to be air, but they're asking if they can place here
|
||||||
// this won't be a schematic block, this will be a throwaway
|
// this won't be a schematic block, this will be a throwaway
|
||||||
return placeBlockCost * 2; // we're going to have to break it eventually
|
return placeBlockCost * 2; // we're going to have to break it eventually
|
||||||
@@ -708,7 +681,7 @@ public class BuilderProcess extends BaritoneProcessHelper implements IBuilderPro
|
|||||||
}
|
}
|
||||||
IBlockState sch = getSchematic(x, y, z);
|
IBlockState sch = getSchematic(x, y, z);
|
||||||
if (sch != null) {
|
if (sch != null) {
|
||||||
if (sch.getBlock() instanceof BlockAir) {
|
if (sch.getBlock() == Blocks.AIR) {
|
||||||
// it should be air
|
// it should be air
|
||||||
// regardless of current contents, we can break it
|
// regardless of current contents, we can break it
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
@@ -22,19 +22,30 @@ import baritone.api.cache.ICachedWorld;
|
|||||||
import baritone.api.pathing.goals.Goal;
|
import baritone.api.pathing.goals.Goal;
|
||||||
import baritone.api.pathing.goals.GoalComposite;
|
import baritone.api.pathing.goals.GoalComposite;
|
||||||
import baritone.api.pathing.goals.GoalXZ;
|
import baritone.api.pathing.goals.GoalXZ;
|
||||||
|
import baritone.api.process.IExploreProcess;
|
||||||
import baritone.api.process.PathingCommand;
|
import baritone.api.process.PathingCommand;
|
||||||
import baritone.api.process.PathingCommandType;
|
import baritone.api.process.PathingCommandType;
|
||||||
|
import baritone.api.utils.MyChunkPos;
|
||||||
import baritone.cache.CachedWorld;
|
import baritone.cache.CachedWorld;
|
||||||
import baritone.utils.BaritoneProcessHelper;
|
import baritone.utils.BaritoneProcessHelper;
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.GsonBuilder;
|
||||||
|
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.ChunkPos;
|
||||||
|
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ExploreProcess extends BaritoneProcessHelper {
|
public class ExploreProcess extends BaritoneProcessHelper implements IExploreProcess {
|
||||||
|
|
||||||
private BlockPos explorationOrigin;
|
private BlockPos explorationOrigin;
|
||||||
|
|
||||||
|
private IChunkFilter filter;
|
||||||
|
|
||||||
public ExploreProcess(Baritone baritone) {
|
public ExploreProcess(Baritone baritone) {
|
||||||
super(baritone);
|
super(baritone);
|
||||||
}
|
}
|
||||||
@@ -44,10 +55,26 @@ public class ExploreProcess extends BaritoneProcessHelper {
|
|||||||
return explorationOrigin != null;
|
return explorationOrigin != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void explore(int centerX, int centerZ) {
|
public void explore(int centerX, int centerZ) {
|
||||||
explorationOrigin = new BlockPos(centerX, 0, centerZ);
|
explorationOrigin = new BlockPos(centerX, 0, centerZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void applyJsonFilter(Path path, boolean invert) throws Exception {
|
||||||
|
filter = new JsonChunkFilter(path, invert);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IChunkFilter calcFilter() {
|
||||||
|
IChunkFilter filter;
|
||||||
|
if (this.filter != null) {
|
||||||
|
filter = new EitherChunk(this.filter, new BaritoneChunkCache());
|
||||||
|
} else {
|
||||||
|
filter = new BaritoneChunkCache();
|
||||||
|
}
|
||||||
|
return filter;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PathingCommand onTick(boolean calcFailed, boolean isSafeToCancel) {
|
public PathingCommand onTick(boolean calcFailed, boolean isSafeToCancel) {
|
||||||
if (calcFailed) {
|
if (calcFailed) {
|
||||||
@@ -55,19 +82,23 @@ public class ExploreProcess extends BaritoneProcessHelper {
|
|||||||
onLostControl();
|
onLostControl();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
Goal[] closestUncached = closestUncachedChunks(explorationOrigin);
|
IChunkFilter filter = calcFilter();
|
||||||
|
if (!Baritone.settings().disableCompletionCheck.value && filter.finished()) {
|
||||||
|
logDirect("Explored all chunks");
|
||||||
|
onLostControl();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
Goal[] closestUncached = closestUncachedChunks(explorationOrigin, filter);
|
||||||
if (closestUncached == null) {
|
if (closestUncached == null) {
|
||||||
logDebug("awaiting region load from disk");
|
logDebug("awaiting region load from disk");
|
||||||
return new PathingCommand(null, PathingCommandType.REQUEST_PAUSE);
|
return new PathingCommand(null, PathingCommandType.REQUEST_PAUSE);
|
||||||
}
|
}
|
||||||
System.out.println("Closest uncached: " + closestUncached);
|
|
||||||
return new PathingCommand(new GoalComposite(closestUncached), PathingCommandType.FORCE_REVALIDATE_GOAL_AND_PATH);
|
return new PathingCommand(new GoalComposite(closestUncached), PathingCommandType.FORCE_REVALIDATE_GOAL_AND_PATH);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Goal[] closestUncachedChunks(BlockPos center) {
|
private Goal[] closestUncachedChunks(BlockPos center, IChunkFilter filter) {
|
||||||
int chunkX = center.getX() >> 4;
|
int chunkX = center.getX() >> 4;
|
||||||
int chunkZ = center.getZ() >> 4;
|
int chunkZ = center.getZ() >> 4;
|
||||||
ICachedWorld cache = baritone.getWorldProvider().getCurrentWorld().getCachedWorld();
|
|
||||||
for (int dist = 0; ; dist++) {
|
for (int dist = 0; ; dist++) {
|
||||||
List<BlockPos> centers = new ArrayList<>();
|
List<BlockPos> centers = new ArrayList<>();
|
||||||
for (int dx = -dist; dx <= dist; dx++) {
|
for (int dx = -dist; dx <= dist; dx++) {
|
||||||
@@ -76,27 +107,143 @@ public class ExploreProcess extends BaritoneProcessHelper {
|
|||||||
if (trueDist != dist) {
|
if (trueDist != dist) {
|
||||||
continue; // not considering this one just yet in our expanding search
|
continue; // not considering this one just yet in our expanding search
|
||||||
}
|
}
|
||||||
|
switch (filter.isAlreadyExplored(chunkX + dx, chunkZ + dz)) {
|
||||||
|
case UNKNOWN:
|
||||||
|
return null; // awaiting load
|
||||||
|
case NOT_EXPLORED:
|
||||||
|
break; // note: this breaks the switch not the for
|
||||||
|
case EXPLORED:
|
||||||
|
continue; // note: this continues the for
|
||||||
|
}
|
||||||
int centerX = (chunkX + dx) * 16 + 8;
|
int centerX = (chunkX + dx) * 16 + 8;
|
||||||
int centerZ = (chunkZ + dz) * 18 + 8;
|
int centerZ = (chunkZ + dz) * 18 + 8;
|
||||||
|
int offset = 16 * Baritone.settings().worldExploringChunkOffset.value;
|
||||||
if (cache.isCached(centerX, centerZ)) {
|
if (dx < 0) {
|
||||||
continue;
|
centerX -= offset;
|
||||||
|
} else {
|
||||||
|
centerX += offset;
|
||||||
}
|
}
|
||||||
if (!((CachedWorld) cache).regionLoaded(centerX, centerZ)) {
|
if (dz < 0) {
|
||||||
Baritone.getExecutor().execute(() -> {
|
centerZ -= offset;
|
||||||
((CachedWorld) cache).tryLoadFromDisk(centerX >> 9, centerZ >> 9);
|
} else {
|
||||||
});
|
centerZ += offset;
|
||||||
return null; // we still need to load regions from disk in order to decide properly
|
|
||||||
}
|
}
|
||||||
centers.add(new BlockPos(centerX, 0, centerZ));
|
centers.add(new BlockPos(centerX, 0, centerZ));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!centers.isEmpty()) {
|
if (centers.size() > Baritone.settings().exploreChunkSetMinimumSize.value) {
|
||||||
return centers.stream().map(pos -> new GoalXZ(pos.getX(), pos.getZ())).toArray(Goal[]::new);
|
return centers.stream().map(pos -> new GoalXZ(pos.getX(), pos.getZ())).toArray(Goal[]::new);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private enum Status {
|
||||||
|
EXPLORED, NOT_EXPLORED, UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
private interface IChunkFilter {
|
||||||
|
Status isAlreadyExplored(int chunkX, int chunkZ);
|
||||||
|
|
||||||
|
boolean finished();
|
||||||
|
}
|
||||||
|
|
||||||
|
private class BaritoneChunkCache implements IChunkFilter {
|
||||||
|
|
||||||
|
private final ICachedWorld cache = baritone.getWorldProvider().getCurrentWorld().getCachedWorld();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Status isAlreadyExplored(int chunkX, int chunkZ) {
|
||||||
|
int centerX = chunkX << 4;
|
||||||
|
int centerZ = chunkZ << 4;
|
||||||
|
if (cache.isCached(centerX, centerZ)) {
|
||||||
|
return Status.EXPLORED;
|
||||||
|
}
|
||||||
|
if (!((CachedWorld) cache).regionLoaded(centerX, centerZ)) {
|
||||||
|
Baritone.getExecutor().execute(() -> {
|
||||||
|
((CachedWorld) cache).tryLoadFromDisk(centerX >> 9, centerZ >> 9);
|
||||||
|
});
|
||||||
|
return Status.UNKNOWN; // we still need to load regions from disk in order to decide properly
|
||||||
|
}
|
||||||
|
return Status.NOT_EXPLORED;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean finished() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class JsonChunkFilter implements IChunkFilter {
|
||||||
|
private final boolean invert; // if true, the list is interpreted as a list of chunks that are NOT explored, if false, the list is interpreted as a list of chunks that ARE explored
|
||||||
|
private final LongOpenHashSet inFilter;
|
||||||
|
private final MyChunkPos[] positions;
|
||||||
|
|
||||||
|
private JsonChunkFilter(Path path, boolean invert) throws Exception { // ioexception, json exception, etc
|
||||||
|
this.invert = invert;
|
||||||
|
Gson gson = new GsonBuilder().create();
|
||||||
|
positions = gson.fromJson(new InputStreamReader(Files.newInputStream(path)), MyChunkPos[].class);
|
||||||
|
logDirect("Loaded " + positions.length + " positions");
|
||||||
|
inFilter = new LongOpenHashSet();
|
||||||
|
for (MyChunkPos mcp : positions) {
|
||||||
|
inFilter.add(ChunkPos.asLong(mcp.x, mcp.z));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Status isAlreadyExplored(int chunkX, int chunkZ) {
|
||||||
|
if (inFilter.contains(ChunkPos.asLong(chunkX, chunkZ)) ^ invert) {
|
||||||
|
// either it's on the list of explored chunks, or it's not on the list of unexplored chunks
|
||||||
|
// either way, we have it
|
||||||
|
return Status.EXPLORED;
|
||||||
|
} else {
|
||||||
|
// either it's not on the list of explored chunks, or it's on the list of unexplored chunks
|
||||||
|
// either way, it depends on if baritone has cached it so defer to that
|
||||||
|
return Status.UNKNOWN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean finished() {
|
||||||
|
if (!invert) {
|
||||||
|
// if invert is false, anything not on the list is uncached
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// but if invert is true, anything not on the list IS assumed cached
|
||||||
|
// so we are done if everything on our list is cached!
|
||||||
|
BaritoneChunkCache bcc = new BaritoneChunkCache();
|
||||||
|
for (MyChunkPos pos : positions) {
|
||||||
|
if (bcc.isAlreadyExplored(pos.x, pos.z) != Status.EXPLORED) {
|
||||||
|
// either waiting for it or dont have it at all
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true; // we have everything cached
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class EitherChunk implements IChunkFilter {
|
||||||
|
private final IChunkFilter a;
|
||||||
|
private final IChunkFilter b;
|
||||||
|
|
||||||
|
private EitherChunk(IChunkFilter a, IChunkFilter b) {
|
||||||
|
this.a = a;
|
||||||
|
this.b = b;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Status isAlreadyExplored(int chunkX, int chunkZ) {
|
||||||
|
if (a.isAlreadyExplored(chunkX, chunkZ) == Status.EXPLORED) {
|
||||||
|
return Status.EXPLORED;
|
||||||
|
}
|
||||||
|
return b.isAlreadyExplored(chunkX, chunkZ);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean finished() {
|
||||||
|
return a.finished() || b.finished();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLostControl() {
|
public void onLostControl() {
|
||||||
explorationOrigin = null;
|
explorationOrigin = null;
|
||||||
@@ -104,6 +251,6 @@ public class ExploreProcess extends BaritoneProcessHelper {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String displayName0() {
|
public String displayName0() {
|
||||||
return "Exploring around " + explorationOrigin + ", currently going to " + new GoalComposite(closestUncachedChunks(explorationOrigin));
|
return "Exploring around " + explorationOrigin + ", currently going to " + new GoalComposite(closestUncachedChunks(explorationOrigin, calcFilter()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,283 @@
|
|||||||
|
/*
|
||||||
|
* 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.process;
|
||||||
|
|
||||||
|
import baritone.Baritone;
|
||||||
|
import baritone.api.pathing.goals.Goal;
|
||||||
|
import baritone.api.pathing.goals.GoalBlock;
|
||||||
|
import baritone.api.pathing.goals.GoalComposite;
|
||||||
|
import baritone.api.process.IFarmProcess;
|
||||||
|
import baritone.api.process.PathingCommand;
|
||||||
|
import baritone.api.process.PathingCommandType;
|
||||||
|
import baritone.api.utils.Rotation;
|
||||||
|
import baritone.api.utils.RotationUtils;
|
||||||
|
import baritone.api.utils.input.Input;
|
||||||
|
import baritone.cache.WorldScanner;
|
||||||
|
import baritone.pathing.movement.MovementHelper;
|
||||||
|
import baritone.utils.BaritoneProcessHelper;
|
||||||
|
import net.minecraft.block.*;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.item.EntityItem;
|
||||||
|
import net.minecraft.init.Blocks;
|
||||||
|
import net.minecraft.init.Items;
|
||||||
|
import net.minecraft.item.EnumDyeColor;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemDye;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.Vec3d;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
|
public class FarmProcess extends BaritoneProcessHelper implements IFarmProcess {
|
||||||
|
|
||||||
|
private boolean active;
|
||||||
|
|
||||||
|
private static final List<Item> FARMLAND_PLANTABLE = Arrays.asList(
|
||||||
|
Items.BEETROOT_SEEDS,
|
||||||
|
Items.MELON_SEEDS,
|
||||||
|
Items.WHEAT_SEEDS,
|
||||||
|
Items.PUMPKIN_SEEDS,
|
||||||
|
Items.POTATO,
|
||||||
|
Items.CARROT
|
||||||
|
);
|
||||||
|
|
||||||
|
private static final List<Item> PICKUP_DROPPED = Arrays.asList(
|
||||||
|
Items.BEETROOT_SEEDS,
|
||||||
|
Items.WHEAT,
|
||||||
|
Items.MELON_SEEDS,
|
||||||
|
Items.MELON,
|
||||||
|
Items.WHEAT_SEEDS,
|
||||||
|
Items.WHEAT,
|
||||||
|
Items.PUMPKIN_SEEDS,
|
||||||
|
Items.POTATO,
|
||||||
|
Items.CARROT,
|
||||||
|
Items.BEETROOT,
|
||||||
|
Item.getItemFromBlock(Blocks.PUMPKIN),
|
||||||
|
Item.getItemFromBlock(Blocks.MELON_BLOCK),
|
||||||
|
Items.NETHER_WART,
|
||||||
|
Items.REEDS,
|
||||||
|
Item.getItemFromBlock(Blocks.CACTUS)
|
||||||
|
);
|
||||||
|
|
||||||
|
public FarmProcess(Baritone baritone) {
|
||||||
|
super(baritone);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isActive() {
|
||||||
|
return active;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void farm() {
|
||||||
|
active = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private enum Harvest {
|
||||||
|
WHEAT((BlockCrops) Blocks.WHEAT),
|
||||||
|
CARROTS((BlockCrops) Blocks.CARROTS),
|
||||||
|
POTATOES((BlockCrops) Blocks.POTATOES),
|
||||||
|
BEETROOT((BlockCrops) Blocks.BEETROOTS),
|
||||||
|
PUMPKIN(Blocks.PUMPKIN, state -> true),
|
||||||
|
MELON(Blocks.MELON_BLOCK, state -> true),
|
||||||
|
NETHERWART(Blocks.NETHER_WART, state -> state.getValue(BlockNetherWart.AGE) >= 3),
|
||||||
|
SUGARCANE(Blocks.REEDS, null) {
|
||||||
|
@Override
|
||||||
|
public boolean readyToHarvest(World world, BlockPos pos, IBlockState state) {
|
||||||
|
return world.getBlockState(pos.down()).getBlock() instanceof BlockReed;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
CACTUS(Blocks.CACTUS, null) {
|
||||||
|
@Override
|
||||||
|
public boolean readyToHarvest(World world, BlockPos pos, IBlockState state) {
|
||||||
|
return world.getBlockState(pos.down()).getBlock() instanceof BlockCactus;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
public final Block block;
|
||||||
|
public final Predicate<IBlockState> readyToHarvest;
|
||||||
|
|
||||||
|
Harvest(BlockCrops blockCrops) {
|
||||||
|
this(blockCrops, blockCrops::isMaxAge);
|
||||||
|
// max age is 7 for wheat, carrots, and potatoes, but 3 for beetroot
|
||||||
|
}
|
||||||
|
|
||||||
|
Harvest(Block block, Predicate<IBlockState> readyToHarvest) {
|
||||||
|
this.block = block;
|
||||||
|
this.readyToHarvest = readyToHarvest;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean readyToHarvest(World world, BlockPos pos, IBlockState state) {
|
||||||
|
return readyToHarvest.test(state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean readyForHarvest(World world, BlockPos pos, IBlockState state) {
|
||||||
|
for (Harvest harvest : Harvest.values()) {
|
||||||
|
if (harvest.block == state.getBlock()) {
|
||||||
|
return harvest.readyToHarvest(world, pos, state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isPlantable(ItemStack stack) {
|
||||||
|
return FARMLAND_PLANTABLE.contains(stack.getItem());
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isBoneMeal(ItemStack stack) {
|
||||||
|
return !stack.isEmpty() && stack.getItem() instanceof ItemDye && EnumDyeColor.byDyeDamage(stack.getMetadata()) == EnumDyeColor.WHITE;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isNetherWart(ItemStack stack) {
|
||||||
|
return !stack.isEmpty() && stack.getItem().equals(Items.NETHER_WART);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PathingCommand onTick(boolean calcFailed, boolean isSafeToCancel) {
|
||||||
|
ArrayList<Block> scan = new ArrayList<>();
|
||||||
|
for (Harvest harvest : Harvest.values()) {
|
||||||
|
scan.add(harvest.block);
|
||||||
|
}
|
||||||
|
scan.add(Blocks.FARMLAND);
|
||||||
|
if (Baritone.settings().replantNetherWart.value) {
|
||||||
|
scan.add(Blocks.SOUL_SAND);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<BlockPos> locations = WorldScanner.INSTANCE.scanChunkRadius(ctx, scan, 256, 10, 4);
|
||||||
|
|
||||||
|
List<BlockPos> toBreak = new ArrayList<>();
|
||||||
|
List<BlockPos> openFarmland = new ArrayList<>();
|
||||||
|
List<BlockPos> bonemealable = new ArrayList<>();
|
||||||
|
List<BlockPos> openSoulsand = new ArrayList<>();
|
||||||
|
for (BlockPos pos : locations) {
|
||||||
|
IBlockState state = ctx.world().getBlockState(pos);
|
||||||
|
boolean airAbove = ctx.world().getBlockState(pos.up()).getBlock() instanceof BlockAir;
|
||||||
|
if (state.getBlock() == Blocks.FARMLAND) {
|
||||||
|
if (airAbove) {
|
||||||
|
openFarmland.add(pos);
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (state.getBlock() == Blocks.SOUL_SAND) {
|
||||||
|
if (airAbove) {
|
||||||
|
openSoulsand.add(pos);
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (readyForHarvest(ctx.world(), pos, state)) {
|
||||||
|
toBreak.add(pos);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (state.getBlock() instanceof IGrowable) {
|
||||||
|
IGrowable ig = (IGrowable) state.getBlock();
|
||||||
|
if (ig.canGrow(ctx.world(), pos, state, true) && ig.canUseBonemeal(ctx.world(), ctx.world().rand, pos, state)) {
|
||||||
|
bonemealable.add(pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
baritone.getInputOverrideHandler().clearAllKeys();
|
||||||
|
for (BlockPos pos : toBreak) {
|
||||||
|
Optional<Rotation> rot = RotationUtils.reachable(ctx, pos);
|
||||||
|
if (rot.isPresent() && isSafeToCancel) {
|
||||||
|
baritone.getLookBehavior().updateTarget(rot.get(), true);
|
||||||
|
MovementHelper.switchToBestToolFor(ctx, ctx.world().getBlockState(pos));
|
||||||
|
if (ctx.isLookingAt(pos)) {
|
||||||
|
baritone.getInputOverrideHandler().setInputForceState(Input.CLICK_LEFT, true);
|
||||||
|
}
|
||||||
|
return new PathingCommand(null, PathingCommandType.REQUEST_PAUSE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ArrayList<BlockPos> both = new ArrayList<>(openFarmland);
|
||||||
|
both.addAll(openSoulsand);
|
||||||
|
for (BlockPos pos : both) {
|
||||||
|
boolean soulsand = openSoulsand.contains(pos);
|
||||||
|
Optional<Rotation> rot = RotationUtils.reachableOffset(ctx.player(), pos, new Vec3d(pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5), ctx.playerController().getBlockReachDistance());
|
||||||
|
if (rot.isPresent() && isSafeToCancel && baritone.getInventoryBehavior().throwaway(true, soulsand ? this::isNetherWart : this::isPlantable)) {
|
||||||
|
baritone.getLookBehavior().updateTarget(rot.get(), true);
|
||||||
|
if (ctx.isLookingAt(pos)) {
|
||||||
|
baritone.getInputOverrideHandler().setInputForceState(Input.CLICK_RIGHT, true);
|
||||||
|
}
|
||||||
|
return new PathingCommand(null, PathingCommandType.REQUEST_PAUSE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (BlockPos pos : bonemealable) {
|
||||||
|
Optional<Rotation> rot = RotationUtils.reachable(ctx, pos);
|
||||||
|
if (rot.isPresent() && isSafeToCancel && baritone.getInventoryBehavior().throwaway(true, this::isBoneMeal)) {
|
||||||
|
baritone.getLookBehavior().updateTarget(rot.get(), true);
|
||||||
|
if (ctx.isLookingAt(pos)) {
|
||||||
|
baritone.getInputOverrideHandler().setInputForceState(Input.CLICK_RIGHT, true);
|
||||||
|
}
|
||||||
|
return new PathingCommand(null, PathingCommandType.REQUEST_PAUSE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (calcFailed) {
|
||||||
|
logDirect("Farm failed");
|
||||||
|
onLostControl();
|
||||||
|
return new PathingCommand(null, PathingCommandType.REQUEST_PAUSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Goal> goalz = new ArrayList<>();
|
||||||
|
for (BlockPos pos : toBreak) {
|
||||||
|
goalz.add(new BuilderProcess.GoalBreak(pos));
|
||||||
|
}
|
||||||
|
if (baritone.getInventoryBehavior().throwaway(false, this::isPlantable)) {
|
||||||
|
for (BlockPos pos : openFarmland) {
|
||||||
|
goalz.add(new GoalBlock(pos.up()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (baritone.getInventoryBehavior().throwaway(false, this::isNetherWart)) {
|
||||||
|
for (BlockPos pos : openSoulsand) {
|
||||||
|
goalz.add(new GoalBlock(pos.up()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (baritone.getInventoryBehavior().throwaway(false, this::isBoneMeal)) {
|
||||||
|
for (BlockPos pos : bonemealable) {
|
||||||
|
goalz.add(new GoalBlock(pos));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (Entity entity : ctx.world().loadedEntityList) {
|
||||||
|
if (entity instanceof EntityItem && entity.onGround) {
|
||||||
|
EntityItem ei = (EntityItem) entity;
|
||||||
|
if (PICKUP_DROPPED.contains(ei.getItem().getItem())) {
|
||||||
|
// +0.1 because of farmland's 0.9375 dummy height lol
|
||||||
|
goalz.add(new GoalBlock(new BlockPos(entity.posX, entity.posY + 0.1, entity.posZ)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new PathingCommand(new GoalComposite(goalz.toArray(new Goal[0])), PathingCommandType.SET_GOAL_AND_PATH);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLostControl() {
|
||||||
|
active = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String displayName0() {
|
||||||
|
return "Farming";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -72,7 +72,7 @@ public final class FollowProcess extends BaritoneProcessHelper implements IFollo
|
|||||||
if (entity == null) {
|
if (entity == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!entity.isAlive()) {
|
if (entity.isDead) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (entity.equals(ctx.player())) {
|
if (entity.equals(ctx.player())) {
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ public class GetToBlockProcess extends BaritoneProcessHelper implements IGetToBl
|
|||||||
}
|
}
|
||||||
|
|
||||||
// blacklist the closest block and its adjacent blocks
|
// blacklist the closest block and its adjacent blocks
|
||||||
public synchronized void blacklistClosest() {
|
public synchronized boolean blacklistClosest() {
|
||||||
List<BlockPos> newBlacklist = new ArrayList<>();
|
List<BlockPos> newBlacklist = new ArrayList<>();
|
||||||
knownLocations.stream().min(Comparator.comparingDouble(ctx.player()::getDistanceSq)).ifPresent(newBlacklist::add);
|
knownLocations.stream().min(Comparator.comparingDouble(ctx.player()::getDistanceSq)).ifPresent(newBlacklist::add);
|
||||||
outer:
|
outer:
|
||||||
@@ -140,6 +140,7 @@ public class GetToBlockProcess extends BaritoneProcessHelper implements IGetToBl
|
|||||||
}
|
}
|
||||||
logDebug("Blacklisting unreachable locations " + newBlacklist);
|
logDebug("Blacklisting unreachable locations " + newBlacklist);
|
||||||
blacklist.addAll(newBlacklist);
|
blacklist.addAll(newBlacklist);
|
||||||
|
return !newBlacklist.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
// safer than direct double comparison from distanceSq
|
// safer than direct double comparison from distanceSq
|
||||||
@@ -206,7 +207,7 @@ public class GetToBlockProcess extends BaritoneProcessHelper implements IGetToBl
|
|||||||
if (!Baritone.settings().enterPortal.value) {
|
if (!Baritone.settings().enterPortal.value) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return block == Blocks.NETHER_PORTAL;
|
return block == Blocks.PORTAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean rightClickOnArrival(Block block) {
|
private boolean rightClickOnArrival(Block block) {
|
||||||
|
|||||||
@@ -22,10 +22,12 @@ import baritone.api.pathing.goals.*;
|
|||||||
import baritone.api.process.IMineProcess;
|
import baritone.api.process.IMineProcess;
|
||||||
import baritone.api.process.PathingCommand;
|
import baritone.api.process.PathingCommand;
|
||||||
import baritone.api.process.PathingCommandType;
|
import baritone.api.process.PathingCommandType;
|
||||||
|
import baritone.api.utils.BlockUtils;
|
||||||
import baritone.api.utils.IPlayerContext;
|
import baritone.api.utils.IPlayerContext;
|
||||||
|
import baritone.api.utils.Rotation;
|
||||||
import baritone.api.utils.RotationUtils;
|
import baritone.api.utils.RotationUtils;
|
||||||
|
import baritone.api.utils.input.Input;
|
||||||
import baritone.cache.CachedChunk;
|
import baritone.cache.CachedChunk;
|
||||||
import baritone.cache.ChunkPacker;
|
|
||||||
import baritone.cache.WorldScanner;
|
import baritone.cache.WorldScanner;
|
||||||
import baritone.pathing.movement.CalculationContext;
|
import baritone.pathing.movement.CalculationContext;
|
||||||
import baritone.pathing.movement.MovementHelper;
|
import baritone.pathing.movement.MovementHelper;
|
||||||
@@ -33,6 +35,7 @@ import baritone.utils.BaritoneProcessHelper;
|
|||||||
import baritone.utils.BlockStateInterface;
|
import baritone.utils.BlockStateInterface;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockAir;
|
import net.minecraft.block.BlockAir;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.item.EntityItem;
|
import net.minecraft.entity.item.EntityItem;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
@@ -73,11 +76,11 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
|||||||
@Override
|
@Override
|
||||||
public PathingCommand onTick(boolean calcFailed, boolean isSafeToCancel) {
|
public PathingCommand onTick(boolean calcFailed, boolean isSafeToCancel) {
|
||||||
if (desiredQuantity > 0) {
|
if (desiredQuantity > 0) {
|
||||||
Item item = mining.get(0).getItemDropped(mining.get(0).getDefaultState(), ctx.world(), null, 0).asItem();
|
Item item = mining.get(0).getItemDropped(mining.get(0).getDefaultState(), new Random(), 0);
|
||||||
int curr = ctx.player().inventory.mainInventory.stream().filter(stack -> item.equals(stack.getItem())).mapToInt(ItemStack::getCount).sum();
|
int curr = ctx.player().inventory.mainInventory.stream().filter(stack -> item.equals(stack.getItem())).mapToInt(ItemStack::getCount).sum();
|
||||||
System.out.println("Currently have " + curr + " " + item);
|
System.out.println("Currently have " + curr + " " + item);
|
||||||
if (curr >= desiredQuantity) {
|
if (curr >= desiredQuantity) {
|
||||||
logDirect("Have " + curr + " " + item.getDisplayName(new ItemStack(item, 1)));
|
logDirect("Have " + curr + " " + item.getItemStackDisplayName(new ItemStack(item, 1)));
|
||||||
cancel();
|
cancel();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -95,14 +98,35 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
int mineGoalUpdateInterval = Baritone.settings().mineGoalUpdateInterval.value;
|
int mineGoalUpdateInterval = Baritone.settings().mineGoalUpdateInterval.value;
|
||||||
|
List<BlockPos> curr = new ArrayList<>(knownOreLocations);
|
||||||
if (mineGoalUpdateInterval != 0 && tickCount++ % mineGoalUpdateInterval == 0) { // big brain
|
if (mineGoalUpdateInterval != 0 && tickCount++ % mineGoalUpdateInterval == 0) { // big brain
|
||||||
List<BlockPos> curr = new ArrayList<>(knownOreLocations);
|
|
||||||
CalculationContext context = new CalculationContext(baritone, true);
|
CalculationContext context = new CalculationContext(baritone, true);
|
||||||
Baritone.getExecutor().execute(() -> rescan(curr, context));
|
Baritone.getExecutor().execute(() -> rescan(curr, context));
|
||||||
}
|
}
|
||||||
if (Baritone.settings().legitMine.value) {
|
if (Baritone.settings().legitMine.value) {
|
||||||
addNearby();
|
addNearby();
|
||||||
}
|
}
|
||||||
|
Optional<BlockPos> shaft = curr.stream()
|
||||||
|
.filter(pos -> pos.getX() == ctx.playerFeet().getX() && pos.getZ() == ctx.playerFeet().getZ())
|
||||||
|
.filter(pos -> pos.getY() > ctx.playerFeet().getY())
|
||||||
|
.filter(pos -> !(BlockStateInterface.get(ctx, pos).getBlock() instanceof BlockAir)) // after breaking a block, it takes mineGoalUpdateInterval ticks for it to actually update this list =(
|
||||||
|
.min(Comparator.comparingDouble(ctx.player()::getDistanceSq));
|
||||||
|
baritone.getInputOverrideHandler().clearAllKeys();
|
||||||
|
if (shaft.isPresent()) {
|
||||||
|
BlockPos pos = shaft.get();
|
||||||
|
IBlockState state = baritone.bsi.get0(pos);
|
||||||
|
if (!MovementHelper.avoidBreaking(baritone.bsi, pos.getX(), pos.getY(), pos.getZ(), state)) {
|
||||||
|
Optional<Rotation> rot = RotationUtils.reachable(ctx, pos);
|
||||||
|
if (rot.isPresent() && isSafeToCancel) {
|
||||||
|
baritone.getLookBehavior().updateTarget(rot.get(), true);
|
||||||
|
MovementHelper.switchToBestToolFor(ctx, ctx.world().getBlockState(pos));
|
||||||
|
if (ctx.isLookingAt(pos) || ctx.playerRotations().isReallyCloseTo(rot.get())) {
|
||||||
|
baritone.getInputOverrideHandler().setInputForceState(Input.CLICK_LEFT, true);
|
||||||
|
}
|
||||||
|
return new PathingCommand(null, PathingCommandType.REQUEST_PAUSE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
PathingCommand command = updateGoal();
|
PathingCommand command = updateGoal();
|
||||||
if (command == null) {
|
if (command == null) {
|
||||||
// none in range
|
// none in range
|
||||||
@@ -179,15 +203,63 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
|||||||
knownOreLocations = locs;
|
knownOreLocations = locs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean internalMiningGoal(BlockPos pos, IPlayerContext ctx, List<BlockPos> locs) {
|
||||||
|
// Here, BlockStateInterface is used because the position may be in a cached chunk (the targeted block is one that is kept track of)
|
||||||
|
return locs.contains(pos) || (Baritone.settings().internalMiningAirException.value && BlockStateInterface.getBlock(ctx, pos) instanceof BlockAir);
|
||||||
|
}
|
||||||
|
|
||||||
private static Goal coalesce(IPlayerContext ctx, BlockPos loc, List<BlockPos> locs) {
|
private static Goal coalesce(IPlayerContext ctx, BlockPos loc, List<BlockPos> locs) {
|
||||||
if (!Baritone.settings().forceInternalMining.value) {
|
if (!Baritone.settings().forceInternalMining.value) {
|
||||||
return new GoalTwoBlocks(loc);
|
return new GoalThreeBlocks(loc);
|
||||||
|
}
|
||||||
|
boolean upwardGoal = internalMiningGoal(loc.up(), ctx, locs);
|
||||||
|
boolean downwardGoal = internalMiningGoal(loc.down(), ctx, locs);
|
||||||
|
boolean doubleDownwardGoal = internalMiningGoal(loc.down(2), ctx, locs);
|
||||||
|
if (upwardGoal == downwardGoal) { // symmetric
|
||||||
|
if (doubleDownwardGoal) {
|
||||||
|
// we have a checkerboard like pattern
|
||||||
|
// this one, and the one two below it
|
||||||
|
// therefore it's fine to path to immediately below this one, since your feet will be in the doubleDownwardGoal
|
||||||
|
return new GoalThreeBlocks(loc);
|
||||||
|
} else {
|
||||||
|
// this block has nothing interesting two below, but is symmetric vertically so we can get either feet or head into it
|
||||||
|
return new GoalTwoBlocks(loc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (upwardGoal) {
|
||||||
|
// downwardGoal known to be false
|
||||||
|
// ignore the gap then potential doubleDownward, because we want to path feet into this one and head into upwardGoal
|
||||||
|
return new GoalBlock(loc);
|
||||||
|
}
|
||||||
|
// upwardGoal known to be false, downwardGoal known to be true
|
||||||
|
if (doubleDownwardGoal) {
|
||||||
|
// this block and two below it are goals
|
||||||
|
// path into the center of the one below, because that includes directly below this one
|
||||||
|
return new GoalTwoBlocks(loc.down());
|
||||||
|
}
|
||||||
|
// upwardGoal false, downwardGoal true, doubleDownwardGoal false
|
||||||
|
// just this block and the one immediately below, no others
|
||||||
|
return new GoalBlock(loc.down());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class GoalThreeBlocks extends GoalTwoBlocks {
|
||||||
|
|
||||||
|
public GoalThreeBlocks(BlockPos pos) {
|
||||||
|
super(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Here, BlockStateInterface is used because the position may be in a cached chunk (the targeted block is one that is kept track of)
|
@Override
|
||||||
boolean upwardGoal = locs.contains(loc.up()) || (Baritone.settings().internalMiningAirException.value && BlockStateInterface.getBlock(ctx, loc.up()) instanceof BlockAir);
|
public boolean isInGoal(int x, int y, int z) {
|
||||||
boolean downwardGoal = locs.contains(loc.down()) || (Baritone.settings().internalMiningAirException.value && BlockStateInterface.getBlock(ctx, loc.down()) instanceof BlockAir);
|
return x == this.x && (y == this.y || y == this.y - 1 || y == this.y - 2) && z == this.z;
|
||||||
return upwardGoal == downwardGoal ? new GoalTwoBlocks(loc) : upwardGoal ? new GoalBlock(loc) : new GoalBlock(loc.down());
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double heuristic(int x, int y, int z) {
|
||||||
|
int xDiff = x - this.x;
|
||||||
|
int yDiff = y - this.y;
|
||||||
|
int zDiff = z - this.z;
|
||||||
|
return GoalBlock.calculate(xDiff, yDiff < -1 ? yDiff + 2 : yDiff == -1 ? 0 : yDiff, zDiff);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<BlockPos> droppedItemsScan(List<Block> mining, World world) {
|
public static List<BlockPos> droppedItemsScan(List<Block> mining, World world) {
|
||||||
@@ -196,8 +268,8 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
|||||||
}
|
}
|
||||||
Set<Item> searchingFor = new HashSet<>();
|
Set<Item> searchingFor = new HashSet<>();
|
||||||
for (Block block : mining) {
|
for (Block block : mining) {
|
||||||
Item drop = block.getItemDropped(block.getDefaultState(), world, null, 0).asItem();
|
Item drop = block.getItemDropped(block.getDefaultState(), new Random(), 0);
|
||||||
Item ore = block.asItem();
|
Item ore = Item.getItemFromBlock(block);
|
||||||
searchingFor.add(drop);
|
searchingFor.add(drop);
|
||||||
searchingFor.add(ore);
|
searchingFor.add(ore);
|
||||||
}
|
}
|
||||||
@@ -216,24 +288,20 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
|||||||
public static List<BlockPos> searchWorld(CalculationContext ctx, List<Block> mining, int max, List<BlockPos> alreadyKnown, List<BlockPos> blacklist) {
|
public static List<BlockPos> searchWorld(CalculationContext ctx, List<Block> mining, int max, List<BlockPos> alreadyKnown, List<BlockPos> blacklist) {
|
||||||
List<BlockPos> locs = new ArrayList<>();
|
List<BlockPos> locs = new ArrayList<>();
|
||||||
List<Block> uninteresting = new ArrayList<>();
|
List<Block> uninteresting = new ArrayList<>();
|
||||||
//long b = System.currentTimeMillis();
|
|
||||||
for (Block m : mining) {
|
for (Block m : mining) {
|
||||||
if (CachedChunk.BLOCKS_TO_KEEP_TRACK_OF.contains(m)) {
|
if (CachedChunk.BLOCKS_TO_KEEP_TRACK_OF.contains(m)) {
|
||||||
// maxRegionDistanceSq 2 means adjacent directly or adjacent diagonally; nothing further than that
|
// maxRegionDistanceSq 2 means adjacent directly or adjacent diagonally; nothing further than that
|
||||||
locs.addAll(ctx.worldData.getCachedWorld().getLocationsOf(ChunkPacker.blockToString(m), Baritone.settings().maxCachedWorldScanCount.value, ctx.getBaritone().getPlayerContext().playerFeet().getX(), ctx.getBaritone().getPlayerContext().playerFeet().getZ(), 2));
|
locs.addAll(ctx.worldData.getCachedWorld().getLocationsOf(BlockUtils.blockToString(m), Baritone.settings().maxCachedWorldScanCount.value, ctx.getBaritone().getPlayerContext().playerFeet().getX(), ctx.getBaritone().getPlayerContext().playerFeet().getZ(), 2));
|
||||||
} else {
|
} else {
|
||||||
uninteresting.add(m);
|
uninteresting.add(m);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
locs = prune(ctx, locs, mining, max, blacklist);
|
locs = prune(ctx, locs, mining, max, blacklist);
|
||||||
//System.out.println("Scan of cached chunks took " + (System.currentTimeMillis() - b) + "ms");
|
if (locs.isEmpty() || (Baritone.settings().extendCacheOnThreshold.value && locs.size() < max)) {
|
||||||
if (locs.isEmpty()) {
|
|
||||||
uninteresting = mining;
|
uninteresting = mining;
|
||||||
}
|
}
|
||||||
if (!uninteresting.isEmpty()) {
|
if (!uninteresting.isEmpty()) {
|
||||||
//long before = System.currentTimeMillis();
|
|
||||||
locs.addAll(WorldScanner.INSTANCE.scanChunkRadius(ctx.getBaritone().getPlayerContext(), uninteresting, max, 10, 32)); // maxSearchRadius is NOT sq
|
locs.addAll(WorldScanner.INSTANCE.scanChunkRadius(ctx.getBaritone().getPlayerContext(), uninteresting, max, 10, 32)); // maxSearchRadius is NOT sq
|
||||||
//System.out.println("Scan of loaded chunks took " + (System.currentTimeMillis() - before) + "ms");
|
|
||||||
}
|
}
|
||||||
locs.addAll(alreadyKnown);
|
locs.addAll(alreadyKnown);
|
||||||
return prune(ctx, locs, mining, max, blacklist);
|
return prune(ctx, locs, mining, max, blacklist);
|
||||||
@@ -304,7 +372,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mineByName(int quantity, String... blocks) {
|
public void mineByName(int quantity, String... blocks) {
|
||||||
mine(quantity, blocks == null || blocks.length == 0 ? null : Arrays.stream(blocks).map(ChunkPacker::stringToBlockRequired).toArray(Block[]::new));
|
mine(quantity, blocks == null || blocks.length == 0 ? null : Arrays.stream(blocks).map(BlockUtils::stringToBlockRequired).toArray(Block[]::new));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -22,22 +22,16 @@ import baritone.api.event.events.TickEvent;
|
|||||||
import baritone.api.event.listener.AbstractGameEventListener;
|
import baritone.api.event.listener.AbstractGameEventListener;
|
||||||
import baritone.api.pathing.goals.Goal;
|
import baritone.api.pathing.goals.Goal;
|
||||||
import baritone.api.pathing.goals.GoalBlock;
|
import baritone.api.pathing.goals.GoalBlock;
|
||||||
|
import baritone.api.utils.Helper;
|
||||||
import baritone.api.utils.IPlayerContext;
|
import baritone.api.utils.IPlayerContext;
|
||||||
import net.minecraft.client.GameSettings;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.GuiMainMenu;
|
import net.minecraft.client.gui.GuiMainMenu;
|
||||||
|
import net.minecraft.client.settings.GameSettings;
|
||||||
import net.minecraft.client.tutorial.TutorialSteps;
|
import net.minecraft.client.tutorial.TutorialSteps;
|
||||||
import net.minecraft.server.integrated.IntegratedServer;
|
|
||||||
import net.minecraft.util.HttpUtil;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.GameType;
|
import net.minecraft.world.GameType;
|
||||||
import net.minecraft.world.WorldSettings;
|
import net.minecraft.world.WorldSettings;
|
||||||
import net.minecraft.world.WorldType;
|
import net.minecraft.world.WorldType;
|
||||||
import net.minecraft.world.dimension.DimensionType;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.nio.file.Files;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Responsible for automatically testing Baritone's pathing algorithm by automatically creating a world with a specific
|
* Responsible for automatically testing Baritone's pathing algorithm by automatically creating a world with a specific
|
||||||
@@ -95,13 +89,11 @@ public class BaritoneAutoTest implements AbstractGameEventListener, Helper {
|
|||||||
mc.launchIntegratedServer("BaritoneAutoTest", "BaritoneAutoTest", worldsettings);
|
mc.launchIntegratedServer("BaritoneAutoTest", "BaritoneAutoTest", worldsettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
IntegratedServer server = mc.getIntegratedServer();
|
|
||||||
|
|
||||||
// If the integrated server is launched and the world has initialized, set the spawn point
|
// If the integrated server is launched and the world has initialized, set the spawn point
|
||||||
// to our defined starting position
|
// to our defined starting position
|
||||||
if (server != null && server.getWorld(DimensionType.OVERWORLD) != null) {
|
if (mc.getIntegratedServer() != null && mc.getIntegratedServer().worlds[0] != null) {
|
||||||
server.getWorld(DimensionType.OVERWORLD).setSpawnPoint(STARTING_POSITION);
|
mc.getIntegratedServer().worlds[0].setSpawnPoint(STARTING_POSITION);
|
||||||
server.getWorld(DimensionType.OVERWORLD).getGameRules().setOrCreateGameRule("spawnRadius", "0", server);
|
mc.getIntegratedServer().worlds[0].getGameRules().setOrCreateGameRule("spawnRadius", "0");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.getType() == TickEvent.Type.IN) { // If we're in-game
|
if (event.getType() == TickEvent.Type.IN) { // If we're in-game
|
||||||
@@ -109,7 +101,7 @@ public class BaritoneAutoTest implements AbstractGameEventListener, Helper {
|
|||||||
// Force the integrated server to share the world to LAN so that
|
// Force the integrated server to share the world to LAN so that
|
||||||
// the ingame pause menu gui doesn't actually pause our game
|
// the ingame pause menu gui doesn't actually pause our game
|
||||||
if (mc.isSingleplayer() && !mc.getIntegratedServer().getPublic()) {
|
if (mc.isSingleplayer() && !mc.getIntegratedServer().getPublic()) {
|
||||||
mc.getIntegratedServer().shareToLAN(GameType.getByName("survival"), false, HttpUtil.getSuitableLanPort());
|
mc.getIntegratedServer().shareToLAN(GameType.getByName("survival"), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// For the first 200 ticks, wait for the world to generate
|
// For the first 200 ticks, wait for the world to generate
|
||||||
@@ -131,16 +123,7 @@ public class BaritoneAutoTest implements AbstractGameEventListener, Helper {
|
|||||||
// If we have reached our goal, print a message and safely close the game
|
// If we have reached our goal, print a message and safely close the game
|
||||||
if (GOAL.isInGoal(ctx.playerFeet())) {
|
if (GOAL.isInGoal(ctx.playerFeet())) {
|
||||||
System.out.println("Successfully pathed to " + ctx.playerFeet() + " in " + event.getCount() + " ticks");
|
System.out.println("Successfully pathed to " + ctx.playerFeet() + " in " + event.getCount() + " ticks");
|
||||||
try {
|
|
||||||
File file = new File("success");
|
|
||||||
System.out.println("Writing success to " + file.getAbsolutePath());
|
|
||||||
Files.write(file.getAbsoluteFile().toPath(), "Success!".getBytes());
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
mc.shutdown();
|
mc.shutdown();
|
||||||
mc.shutdownMinecraftApplet();
|
|
||||||
System.exit(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we have exceeded the expected number of ticks to complete the pathing
|
// If we have exceeded the expected number of ticks to complete the pathing
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ package baritone.utils;
|
|||||||
|
|
||||||
import baritone.Baritone;
|
import baritone.Baritone;
|
||||||
import baritone.api.process.IBaritoneProcess;
|
import baritone.api.process.IBaritoneProcess;
|
||||||
|
import baritone.api.utils.Helper;
|
||||||
import baritone.api.utils.IPlayerContext;
|
import baritone.api.utils.IPlayerContext;
|
||||||
|
|
||||||
public abstract class BaritoneProcessHelper implements IBaritoneProcess, Helper {
|
public abstract class BaritoneProcessHelper implements IBaritoneProcess, Helper {
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
package baritone.utils;
|
package baritone.utils;
|
||||||
|
|
||||||
|
import baritone.api.utils.Helper;
|
||||||
import baritone.api.utils.IPlayerContext;
|
import baritone.api.utils.IPlayerContext;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.EnumHand;
|
import net.minecraft.util.EnumHand;
|
||||||
@@ -53,7 +54,7 @@ public final class BlockBreakHelper implements Helper {
|
|||||||
|
|
||||||
public void tick(boolean isLeftClick) {
|
public void tick(boolean isLeftClick) {
|
||||||
RayTraceResult trace = playerContext.objectMouseOver();
|
RayTraceResult trace = playerContext.objectMouseOver();
|
||||||
boolean isBlockTrace = trace != null && trace.type == RayTraceResult.Type.BLOCK;
|
boolean isBlockTrace = trace != null && trace.typeOfHit == RayTraceResult.Type.BLOCK;
|
||||||
|
|
||||||
if (isLeftClick && isBlockTrace) {
|
if (isLeftClick && isBlockTrace) {
|
||||||
tryBreakBlock(trace.getBlockPos(), trace.sideHit);
|
tryBreakBlock(trace.getBlockPos(), trace.sideHit);
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
package baritone.utils;
|
package baritone.utils;
|
||||||
|
|
||||||
import baritone.Baritone;
|
import baritone.Baritone;
|
||||||
|
import baritone.api.utils.Helper;
|
||||||
import baritone.api.utils.IPlayerContext;
|
import baritone.api.utils.IPlayerContext;
|
||||||
import net.minecraft.util.EnumActionResult;
|
import net.minecraft.util.EnumActionResult;
|
||||||
import net.minecraft.util.EnumHand;
|
import net.minecraft.util.EnumHand;
|
||||||
@@ -37,7 +38,7 @@ public class BlockPlaceHelper implements Helper {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
RayTraceResult mouseOver = ctx.objectMouseOver();
|
RayTraceResult mouseOver = ctx.objectMouseOver();
|
||||||
if (!rightClickRequested || ctx.player().isRowingBoat() || mouseOver == null || mouseOver.getBlockPos() == null || mouseOver.type != RayTraceResult.Type.BLOCK) {
|
if (!rightClickRequested || ctx.player().isRowingBoat() || mouseOver == null || mouseOver.getBlockPos() == null || mouseOver.typeOfHit != RayTraceResult.Type.BLOCK) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
rightClickTimer = Baritone.settings().rightClickSpeed.value;
|
rightClickTimer = Baritone.settings().rightClickSpeed.value;
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ public class BlockStateInterface {
|
|||||||
this.loadedChunks = worldLoaded; // this will only be used on the main thread
|
this.loadedChunks = worldLoaded; // this will only be used on the main thread
|
||||||
}
|
}
|
||||||
this.useTheRealWorld = !Baritone.settings().pathThroughCachedOnly.value;
|
this.useTheRealWorld = !Baritone.settings().pathThroughCachedOnly.value;
|
||||||
if (!Minecraft.getInstance().isCallingFromMinecraftThread()) {
|
if (!Minecraft.getMinecraft().isCallingFromMinecraftThread()) {
|
||||||
throw new IllegalStateException();
|
throw new IllegalStateException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,9 +25,13 @@ import baritone.api.utils.BetterBlockPos;
|
|||||||
import net.minecraft.client.gui.GuiScreen;
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
import net.minecraft.client.renderer.GlStateManager;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.util.math.*;
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.RayTraceResult;
|
||||||
|
import net.minecraft.util.math.Vec3d;
|
||||||
import org.lwjgl.BufferUtils;
|
import org.lwjgl.BufferUtils;
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.input.Mouse;
|
||||||
|
import org.lwjgl.util.glu.GLU;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.nio.FloatBuffer;
|
import java.nio.FloatBuffer;
|
||||||
@@ -53,18 +57,15 @@ public class GuiClick extends GuiScreen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(int mouseX, int mouseY, float partialTicks) {
|
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||||
double mx = mc.mouseHelper.getMouseX();
|
int mx = Mouse.getX();
|
||||||
double my = mc.mouseHelper.getMouseY();
|
int my = Mouse.getY();
|
||||||
my = mc.mainWindow.getHeight() - my;
|
|
||||||
my *= mc.mainWindow.getFramebufferHeight() / (double) mc.mainWindow.getHeight();
|
|
||||||
mx *= mc.mainWindow.getFramebufferWidth() / (double) mc.mainWindow.getWidth();
|
|
||||||
Vec3d near = toWorld(mx, my, 0);
|
Vec3d near = toWorld(mx, my, 0);
|
||||||
Vec3d far = toWorld(mx, my, 1); // "Use 0.945 that's what stack overflow says" - leijurv
|
Vec3d far = toWorld(mx, my, 1); // "Use 0.945 that's what stack overflow says" - leijurv
|
||||||
if (near != null && far != null) {
|
if (near != null && far != null) {
|
||||||
Vec3d viewerPos = new Vec3d(mc.getRenderManager().viewerPosX, mc.getRenderManager().viewerPosY, mc.getRenderManager().viewerPosZ);
|
Vec3d viewerPos = new Vec3d(mc.getRenderManager().viewerPosX, mc.getRenderManager().viewerPosY, mc.getRenderManager().viewerPosZ);
|
||||||
RayTraceResult result = mc.world.rayTraceBlocks(near.add(viewerPos), far.add(viewerPos), RayTraceFluidMode.NEVER, false, true);
|
RayTraceResult result = mc.world.rayTraceBlocks(near.add(viewerPos), far.add(viewerPos), false, false, true);
|
||||||
if (result != null && result.type == RayTraceResult.Type.BLOCK) {
|
if (result != null && result.typeOfHit == RayTraceResult.Type.BLOCK) {
|
||||||
currentMouseOver = result.getBlockPos();
|
currentMouseOver = result.getBlockPos();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -72,7 +73,7 @@ public class GuiClick extends GuiScreen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mouseReleased(double mouseX, double mouseY, int mouseButton) {
|
protected void mouseReleased(int mouseX, int mouseY, int mouseButton) {
|
||||||
if (mouseButton == 0) {
|
if (mouseButton == 0) {
|
||||||
if (clickStart != null && !clickStart.equals(currentMouseOver)) {
|
if (clickStart != null && !clickStart.equals(currentMouseOver)) {
|
||||||
((Baritone) BaritoneAPI.getProvider().getPrimaryBaritone()).getBuilderProcess().clearArea(clickStart, currentMouseOver);
|
((Baritone) BaritoneAPI.getProvider().getPrimaryBaritone()).getBuilderProcess().clearArea(clickStart, currentMouseOver);
|
||||||
@@ -84,19 +85,17 @@ public class GuiClick extends GuiScreen {
|
|||||||
BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().setGoalAndPath(new GoalBlock(currentMouseOver.up()));
|
BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().setGoalAndPath(new GoalBlock(currentMouseOver.up()));
|
||||||
}
|
}
|
||||||
clickStart = null;
|
clickStart = null;
|
||||||
return super.mouseReleased(mouseX, mouseY, mouseButton);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mouseClicked(double mouseX, double mouseY, int mouseButton) {
|
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) {
|
||||||
clickStart = currentMouseOver;
|
clickStart = currentMouseOver;
|
||||||
return super.mouseClicked(mouseX, mouseY, mouseButton);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onRender() {
|
public void onRender() {
|
||||||
GlStateManager.getFloatv(GL_MODELVIEW_MATRIX, (FloatBuffer) MODELVIEW.clear());
|
GlStateManager.getFloat(GL_MODELVIEW_MATRIX, (FloatBuffer) MODELVIEW.clear());
|
||||||
GlStateManager.getFloatv(GL_PROJECTION_MATRIX, (FloatBuffer) PROJECTION.clear());
|
GlStateManager.getFloat(GL_PROJECTION_MATRIX, (FloatBuffer) PROJECTION.clear());
|
||||||
GL11.glGetIntegerv(GL_VIEWPORT, (IntBuffer) VIEWPORT.clear());
|
GlStateManager.glGetInteger(GL_VIEWPORT, (IntBuffer) VIEWPORT.clear());
|
||||||
|
|
||||||
if (currentMouseOver != null) {
|
if (currentMouseOver != null) {
|
||||||
Entity e = mc.getRenderViewEntity();
|
Entity e = mc.getRenderViewEntity();
|
||||||
@@ -104,16 +103,16 @@ public class GuiClick extends GuiScreen {
|
|||||||
PathRenderer.drawManySelectionBoxes(e, Collections.singletonList(currentMouseOver), Color.CYAN);
|
PathRenderer.drawManySelectionBoxes(e, Collections.singletonList(currentMouseOver), Color.CYAN);
|
||||||
if (clickStart != null && !clickStart.equals(currentMouseOver)) {
|
if (clickStart != null && !clickStart.equals(currentMouseOver)) {
|
||||||
GlStateManager.enableBlend();
|
GlStateManager.enableBlend();
|
||||||
GlStateManager.blendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO);
|
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
|
||||||
GlStateManager.color4f(Color.RED.getColorComponents(null)[0], Color.RED.getColorComponents(null)[1], Color.RED.getColorComponents(null)[2], 0.4F);
|
GlStateManager.color(Color.RED.getColorComponents(null)[0], Color.RED.getColorComponents(null)[1], Color.RED.getColorComponents(null)[2], 0.4F);
|
||||||
GlStateManager.lineWidth(Baritone.settings().pathRenderLineWidthPixels.value);
|
GlStateManager.glLineWidth(Baritone.settings().pathRenderLineWidthPixels.value);
|
||||||
GlStateManager.disableTexture2D();
|
GlStateManager.disableTexture2D();
|
||||||
GlStateManager.depthMask(false);
|
GlStateManager.depthMask(false);
|
||||||
GlStateManager.disableDepthTest();
|
GlStateManager.disableDepth();
|
||||||
BetterBlockPos a = new BetterBlockPos(currentMouseOver);
|
BetterBlockPos a = new BetterBlockPos(currentMouseOver);
|
||||||
BetterBlockPos b = new BetterBlockPos(clickStart);
|
BetterBlockPos b = new BetterBlockPos(clickStart);
|
||||||
PathRenderer.drawAABB(new AxisAlignedBB(Math.min(a.x, b.x), Math.min(a.y, b.y), Math.min(a.z, b.z), Math.max(a.x, b.x) + 1, Math.max(a.y, b.y) + 1, Math.max(a.z, b.z) + 1));
|
PathRenderer.drawAABB(new AxisAlignedBB(Math.min(a.x, b.x), Math.min(a.y, b.y), Math.min(a.z, b.z), Math.max(a.x, b.x) + 1, Math.max(a.y, b.y) + 1, Math.max(a.z, b.z) + 1));
|
||||||
GlStateManager.enableDepthTest();
|
GlStateManager.enableDepth();
|
||||||
|
|
||||||
GlStateManager.depthMask(true);
|
GlStateManager.depthMask(true);
|
||||||
GlStateManager.enableTexture2D();
|
GlStateManager.enableTexture2D();
|
||||||
@@ -123,194 +122,10 @@ public class GuiClick extends GuiScreen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Vec3d toWorld(double x, double y, double z) {
|
public Vec3d toWorld(double x, double y, double z) {
|
||||||
boolean result = gluUnProject((float) x, (float) y, (float) z, MODELVIEW, PROJECTION, VIEWPORT, (FloatBuffer) TO_WORLD_BUFFER.clear());
|
boolean result = GLU.gluUnProject((float) x, (float) y, (float) z, MODELVIEW, PROJECTION, VIEWPORT, (FloatBuffer) TO_WORLD_BUFFER.clear());
|
||||||
if (result) {
|
if (result) {
|
||||||
return new Vec3d(TO_WORLD_BUFFER.get(0), TO_WORLD_BUFFER.get(1), TO_WORLD_BUFFER.get(2));
|
return new Vec3d(TO_WORLD_BUFFER.get(0), TO_WORLD_BUFFER.get(1), TO_WORLD_BUFFER.get(2));
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// skidded from lwjgl2 :ok_hand:
|
|
||||||
// its uhhhhh mit license so its ok
|
|
||||||
// here is the uhh license
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2002-2007 Lightweight Java Game Library Project
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are
|
|
||||||
* met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* * Neither the name of 'Light Weight Java Game Library' nor the names of
|
|
||||||
* its contributors may be used to endorse or promote products derived
|
|
||||||
* from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
||||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
||||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public static boolean gluUnProject(
|
|
||||||
float winx,
|
|
||||||
float winy,
|
|
||||||
float winz,
|
|
||||||
FloatBuffer modelMatrix,
|
|
||||||
FloatBuffer projMatrix,
|
|
||||||
IntBuffer viewport,
|
|
||||||
FloatBuffer obj_pos) {
|
|
||||||
FloatBuffer finalMatrix = BufferUtils.createFloatBuffer(16);
|
|
||||||
float[] in = new float[4];
|
|
||||||
float[] out = new float[4];
|
|
||||||
|
|
||||||
__gluMultMatricesf(modelMatrix, projMatrix, finalMatrix);
|
|
||||||
|
|
||||||
if (!__gluInvertMatrixf(finalMatrix, finalMatrix))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
in[0] = winx;
|
|
||||||
in[1] = winy;
|
|
||||||
in[2] = winz;
|
|
||||||
in[3] = 1.0f;
|
|
||||||
|
|
||||||
// Map x and y from window coordinates
|
|
||||||
in[0] = (in[0] - viewport.get(viewport.position() + 0)) / viewport.get(viewport.position() + 2);
|
|
||||||
in[1] = (in[1] - viewport.get(viewport.position() + 1)) / viewport.get(viewport.position() + 3);
|
|
||||||
|
|
||||||
// Map to range -1 to 1
|
|
||||||
in[0] = in[0] * 2 - 1;
|
|
||||||
in[1] = in[1] * 2 - 1;
|
|
||||||
in[2] = in[2] * 2 - 1;
|
|
||||||
|
|
||||||
__gluMultMatrixVecf(finalMatrix, in, out);
|
|
||||||
|
|
||||||
if (out[3] == 0.0)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
out[3] = 1.0f / out[3];
|
|
||||||
|
|
||||||
obj_pos.put(obj_pos.position() + 0, out[0] * out[3]);
|
|
||||||
obj_pos.put(obj_pos.position() + 1, out[1] * out[3]);
|
|
||||||
obj_pos.put(obj_pos.position() + 2, out[2] * out[3]);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void __gluMultMatrixVecf(FloatBuffer m, float[] in, float[] out) {
|
|
||||||
for (int i = 0; i < 4; i++) {
|
|
||||||
out[i] =
|
|
||||||
in[0] * m.get(m.position() + 0 * 4 + i)
|
|
||||||
+ in[1] * m.get(m.position() + 1 * 4 + i)
|
|
||||||
+ in[2] * m.get(m.position() + 2 * 4 + i)
|
|
||||||
+ in[3] * m.get(m.position() + 3 * 4 + i);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void __gluMultMatricesf(FloatBuffer a, FloatBuffer b, FloatBuffer r) {
|
|
||||||
for (int i = 0; i < 4; i++) {
|
|
||||||
for (int j = 0; j < 4; j++) {
|
|
||||||
r.put(r.position() + i * 4 + j,
|
|
||||||
a.get(a.position() + i * 4 + 0) * b.get(b.position() + 0 * 4 + j) + a.get(a.position() + i * 4 + 1) * b.get(b.position() + 1 * 4 + j) + a.get(a.position() + i * 4 + 2) * b.get(b.position() + 2 * 4 + j) + a.get(a.position() + i * 4 + 3) * b.get(b.position() + 3 * 4 + j));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean __gluInvertMatrixf(FloatBuffer src, FloatBuffer inverse) {
|
|
||||||
int i, j, k, swap;
|
|
||||||
float t;
|
|
||||||
FloatBuffer temp = BufferUtils.createFloatBuffer(16);
|
|
||||||
|
|
||||||
|
|
||||||
for (i = 0; i < 16; i++) {
|
|
||||||
temp.put(i, src.get(i + src.position()));
|
|
||||||
}
|
|
||||||
__gluMakeIdentityf(inverse);
|
|
||||||
|
|
||||||
for (i = 0; i < 4; i++) {
|
|
||||||
/*
|
|
||||||
* * Look for largest element in column
|
|
||||||
*/
|
|
||||||
swap = i;
|
|
||||||
for (j = i + 1; j < 4; j++) {
|
|
||||||
/*
|
|
||||||
* if (fabs(temp[j][i]) > fabs(temp[i][i])) { swap = j;
|
|
||||||
*/
|
|
||||||
if (Math.abs(temp.get(j * 4 + i)) > Math.abs(temp.get(i * 4 + i))) {
|
|
||||||
swap = j;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (swap != i) {
|
|
||||||
/*
|
|
||||||
* * Swap rows.
|
|
||||||
*/
|
|
||||||
for (k = 0; k < 4; k++) {
|
|
||||||
t = temp.get(i * 4 + k);
|
|
||||||
temp.put(i * 4 + k, temp.get(swap * 4 + k));
|
|
||||||
temp.put(swap * 4 + k, t);
|
|
||||||
|
|
||||||
t = inverse.get(i * 4 + k);
|
|
||||||
inverse.put(i * 4 + k, inverse.get(swap * 4 + k));
|
|
||||||
//inverse.put((i << 2) + k, inverse.get((swap << 2) + k));
|
|
||||||
inverse.put(swap * 4 + k, t);
|
|
||||||
//inverse.put((swap << 2) + k, t);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (temp.get(i * 4 + i) == 0) {
|
|
||||||
/*
|
|
||||||
* * No non-zero pivot. The matrix is singular, which shouldn't *
|
|
||||||
* happen. This means the user gave us a bad matrix.
|
|
||||||
*/
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
t = temp.get(i * 4 + i);
|
|
||||||
for (k = 0; k < 4; k++) {
|
|
||||||
temp.put(i * 4 + k, temp.get(i * 4 + k) / t);
|
|
||||||
inverse.put(i * 4 + k, inverse.get(i * 4 + k) / t);
|
|
||||||
}
|
|
||||||
for (j = 0; j < 4; j++) {
|
|
||||||
if (j != i) {
|
|
||||||
t = temp.get(j * 4 + i);
|
|
||||||
for (k = 0; k < 4; k++) {
|
|
||||||
temp.put(j * 4 + k, temp.get(j * 4 + k) - temp.get(i * 4 + k) * t);
|
|
||||||
inverse.put(j * 4 + k, inverse.get(j * 4 + k) - inverse.get(i * 4 + k) * t);
|
|
||||||
/*inverse.put(
|
|
||||||
(j << 2) + k,
|
|
||||||
inverse.get((j << 2) + k) - inverse.get((i << 2) + k) * t);*/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final float[] IDENTITY_MATRIX =
|
|
||||||
new float[]{
|
|
||||||
1.0f, 0.0f, 0.0f, 0.0f,
|
|
||||||
0.0f, 1.0f, 0.0f, 0.0f,
|
|
||||||
0.0f, 0.0f, 1.0f, 0.0f,
|
|
||||||
0.0f, 0.0f, 0.0f, 1.0f};
|
|
||||||
|
|
||||||
private static void __gluMakeIdentityf(FloatBuffer m) {
|
|
||||||
int oldPos = m.position();
|
|
||||||
m.put(IDENTITY_MATRIX);
|
|
||||||
m.position(oldPos);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ public final class InputOverrideHandler extends Behavior implements IInputOverri
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (ctx.player().movementInput.getClass() == PlayerMovementInput.class) { // allow other movement inputs that aren't this one, e.g. for a freecam
|
if (ctx.player().movementInput.getClass() == PlayerMovementInput.class) { // allow other movement inputs that aren't this one, e.g. for a freecam
|
||||||
ctx.player().movementInput = new MovementInputFromOptions(Minecraft.getInstance().gameSettings);
|
ctx.player().movementInput = new MovementInputFromOptions(Minecraft.getMinecraft().gameSettings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// only set it if it was previously incorrect
|
// only set it if it was previously incorrect
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import baritone.api.event.events.RenderEvent;
|
|||||||
import baritone.api.pathing.calc.IPath;
|
import baritone.api.pathing.calc.IPath;
|
||||||
import baritone.api.pathing.goals.*;
|
import baritone.api.pathing.goals.*;
|
||||||
import baritone.api.utils.BetterBlockPos;
|
import baritone.api.utils.BetterBlockPos;
|
||||||
|
import baritone.api.utils.Helper;
|
||||||
import baritone.api.utils.interfaces.IGoalRenderPos;
|
import baritone.api.utils.interfaces.IGoalRenderPos;
|
||||||
import baritone.behavior.PathingBehavior;
|
import baritone.behavior.PathingBehavior;
|
||||||
import baritone.pathing.path.PathExecutor;
|
import baritone.pathing.path.PathExecutor;
|
||||||
@@ -33,12 +34,10 @@ import net.minecraft.client.renderer.Tessellator;
|
|||||||
import net.minecraft.client.renderer.tileentity.TileEntityBeaconRenderer;
|
import net.minecraft.client.renderer.tileentity.TileEntityBeaconRenderer;
|
||||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.util.math.shapes.VoxelShape;
|
|
||||||
import net.minecraft.util.math.shapes.VoxelShapes;
|
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@@ -53,7 +52,6 @@ import static org.lwjgl.opengl.GL11.*;
|
|||||||
*/
|
*/
|
||||||
public final class PathRenderer implements Helper {
|
public final class PathRenderer implements Helper {
|
||||||
|
|
||||||
private static final ResourceLocation TEXTURE_BEACON_BEAM = new ResourceLocation("textures/entity/beacon_beam.png");
|
|
||||||
private static final Tessellator TESSELLATOR = Tessellator.getInstance();
|
private static final Tessellator TESSELLATOR = Tessellator.getInstance();
|
||||||
private static final BufferBuilder BUFFER = TESSELLATOR.getBuffer();
|
private static final BufferBuilder BUFFER = TESSELLATOR.getBuffer();
|
||||||
|
|
||||||
@@ -66,8 +64,8 @@ public final class PathRenderer implements Helper {
|
|||||||
((GuiClick) mc.currentScreen).onRender();
|
((GuiClick) mc.currentScreen).onRender();
|
||||||
}
|
}
|
||||||
|
|
||||||
int thisPlayerDimension = behavior.baritone.getPlayerContext().world().getDimension().getType().getId();
|
int thisPlayerDimension = behavior.baritone.getPlayerContext().world().provider.getDimensionType().getId();
|
||||||
int currentRenderViewDimension = BaritoneAPI.getProvider().getPrimaryBaritone().getPlayerContext().world().getDimension().getType().getId();
|
int currentRenderViewDimension = BaritoneAPI.getProvider().getPrimaryBaritone().getPlayerContext().world().provider.getDimensionType().getId();
|
||||||
|
|
||||||
if (thisPlayerDimension != currentRenderViewDimension) {
|
if (thisPlayerDimension != currentRenderViewDimension) {
|
||||||
// this is a path for a bot in a different dimension, don't render it
|
// this is a path for a bot in a different dimension, don't render it
|
||||||
@@ -133,13 +131,13 @@ public final class PathRenderer implements Helper {
|
|||||||
|
|
||||||
public static void drawPath(IPath path, int startIndex, Entity player, float partialTicks, Color color, boolean fadeOut, int fadeStart0, int fadeEnd0) {
|
public static void drawPath(IPath path, int startIndex, Entity player, float partialTicks, Color color, boolean fadeOut, int fadeStart0, int fadeEnd0) {
|
||||||
GlStateManager.enableBlend();
|
GlStateManager.enableBlend();
|
||||||
GlStateManager.blendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO);
|
GlStateManager.tryBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO);
|
||||||
GlStateManager.color4f(color.getColorComponents(null)[0], color.getColorComponents(null)[1], color.getColorComponents(null)[2], 0.4F);
|
GlStateManager.color(color.getColorComponents(null)[0], color.getColorComponents(null)[1], color.getColorComponents(null)[2], 0.4F);
|
||||||
GlStateManager.lineWidth(Baritone.settings().pathRenderLineWidthPixels.value);
|
GlStateManager.glLineWidth(Baritone.settings().pathRenderLineWidthPixels.value);
|
||||||
GlStateManager.disableTexture2D();
|
GlStateManager.disableTexture2D();
|
||||||
GlStateManager.depthMask(false);
|
GlStateManager.depthMask(false);
|
||||||
if (Baritone.settings().renderPathIgnoreDepth.value) {
|
if (Baritone.settings().renderPathIgnoreDepth.value) {
|
||||||
GlStateManager.disableDepthTest();
|
GlStateManager.disableDepth();
|
||||||
}
|
}
|
||||||
List<BetterBlockPos> positions = path.positions();
|
List<BetterBlockPos> positions = path.positions();
|
||||||
int next;
|
int next;
|
||||||
@@ -176,13 +174,13 @@ public final class PathRenderer implements Helper {
|
|||||||
}
|
}
|
||||||
alpha = 0.4F * (1.0F - (float) (i - fadeStart) / (float) (fadeEnd - fadeStart));
|
alpha = 0.4F * (1.0F - (float) (i - fadeStart) / (float) (fadeEnd - fadeStart));
|
||||||
}
|
}
|
||||||
GlStateManager.color4f(color.getColorComponents(null)[0], color.getColorComponents(null)[1], color.getColorComponents(null)[2], alpha);
|
GlStateManager.color(color.getColorComponents(null)[0], color.getColorComponents(null)[1], color.getColorComponents(null)[2], alpha);
|
||||||
}
|
}
|
||||||
drawLine(x1, y1, z1, x2, y2, z2);
|
drawLine(x1, y1, z1, x2, y2, z2);
|
||||||
tessellator.draw();
|
tessellator.draw();
|
||||||
}
|
}
|
||||||
if (Baritone.settings().renderPathIgnoreDepth.value) {
|
if (Baritone.settings().renderPathIgnoreDepth.value) {
|
||||||
GlStateManager.enableDepthTest();
|
GlStateManager.enableDepth();
|
||||||
}
|
}
|
||||||
//GlStateManager.color(0.0f, 0.0f, 0.0f, 0.4f);
|
//GlStateManager.color(0.0f, 0.0f, 0.0f, 0.4f);
|
||||||
GlStateManager.depthMask(true);
|
GlStateManager.depthMask(true);
|
||||||
@@ -204,14 +202,14 @@ public final class PathRenderer implements Helper {
|
|||||||
|
|
||||||
public static void drawManySelectionBoxes(Entity player, Collection<BlockPos> positions, Color color) {
|
public static void drawManySelectionBoxes(Entity player, Collection<BlockPos> positions, Color color) {
|
||||||
GlStateManager.enableBlend();
|
GlStateManager.enableBlend();
|
||||||
GlStateManager.blendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO);
|
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
|
||||||
GlStateManager.color4f(color.getColorComponents(null)[0], color.getColorComponents(null)[1], color.getColorComponents(null)[2], 0.4F);
|
GlStateManager.color(color.getColorComponents(null)[0], color.getColorComponents(null)[1], color.getColorComponents(null)[2], 0.4F);
|
||||||
GlStateManager.lineWidth(Baritone.settings().pathRenderLineWidthPixels.value);
|
GlStateManager.glLineWidth(Baritone.settings().pathRenderLineWidthPixels.value);
|
||||||
GlStateManager.disableTexture2D();
|
GlStateManager.disableTexture2D();
|
||||||
GlStateManager.depthMask(false);
|
GlStateManager.depthMask(false);
|
||||||
|
|
||||||
if (Baritone.settings().renderSelectionBoxesIgnoreDepth.value) {
|
if (Baritone.settings().renderSelectionBoxesIgnoreDepth.value) {
|
||||||
GlStateManager.disableDepthTest();
|
GlStateManager.disableDepth();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -219,14 +217,17 @@ public final class PathRenderer implements Helper {
|
|||||||
BlockStateInterface bsi = new BlockStateInterface(BaritoneAPI.getProvider().getPrimaryBaritone().getPlayerContext()); // TODO this assumes same dimension between primary baritone and render view? is this safe?
|
BlockStateInterface bsi = new BlockStateInterface(BaritoneAPI.getProvider().getPrimaryBaritone().getPlayerContext()); // TODO this assumes same dimension between primary baritone and render view? is this safe?
|
||||||
positions.forEach(pos -> {
|
positions.forEach(pos -> {
|
||||||
IBlockState state = bsi.get0(pos);
|
IBlockState state = bsi.get0(pos);
|
||||||
VoxelShape shape = state.getShape(player.world, pos);
|
AxisAlignedBB toDraw;
|
||||||
AxisAlignedBB toDraw = shape.isEmpty() ? VoxelShapes.fullCube().getBoundingBox() : shape.getBoundingBox();
|
if (state.getBlock().equals(Blocks.AIR)) {
|
||||||
toDraw = toDraw.offset(pos);
|
toDraw = Blocks.DIRT.getDefaultState().getSelectedBoundingBox(player.world, pos);
|
||||||
|
} else {
|
||||||
|
toDraw = state.getSelectedBoundingBox(player.world, pos);
|
||||||
|
}
|
||||||
drawAABB(toDraw);
|
drawAABB(toDraw);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (Baritone.settings().renderSelectionBoxesIgnoreDepth.value) {
|
if (Baritone.settings().renderSelectionBoxesIgnoreDepth.value) {
|
||||||
GlStateManager.enableDepthTest();
|
GlStateManager.enableDepth();
|
||||||
}
|
}
|
||||||
|
|
||||||
GlStateManager.depthMask(true);
|
GlStateManager.depthMask(true);
|
||||||
@@ -300,10 +301,10 @@ public final class PathRenderer implements Helper {
|
|||||||
if (Baritone.settings().renderGoalXZBeacon.value) {
|
if (Baritone.settings().renderGoalXZBeacon.value) {
|
||||||
glPushAttrib(GL_LIGHTING_BIT);
|
glPushAttrib(GL_LIGHTING_BIT);
|
||||||
|
|
||||||
mc.getTextureManager().bindTexture(TEXTURE_BEACON_BEAM);
|
mc.getTextureManager().bindTexture(TileEntityBeaconRenderer.TEXTURE_BEACON_BEAM);
|
||||||
|
|
||||||
if (Baritone.settings().renderGoalIgnoreDepth.value) {
|
if (Baritone.settings().renderGoalIgnoreDepth.value) {
|
||||||
GlStateManager.disableDepthTest();
|
GlStateManager.disableDepth();
|
||||||
}
|
}
|
||||||
|
|
||||||
TileEntityBeaconRenderer.renderBeamSegment(
|
TileEntityBeaconRenderer.renderBeamSegment(
|
||||||
@@ -312,18 +313,14 @@ public final class PathRenderer implements Helper {
|
|||||||
goalPos.getZ() - renderPosZ,
|
goalPos.getZ() - renderPosZ,
|
||||||
partialTicks,
|
partialTicks,
|
||||||
1.0,
|
1.0,
|
||||||
player.world.getGameTime(),
|
player.world.getTotalWorldTime(),
|
||||||
0,
|
0,
|
||||||
256,
|
256,
|
||||||
color.getColorComponents(null),
|
color.getColorComponents(null)
|
||||||
|
|
||||||
// Arguments filled by the private method lol
|
|
||||||
0.2D,
|
|
||||||
0.25D
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if (Baritone.settings().renderGoalIgnoreDepth.value) {
|
if (Baritone.settings().renderGoalIgnoreDepth.value) {
|
||||||
GlStateManager.enableDepthTest();
|
GlStateManager.enableDepth();
|
||||||
}
|
}
|
||||||
|
|
||||||
glPopAttrib();
|
glPopAttrib();
|
||||||
@@ -349,13 +346,13 @@ public final class PathRenderer implements Helper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
GlStateManager.enableBlend();
|
GlStateManager.enableBlend();
|
||||||
GlStateManager.blendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO);
|
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
|
||||||
GlStateManager.color4f(color.getColorComponents(null)[0], color.getColorComponents(null)[1], color.getColorComponents(null)[2], 0.6F);
|
GlStateManager.color(color.getColorComponents(null)[0], color.getColorComponents(null)[1], color.getColorComponents(null)[2], 0.6F);
|
||||||
GlStateManager.lineWidth(Baritone.settings().goalRenderLineWidthPixels.value);
|
GlStateManager.glLineWidth(Baritone.settings().goalRenderLineWidthPixels.value);
|
||||||
GlStateManager.disableTexture2D();
|
GlStateManager.disableTexture2D();
|
||||||
GlStateManager.depthMask(false);
|
GlStateManager.depthMask(false);
|
||||||
if (Baritone.settings().renderGoalIgnoreDepth.value) {
|
if (Baritone.settings().renderGoalIgnoreDepth.value) {
|
||||||
GlStateManager.disableDepthTest();
|
GlStateManager.disableDepth();
|
||||||
}
|
}
|
||||||
|
|
||||||
renderHorizontalQuad(minX, maxX, minZ, maxZ, y1);
|
renderHorizontalQuad(minX, maxX, minZ, maxZ, y1);
|
||||||
@@ -373,7 +370,7 @@ public final class PathRenderer implements Helper {
|
|||||||
TESSELLATOR.draw();
|
TESSELLATOR.draw();
|
||||||
|
|
||||||
if (Baritone.settings().renderGoalIgnoreDepth.value) {
|
if (Baritone.settings().renderGoalIgnoreDepth.value) {
|
||||||
GlStateManager.enableDepthTest();
|
GlStateManager.enableDepth();
|
||||||
}
|
}
|
||||||
GlStateManager.depthMask(true);
|
GlStateManager.depthMask(true);
|
||||||
GlStateManager.enableTexture2D();
|
GlStateManager.enableTexture2D();
|
||||||
|
|||||||
@@ -92,8 +92,8 @@ public class PathingControlManager implements IPathingControlManager {
|
|||||||
p.secretInternalSetGoal(null);
|
p.secretInternalSetGoal(null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (inControlThisTick != inControlLastTick && command.commandType != PathingCommandType.REQUEST_PAUSE) {
|
if (inControlThisTick != inControlLastTick && command.commandType != PathingCommandType.REQUEST_PAUSE && inControlLastTick != null && !inControlLastTick.isTemporary()) {
|
||||||
// if control has changed, and the new process wants to do something
|
// if control has changed from a real process to another real process, and the new process wants to do something
|
||||||
p.cancelSegmentIfSafe();
|
p.cancelSegmentIfSafe();
|
||||||
// get rid of the in progress stuff from the last process
|
// get rid of the in progress stuff from the last process
|
||||||
}
|
}
|
||||||
@@ -200,10 +200,10 @@ public class PathingControlManager implements IPathingControlManager {
|
|||||||
PathingCommand exec = proc.onTick(Objects.equals(proc, inControlLastTick) && baritone.getPathingBehavior().calcFailedLastTick(), baritone.getPathingBehavior().isSafeToCancel());
|
PathingCommand exec = proc.onTick(Objects.equals(proc, inControlLastTick) && baritone.getPathingBehavior().calcFailedLastTick(), baritone.getPathingBehavior().isSafeToCancel());
|
||||||
if (exec == null) {
|
if (exec == null) {
|
||||||
if (proc.isActive()) {
|
if (proc.isActive()) {
|
||||||
throw new IllegalStateException(proc.displayName() + " returned null PathingCommand");
|
throw new IllegalStateException(proc.displayName() + " actively returned null PathingCommand");
|
||||||
}
|
}
|
||||||
proc.onLostControl();
|
// no need to call onLostControl; they are reporting inactive.
|
||||||
} else {
|
} else if (exec.commandType != PathingCommandType.DEFER) {
|
||||||
inControlThisTick = proc;
|
inControlThisTick = proc;
|
||||||
if (!proc.isTemporary()) {
|
if (!proc.isTemporary()) {
|
||||||
iterator.forEachRemaining(IBaritoneProcess::onLostControl);
|
iterator.forEachRemaining(IBaritoneProcess::onLostControl);
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import net.minecraft.client.entity.EntityPlayerSP;
|
|||||||
import net.minecraft.enchantment.EnchantmentHelper;
|
import net.minecraft.enchantment.EnchantmentHelper;
|
||||||
import net.minecraft.init.Enchantments;
|
import net.minecraft.init.Enchantments;
|
||||||
import net.minecraft.init.MobEffects;
|
import net.minecraft.init.MobEffects;
|
||||||
|
import net.minecraft.item.Item.ToolMaterial;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.ItemTool;
|
import net.minecraft.item.ItemTool;
|
||||||
|
|
||||||
@@ -74,13 +75,19 @@ public class ToolSet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Evaluate the material cost of a possible tool. Will return 1 for tools, -1 for other
|
* Evaluate the material cost of a possible tool. The priority matches the
|
||||||
|
* listed order in the Item.ToolMaterial enum.
|
||||||
*
|
*
|
||||||
* @param itemStack a possibly empty ItemStack
|
* @param itemStack a possibly empty ItemStack
|
||||||
* @return Either 1 or -1
|
* @return values range from -1 to 4
|
||||||
*/
|
*/
|
||||||
private int getMaterialCost(ItemStack itemStack) {
|
private int getMaterialCost(ItemStack itemStack) {
|
||||||
return itemStack.getItem() instanceof ItemTool ? 1 : -1;
|
if (itemStack.getItem() instanceof ItemTool) {
|
||||||
|
ItemTool tool = (ItemTool) itemStack.getItem();
|
||||||
|
return ToolMaterial.valueOf(tool.getToolMaterialName()).ordinal();
|
||||||
|
} else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -17,10 +17,12 @@
|
|||||||
|
|
||||||
package baritone.utils.accessor;
|
package baritone.utils.accessor;
|
||||||
|
|
||||||
|
import net.minecraft.world.WorldProvider;
|
||||||
import net.minecraft.world.chunk.storage.IChunkLoader;
|
import net.minecraft.world.chunk.storage.IChunkLoader;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Brady
|
* @author Brady
|
||||||
|
* @see WorldProvider
|
||||||
* @since 8/4/2018
|
* @since 8/4/2018
|
||||||
*/
|
*/
|
||||||
public interface IChunkProviderServer {
|
public interface IChunkProviderServer {
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ package baritone.utils.pathing;
|
|||||||
|
|
||||||
import baritone.api.pathing.calc.IPath;
|
import baritone.api.pathing.calc.IPath;
|
||||||
import baritone.api.utils.BetterBlockPos;
|
import baritone.api.utils.BetterBlockPos;
|
||||||
|
import baritone.api.utils.Helper;
|
||||||
import baritone.api.utils.IPlayerContext;
|
import baritone.api.utils.IPlayerContext;
|
||||||
import baritone.pathing.movement.CalculationContext;
|
import baritone.pathing.movement.CalculationContext;
|
||||||
import it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap;
|
import it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap;
|
||||||
@@ -31,7 +32,7 @@ public final class Favoring {
|
|||||||
for (Avoidance avoid : Avoidance.create(ctx)) {
|
for (Avoidance avoid : Avoidance.create(ctx)) {
|
||||||
avoid.applySpherical(favorings);
|
avoid.applySpherical(favorings);
|
||||||
}
|
}
|
||||||
System.out.println("Favoring size: " + favorings.size());
|
Helper.HELPER.logDebug("Favoring size: " + favorings.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Favoring(IPath previous, CalculationContext context) { // create one just from previous path, no mob avoidances
|
public Favoring(IPath previous, CalculationContext context) { // create one just from previous path, no mob avoidances
|
||||||
|
|||||||
@@ -19,10 +19,10 @@ package baritone.utils.player;
|
|||||||
|
|
||||||
import baritone.api.BaritoneAPI;
|
import baritone.api.BaritoneAPI;
|
||||||
import baritone.api.cache.IWorldData;
|
import baritone.api.cache.IWorldData;
|
||||||
|
import baritone.api.utils.Helper;
|
||||||
import baritone.api.utils.IPlayerContext;
|
import baritone.api.utils.IPlayerContext;
|
||||||
import baritone.api.utils.IPlayerController;
|
import baritone.api.utils.IPlayerController;
|
||||||
import baritone.api.utils.RayTraceUtils;
|
import baritone.api.utils.RayTraceUtils;
|
||||||
import baritone.utils.Helper;
|
|
||||||
import net.minecraft.client.entity.EntityPlayerSP;
|
import net.minecraft.client.entity.EntityPlayerSP;
|
||||||
import net.minecraft.util.math.RayTraceResult;
|
import net.minecraft.util.math.RayTraceResult;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|||||||
@@ -17,8 +17,8 @@
|
|||||||
|
|
||||||
package baritone.utils.player;
|
package baritone.utils.player;
|
||||||
|
|
||||||
|
import baritone.api.utils.Helper;
|
||||||
import baritone.api.utils.IPlayerController;
|
import baritone.api.utils.IPlayerController;
|
||||||
import baritone.utils.Helper;
|
|
||||||
import net.minecraft.client.entity.EntityPlayerSP;
|
import net.minecraft.client.entity.EntityPlayerSP;
|
||||||
import net.minecraft.client.multiplayer.WorldClient;
|
import net.minecraft.client.multiplayer.WorldClient;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
|||||||
@@ -17,8 +17,8 @@
|
|||||||
|
|
||||||
package baritone.utils.schematic;
|
package baritone.utils.schematic;
|
||||||
|
|
||||||
import net.minecraft.block.BlockAir;
|
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
|
||||||
import java.util.OptionalInt;
|
import java.util.OptionalInt;
|
||||||
@@ -36,7 +36,7 @@ public class MapArtSchematic extends Schematic {
|
|||||||
for (int z = 0; z < lengthZ; z++) {
|
for (int z = 0; z < lengthZ; z++) {
|
||||||
IBlockState[] column = states[x][z];
|
IBlockState[] column = states[x][z];
|
||||||
|
|
||||||
OptionalInt lowestBlockY = lastIndexMatching(column, block -> !(block instanceof BlockAir));
|
OptionalInt lowestBlockY = lastIndexMatching(column, block -> block != Blocks.AIR);
|
||||||
if (lowestBlockY.isPresent()) {
|
if (lowestBlockY.isPresent()) {
|
||||||
heightMap[x][z] = lowestBlockY.getAsInt();
|
heightMap[x][z] = lowestBlockY.getAsInt();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
package baritone.utils.schematic;
|
package baritone.utils.schematic;
|
||||||
|
|
||||||
import baritone.api.utils.ISchematic;
|
import baritone.api.utils.ISchematic;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
|
||||||
@@ -28,7 +29,7 @@ public class Schematic implements ISchematic {
|
|||||||
protected final IBlockState[][][] states;
|
protected final IBlockState[][][] states;
|
||||||
|
|
||||||
public Schematic(NBTTagCompound schematic) {
|
public Schematic(NBTTagCompound schematic) {
|
||||||
/*String type = schematic.getString("Materials");
|
String type = schematic.getString("Materials");
|
||||||
if (!type.equals("Alpha")) {
|
if (!type.equals("Alpha")) {
|
||||||
throw new IllegalStateException("bad schematic " + type);
|
throw new IllegalStateException("bad schematic " + type);
|
||||||
}
|
}
|
||||||
@@ -63,8 +64,7 @@ public class Schematic implements ISchematic {
|
|||||||
states[x][z][y] = block.getStateFromMeta(meta);
|
states[x][z][y] = block.getStateFromMeta(meta);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
throw new UnsupportedOperationException("1.13 be like: numeric IDs btfo");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user