diff --git a/.github/workflows/gradle_build.yml b/.github/workflows/gradle_build.yml index 08e9ab1d3..9d4ed379b 100644 --- a/.github/workflows/gradle_build.yml +++ b/.github/workflows/gradle_build.yml @@ -28,7 +28,7 @@ jobs: run: chmod +x gradlew - name: Build with Gradle - run: ./gradlew build -Pmod_version="$(git describe --always --tags | cut -c2-)" + run: ./gradlew build -Pmod_version="$(git describe --always --tags --first-parent | cut -c2-)" - name: Archive Artifacts uses: actions/upload-artifact@v3 diff --git a/.gitignore b/.gitignore index 191a4edc5..fe4b0d407 100644 --- a/.gitignore +++ b/.gitignore @@ -42,3 +42,5 @@ mapping libs/lwjgl-platform-2.9.4-nightly-20150209-natives-osx.jar libs/java-objc-bridge-1.1.jar + +mapping diff --git a/Dockerfile b/Dockerfile index 9023e2020..8a00fc3da 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,6 +6,7 @@ RUN apt update -y RUN apt install \ openjdk-17-jdk \ + git \ --assume-yes COPY . /code diff --git a/README.md b/README.md index bc3552c5a..3f2923f92 100644 --- a/README.md +++ b/README.md @@ -8,9 +8,9 @@ Minecraft Minecraft Minecraft - Minecraft + Minecraft Minecraft - Minecraft + Minecraft Minecraft Minecraft Minecraft @@ -60,7 +60,7 @@ Baritone is the pathfinding system used in [Impact](https://impactclient.net/) s | Forge | Fabric | |---------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------| -| [1.12.2 Forge](https://github.com/cabaletta/baritone/releases/download/v1.2.18/baritone-api-forge-1.2.18.jar) | | +| [1.12.2 Forge](https://github.com/cabaletta/baritone/releases/download/v1.2.19/baritone-api-forge-1.2.19.jar) | | | [1.16.5 Forge](https://github.com/cabaletta/baritone/releases/download/v1.6.5/baritone-api-forge-1.6.5.jar) | [1.16.5 Fabric](https://github.com/cabaletta/baritone/releases/download/v1.6.5/baritone-api-fabric-1.6.5.jar) | | [1.17.1 Forge](https://github.com/cabaletta/baritone/releases/download/v1.7.3/baritone-api-forge-1.7.3.jar) | [1.17.1 Fabric](https://github.com/cabaletta/baritone/releases/download/v1.7.3/baritone-api-fabric-1.7.3.jar) | | [1.18.2 Forge](https://github.com/cabaletta/baritone/releases/download/v1.8.5/baritone-api-forge-1.8.5.jar) | [1.18.2 Fabric](https://github.com/cabaletta/baritone/releases/download/v1.8.5/baritone-api-fabric-1.8.5.jar) | @@ -69,7 +69,7 @@ Baritone is the pathfinding system used in [Impact](https://impactclient.net/) s | [1.19.4 Forge](https://github.com/cabaletta/baritone/releases/download/v1.9.3/baritone-api-forge-1.9.3.jar) | [1.19.4 Fabric](https://github.com/cabaletta/baritone/releases/download/v1.9.3/baritone-api-fabric-1.9.3.jar) | | [1.20.1 Forge](https://github.com/cabaletta/baritone/releases/download/v1.10.1/baritone-api-forge-1.10.1.jar) | [1.20.1 Fabric](https://github.com/cabaletta/baritone/releases/download/v1.10.1/baritone-api-fabric-1.10.1.jar) | -**Message for 2b2t players looking for 1.19/1.20 Baritone** Download it from right above ^. But also please check back in a few days for Baritone Elytra ([vid 1](https://youtu.be/4bGGPo8yiHo) [vid 2](https://www.youtube.com/watch?v=pUN9nmINe3I)), which will be ported to 1.19/1.20 soon! It will work on 2b2t with its anticheat, that was the whole point of Baritone Elytra (it's fully vanilla compatible). Also join [**the discord**](http://discord.gg/s6fRBAUpmr). Thanks! +**Message for 2b2t players looking for 1.19/1.20 Baritone** If you like, please try the beta for Baritone Elytra for 2b2t, find it in #announcements of [the Baritone discord](http://discord.gg/s6fRBAUpmr). It supports 1.19.4 and 1.20.1, Forge or Fabric. If you have to see it to believe it, watch [this YouTube video](https://youtu.be/NnSlQi-68eQ). **How to immediately get started:** Type `#goto 1000 500` in chat to go to x=1000 z=500. Type `#mine diamond_ore` to mine diamond ore. Type `#stop` to stop. For more, read [the usage page](USAGE.md) and/or watch this [tutorial playlist](https://www.youtube.com/playlist?list=PLnwnJ1qsS7CoQl9Si-RTluuzCo_4Oulpa). Also try `#elytra` for Elytra flying in the Nether using fireworks. diff --git a/build.gradle b/build.gradle index 1f5cd9419..086d16c90 100755 --- a/build.gradle +++ b/build.gradle @@ -21,12 +21,19 @@ allprojects { apply plugin: "maven-publish" archivesBaseName = rootProject.archives_base_name - def vers = 'git describe --always --dirty'.execute().text.trim() - if (vers.isEmpty()) { + + def vers = "" + try { + vers = 'git describe --always --tags --first-parent --dirty'.execute().text.trim() + } catch (Exception e) { + println "Version detection failed: " + e + } + if (!vers.startsWith("v")) { println "using version number: " + rootProject.mod_version version = rootProject.mod_version } else { - version = rootProject.mod_version + "-" + vers + version = vers.substring(1) + println "Detected version " + version } group = rootProject.maven_group @@ -70,7 +77,7 @@ allprojects { // The following line declares the yarn mappings you may select this one as well. // mappings "net.fabricmc:yarn:1.17.1+build.32:v2" //launchImplementation('dev.babbaj:nether-pathfinder:1.3.0') - implementation 'dev.babbaj:nether-pathfinder:1.3.0' + implementation 'dev.babbaj:nether-pathfinder:1.4.1' } unimined.minecraft(sourceSets.main, true) { @@ -141,4 +148,4 @@ javadoc { options.encoding "UTF-8" // allow emoji in comments :^) source = sourceSets.api.allJava classpath += sourceSets.api.compileClasspath -} \ No newline at end of file +} diff --git a/buildSrc/src/main/java/baritone/gradle/task/ProguardTask.java b/buildSrc/src/main/java/baritone/gradle/task/ProguardTask.java index c2f3c5be7..a9c7f94ea 100644 --- a/buildSrc/src/main/java/baritone/gradle/task/ProguardTask.java +++ b/buildSrc/src/main/java/baritone/gradle/task/ProguardTask.java @@ -125,6 +125,9 @@ private String getJavaBinPathForProguard() throws Exception { ex.printStackTrace(); } + path = findJavaByGradleCurrentRuntime(); + if (path != null) return path; + try { path = findJavaByJavaHome(); if (path != null) return path; @@ -133,10 +136,6 @@ private String getJavaBinPathForProguard() throws Exception { ex.printStackTrace(); } - - path = findJavaByGradleCurrentRuntime(); - if (path != null) return path; - throw new Exception("Unable to find java to determine ProGuard libraryjars. Please specify forkOptions.executable in javaCompile," + " JAVA_HOME environment variable, or make sure to run Gradle with the correct JDK (a v1.8 only)"); } diff --git a/fabric/build.gradle b/fabric/build.gradle index f3798343e..9674f4e7a 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -101,4 +101,4 @@ publishing { repositories { // Add repositories to publish to here. } -} \ No newline at end of file +} diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 177c8988d..9171a3d68 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -743,7 +743,7 @@ public final class Settings { /** * Automatically elytra fly without having to force the client-sided rotations. */ - public final Setting elytraFreeLook = new Setting<>(false); + public final Setting elytraFreeLook = new Setting<>(true); /** * Forces the client-sided yaw rotation to an average of the last {@link #smoothLookTicks} of server-sided rotations. @@ -753,7 +753,7 @@ public final class Settings { /** * Same as {@link #smoothLook} but for elytra flying. */ - public final Setting elytraSmoothLook = new Setting<>(true); + public final Setting elytraSmoothLook = new Setting<>(false); /** * The number of ticks to average across for {@link #smoothLook}; @@ -1426,7 +1426,7 @@ public final class Settings { * Whether nether-pathfinder should generate terrain based on {@link #elytraNetherSeed}. * If false all chunks that haven't been loaded are assumed to be air. */ - public final Setting elytraPredictTerrain = new Setting<>(true); + public final Setting elytraPredictTerrain = new Setting<>(false); /** * Automatically swap the current elytra with a new one when the durability gets too low @@ -1468,6 +1468,11 @@ public final class Settings { */ public final Setting elytraTermsAccepted = new Setting<>(false); + /** + * Verbose chat logging in elytra mode + */ + public final Setting elytraChatSpam = new Setting<>(false); + /** * A map of lowercase setting field names to their respective setting */ diff --git a/src/main/java/baritone/behavior/LookBehavior.java b/src/main/java/baritone/behavior/LookBehavior.java index e694a8ee0..98e12aeff 100644 --- a/src/main/java/baritone/behavior/LookBehavior.java +++ b/src/main/java/baritone/behavior/LookBehavior.java @@ -82,7 +82,6 @@ public void onTick(TickEvent event) { @Override public void onPlayerUpdate(PlayerUpdateEvent event) { - System.out.println(event.getState() + " " + ctx.player().getXRot() + " " + ctx.player().getYRot() + " " + ctx.player().xRotO + " " + ctx.player().yRotO); if (this.target == null) { return; diff --git a/src/main/java/baritone/cache/CachedWorld.java b/src/main/java/baritone/cache/CachedWorld.java index e456382e6..aed1faeb5 100644 --- a/src/main/java/baritone/cache/CachedWorld.java +++ b/src/main/java/baritone/cache/CachedWorld.java @@ -196,9 +196,7 @@ private synchronized void prune() { int distZ = ((region.getZ() << 9) + 256) - pruneCenter.getZ(); double dist = Math.sqrt(distX * distX + distZ * distZ); if (dist > 1024) { - if (!Baritone.settings().censorCoordinates.value) { - logDebug("Deleting cached region " + region.getX() + "," + region.getZ() + " from ram"); - } + logDebug("Deleting cached region from ram"); cachedRegions.remove(getRegionID(region.getX(), region.getZ())); } } diff --git a/src/main/java/baritone/cache/FasterWorldScanner.java b/src/main/java/baritone/cache/FasterWorldScanner.java index e1c8589e7..b6d3d8963 100644 --- a/src/main/java/baritone/cache/FasterWorldScanner.java +++ b/src/main/java/baritone/cache/FasterWorldScanner.java @@ -20,6 +20,7 @@ import baritone.api.cache.ICachedWorld; import baritone.api.cache.IWorldScanner; import baritone.api.utils.BetterBlockPos; +import baritone.api.utils.BlockOptionalMeta; import baritone.api.utils.BlockOptionalMetaLookup; import baritone.api.utils.IPlayerContext; import baritone.utils.accessor.IPalettedContainer; @@ -45,6 +46,9 @@ public enum FasterWorldScanner implements IWorldScanner { INSTANCE; + + private static final BlockState[] PALETTE_REGISTRY_SENTINEL = new BlockState[0]; + @Override public List scanChunkRadius(IPlayerContext ctx, BlockOptionalMetaLookup filter, int max, int yLevelThreshold, int maxSearchRadius) { assert ctx.world() != null; @@ -151,7 +155,7 @@ private Stream scanChunkInternal(IPlayerContext ctx, BlockOptionalMeta long chunkX = (long) pos.x << 4; long chunkZ = (long) pos.z << 4; - int playerSectionY = ctx.playerFeet().y >> 4; + int playerSectionY = (ctx.playerFeet().y - ctx.world().getMinBuildHeight()) >> 4; return collectChunkSections(lookup, chunkProvider.getChunk(pos.x, pos.z, false), chunkX, chunkZ, playerSectionY).stream(); } @@ -219,13 +223,18 @@ private void visitSection(BlockOptionalMetaLookup lookup, LevelChunkSection sect private boolean[] getIncludedFilterIndices(BlockOptionalMetaLookup lookup, Palette palette) { boolean commonBlockFound = false; - IdMapper paletteMap = getPalette(palette); - int size = paletteMap.size(); + BlockState[] paletteMap = getPalette(palette); + + if (paletteMap == PALETTE_REGISTRY_SENTINEL) { + return getIncludedFilterIndicesFromRegistry(lookup); + } + + int size = paletteMap.length; boolean[] isInFilter = new boolean[size]; for (int i = 0; i < size; i++) { - BlockState state = paletteMap.byId(i); + BlockState state = paletteMap[i]; if (lookup.has(state)) { isInFilter[i] = true; commonBlockFound = true; @@ -240,21 +249,34 @@ private boolean[] getIncludedFilterIndices(BlockOptionalMetaLookup lookup, Palet return isInFilter; } + private boolean[] getIncludedFilterIndicesFromRegistry(BlockOptionalMetaLookup lookup) { + boolean[] isInFilter = new boolean[Block.BLOCK_STATE_REGISTRY.size()]; + + for (BlockOptionalMeta bom : lookup.blocks()) { + for (BlockState state : bom.getAllBlockStates()) { + isInFilter[Block.BLOCK_STATE_REGISTRY.getId(state)] = true; + } + } + + return isInFilter; + } + /** * cheats to get the actual map of id -> blockstate from the various palette implementations */ - private static IdMapper getPalette(Palette palette) { + private static BlockState[] getPalette(Palette palette) { if (palette instanceof GlobalPalette) { - return Block.BLOCK_STATE_REGISTRY; + // copying the entire registry is not nice so we treat it as a special case + return PALETTE_REGISTRY_SENTINEL; } else { FriendlyByteBuf buf = new FriendlyByteBuf(Unpooled.buffer()); palette.write(buf); int size = buf.readVarInt(); - IdMapper states = new IdMapper<>(); + BlockState[] states = new BlockState[size]; for (int i = 0; i < size; i++) { BlockState state = Block.BLOCK_STATE_REGISTRY.byId(buf.readVarInt()); assert state != null; - states.addMapping(state, i); + states[i] = state; } return states; } diff --git a/src/main/java/baritone/process/BuilderProcess.java b/src/main/java/baritone/process/BuilderProcess.java index 86378bbbc..0ae796e6e 100644 --- a/src/main/java/baritone/process/BuilderProcess.java +++ b/src/main/java/baritone/process/BuilderProcess.java @@ -1063,6 +1063,9 @@ private boolean valid(BlockState current, BlockState desired, boolean itemVerify if (desired.getBlock() instanceof AirBlock && Baritone.settings().buildIgnoreBlocks.value.contains(current.getBlock())) { return true; } + if (!(current.getBlock() instanceof AirBlock) && Baritone.settings().buildIgnoreExisting.value && !itemVerify) { + return true; + } if (Baritone.settings().buildSkipBlocks.value.contains(desired.getBlock()) && !itemVerify) { return true; } diff --git a/src/main/java/baritone/process/ElytraProcess.java b/src/main/java/baritone/process/ElytraProcess.java index e0b6a1a03..2c57c6f55 100644 --- a/src/main/java/baritone/process/ElytraProcess.java +++ b/src/main/java/baritone/process/ElytraProcess.java @@ -69,6 +69,16 @@ public class ElytraProcess extends BaritoneProcessHelper implements IBaritonePro private ElytraBehavior behavior; private boolean predictingTerrain; + @Override + public void onLostControl() { + this.state = State.START_FLYING; // TODO: null state? + this.goingToLandingSpot = false; + this.landingSpot = null; + this.reachedGoal = false; + this.goal = null; + destroyBehaviorAsync(); + } + private ElytraProcess(Baritone baritone) { super(baritone); baritone.getGameEventHandler().registerEventListener(this); @@ -276,16 +286,6 @@ public void landingSpotIsBad(BetterBlockPos endPos) { this.state = State.FLYING; } - @Override - public void onLostControl() { - this.goal = null; - this.goingToLandingSpot = false; - this.landingSpot = null; - this.reachedGoal = false; - this.state = State.START_FLYING; // TODO: null state? - destroyBehaviorAsync(); - } - private void destroyBehaviorAsync() { ElytraBehavior behavior = this.behavior; if (behavior != null) { @@ -405,8 +405,6 @@ public enum State { @Override public void onRenderPass(RenderEvent event) { - System.out.println(event.getPartialTicks() + " " + ctx.player().getXRot() + " " + ctx.player().getYRot() + " " + ctx.player().xRotO + " " + ctx.player().yRotO); - if (this.behavior != null) this.behavior.onRenderPass(event); } diff --git a/src/main/java/baritone/process/elytra/ElytraBehavior.java b/src/main/java/baritone/process/elytra/ElytraBehavior.java index 2ba8744fb..d4913f466 100644 --- a/src/main/java/baritone/process/elytra/ElytraBehavior.java +++ b/src/main/java/baritone/process/elytra/ElytraBehavior.java @@ -24,6 +24,7 @@ import baritone.api.event.events.*; import baritone.api.pathing.goals.GoalBlock; import baritone.api.utils.*; +import baritone.api.utils.input.Input; import baritone.process.ElytraProcess; import baritone.utils.BlockStateInterface; import baritone.utils.IRenderer; @@ -42,6 +43,7 @@ import net.minecraft.world.inventory.ClickType; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; +import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.ClipContext; import net.minecraft.world.level.chunk.ChunkSource; import net.minecraft.world.level.chunk.LevelChunk; @@ -100,7 +102,7 @@ public final class ElytraBehavior implements Helper { private BlockStateInterface bsi; private final BlockStateOctreeInterface boi; - public final BlockPos destination; + public final BetterBlockPos destination; private final boolean appendDestination; private final ExecutorService solverExecutor; @@ -121,7 +123,7 @@ public ElytraBehavior(Baritone baritone, ElytraProcess process, BlockPos destina this.blockedLines = new CopyOnWriteArrayList<>(); this.pathManager = this.new PathManager(); this.process = process; - this.destination = destination; + this.destination = new BetterBlockPos(destination); this.appendDestination = appendDestination; this.solverExecutor = Executors.newSingleThreadExecutor(); this.nextTickBoostCounter = new int[2]; @@ -172,9 +174,9 @@ public CompletableFuture pathToDestination(final BlockPos from) { .thenRun(() -> { final double distance = this.path.get(0).distanceTo(this.path.get(this.path.size() - 1)); if (this.completePath) { - logDirect(String.format("Computed path (%.1f blocks in %.4f seconds)", distance, (System.nanoTime() - start) / 1e9d)); + logVerbose(String.format("Computed path (%.1f blocks in %.4f seconds)", distance, (System.nanoTime() - start) / 1e9d)); } else { - logDirect(String.format("Computed segment (Next %.1f blocks in %.4f seconds)", distance, (System.nanoTime() - start) / 1e9d)); + logVerbose(String.format("Computed segment (Next %.1f blocks in %.4f seconds)", distance, (System.nanoTime() - start) / 1e9d)); } }) .whenComplete((result, ex) -> { @@ -190,16 +192,16 @@ public CompletableFuture pathToDestination(final BlockPos from) { }); } - public CompletableFuture pathRecalcSegment(final int upToIncl) { + public CompletableFuture pathRecalcSegment(final OptionalInt upToIncl) { if (this.recalculating) { throw new IllegalStateException("already recalculating"); } this.recalculating = true; - final List after = this.path.subList(upToIncl + 1, this.path.size()); + final List after = upToIncl.isPresent() ? this.path.subList(upToIncl.getAsInt() + 1, this.path.size()) : Collections.emptyList(); final boolean complete = this.completePath; - return this.path0(ctx.playerFeet(), this.path.get(upToIncl), segment -> segment.append(after.stream(), complete)) + return this.path0(ctx.playerFeet(), upToIncl.isPresent() ? this.path.get(upToIncl.getAsInt()) : ElytraBehavior.this.destination, segment -> segment.append(after.stream(), complete || (segment.isFinished() && !upToIncl.isPresent()))) .whenComplete((result, ex) -> { this.recalculating = false; if (ex != null) { @@ -229,9 +231,9 @@ public void pathNextSegment(final int afterIncl) { final double distance = this.path.get(0).distanceTo(this.path.get(recompute)); if (this.completePath) { - logDirect(String.format("Computed path (%.1f blocks in %.4f seconds)", distance, (System.nanoTime() - start) / 1e9d)); + logVerbose(String.format("Computed path (%.1f blocks in %.4f seconds)", distance, (System.nanoTime() - start) / 1e9d)); } else { - logDirect(String.format("Computed segment (Next %.1f blocks in %.4f seconds)", distance, (System.nanoTime() - start) / 1e9d)); + logVerbose(String.format("Computed segment (Next %.1f blocks in %.4f seconds)", distance, (System.nanoTime() - start) / 1e9d)); } }) .whenComplete((result, ex) -> { @@ -241,7 +243,7 @@ public void pathNextSegment(final int afterIncl) { if (cause instanceof PathCalculationException) { logDirect("Failed to compute next segment"); if (ctx.player().distanceToSqr(pathStart.getCenter()) < 16 * 16) { - logDirect("Player is near the segment start, therefore repeating this calculation is pointless. Marking as complete"); + logVerbose("Player is near the segment start, therefore repeating this calculation is pointless. Marking as complete"); completePath = true; } } else { @@ -302,7 +304,7 @@ private void pathfindAroundObstacles() { int rangeStartIncl = playerNear; int rangeEndExcl = playerNear; - while (rangeEndExcl < path.size() && ctx.world().isLoaded(path.get(rangeEndExcl))) { + while (rangeEndExcl < path.size() && context.hasChunk(new ChunkPos(path.get(rangeEndExcl)))) { rangeEndExcl++; } // rangeEndExcl now represents an index either not in the path, or just outside render distance @@ -317,9 +319,9 @@ private void pathfindAroundObstacles() { } if (ElytraBehavior.this.process.state != ElytraProcess.State.LANDING && this.ticksNearUnchanged > 100) { - this.pathRecalcSegment(rangeEndExcl - 1) + this.pathRecalcSegment(OptionalInt.of(rangeEndExcl - 1)) .thenRun(() -> { - logDirect("Recalculating segment, no progress in last 100 ticks"); + logVerbose("Recalculating segment, no progress in last 100 ticks"); }); this.ticksNearUnchanged = 0; return; @@ -332,14 +334,21 @@ private void pathfindAroundObstacles() { } if (!ElytraBehavior.this.clearView(this.path.getVec(i), this.path.getVec(i + 1), false)) { // obstacle. where do we return to pathing? - // find the next valid segment + // if the end of render distance is closer to goal, then that's fine, otherwise we'd be "digging our hole deeper" and making an already bad backtrack worse + OptionalInt rejoinMainPathAt; + if (this.path.get(rangeEndExcl - 1).distanceSq(ElytraBehavior.this.destination) < ctx.playerFeet().distanceSq(ElytraBehavior.this.destination)) { + rejoinMainPathAt = OptionalInt.of(rangeEndExcl - 1); // rejoin after current render distance + } else { + rejoinMainPathAt = OptionalInt.empty(); // large backtrack detected. ignore render distance, rejoin later on + } + final BetterBlockPos blockage = this.path.get(i); - final double distance = ctx.playerFeet().distanceTo(this.path.get(rangeEndExcl - 1)); + final double distance = ctx.playerFeet().distanceTo(this.path.get(rejoinMainPathAt.orElse(path.size() - 1))); final long start = System.nanoTime(); - this.pathRecalcSegment(rangeEndExcl - 1) + this.pathRecalcSegment(rejoinMainPathAt) .thenRun(() -> { - logDirect(String.format("Recalculated segment around path blockage near %s %s %s (next %.1f blocks in %.4f seconds)", + logVerbose(String.format("Recalculated segment around path blockage near %s %s %s (next %.1f blocks in %.4f seconds)", SettingsUtil.maybeCensor(blockage.x), SettingsUtil.maybeCensor(blockage.y), SettingsUtil.maybeCensor(blockage.z), @@ -351,7 +360,7 @@ private void pathfindAroundObstacles() { } } if (!canSeeAny && rangeStartIncl < rangeEndExcl - 2 && process.state != ElytraProcess.State.GET_TO_JUMP) { - this.pathRecalcSegment(rangeEndExcl - 1).thenRun(() -> logDirect("Recalculated segment since no path points were visible")); + this.pathRecalcSegment(OptionalInt.of(rangeEndExcl - 1)).thenRun(() -> logVerbose("Recalculated segment since no path points were visible")); } } @@ -572,10 +581,10 @@ public void tick() { trySwapElytra(); if (ctx.player().horizontalCollision) { - logDirect("hbonk"); + logVerbose("hbonk"); } if (ctx.player().verticalCollision) { - logDirect("vbonk"); + logVerbose("vbonk"); } final SolverContext solverContext = this.new SolverContext(false); @@ -594,15 +603,20 @@ public void tick() { this.deployedFireworkLastTick = false; } + final boolean inLava = ctx.player().isInLava(); + if (inLava) { + baritone.getInputOverrideHandler().setInputForceState(Input.JUMP, true); + } + if (solution == null) { - logDirect("no solution"); + logVerbose("no solution"); return; } baritone.getLookBehavior().updateTarget(solution.rotation, false); if (!solution.solvedPitch) { - logDirect("no pitch solution, probably gonna crash in a few ticks LOL!!!"); + logVerbose("no pitch solution, probably gonna crash in a few ticks LOL!!!"); return; } else { this.aimPos = new BetterBlockPos(solution.goingTo.x, solution.goingTo.y, solution.goingTo.z); @@ -612,7 +626,7 @@ public void tick() { solution.context.start, solution.goingTo, solution.context.boost.isBoosted(), - solution.forceUseFirework + solution.forceUseFirework || inLava ); } @@ -744,7 +758,7 @@ private void tickUseFireworks(final Vec3 start, final Vec3 goingTo, final boolea logDirect("no fireworks"); return; } - logDirect("attempting to use firework" + (forceUseFirework ? " (forced)" : "")); + logVerbose("attempting to use firework" + (forceUseFirework ? " (forced)" : "")); ctx.playerController().processRightClick(ctx.player(), ctx.world(), InteractionHand.MAIN_HAND); this.minimumBoostTicks = 10 * (1 + getFireworkBoost(ctx.player().getItemInHand(InteractionHand.MAIN_HAND)).orElse(0)); this.remainingFireworkTicks = 10; @@ -994,7 +1008,7 @@ public boolean clearView(Vec3 start, Vec3 dest, boolean ignoreLava) { // if start == dest then the cpp raytracer dies clear = start.equals(dest) || this.context.raytrace(start, dest); } else { - clear = ctx.world().clip(new ClipContext(start, dest, ClipContext.Block.COLLIDER, ClipContext.Fluid.ANY, ctx.player())).getType() == HitResult.Type.MISS; + clear = ctx.world().clip(new ClipContext(start, dest, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, ctx.player())).getType() == HitResult.Type.MISS; } if (Baritone.settings().elytraRenderRaytraces.value) { @@ -1303,4 +1317,10 @@ private void trySwapElytra() { queueWindowClick(ctx.player().inventoryMenu.containerId, slotId, 0, ClickType.PICKUP); } } + + void logVerbose(String message) { + if (Baritone.settings().elytraChatSpam.value) { + logDebug(message); + } + } } diff --git a/src/main/java/baritone/process/elytra/NetherPathfinderContext.java b/src/main/java/baritone/process/elytra/NetherPathfinderContext.java index de666a0a8..aa9f4965a 100644 --- a/src/main/java/baritone/process/elytra/NetherPathfinderContext.java +++ b/src/main/java/baritone/process/elytra/NetherPathfinderContext.java @@ -60,6 +60,10 @@ public NetherPathfinderContext(long seed) { this.executor = Executors.newSingleThreadExecutor(); } + public boolean hasChunk(ChunkPos pos) { + return NetherPathfinder.hasChunkFromJava(this.context, pos.x, pos.z); + } + public void queueCacheCulling(int chunkX, int chunkZ, int maxDistanceBlocks, BlockStateOctreeInterface boi) { this.executor.execute(() -> { synchronized (this.cullingLock) { diff --git a/src/main/java/baritone/utils/BlockStateInterface.java b/src/main/java/baritone/utils/BlockStateInterface.java index 2931b9392..095694db9 100644 --- a/src/main/java/baritone/utils/BlockStateInterface.java +++ b/src/main/java/baritone/utils/BlockStateInterface.java @@ -132,7 +132,7 @@ public BlockState get0(int x, int y, int z) { // Mickey resigned prevCached = region; cached = region; } - BlockState type = cached.getBlock(x & 511, y, z & 511); + BlockState type = cached.getBlock(x & 511, y + world.dimensionType().minY(), z & 511); if (type == null) { return AIR; }