Compare commits
1 Commits
v1.1.0
...
binary-hea
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
59e0d6406e |
@@ -28,8 +28,6 @@ Baritone is the pathfinding system used in [Impact](https://impactdevelopment.gi
|
||||
This project is an updated version of [MineBot](https://github.com/leijurv/MineBot/),
|
||||
the original version of the bot for Minecraft 1.8, rebuilt for 1.12.2. Baritone focuses on reliability and particularly performance (it's over [30x faster](https://github.com/cabaletta/baritone/pull/180#issuecomment-423822928) than MineBot at calculating paths).
|
||||
|
||||
Have committed at least once a day for the last 6 months =D 🦀
|
||||
|
||||
Here are some links to help to get started:
|
||||
|
||||
- [Features](FEATURES.md)
|
||||
|
||||
2
SETUP.md
2
SETUP.md
@@ -65,7 +65,7 @@ $ gradlew build
|
||||
|
||||

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