From b005ce8e6b18036802cd0233902194fff504f36c Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 17 Jan 2019 18:54:37 -0800 Subject: [PATCH 01/58] mega cancer render cached chunks --- .../launch/mixins/MixinChunkCache.java | 46 +++++++++++++++++++ src/launch/resources/mixins.baritone.json | 1 + src/main/java/baritone/Baritone.java | 7 ++- .../java/baritone/event/GameEventHandler.java | 4 ++ 4 files changed, 54 insertions(+), 4 deletions(-) create mode 100644 src/launch/java/baritone/launch/mixins/MixinChunkCache.java diff --git a/src/launch/java/baritone/launch/mixins/MixinChunkCache.java b/src/launch/java/baritone/launch/mixins/MixinChunkCache.java new file mode 100644 index 00000000..17fefb6d --- /dev/null +++ b/src/launch/java/baritone/launch/mixins/MixinChunkCache.java @@ -0,0 +1,46 @@ +/* + * 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 . + */ + +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.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.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(ChunkCache.class) +public class MixinChunkCache { + @Inject( + method = "getBlockState", + at = @At("HEAD"), + cancellable = true + ) + private void getBlockState(BlockPos pos, CallbackInfoReturnable ci) { + Baritone baritone = (Baritone) BaritoneAPI.getProvider().getPrimaryBaritone(); + IPlayerContext ctx = baritone.getPlayerContext(); + if (ctx.player() != null && ctx.world() != null && baritone.bsi != null) { + ci.setReturnValue(baritone.bsi.get0(pos)); + //ci.setReturnValue(Blocks.DIRT.getDefaultState()); + } + } +} diff --git a/src/launch/resources/mixins.baritone.json b/src/launch/resources/mixins.baritone.json index 09ebbafd..eab28fdb 100644 --- a/src/launch/resources/mixins.baritone.json +++ b/src/launch/resources/mixins.baritone.json @@ -10,6 +10,7 @@ "client": [ "MixinAnvilChunkLoader", "MixinBlockPos", + "MixinChunkCache", "MixinChunkProviderClient", "MixinChunkProviderServer", "MixinEntity", diff --git a/src/main/java/baritone/Baritone.java b/src/main/java/baritone/Baritone.java index c3a8e272..3414fdf3 100755 --- a/src/main/java/baritone/Baritone.java +++ b/src/main/java/baritone/Baritone.java @@ -29,10 +29,7 @@ import baritone.process.CustomGoalProcess; import baritone.process.FollowProcess; import baritone.process.GetToBlockProcess; import baritone.process.MineProcess; -import baritone.utils.BaritoneAutoTest; -import baritone.utils.ExampleBaritoneControl; -import baritone.utils.InputOverrideHandler; -import baritone.utils.PathingControlManager; +import baritone.utils.*; import baritone.utils.player.PrimaryPlayerContext; import net.minecraft.client.Minecraft; @@ -89,6 +86,8 @@ public class Baritone implements IBaritone { private IPlayerContext playerContext; private WorldProvider worldProvider; + public BlockStateInterface bsi; + Baritone() { this.gameEventHandler = new GameEventHandler(this); } diff --git a/src/main/java/baritone/event/GameEventHandler.java b/src/main/java/baritone/event/GameEventHandler.java index e85c46de..55bf21b7 100644 --- a/src/main/java/baritone/event/GameEventHandler.java +++ b/src/main/java/baritone/event/GameEventHandler.java @@ -23,6 +23,7 @@ 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; @@ -46,6 +47,9 @@ public final class GameEventHandler implements IEventBus, Helper { @Override public final void onTick(TickEvent event) { + try { + baritone.bsi = new BlockStateInterface(baritone.getPlayerContext(), true); + } catch (Exception ex) {} listeners.forEach(l -> l.onTick(event)); } From 735cf47c35e6f6c3f1e5160143edb51b55b011ff Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 28 Jan 2019 17:34:14 -0800 Subject: [PATCH 02/58] actually works --- src/api/java/baritone/api/Settings.java | 5 ++ .../launch/mixins/MixinChunkCache.java | 16 ++++++- .../launch/mixins/MixinChunkRenderWorker.java | 46 +++++++++++++++++++ src/launch/resources/mixins.baritone.json | 1 + .../utils/ExampleBaritoneControl.java | 8 ++++ 5 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 src/launch/java/baritone/launch/mixins/MixinChunkRenderWorker.java diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 1b4f62e0..46c835cd 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -445,6 +445,11 @@ public class Settings { */ public Setting pathThroughCachedOnly = new Setting<>(false); + /** + * 😎 + */ + public Setting renderCachedChunks = new Setting<>(false); + /** * Whether or not to use the "#" command prefix */ diff --git a/src/launch/java/baritone/launch/mixins/MixinChunkCache.java b/src/launch/java/baritone/launch/mixins/MixinChunkCache.java index 17fefb6d..f8d0a0bf 100644 --- a/src/launch/java/baritone/launch/mixins/MixinChunkCache.java +++ b/src/launch/java/baritone/launch/mixins/MixinChunkCache.java @@ -38,9 +38,21 @@ public class MixinChunkCache { private void getBlockState(BlockPos pos, CallbackInfoReturnable ci) { Baritone baritone = (Baritone) BaritoneAPI.getProvider().getPrimaryBaritone(); IPlayerContext ctx = baritone.getPlayerContext(); - if (ctx.player() != null && ctx.world() != null && baritone.bsi != null) { + if (ctx.player() != null && ctx.world() != null && baritone.bsi != null && Baritone.settings().renderCachedChunks.get()) { ci.setReturnValue(baritone.bsi.get0(pos)); - //ci.setReturnValue(Blocks.DIRT.getDefaultState()); + } + } + + @Inject( + method = "isEmpty", + at = @At("HEAD"), + cancellable = true + ) + private void isEmpty(CallbackInfoReturnable ci) { + Baritone baritone = (Baritone) BaritoneAPI.getProvider().getPrimaryBaritone(); + IPlayerContext ctx = baritone.getPlayerContext(); + if (ctx.player() != null && ctx.world() != null && baritone.bsi != null && Baritone.settings().renderCachedChunks.get()) { + ci.setReturnValue(false); } } } diff --git a/src/launch/java/baritone/launch/mixins/MixinChunkRenderWorker.java b/src/launch/java/baritone/launch/mixins/MixinChunkRenderWorker.java new file mode 100644 index 00000000..493d4869 --- /dev/null +++ b/src/launch/java/baritone/launch/mixins/MixinChunkRenderWorker.java @@ -0,0 +1,46 @@ +/* + * 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 . + */ + +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.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(ChunkRenderWorker.class) +public class MixinChunkRenderWorker { + @Inject( + method = "isChunkExisting", + at = @At("HEAD"), + cancellable = true + ) + private void isChunkExisting(BlockPos pos, World world, CallbackInfoReturnable ci) { + Baritone baritone = (Baritone) BaritoneAPI.getProvider().getPrimaryBaritone(); + IPlayerContext ctx = baritone.getPlayerContext(); + if (ctx.player() != null && ctx.world() != null && baritone.bsi != null && Baritone.settings().renderCachedChunks.get()) { + ci.setReturnValue(baritone.bsi.isLoaded(pos.getX(), pos.getZ())); + } + } +} + diff --git a/src/launch/resources/mixins.baritone.json b/src/launch/resources/mixins.baritone.json index eab28fdb..9a7dce45 100644 --- a/src/launch/resources/mixins.baritone.json +++ b/src/launch/resources/mixins.baritone.json @@ -13,6 +13,7 @@ "MixinChunkCache", "MixinChunkProviderClient", "MixinChunkProviderServer", + "MixinChunkRenderWorker", "MixinEntity", "MixinEntityLivingBase", "MixinEntityPlayerSP", diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java index 508a5e1b..f5d054be 100644 --- a/src/main/java/baritone/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java @@ -24,6 +24,7 @@ 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; @@ -35,6 +36,7 @@ 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; @@ -284,6 +286,12 @@ 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> contents = baritone.getMemoryBehavior().echest(); if (contents.isPresent()) { From 784b2f541d39b61b9ac2b0a9133a9f3044efad69 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 28 Jan 2019 19:02:07 -0800 Subject: [PATCH 03/58] lol --- .../mixins/MixinChunkRenderContainer.java | 40 +++++++++++++++++++ src/launch/resources/mixins.baritone.json | 1 + 2 files changed, 41 insertions(+) create mode 100644 src/launch/java/baritone/launch/mixins/MixinChunkRenderContainer.java diff --git a/src/launch/java/baritone/launch/mixins/MixinChunkRenderContainer.java b/src/launch/java/baritone/launch/mixins/MixinChunkRenderContainer.java new file mode 100644 index 00000000..49af7d72 --- /dev/null +++ b/src/launch/java/baritone/launch/mixins/MixinChunkRenderContainer.java @@ -0,0 +1,40 @@ +/* + * 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 . + */ + +package baritone.launch.mixins; + +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.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; + +@Mixin(ChunkRenderContainer.class) +public class MixinChunkRenderContainer { + @Inject( + method = "preRenderChunk", + at = @At("HEAD") + ) + private void preRenderChunk(RenderChunk renderChunkIn, CallbackInfo ci) { + if (Minecraft.getMinecraft().world.getChunk(renderChunkIn.getPosition()).isEmpty()) { + GlStateManager.translate(0, Math.sin(System.currentTimeMillis() / 1000D + (renderChunkIn.getPosition().getX() + renderChunkIn.getPosition().getZ()) / 16D) * 4, 0); + } + } +} diff --git a/src/launch/resources/mixins.baritone.json b/src/launch/resources/mixins.baritone.json index 9a7dce45..10e3510d 100644 --- a/src/launch/resources/mixins.baritone.json +++ b/src/launch/resources/mixins.baritone.json @@ -13,6 +13,7 @@ "MixinChunkCache", "MixinChunkProviderClient", "MixinChunkProviderServer", + "MixinChunkRenderContainer", "MixinChunkRenderWorker", "MixinEntity", "MixinEntityLivingBase", From 5179cfc5ba3a708445b6878bc2db72c9dc891168 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 28 Jan 2019 21:28:26 -0800 Subject: [PATCH 04/58] semitransparency working --- .../launch/mixins/MixinChunkRenderContainer.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/launch/java/baritone/launch/mixins/MixinChunkRenderContainer.java b/src/launch/java/baritone/launch/mixins/MixinChunkRenderContainer.java index 49af7d72..1894caaa 100644 --- a/src/launch/java/baritone/launch/mixins/MixinChunkRenderContainer.java +++ b/src/launch/java/baritone/launch/mixins/MixinChunkRenderContainer.java @@ -21,11 +21,14 @@ 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( @@ -34,7 +37,12 @@ public class MixinChunkRenderContainer { ) private void preRenderChunk(RenderChunk renderChunkIn, CallbackInfo ci) { if (Minecraft.getMinecraft().world.getChunk(renderChunkIn.getPosition()).isEmpty()) { - GlStateManager.translate(0, Math.sin(System.currentTimeMillis() / 1000D + (renderChunkIn.getPosition().getX() + renderChunkIn.getPosition().getZ()) / 16D) * 4, 0); + GlStateManager.enableAlpha(); + GlStateManager.enableBlend(); + GL14.glBlendColor(0, 0, 0, 0.5F); + GlStateManager.tryBlendFuncSeparate(GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA, GL_ONE, GL_ZERO); + } else { + GlStateManager.tryBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO); } } } From b471d7419efaa24053c9128b2efcbf9b68cda864 Mon Sep 17 00:00:00 2001 From: Brady Date: Tue, 29 Jan 2019 12:41:14 -0600 Subject: [PATCH 05/58] Replace most of the @Inject usages for cancer render with @Redirect --- .../launch/mixins/MixinChunkCache.java | 58 -------------- .../mixins/MixinChunkRenderContainer.java | 1 + .../launch/mixins/MixinChunkRenderWorker.java | 33 +++++--- .../launch/mixins/MixinRenderChunk.java | 75 +++++++++++++++++++ src/launch/resources/mixins.baritone.json | 2 +- 5 files changed, 98 insertions(+), 71 deletions(-) delete mode 100644 src/launch/java/baritone/launch/mixins/MixinChunkCache.java create mode 100644 src/launch/java/baritone/launch/mixins/MixinRenderChunk.java diff --git a/src/launch/java/baritone/launch/mixins/MixinChunkCache.java b/src/launch/java/baritone/launch/mixins/MixinChunkCache.java deleted file mode 100644 index f8d0a0bf..00000000 --- a/src/launch/java/baritone/launch/mixins/MixinChunkCache.java +++ /dev/null @@ -1,58 +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 . - */ - -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.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.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(ChunkCache.class) -public class MixinChunkCache { - @Inject( - method = "getBlockState", - at = @At("HEAD"), - cancellable = true - ) - private void getBlockState(BlockPos pos, CallbackInfoReturnable ci) { - Baritone baritone = (Baritone) BaritoneAPI.getProvider().getPrimaryBaritone(); - IPlayerContext ctx = baritone.getPlayerContext(); - if (ctx.player() != null && ctx.world() != null && baritone.bsi != null && Baritone.settings().renderCachedChunks.get()) { - ci.setReturnValue(baritone.bsi.get0(pos)); - } - } - - @Inject( - method = "isEmpty", - at = @At("HEAD"), - cancellable = true - ) - private void isEmpty(CallbackInfoReturnable ci) { - Baritone baritone = (Baritone) BaritoneAPI.getProvider().getPrimaryBaritone(); - IPlayerContext ctx = baritone.getPlayerContext(); - if (ctx.player() != null && ctx.world() != null && baritone.bsi != null && Baritone.settings().renderCachedChunks.get()) { - ci.setReturnValue(false); - } - } -} diff --git a/src/launch/java/baritone/launch/mixins/MixinChunkRenderContainer.java b/src/launch/java/baritone/launch/mixins/MixinChunkRenderContainer.java index 1894caaa..19cbfc14 100644 --- a/src/launch/java/baritone/launch/mixins/MixinChunkRenderContainer.java +++ b/src/launch/java/baritone/launch/mixins/MixinChunkRenderContainer.java @@ -31,6 +31,7 @@ import static org.lwjgl.opengl.GL11.*; @Mixin(ChunkRenderContainer.class) public class MixinChunkRenderContainer { + @Inject( method = "preRenderChunk", at = @At("HEAD") diff --git a/src/launch/java/baritone/launch/mixins/MixinChunkRenderWorker.java b/src/launch/java/baritone/launch/mixins/MixinChunkRenderWorker.java index 493d4869..3621b664 100644 --- a/src/launch/java/baritone/launch/mixins/MixinChunkRenderWorker.java +++ b/src/launch/java/baritone/launch/mixins/MixinChunkRenderWorker.java @@ -24,23 +24,32 @@ 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.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import org.spongepowered.asm.mixin.injection.Redirect; @Mixin(ChunkRenderWorker.class) -public class MixinChunkRenderWorker { - @Inject( - method = "isChunkExisting", - at = @At("HEAD"), - cancellable = true +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 void isChunkExisting(BlockPos pos, World world, CallbackInfoReturnable ci) { - Baritone baritone = (Baritone) BaritoneAPI.getProvider().getPrimaryBaritone(); - IPlayerContext ctx = baritone.getPlayerContext(); - if (ctx.player() != null && ctx.world() != null && baritone.bsi != null && Baritone.settings().renderCachedChunks.get()) { - ci.setReturnValue(baritone.bsi.isLoaded(pos.getX(), pos.getZ())); + 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()); + } } + + return this.isChunkExisting(pos, world); } } diff --git a/src/launch/java/baritone/launch/mixins/MixinRenderChunk.java b/src/launch/java/baritone/launch/mixins/MixinRenderChunk.java new file mode 100644 index 00000000..47402c6b --- /dev/null +++ b/src/launch/java/baritone/launch/mixins/MixinRenderChunk.java @@ -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 . + */ + +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 (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 false; + } + } + + return chunkCache.isEmpty(); + } + + @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); + } +} diff --git a/src/launch/resources/mixins.baritone.json b/src/launch/resources/mixins.baritone.json index 10e3510d..aa9a724f 100644 --- a/src/launch/resources/mixins.baritone.json +++ b/src/launch/resources/mixins.baritone.json @@ -10,7 +10,6 @@ "client": [ "MixinAnvilChunkLoader", "MixinBlockPos", - "MixinChunkCache", "MixinChunkProviderClient", "MixinChunkProviderServer", "MixinChunkRenderContainer", @@ -23,6 +22,7 @@ "MixinMinecraft", "MixinNetHandlerPlayClient", "MixinNetworkManager", + "MixinRenderChunk", "MixinWorldClient" ] } \ No newline at end of file From 9028564c10d64ff4ed33b5200a2eaf08514c6567 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 29 Jan 2019 13:54:54 -0800 Subject: [PATCH 06/58] only when the setting is enabled --- .../mixins/MixinChunkRenderContainer.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/launch/java/baritone/launch/mixins/MixinChunkRenderContainer.java b/src/launch/java/baritone/launch/mixins/MixinChunkRenderContainer.java index 19cbfc14..8075f1f2 100644 --- a/src/launch/java/baritone/launch/mixins/MixinChunkRenderContainer.java +++ b/src/launch/java/baritone/launch/mixins/MixinChunkRenderContainer.java @@ -17,6 +17,7 @@ package baritone.launch.mixins; +import baritone.Baritone; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ChunkRenderContainer; import net.minecraft.client.renderer.GlStateManager; @@ -37,13 +38,15 @@ public class MixinChunkRenderContainer { at = @At("HEAD") ) private void preRenderChunk(RenderChunk renderChunkIn, CallbackInfo ci) { - if (Minecraft.getMinecraft().world.getChunk(renderChunkIn.getPosition()).isEmpty()) { - GlStateManager.enableAlpha(); - GlStateManager.enableBlend(); - GL14.glBlendColor(0, 0, 0, 0.5F); - GlStateManager.tryBlendFuncSeparate(GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA, GL_ONE, GL_ZERO); - } else { - GlStateManager.tryBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO); + if (Baritone.settings().renderCachedChunks.get()) { + if (Minecraft.getMinecraft().world.getChunk(renderChunkIn.getPosition()).isEmpty()) { + GlStateManager.enableAlpha(); + GlStateManager.enableBlend(); + GL14.glBlendColor(0, 0, 0, 0.5F); + GlStateManager.tryBlendFuncSeparate(GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA, GL_ONE, GL_ZERO); + } else { + GlStateManager.tryBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO); + } } } } From 1968f47fc914a134a12589c260428eb31fee1c9d Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 29 Jan 2019 19:44:23 -0800 Subject: [PATCH 07/58] add a setting to play with --- src/api/java/baritone/api/Settings.java | 6 ++++++ .../baritone/launch/mixins/MixinChunkRenderContainer.java | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 9cb4b2ba..a1ae9c71 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -464,6 +464,12 @@ public final class Settings { */ public Setting renderCachedChunks = new Setting<>(false); + /** + * 0.0f = not visible, fully transparent + * 1.0f = fully opaque + */ + public Setting cachedChunksOpacity = new Setting<>(0.5f); + /** * Whether or not to use the "#" command prefix */ diff --git a/src/launch/java/baritone/launch/mixins/MixinChunkRenderContainer.java b/src/launch/java/baritone/launch/mixins/MixinChunkRenderContainer.java index 8075f1f2..286ca5d4 100644 --- a/src/launch/java/baritone/launch/mixins/MixinChunkRenderContainer.java +++ b/src/launch/java/baritone/launch/mixins/MixinChunkRenderContainer.java @@ -42,7 +42,7 @@ public class MixinChunkRenderContainer { if (Minecraft.getMinecraft().world.getChunk(renderChunkIn.getPosition()).isEmpty()) { GlStateManager.enableAlpha(); GlStateManager.enableBlend(); - GL14.glBlendColor(0, 0, 0, 0.5F); + GL14.glBlendColor(1, 1, 1, Baritone.settings().cachedChunksOpacity.get()); GlStateManager.tryBlendFuncSeparate(GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA, GL_ONE, GL_ZERO); } else { GlStateManager.tryBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO); From 06b3c5ddb596c425d073df41e862556b837c12ad Mon Sep 17 00:00:00 2001 From: Brady Date: Wed, 30 Jan 2019 12:42:26 -0600 Subject: [PATCH 08/58] LeijurvUtils --- .../mixins/MixinChunkRenderContainer.java | 4 +- .../java/baritone/utils/LeijurvUtils.java | 85 +++++++++++++++++++ 2 files changed, 87 insertions(+), 2 deletions(-) create mode 100644 src/main/java/baritone/utils/LeijurvUtils.java diff --git a/src/launch/java/baritone/launch/mixins/MixinChunkRenderContainer.java b/src/launch/java/baritone/launch/mixins/MixinChunkRenderContainer.java index 286ca5d4..4a7830f5 100644 --- a/src/launch/java/baritone/launch/mixins/MixinChunkRenderContainer.java +++ b/src/launch/java/baritone/launch/mixins/MixinChunkRenderContainer.java @@ -18,11 +18,11 @@ package baritone.launch.mixins; import baritone.Baritone; +import baritone.utils.LeijurvUtils; 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; @@ -42,7 +42,7 @@ public class MixinChunkRenderContainer { if (Minecraft.getMinecraft().world.getChunk(renderChunkIn.getPosition()).isEmpty()) { GlStateManager.enableAlpha(); GlStateManager.enableBlend(); - GL14.glBlendColor(1, 1, 1, Baritone.settings().cachedChunksOpacity.get()); + LeijurvUtils.updateAndGet().run(); GlStateManager.tryBlendFuncSeparate(GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA, GL_ONE, GL_ZERO); } else { GlStateManager.tryBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO); diff --git a/src/main/java/baritone/utils/LeijurvUtils.java b/src/main/java/baritone/utils/LeijurvUtils.java new file mode 100644 index 00000000..05aa65db --- /dev/null +++ b/src/main/java/baritone/utils/LeijurvUtils.java @@ -0,0 +1,85 @@ +/* + * 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 . + */ + +package baritone.utils; + +import baritone.Baritone; +import org.lwjgl.opengl.GL14; + +import java.lang.invoke.LambdaMetafactory; +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; +import java.lang.invoke.MethodType; + +/** + * Is your name Leijurv and you have a severe handicap for X? Well, no worries! This class has YOU covered! + * + * @author Brady + * @since 1/30/2019 + */ +public class LeijurvUtils { + + private static final MethodHandles.Lookup LOOKUP = MethodHandles.lookup(); + + private static Runnable glBlendColorChunkOwnage = null; + private static float existingAlpha; + + public static Runnable updateAndGet() { + float currentAlpha = Baritone.settings().cachedChunksOpacity.get(); + if (glBlendColorChunkOwnage == null || existingAlpha != currentAlpha) { + glBlendColorChunkOwnage = createBlendColorRunnable(1, 1, 1, existingAlpha = currentAlpha); + } + return glBlendColorChunkOwnage; + } + + /** + * Hahhahaha + * WHY???? you may ask. well: + * + * basically proguard sucks (actually the gradle automated setup for it does) and I'm too + * lazy to actually make it work. (It is unable to recognize the GL14 class). This is an + * AWESOME workaround by creating a runnable for the {@code glBlendColor} method without having + * to directly reference the method itself with the added bonus of pre-filling the invocation arguments. + * + * @param r red + * @param g green + * @param b blue + * @param a alpha + * @return Epic runnable that calls {@link GL14#glBlendColor(float, float, float, float)} + */ + public static Runnable createBlendColorRunnable(float r, float g, float b, float a) { + try { + MethodHandle glBlendColor = LOOKUP.findStatic( + Class.forName("org.lwjgl.opengl.GL14"), + "glBlendColor", + MethodType.methodType(Void.TYPE, Float.TYPE, Float.TYPE, Float.TYPE, Float.TYPE) + ); + + // noinspection unchecked + return (Runnable) LambdaMetafactory.metafactory( + LOOKUP, + "run", + glBlendColor.type().changeReturnType(Runnable.class), + MethodType.methodType(Void.TYPE), + glBlendColor, + MethodType.methodType(Void.TYPE) + ).dynamicInvoker().invoke(r, g, b, a); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } +} From 8947eff3b19b7705f6127bdb7a9700660c160a33 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 30 Jan 2019 11:42:46 -0800 Subject: [PATCH 09/58] bsi might be old --- .../java/baritone/launch/mixins/MixinChunkRenderWorker.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/launch/java/baritone/launch/mixins/MixinChunkRenderWorker.java b/src/launch/java/baritone/launch/mixins/MixinChunkRenderWorker.java index 3621b664..a8247a9b 100644 --- a/src/launch/java/baritone/launch/mixins/MixinChunkRenderWorker.java +++ b/src/launch/java/baritone/launch/mixins/MixinChunkRenderWorker.java @@ -31,7 +31,8 @@ import org.spongepowered.asm.mixin.injection.Redirect; @Mixin(ChunkRenderWorker.class) public abstract class MixinChunkRenderWorker { - @Shadow protected abstract boolean isChunkExisting(BlockPos pos, World worldIn); + @Shadow + protected abstract boolean isChunkExisting(BlockPos pos, World worldIn); @Redirect( method = "processTask", @@ -45,7 +46,7 @@ public abstract class MixinChunkRenderWorker { 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()); + return baritone.bsi.isLoaded(pos.getX(), pos.getZ()) || this.isChunkExisting(pos, world); } } From 68a9a1439a9b930daa57b7b9d33f263996a3dccc Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 30 Jan 2019 11:45:03 -0800 Subject: [PATCH 10/58] maybe this will allow emoji --- build.gradle | 1 + src/main/java/baritone/behavior/PathingBehavior.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 8583642d..a9477967 100755 --- a/build.gradle +++ b/build.gradle @@ -101,6 +101,7 @@ mixin { javadoc { options.addStringOption('Xwerror', '-quiet') // makes the build fail on travis when there is a javadoc error options.linkSource true + options.encoding "UTF-8" source += sourceSets.api.allJava classpath += sourceSets.api.compileClasspath } diff --git a/src/main/java/baritone/behavior/PathingBehavior.java b/src/main/java/baritone/behavior/PathingBehavior.java index d8454c1f..ea752082 100644 --- a/src/main/java/baritone/behavior/PathingBehavior.java +++ b/src/main/java/baritone/behavior/PathingBehavior.java @@ -147,7 +147,7 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior, synchronized (pathCalcLock) { if (inProgress != null) { // we are calculating - // are we calculating the right thing though? + // are we calculating the right thing though? 🤔 BetterBlockPos calcFrom = inProgress.getStart(); // if current just succeeded, we should be standing in calcFrom, so that's cool and good // but if current just failed, we should discard this calculation since it doesn't start from where we're standing From 90fa347fc2a616984662533e6cd4a0e202a23d15 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 30 Jan 2019 11:54:02 -0800 Subject: [PATCH 11/58] also get rid of warning in build stage --- build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/build.gradle b/build.gradle index a9477967..bcd0fdeb 100755 --- a/build.gradle +++ b/build.gradle @@ -48,6 +48,7 @@ apply plugin: 'org.spongepowered.mixin' sourceCompatibility = targetCompatibility = '1.8' compileJava { sourceCompatibility = targetCompatibility = '1.8' + options.encoding = "UTF-8" } sourceSets { From 22bd5be5a9b9fbb085dbb5be02f0d22b7ea47250 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 30 Jan 2019 11:54:38 -0800 Subject: [PATCH 12/58] explain --- build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index bcd0fdeb..f356a3b2 100755 --- a/build.gradle +++ b/build.gradle @@ -48,7 +48,7 @@ apply plugin: 'org.spongepowered.mixin' sourceCompatibility = targetCompatibility = '1.8' compileJava { sourceCompatibility = targetCompatibility = '1.8' - options.encoding = "UTF-8" + options.encoding = "UTF-8" // allow emoji in comments :^) } sourceSets { @@ -102,7 +102,7 @@ mixin { javadoc { options.addStringOption('Xwerror', '-quiet') // makes the build fail on travis when there is a javadoc error options.linkSource true - options.encoding "UTF-8" + options.encoding "UTF-8" // allow emoji in comments :^) source += sourceSets.api.allJava classpath += sourceSets.api.compileClasspath } From b177ae7ee6494705257ebc6bbeebef89b635aad4 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 30 Jan 2019 11:57:54 -0800 Subject: [PATCH 13/58] proguard can just ignore GL14 reference actually --- scripts/proguard.pro | 3 + .../mixins/MixinChunkRenderContainer.java | 4 +- .../java/baritone/utils/LeijurvUtils.java | 85 ------------------- 3 files changed, 5 insertions(+), 87 deletions(-) delete mode 100644 src/main/java/baritone/utils/LeijurvUtils.java diff --git a/scripts/proguard.pro b/scripts/proguard.pro index 07e1ec41..df6ad43a 100644 --- a/scripts/proguard.pro +++ b/scripts/proguard.pro @@ -12,6 +12,9 @@ -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 diff --git a/src/launch/java/baritone/launch/mixins/MixinChunkRenderContainer.java b/src/launch/java/baritone/launch/mixins/MixinChunkRenderContainer.java index 4a7830f5..e2c1e025 100644 --- a/src/launch/java/baritone/launch/mixins/MixinChunkRenderContainer.java +++ b/src/launch/java/baritone/launch/mixins/MixinChunkRenderContainer.java @@ -18,11 +18,11 @@ package baritone.launch.mixins; import baritone.Baritone; -import baritone.utils.LeijurvUtils; 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; @@ -42,7 +42,7 @@ public class MixinChunkRenderContainer { if (Minecraft.getMinecraft().world.getChunk(renderChunkIn.getPosition()).isEmpty()) { GlStateManager.enableAlpha(); GlStateManager.enableBlend(); - LeijurvUtils.updateAndGet().run(); + GL14.glBlendColor(0, 0, 0, Baritone.settings().cachedChunksOpacity.get()); GlStateManager.tryBlendFuncSeparate(GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA, GL_ONE, GL_ZERO); } else { GlStateManager.tryBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO); diff --git a/src/main/java/baritone/utils/LeijurvUtils.java b/src/main/java/baritone/utils/LeijurvUtils.java deleted file mode 100644 index 05aa65db..00000000 --- a/src/main/java/baritone/utils/LeijurvUtils.java +++ /dev/null @@ -1,85 +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 . - */ - -package baritone.utils; - -import baritone.Baritone; -import org.lwjgl.opengl.GL14; - -import java.lang.invoke.LambdaMetafactory; -import java.lang.invoke.MethodHandle; -import java.lang.invoke.MethodHandles; -import java.lang.invoke.MethodType; - -/** - * Is your name Leijurv and you have a severe handicap for X? Well, no worries! This class has YOU covered! - * - * @author Brady - * @since 1/30/2019 - */ -public class LeijurvUtils { - - private static final MethodHandles.Lookup LOOKUP = MethodHandles.lookup(); - - private static Runnable glBlendColorChunkOwnage = null; - private static float existingAlpha; - - public static Runnable updateAndGet() { - float currentAlpha = Baritone.settings().cachedChunksOpacity.get(); - if (glBlendColorChunkOwnage == null || existingAlpha != currentAlpha) { - glBlendColorChunkOwnage = createBlendColorRunnable(1, 1, 1, existingAlpha = currentAlpha); - } - return glBlendColorChunkOwnage; - } - - /** - * Hahhahaha - * WHY???? you may ask. well: - * - * basically proguard sucks (actually the gradle automated setup for it does) and I'm too - * lazy to actually make it work. (It is unable to recognize the GL14 class). This is an - * AWESOME workaround by creating a runnable for the {@code glBlendColor} method without having - * to directly reference the method itself with the added bonus of pre-filling the invocation arguments. - * - * @param r red - * @param g green - * @param b blue - * @param a alpha - * @return Epic runnable that calls {@link GL14#glBlendColor(float, float, float, float)} - */ - public static Runnable createBlendColorRunnable(float r, float g, float b, float a) { - try { - MethodHandle glBlendColor = LOOKUP.findStatic( - Class.forName("org.lwjgl.opengl.GL14"), - "glBlendColor", - MethodType.methodType(Void.TYPE, Float.TYPE, Float.TYPE, Float.TYPE, Float.TYPE) - ); - - // noinspection unchecked - return (Runnable) LambdaMetafactory.metafactory( - LOOKUP, - "run", - glBlendColor.type().changeReturnType(Runnable.class), - MethodType.methodType(Void.TYPE), - glBlendColor, - MethodType.methodType(Void.TYPE) - ).dynamicInvoker().invoke(r, g, b, a); - } catch (Throwable e) { - throw new RuntimeException(e); - } - } -} From b953da0341344632e54d4b3132a1ce3da35b22f7 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 30 Jan 2019 12:19:15 -0800 Subject: [PATCH 14/58] more accurate isEmpty --- .../launch/mixins/MixinRenderChunk.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/launch/java/baritone/launch/mixins/MixinRenderChunk.java b/src/launch/java/baritone/launch/mixins/MixinRenderChunk.java index 47402c6b..4190ae59 100644 --- a/src/launch/java/baritone/launch/mixins/MixinRenderChunk.java +++ b/src/launch/java/baritone/launch/mixins/MixinRenderChunk.java @@ -43,15 +43,28 @@ public class MixinRenderChunk { ) ) 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) { - return false; + 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 chunkCache.isEmpty(); + return true; } @Redirect( From 272dd7942650d7fb45510e502f6858a3a628b8d1 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 30 Jan 2019 15:49:37 -0800 Subject: [PATCH 15/58] much needed pathing overhaul --- .../pathing/calc/AStarPathFinder.java | 58 +++++-------------- .../pathing/calc/AbstractNodeCostSearch.java | 56 ++++++++++++++---- 2 files changed, 57 insertions(+), 57 deletions(-) diff --git a/src/main/java/baritone/pathing/calc/AStarPathFinder.java b/src/main/java/baritone/pathing/calc/AStarPathFinder.java index b32fc99f..6f44fac2 100644 --- a/src/main/java/baritone/pathing/calc/AStarPathFinder.java +++ b/src/main/java/baritone/pathing/calc/AStarPathFinder.java @@ -25,7 +25,6 @@ import baritone.api.utils.BetterBlockPos; import baritone.pathing.calc.openset.BinaryHeapOpenSet; import baritone.pathing.movement.CalculationContext; import baritone.pathing.movement.Moves; -import baritone.utils.Helper; import baritone.utils.pathing.BetterWorldBorder; import baritone.utils.pathing.Favoring; import baritone.utils.pathing.MutableMoveResult; @@ -37,7 +36,7 @@ import java.util.Optional; * * @author leijurv */ -public final class AStarPathFinder extends AbstractNodeCostSearch implements Helper { +public final class AStarPathFinder extends AbstractNodeCostSearch { private final Favoring favoring; private final CalculationContext calcContext; @@ -55,14 +54,12 @@ public final class AStarPathFinder extends AbstractNodeCostSearch implements Hel startNode.combinedCost = startNode.estimatedCostToGoal; BinaryHeapOpenSet openSet = new BinaryHeapOpenSet(); openSet.insert(startNode); - bestSoFar = new PathNode[COEFFICIENTS.length];//keep track of the best node by the metric of (estimatedCostToGoal + cost / COEFFICIENTS[i]) - double[] bestHeuristicSoFar = new double[COEFFICIENTS.length]; + double[] bestHeuristicSoFar = new double[COEFFICIENTS.length];//keep track of the best node by the metric of (estimatedCostToGoal + cost / COEFFICIENTS[i]) for (int i = 0; i < bestHeuristicSoFar.length; i++) { bestHeuristicSoFar[i] = startNode.estimatedCostToGoal; bestSoFar[i] = startNode; } MutableMoveResult res = new MutableMoveResult(); - Favoring favored = favoring; BetterWorldBorder worldBorder = new BetterWorldBorder(calcContext.world.getWorldBorder()); long startTime = System.currentTimeMillis(); boolean slowPath = Baritone.settings().slowPath.get(); @@ -75,10 +72,10 @@ public final class AStarPathFinder extends AbstractNodeCostSearch implements Hel int numNodes = 0; int numMovementsConsidered = 0; int numEmptyChunk = 0; - boolean favoring = !favored.isEmpty(); + boolean isFavoring = !favoring.isEmpty(); int timeCheckInterval = 1 << 6; int pathingMaxChunkBorderFetch = Baritone.settings().pathingMaxChunkBorderFetch.get(); // grab all settings beforehand so that changing settings during pathing doesn't cause a crash or unpredictable behavior - boolean minimumImprovementRepropagation = Baritone.settings().minimumImprovementRepropagation.get(); + double minimumImprovement = Baritone.settings().minimumImprovementRepropagation.get() ? MIN_IMPROVEMENT : 0; while (!openSet.isEmpty() && numEmptyChunk < pathingMaxChunkBorderFetch && !cancelRequested) { if ((numNodes & (timeCheckInterval - 1)) == 0) { // only call this once every 64 nodes (about half a millisecond) long now = System.currentTimeMillis(); // since nanoTime is slow on windows (takes many microseconds) @@ -136,21 +133,13 @@ public final class AStarPathFinder extends AbstractNodeCostSearch implements Hel throw new IllegalStateException(moves + " " + res.y + " " + (currentNode.y + moves.yOffset)); } long hashCode = BetterBlockPos.longHash(res.x, res.y, res.z); - if (favoring) { + if (isFavoring) { // see issue #18 - actionCost *= favored.calculate(hashCode); + actionCost *= favoring.calculate(hashCode); } PathNode neighbor = getNodeAtPosition(res.x, res.y, res.z, hashCode); double tentativeCost = currentNode.cost + actionCost; - if (tentativeCost < neighbor.cost) { - double improvementBy = neighbor.cost - tentativeCost; - // there are floating point errors caused by random combinations of traverse and diagonal over a flat area - // that means that sometimes there's a cost improvement of like 10 ^ -16 - // it's not worth the time to update the costs, decrease-key the heap, potentially repropagate, etc - if (improvementBy < 0.01 && minimumImprovementRepropagation) { - // who cares about a hundredth of a tick? that's half a millisecond for crying out loud! - continue; - } + if (neighbor.cost - tentativeCost > minimumImprovement) { neighbor.previous = currentNode; neighbor.cost = tentativeCost; neighbor.combinedCost = tentativeCost + neighbor.estimatedCostToGoal; @@ -159,12 +148,9 @@ public final class AStarPathFinder extends AbstractNodeCostSearch implements Hel } else { openSet.insert(neighbor);//dont double count, dont insert into open set if it's already there } - for (int i = 0; i < bestSoFar.length; i++) { + for (int i = 0; i < COEFFICIENTS.length; i++) { double heuristic = neighbor.estimatedCostToGoal + neighbor.cost / COEFFICIENTS[i]; - if (heuristic < bestHeuristicSoFar[i]) { - if (bestHeuristicSoFar[i] - heuristic < 0.01 && minimumImprovementRepropagation) { - continue; - } + if (bestHeuristicSoFar[i] - heuristic > minimumImprovement) { bestHeuristicSoFar[i] = heuristic; bestSoFar[i] = neighbor; if (getDistFromStartSq(neighbor) > MIN_DIST_PATH * MIN_DIST_PATH) { @@ -182,28 +168,10 @@ public final class AStarPathFinder extends AbstractNodeCostSearch implements Hel System.out.println("Open set size: " + openSet.size()); System.out.println("PathNode map size: " + mapSize()); System.out.println((int) (numNodes * 1.0 / ((System.currentTimeMillis() - startTime) / 1000F)) + " nodes per second"); - double bestDist = 0; - for (int i = 0; i < bestSoFar.length; i++) { - if (bestSoFar[i] == null) { - continue; - } - double dist = getDistFromStartSq(bestSoFar[i]); - if (dist > bestDist) { - bestDist = dist; - } - if (dist > MIN_DIST_PATH * MIN_DIST_PATH) { // square the comparison since distFromStartSq is squared - logDebug("Took " + (System.currentTimeMillis() - startTime) + "ms, A* cost coefficient " + COEFFICIENTS[i] + ", " + numMovementsConsidered + " movements considered"); - if (COEFFICIENTS[i] >= 3) { - System.out.println("Warning: cost coefficient is greater than three! Probably means that"); - System.out.println("the path I found is pretty terrible (like sneak-bridging for dozens of blocks)"); - System.out.println("But I'm going to do it anyway, because yolo"); - } - System.out.println("Path goes for " + Math.sqrt(dist) + " blocks"); - return Optional.of(new Path(startNode, bestSoFar[i], numNodes, goal, calcContext)); - } + Optional result = bestSoFar(true, numNodes); + if (result.isPresent()) { + logDebug("Took " + (System.currentTimeMillis() - startTime) + "ms, " + numMovementsConsidered + " movements considered"); } - logDebug("Even with a cost coefficient of " + COEFFICIENTS[COEFFICIENTS.length - 1] + ", I couldn't get more than " + Math.sqrt(bestDist) + " blocks"); - logDebug("No path found =("); - return Optional.empty(); + return result; } } diff --git a/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java b/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java index 625e8e59..a9974e8d 100644 --- a/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java +++ b/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java @@ -34,7 +34,7 @@ import java.util.Optional; * * @author leijurv */ -public abstract class AbstractNodeCostSearch implements IPathFinder { +public abstract class AbstractNodeCostSearch implements IPathFinder, Helper { protected final int startX; protected final int startY; @@ -53,7 +53,7 @@ public abstract class AbstractNodeCostSearch implements IPathFinder { protected PathNode mostRecentConsidered; - protected PathNode[] bestSoFar; + protected final PathNode[] bestSoFar = new PathNode[COEFFICIENTS.length]; private volatile boolean isFinished; @@ -63,13 +63,23 @@ public abstract class AbstractNodeCostSearch implements IPathFinder { * This is really complicated and hard to explain. I wrote a comment in the old version of MineBot but it was so * long it was easier as a Google Doc (because I could insert charts). * - * @see + * @see here */ - protected static final double[] COEFFICIENTS = {1.5, 2, 2.5, 3, 4, 5, 10}; // big TODO tune + protected static final double[] COEFFICIENTS = {1.5, 2, 2.5, 3, 4, 5, 10}; + /** * If a path goes less than 5 blocks and doesn't make it to its goal, it's not worth considering. */ - protected final static double MIN_DIST_PATH = 5; + protected static final double MIN_DIST_PATH = 5; + + /** + * there are floating point errors caused by random combinations of traverse and diagonal over a flat area + * that means that sometimes there's a cost improvement of like 10 ^ -16 + * it's not worth the time to update the costs, decrease-key the heap, potentially repropagate, etc + *

+ * who cares about a hundredth of a tick? that's half a millisecond for crying out loud! + */ + protected static final double MIN_IMPROVEMENT = 0.01; AbstractNodeCostSearch(int startX, int startY, int startZ, Goal goal, CalculationContext context) { this.startX = startX; @@ -170,25 +180,43 @@ public abstract class AbstractNodeCostSearch implements IPathFinder { return Optional.ofNullable(mostRecentConsidered).map(node -> new Path(startNode, node, 0, goal, context)); } - protected int mapSize() { - return map.size(); + @Override + public Optional bestPathSoFar() { + return bestSoFar(false, 0); } - @Override - public Optional bestPathSoFar() { // TODO cleanup code duplication between here and AStarPathFinder + protected Optional bestSoFar(boolean logInfo, int numNodes) { if (startNode == null || bestSoFar == null) { return Optional.empty(); } - for (int i = 0; i < bestSoFar.length; i++) { + double bestDist = 0; + for (int i = 0; i < COEFFICIENTS.length; i++) { if (bestSoFar[i] == null) { continue; } - if (getDistFromStartSq(bestSoFar[i]) > MIN_DIST_PATH * MIN_DIST_PATH) { // square the comparison since distFromStartSq is squared - return Optional.of(new Path(startNode, bestSoFar[i], 0, goal, context)); + double dist = getDistFromStartSq(bestSoFar[i]); + if (dist > bestDist) { + bestDist = dist; + } + if (dist > MIN_DIST_PATH * MIN_DIST_PATH) { // square the comparison since distFromStartSq is squared + if (logInfo) { + if (COEFFICIENTS[i] >= 3) { + System.out.println("Warning: cost coefficient is greater than three! Probably means that"); + System.out.println("the path I found is pretty terrible (like sneak-bridging for dozens of blocks)"); + System.out.println("But I'm going to do it anyway, because yolo"); + } + System.out.println("Path goes for " + Math.sqrt(dist) + " blocks"); + logDebug("A* cost coefficient " + COEFFICIENTS[i]); + } + return Optional.of(new Path(startNode, bestSoFar[i], numNodes, goal, context)); } } // instead of returning bestSoFar[0], be less misleading // if it actually won't find any path, don't make them think it will by rendering a dark blue that will never actually happen + if (logInfo) { + logDebug("Even with a cost coefficient of " + COEFFICIENTS[COEFFICIENTS.length - 1] + ", I couldn't get more than " + Math.sqrt(bestDist) + " blocks"); + logDebug("No path found =("); + } return Optional.empty(); } @@ -205,4 +233,8 @@ public abstract class AbstractNodeCostSearch implements IPathFinder { public BetterBlockPos getStart() { return new BetterBlockPos(startX, startY, startZ); } + + protected int mapSize() { + return map.size(); + } } From 246c00c7733885a6ab8026e6a9088b829d2f34ea Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 31 Jan 2019 19:19:44 -0800 Subject: [PATCH 16/58] dont repeat that --- .../java/baritone/pathing/path/PathExecutor.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/baritone/pathing/path/PathExecutor.java b/src/main/java/baritone/pathing/path/PathExecutor.java index a2c0e2ff..8ad0db59 100644 --- a/src/main/java/baritone/pathing/path/PathExecutor.java +++ b/src/main/java/baritone/pathing/path/PathExecutor.java @@ -377,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 (behavior.baritone.getInputOverrideHandler().isInputForcedDown(Input.SPRINT)) { - behavior.baritone.getInputOverrideHandler().setInputForceState(Input.SPRINT, false); + if (requested) { 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) { From 747bee41b75633224a851f249e3cf4c0904f6221 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 31 Jan 2019 20:26:24 -0800 Subject: [PATCH 17/58] holding control shouldnt make all bots sprint --- .../baritone/launch/mixins/MixinEntityPlayerSP.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/launch/java/baritone/launch/mixins/MixinEntityPlayerSP.java b/src/launch/java/baritone/launch/mixins/MixinEntityPlayerSP.java index bbf92011..6e0eb3f0 100644 --- a/src/launch/java/baritone/launch/mixins/MixinEntityPlayerSP.java +++ b/src/launch/java/baritone/launch/mixins/MixinEntityPlayerSP.java @@ -18,6 +18,7 @@ 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; @@ -100,8 +101,16 @@ public class MixinEntityPlayerSP { ) private boolean isKeyDown(KeyBinding keyBinding) { SprintStateEvent event = new SprintStateEvent(); - BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this).getGameEventHandler().onPlayerSprintState(event); - return event.getState() == null ? keyBinding.isKeyDown() : event.getState(); + 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(); } @Inject( From 5c1cf050e2bf5bd83566fb17bdc104d15d83c0c6 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 31 Jan 2019 20:27:14 -0800 Subject: [PATCH 18/58] im idiot --- src/launch/java/baritone/launch/mixins/MixinEntityPlayerSP.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/launch/java/baritone/launch/mixins/MixinEntityPlayerSP.java b/src/launch/java/baritone/launch/mixins/MixinEntityPlayerSP.java index 6e0eb3f0..87cc6562 100644 --- a/src/launch/java/baritone/launch/mixins/MixinEntityPlayerSP.java +++ b/src/launch/java/baritone/launch/mixins/MixinEntityPlayerSP.java @@ -106,7 +106,7 @@ public class MixinEntityPlayerSP { if (event.getState() != null) { return event.getState(); } - if (baritone == BaritoneAPI.getProvider().getPrimaryBaritone()) { + if (baritone != BaritoneAPI.getProvider().getPrimaryBaritone()) { // hitting control shouldn't make all bots sprint return false; } From dc3bab26deb69ccb42159245c2a695521637490a Mon Sep 17 00:00:00 2001 From: Leijurv Date: Fri, 1 Feb 2019 22:54:14 -0800 Subject: [PATCH 19/58] 6 months =D --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 7782651a..1826eb20 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,8 @@ 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) From 913247996e9250d5c734a44dca0fd103f7c5fcfd Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 2 Feb 2019 14:23:01 -0800 Subject: [PATCH 20/58] smh my head. who right clicks gradle tasks?? --- SETUP.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SETUP.md b/SETUP.md index 6400990d..a479227b 100644 --- a/SETUP.md +++ b/SETUP.md @@ -65,7 +65,7 @@ $ gradlew build ![Image](https://i.imgur.com/PE6r9iN.png) -- Right click on **build** and press **Run** +- Double click on **build** to run it ## Artifacts From d799fac688b345bb66cbac9d76b3795b558340cf Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 3 Feb 2019 19:27:28 -0800 Subject: [PATCH 21/58] epicer gradle output --- .../src/main/java/baritone/gradle/task/ProguardTask.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/buildSrc/src/main/java/baritone/gradle/task/ProguardTask.java b/buildSrc/src/main/java/baritone/gradle/task/ProguardTask.java index 351ded3a..4d10e7f5 100644 --- a/buildSrc/src/main/java/baritone/gradle/task/ProguardTask.java +++ b/buildSrc/src/main/java/baritone/gradle/task/ProguardTask.java @@ -298,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()); - this.printOutputLog(p.getErrorStream()); + this.printOutputLog(p.getInputStream(), System.out); + this.printOutputLog(p.getErrorStream(), System.err); // Halt the current thread until the process is complete, if the exit code isn't 0, throw an exception int exitCode = p.waitFor(); @@ -308,12 +308,12 @@ public class ProguardTask extends BaritoneGradleTask { } } - private void printOutputLog(InputStream stream) { + private void printOutputLog(InputStream stream, PrintStream outerr) { new Thread(() -> { try (BufferedReader reader = new BufferedReader(new InputStreamReader(stream))) { String line; while ((line = reader.readLine()) != null) { - System.out.println(line); + outerr.println(line); } } catch (Exception e) { e.printStackTrace(); From 0e1534613cf82b9e98020da9d7c73c73780b686e Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 3 Feb 2019 19:34:24 -0800 Subject: [PATCH 22/58] appease codacy --- .../baritone/pathing/movement/movements/MovementTraverse.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java index 4f9b6b51..74e4b6f3 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java @@ -281,6 +281,8 @@ 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 From 5382d265f2ba13045fcc77af8132293c521ac5dc Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 3 Feb 2019 19:46:59 -0800 Subject: [PATCH 23/58] crucial performance optimization --- src/main/java/baritone/pathing/calc/AStarPathFinder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/pathing/calc/AStarPathFinder.java b/src/main/java/baritone/pathing/calc/AStarPathFinder.java index 6f44fac2..fda41cfd 100644 --- a/src/main/java/baritone/pathing/calc/AStarPathFinder.java +++ b/src/main/java/baritone/pathing/calc/AStarPathFinder.java @@ -153,7 +153,7 @@ public final class AStarPathFinder extends AbstractNodeCostSearch { if (bestHeuristicSoFar[i] - heuristic > minimumImprovement) { bestHeuristicSoFar[i] = heuristic; bestSoFar[i] = neighbor; - if (getDistFromStartSq(neighbor) > MIN_DIST_PATH * MIN_DIST_PATH) { + if (failing && getDistFromStartSq(neighbor) > MIN_DIST_PATH * MIN_DIST_PATH) { failing = false; } } From 04e7da9b73e104052b0493dff7a7bcdd6679d5b4 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 4 Feb 2019 13:07:05 -0800 Subject: [PATCH 24/58] lower walk into can be water, but not upper --- .../baritone/pathing/movement/movements/MovementDiagonal.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java b/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java index a47fc263..0abaccf7 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java @@ -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()) && pb3.getBlock() != Blocks.WATER))) { + 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 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()) && pb1.getBlock() != Blocks.WATER))) { + 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 return; } From ee23d59e111ba741aa9a6539c3302897310c2c59 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 4 Feb 2019 13:07:16 -0800 Subject: [PATCH 25/58] now we can cache flowing water properly --- src/main/java/baritone/cache/ChunkPacker.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/baritone/cache/ChunkPacker.java b/src/main/java/baritone/cache/ChunkPacker.java index 60ac6331..e2903cea 100644 --- a/src/main/java/baritone/cache/ChunkPacker.java +++ b/src/main/java/baritone/cache/ChunkPacker.java @@ -124,12 +124,13 @@ public final class ChunkPacker { private static PathingBlockType getPathingBlockType(IBlockState state) { Block block = state.getBlock(); - if (block == Blocks.WATER && !MovementHelper.isFlowing(state)) { + if ((block == Blocks.WATER || block == Blocks.FLOWING_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) || block == Blocks.FLOWING_WATER || MovementHelper.isBottomSlab(state)) { + if (MovementHelper.avoidWalkingInto(block) || MovementHelper.isBottomSlab(state)) { return PathingBlockType.AVOID; } // We used to do an AABB check here From 57b2e360ca43cfc1639faf085032621594c9959b Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 4 Feb 2019 13:27:35 -0800 Subject: [PATCH 26/58] dont include current movement cost while deciding when to plan ahead --- .../baritone/api/behavior/IPathingBehavior.java | 15 ++++++++++++++- .../java/baritone/behavior/PathingBehavior.java | 4 +++- .../java/baritone/pathing/path/PathExecutor.java | 2 ++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/api/java/baritone/api/behavior/IPathingBehavior.java b/src/api/java/baritone/api/behavior/IPathingBehavior.java index d28195ae..64be71d5 100644 --- a/src/api/java/baritone/api/behavior/IPathingBehavior.java +++ b/src/api/java/baritone/api/behavior/IPathingBehavior.java @@ -38,11 +38,24 @@ public interface IPathingBehavior extends IBehavior { * @return The estimated remaining ticks in the current segment. */ default Optional 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 ticksRemainingInSegment(boolean includeCurrentMovement) { IPathExecutor current = getCurrent(); if (current == null) { return Optional.empty(); } - return Optional.of(current.getPath().ticksRemainingFrom(current.getPosition())); + int start = includeCurrentMovement ? current.getPosition() : current.getPosition() + 1; + return Optional.of(current.getPath().ticksRemainingFrom(start)); } /** diff --git a/src/main/java/baritone/behavior/PathingBehavior.java b/src/main/java/baritone/behavior/PathingBehavior.java index ea752082..8339625d 100644 --- a/src/main/java/baritone/behavior/PathingBehavior.java +++ b/src/main/java/baritone/behavior/PathingBehavior.java @@ -193,8 +193,10 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior, // and this path doesn't get us all the way there return; } - if (ticksRemainingInSegment().get() < Baritone.settings().planningTickLookAhead.get()) { + if (ticksRemainingInSegment(false).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); diff --git a/src/main/java/baritone/pathing/path/PathExecutor.java b/src/main/java/baritone/pathing/path/PathExecutor.java index 8ad0db59..1b59f8e3 100644 --- a/src/main/java/baritone/pathing/path/PathExecutor.java +++ b/src/main/java/baritone/pathing/path/PathExecutor.java @@ -249,6 +249,8 @@ 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; From 798f25ff81dc767fe69768831aa468827c0c64f0 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 4 Feb 2019 13:52:11 -0800 Subject: [PATCH 27/58] dont glitch weirdly when failing a parkour jump --- .../baritone/pathing/movement/movements/MovementParkour.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java index 38fd510a..74acac48 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java @@ -187,6 +187,11 @@ 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); } From 2cbe77aa049e203a09ee37fab66aeaf9b1d4c65f Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 4 Feb 2019 15:24:27 -0800 Subject: [PATCH 28/58] many fixes --- src/api/java/baritone/api/Settings.java | 8 +++- .../mixins/MixinChunkRenderContainer.java | 14 ++---- .../launch/mixins/MixinRenderList.java | 46 +++++++++++++++++++ .../launch/mixins/MixinVboRenderList.java | 46 +++++++++++++++++++ src/launch/resources/mixins.baritone.json | 2 + .../java/baritone/event/GameEventHandler.java | 10 ++-- 6 files changed, 113 insertions(+), 13 deletions(-) create mode 100644 src/launch/java/baritone/launch/mixins/MixinRenderList.java create mode 100644 src/launch/java/baritone/launch/mixins/MixinVboRenderList.java diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index a1ae9c71..db97999b 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -460,7 +460,13 @@ public final class Settings { public final Setting pathThroughCachedOnly = new Setting<>(false); /** - * 😎 + * 😎 Render cached chunks as semitransparent. + *

+ * Can be very useful on servers with low render distance. + *

+ * 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. + *

+ * SOLID is rendered as stone in the overworld, netherrack in the nether, and end stone in the end */ public Setting renderCachedChunks = new Setting<>(false); diff --git a/src/launch/java/baritone/launch/mixins/MixinChunkRenderContainer.java b/src/launch/java/baritone/launch/mixins/MixinChunkRenderContainer.java index e2c1e025..fef16d6b 100644 --- a/src/launch/java/baritone/launch/mixins/MixinChunkRenderContainer.java +++ b/src/launch/java/baritone/launch/mixins/MixinChunkRenderContainer.java @@ -38,15 +38,11 @@ public class MixinChunkRenderContainer { at = @At("HEAD") ) private void preRenderChunk(RenderChunk renderChunkIn, CallbackInfo ci) { - if (Baritone.settings().renderCachedChunks.get()) { - if (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); - } else { - GlStateManager.tryBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO); - } + 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); } } } diff --git a/src/launch/java/baritone/launch/mixins/MixinRenderList.java b/src/launch/java/baritone/launch/mixins/MixinRenderList.java new file mode 100644 index 00000000..55d1da70 --- /dev/null +++ b/src/launch/java/baritone/launch/mixins/MixinRenderList.java @@ -0,0 +1,46 @@ +/* + * 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 . + */ + +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); + } + } +} diff --git a/src/launch/java/baritone/launch/mixins/MixinVboRenderList.java b/src/launch/java/baritone/launch/mixins/MixinVboRenderList.java new file mode 100644 index 00000000..c2c9fd8c --- /dev/null +++ b/src/launch/java/baritone/launch/mixins/MixinVboRenderList.java @@ -0,0 +1,46 @@ +/* + * 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 . + */ + +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); + } + } +} diff --git a/src/launch/resources/mixins.baritone.json b/src/launch/resources/mixins.baritone.json index aa9a724f..ddd3a718 100644 --- a/src/launch/resources/mixins.baritone.json +++ b/src/launch/resources/mixins.baritone.json @@ -23,6 +23,8 @@ "MixinNetHandlerPlayClient", "MixinNetworkManager", "MixinRenderChunk", + "MixinRenderList", + "MixinVboRenderList", "MixinWorldClient" ] } \ No newline at end of file diff --git a/src/main/java/baritone/event/GameEventHandler.java b/src/main/java/baritone/event/GameEventHandler.java index 1bf63502..84bac80f 100644 --- a/src/main/java/baritone/event/GameEventHandler.java +++ b/src/main/java/baritone/event/GameEventHandler.java @@ -47,9 +47,13 @@ public final class GameEventHandler implements IEventBus, Helper { @Override public final void onTick(TickEvent event) { - try { - baritone.bsi = new BlockStateInterface(baritone.getPlayerContext(), true); - } catch (Exception ex) {} + 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)); } From 58fa1571f39318cbf762fc09775fa2b8c360c214 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 4 Feb 2019 15:43:02 -0800 Subject: [PATCH 29/58] added more info --- src/api/java/baritone/api/Settings.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index db97999b..1ead7696 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -462,7 +462,9 @@ public final class Settings { /** * 😎 Render cached chunks as semitransparent. *

- * Can be very useful on servers with low render distance. + * 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. *

* 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. *

From 8c899698e09c8a2324615585de9f05aebfdfa4a1 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 4 Feb 2019 16:27:32 -0800 Subject: [PATCH 30/58] explore for blocks, fixes #323 --- src/api/java/baritone/api/Settings.java | 5 +++++ .../java/baritone/process/GetToBlockProcess.java | 16 ++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 1ead7696..fd1d9ab8 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -504,6 +504,11 @@ public final class Settings { */ public final Setting mineGoalUpdateInterval = new Setting<>(5); + /** + * When GetToBlock doesn't know any locations for the desired block, explore randomly instead of giving up. + */ + public final Setting 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)? */ diff --git a/src/main/java/baritone/process/GetToBlockProcess.java b/src/main/java/baritone/process/GetToBlockProcess.java index f3e245da..c3ac0616 100644 --- a/src/main/java/baritone/process/GetToBlockProcess.java +++ b/src/main/java/baritone/process/GetToBlockProcess.java @@ -18,10 +18,7 @@ package baritone.process; import baritone.Baritone; -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.pathing.goals.*; import baritone.api.process.IGetToBlockProcess; import baritone.api.process.PathingCommand; import baritone.api.process.PathingCommandType; @@ -44,6 +41,7 @@ public class GetToBlockProcess extends BaritoneProcessHelper implements IGetToBl private Block gettingTo; private List knownLocations; + private BlockPos start; private int tickCount = 0; @@ -55,6 +53,7 @@ public class GetToBlockProcess extends BaritoneProcessHelper implements IGetToBl public void getToBlock(Block block) { onLostControl(); gettingTo = block; + start = ctx.playerFeet(); rescan(new ArrayList<>(), new CalculationContext(baritone)); } @@ -69,6 +68,14 @@ 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(); @@ -106,6 +113,7 @@ public class GetToBlockProcess extends BaritoneProcessHelper implements IGetToBl public void onLostControl() { gettingTo = null; knownLocations = null; + start = null; baritone.getInputOverrideHandler().clearAllKeys(); } From 40a66b03063e7e65a6c8b0a8a558c06648c4a55f Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 4 Feb 2019 18:05:05 -0800 Subject: [PATCH 31/58] almost forge support --- build.gradle | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index f356a3b2..57597d7a 100755 --- a/build.gradle +++ b/build.gradle @@ -60,7 +60,7 @@ sourceSets { minecraft { version = '1.12.2' mappings = 'stable_39' - tweakClass = 'baritone.launch.BaritoneTweaker' + tweakClass = 'org.spongepowered.asm.launch.MixinTweaker' runDir = 'run' // The sources jar should use SRG names not MCP to ensure compatibility with all mappings @@ -113,6 +113,15 @@ 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' From 90cb11f55e011adc78ef304f6578a30781efda41 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 4 Feb 2019 18:19:51 -0800 Subject: [PATCH 32/58] this is needed --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 57597d7a..d1cc1919 100755 --- a/build.gradle +++ b/build.gradle @@ -95,7 +95,7 @@ dependencies { } mixin { - defaultObfuscationEnv notch + defaultObfuscationEnv searge add sourceSets.launch, 'mixins.baritone.refmap.json' } From 62b11c0a8ad1e3fc68701c432d9d72a04ee407fc Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 4 Feb 2019 19:01:01 -0800 Subject: [PATCH 33/58] i'm legitimately sorry --- build.gradle | 2 +- .../main/java/baritone/gradle/util/Determinizer.java | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index d1cc1919..44c258ee 100755 --- a/build.gradle +++ b/build.gradle @@ -60,7 +60,7 @@ sourceSets { minecraft { version = '1.12.2' mappings = 'stable_39' - tweakClass = 'org.spongepowered.asm.launch.MixinTweaker' + tweakClass = 'baritone.launch.BaritoneTweaker' runDir = 'run' // The sources jar should use SRG names not MCP to ensure compatibility with all mappings diff --git a/buildSrc/src/main/java/baritone/gradle/util/Determinizer.java b/buildSrc/src/main/java/baritone/gradle/util/Determinizer.java index fc268cd3..462516d6 100644 --- a/buildSrc/src/main/java/baritone/gradle/util/Determinizer.java +++ b/buildSrc/src/main/java/baritone/gradle/util/Determinizer.java @@ -60,12 +60,22 @@ public class Determinizer { if (entry.getName().equals("META-INF/fml_cache_class_versions.json")) { continue; } + JarEntry clone = new JarEntry(entry.getName()); clone.setTime(42069); jos.putNextEntry(clone); 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")) { + 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); } From b55e4493983edcec4840229d2ee4c1954c18b2ca Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 4 Feb 2019 19:01:50 -0800 Subject: [PATCH 34/58] extra line --- buildSrc/src/main/java/baritone/gradle/util/Determinizer.java | 1 - 1 file changed, 1 deletion(-) diff --git a/buildSrc/src/main/java/baritone/gradle/util/Determinizer.java b/buildSrc/src/main/java/baritone/gradle/util/Determinizer.java index 462516d6..77df2cf7 100644 --- a/buildSrc/src/main/java/baritone/gradle/util/Determinizer.java +++ b/buildSrc/src/main/java/baritone/gradle/util/Determinizer.java @@ -60,7 +60,6 @@ public class Determinizer { if (entry.getName().equals("META-INF/fml_cache_class_versions.json")) { continue; } - JarEntry clone = new JarEntry(entry.getName()); clone.setTime(42069); jos.putNextEntry(clone); From dfe171a5c2cdcb22ad1f08843ad12dc52e11e8b8 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 4 Feb 2019 19:34:44 -0800 Subject: [PATCH 35/58] forge --- .../gradle/task/BaritoneGradleTask.java | 6 ++++-- .../baritone/gradle/task/CreateDistTask.java | 4 +++- .../baritone/gradle/task/ProguardTask.java | 21 ++++++++++++++++--- .../baritone/gradle/util/Determinizer.java | 20 ++++++++++++------ 4 files changed, 39 insertions(+), 12 deletions(-) diff --git a/buildSrc/src/main/java/baritone/gradle/task/BaritoneGradleTask.java b/buildSrc/src/main/java/baritone/gradle/task/BaritoneGradleTask.java index 0450509f..42bd0736 100644 --- a/buildSrc/src/main/java/baritone/gradle/task/BaritoneGradleTask.java +++ b/buildSrc/src/main/java/baritone/gradle/task/BaritoneGradleTask.java @@ -52,10 +52,11 @@ 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_STANDALONE = "%s-standalone-%s.jar", + ARTIFACT_FORGE = "%s-forge-%s.jar"; protected String artifactName, artifactVersion; - protected Path artifactPath, artifactUnoptimizedPath, artifactApiPath, artifactStandalonePath, proguardOut; + protected Path artifactPath, artifactUnoptimizedPath, artifactApiPath, artifactStandalonePath, artifactForgePath, proguardOut; protected void verifyArtifacts() throws IllegalStateException { this.artifactName = getProject().getName(); @@ -65,6 +66,7 @@ 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); diff --git a/buildSrc/src/main/java/baritone/gradle/task/CreateDistTask.java b/buildSrc/src/main/java/baritone/gradle/task/CreateDistTask.java index 49e2e142..71df695a 100644 --- a/buildSrc/src/main/java/baritone/gradle/task/CreateDistTask.java +++ b/buildSrc/src/main/java/baritone/gradle/task/CreateDistTask.java @@ -45,6 +45,7 @@ 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/"); @@ -56,9 +57,10 @@ 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 shasum = Stream.of(api, standalone, unoptimized) + List shasum = Stream.of(api, standalone, unoptimized, forge) .map(path -> sha1(path) + " " + path.getFileName().toString()) .collect(Collectors.toList()); diff --git a/buildSrc/src/main/java/baritone/gradle/task/ProguardTask.java b/buildSrc/src/main/java/baritone/gradle/task/ProguardTask.java index 4d10e7f5..54cb3119 100644 --- a/buildSrc/src/main/java/baritone/gradle/task/ProguardTask.java +++ b/buildSrc/src/main/java/baritone/gradle/task/ProguardTask.java @@ -59,6 +59,8 @@ public class ProguardTask extends BaritoneGradleTask { private List requiredLibraries; + private File mixin; + @TaskAction protected void exec() throws Exception { super.verifyArtifacts(); @@ -71,6 +73,7 @@ public class ProguardTask extends BaritoneGradleTask { acquireDependencies(); proguardApi(); proguardStandalone(); + createForge(); cleanup(); } @@ -79,7 +82,7 @@ public class ProguardTask extends BaritoneGradleTask { 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 { @@ -173,10 +176,18 @@ 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)) { + System.out.println(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 @@ -264,12 +275,16 @@ public class ProguardTask extends BaritoneGradleTask { private void proguardApi() throws Exception { runProguard(getTemporaryFile(PROGUARD_API_CONFIG)); - Determinizer.determinize(this.proguardOut.toString(), this.artifactApiPath.toString()); + Determinizer.determinize(this.proguardOut.toString(), this.artifactApiPath.toString(), Optional.empty()); } private void proguardStandalone() throws Exception { runProguard(getTemporaryFile(PROGUARD_STANDALONE_CONFIG)); - Determinizer.determinize(this.proguardOut.toString(), this.artifactStandalonePath.toString()); + 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)); } private void cleanup() { diff --git a/buildSrc/src/main/java/baritone/gradle/util/Determinizer.java b/buildSrc/src/main/java/baritone/gradle/util/Determinizer.java index 77df2cf7..d9f475a5 100644 --- a/buildSrc/src/main/java/baritone/gradle/util/Determinizer.java +++ b/buildSrc/src/main/java/baritone/gradle/util/Determinizer.java @@ -22,10 +22,7 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import java.io.*; -import java.util.ArrayList; -import java.util.Comparator; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.jar.JarEntry; import java.util.jar.JarFile; import java.util.jar.JarOutputStream; @@ -39,7 +36,7 @@ import java.util.stream.Collectors; */ public class Determinizer { - public static void determinize(String inputPath, String outputPath) throws IOException { + public static void determinize(String inputPath, String outputPath, Optional toInclude) throws IOException { System.out.println("Running Determinizer"); System.out.println(" Input path: " + inputPath); System.out.println(" Output path: " + outputPath); @@ -66,7 +63,7 @@ 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")) { + } 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()); @@ -79,6 +76,17 @@ public class Determinizer { 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(); } } From adbf9272702356c3ea7c2f0f2dcbb3d1c30595eb Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 4 Feb 2019 19:35:22 -0800 Subject: [PATCH 36/58] spacing --- .../src/main/java/baritone/gradle/task/BaritoneGradleTask.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildSrc/src/main/java/baritone/gradle/task/BaritoneGradleTask.java b/buildSrc/src/main/java/baritone/gradle/task/BaritoneGradleTask.java index 42bd0736..384e99fe 100644 --- a/buildSrc/src/main/java/baritone/gradle/task/BaritoneGradleTask.java +++ b/buildSrc/src/main/java/baritone/gradle/task/BaritoneGradleTask.java @@ -66,7 +66,7 @@ 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.artifactForgePath = this.getBuildFile(formatVersion(ARTIFACT_FORGE)); this.proguardOut = this.getTemporaryFile(PROGUARD_EXPORT_PATH); From e85de55c8f91a33d8e5314f6c59b58cec8f7f16f Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 4 Feb 2019 19:36:16 -0800 Subject: [PATCH 37/58] spacing 2 --- buildSrc/src/main/java/baritone/gradle/task/CreateDistTask.java | 2 +- buildSrc/src/main/java/baritone/gradle/task/ProguardTask.java | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/buildSrc/src/main/java/baritone/gradle/task/CreateDistTask.java b/buildSrc/src/main/java/baritone/gradle/task/CreateDistTask.java index 71df695a..5090a2ea 100644 --- a/buildSrc/src/main/java/baritone/gradle/task/CreateDistTask.java +++ b/buildSrc/src/main/java/baritone/gradle/task/CreateDistTask.java @@ -57,7 +57,7 @@ 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); + Files.copy(this.artifactForgePath, forge, REPLACE_EXISTING); // Calculate all checksums and format them like "shasum" List shasum = Stream.of(api, standalone, unoptimized, forge) diff --git a/buildSrc/src/main/java/baritone/gradle/task/ProguardTask.java b/buildSrc/src/main/java/baritone/gradle/task/ProguardTask.java index 54cb3119..590211d5 100644 --- a/buildSrc/src/main/java/baritone/gradle/task/ProguardTask.java +++ b/buildSrc/src/main/java/baritone/gradle/task/ProguardTask.java @@ -176,9 +176,7 @@ 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)) { - System.out.println(lib); if (lib.contains("mixin")) { - mixin = file; } Files.copy(file.toPath(), getTemporaryFile("tempLibraries/" + lib + ".jar"), REPLACE_EXISTING); From ed8f9863e32a922d63dbcb1f591d030649a2d40c Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 4 Feb 2019 19:37:36 -0800 Subject: [PATCH 38/58] spacing 3 --- build.gradle | 1 - 1 file changed, 1 deletion(-) diff --git a/build.gradle b/build.gradle index 44c258ee..02950ffa 100755 --- a/build.gradle +++ b/build.gradle @@ -113,7 +113,6 @@ jar { reproducibleFileOrder = true } - jar { manifest { attributes( From 4aededff46e47d71b9b2be47840f2edefa90d6f0 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 4 Feb 2019 19:57:01 -0800 Subject: [PATCH 39/58] allow prefix and non prefix control at the same time --- src/api/java/baritone/api/Settings.java | 2 +- .../baritone/utils/ExampleBaritoneControl.java | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index fd1d9ab8..508af1cc 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -481,7 +481,7 @@ public final class Settings { /** * Whether or not to use the "#" command prefix */ - public final Setting prefix = new Setting<>(false); + public final Setting prefixControl = new Setting<>(true); /** * Don't stop walking forward when you need to break blocks in your way diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java index 1c710bde..cca2bf3a 100644 --- a/src/main/java/baritone/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java @@ -87,22 +87,22 @@ 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().prefix.get()) { + if (Baritone.settings().prefixControl.get()) { if (msg.startsWith(COMMAND_PREFIX)) { if (!runCommand(msg.substring(COMMAND_PREFIX.length()))) { logDirect("Invalid command"); } - event.cancel(); // always cancel if using prefix - } - } else { - if (runCommand(msg)) { - event.cancel(); + event.cancel(); // always cancel if using prefixControl + return; } } + if (!Baritone.settings().chatControl.get() && !Baritone.settings().removePrefix.get()) { + return; + } + if (runCommand(msg)) { + event.cancel(); + } } public boolean runCommand(String msg0) { // you may think this can be private, but impcat calls it from .b =) From b9ae8306dd8b62e3020d41a982f2021fb970051b Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 4 Feb 2019 20:11:40 -0800 Subject: [PATCH 40/58] v1.1.0 --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 02950ffa..5c369408 100755 --- a/build.gradle +++ b/build.gradle @@ -16,7 +16,7 @@ */ group 'baritone' -version '1.0.0-hotfix-2' +version '1.1.0' buildscript { repositories { From 568bb1b0e8f05980c64c3d133f6b97fc24b404a8 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 4 Feb 2019 21:23:19 -0800 Subject: [PATCH 41/58] some forge info --- README.md | 4 ++++ SETUP.md | 11 ++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1826eb20..2b494e64 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,10 @@ Here are some links to help to get started: Quick start example: `thisway 1000` or `goal 70` to set the goal, `path` to actually start pathing. Also try `mine diamond_ore`. `cancel` to cancel. +Put a `#` in front so that if you make a typo it doesn't go into public chat (anything beginning with `#` isn't sent). + +`.b` is also a valid prefix, but **only** in Impact. + # API example ``` diff --git a/SETUP.md b/SETUP.md index a479227b..2dc1eb47 100644 --- a/SETUP.md +++ b/SETUP.md @@ -1,5 +1,13 @@ # Setup +## Prebuilt +[Releases](https://github.com/cabaletta/baritone/releases) + +Not always completely up to date with latest features. + +The forge release (currently `baritone-forge-1.1.0.jar`) can simply be added as a Forge mod. However, it is not fully compatible with the latest version of Forge. `freeLook` was broken in Forge 14.23.4.2744. You should use Forge 14.23.4.2743 or **older** with Baritone. Newer versions of Forge "work", sort of, but Baritone's movement becomes unreliable and `freeLook` must be off. + +## Build it yourself - Clone or download Baritone ![Image](https://i.imgur.com/kbqBtoN.png) @@ -69,8 +77,9 @@ $ gradlew build ## Artifacts -Building Baritone will result in 3 artifacts created in the ``dist`` directory. +Building Baritone will result in 4 artifacts created in the ``dist`` directory. +- **Forge**: Forge mod - **API**: Only the non-api packages are obfuscated. This should be used in environments where other mods would like to use Baritone's features. - **Standalone**: Everything is obfuscated. This should be used in environments where there are no other mods present that would like to use Baritone's features. - **Unoptimized**: Nothing is obfuscated. This shouldn't be used ever in production. From 3d5de440fd78498e432628f86b4e904f99193005 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 4 Feb 2019 21:30:58 -0800 Subject: [PATCH 42/58] what a mess --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2b494e64..16fc7090 100644 --- a/README.md +++ b/README.md @@ -45,9 +45,11 @@ Here are some links to help to get started: Quick start example: `thisway 1000` or `goal 70` to set the goal, `path` to actually start pathing. Also try `mine diamond_ore`. `cancel` to cancel. -Put a `#` in front so that if you make a typo it doesn't go into public chat (anything beginning with `#` isn't sent). +On v1.1.0 and newer: Put a `#` in front so that if you make a typo it doesn't go into public chat (anything beginning with `#` isn't sent). -`.b` is also a valid prefix, but **only** in Impact. +For older than v1.1.0, `#` must be enabled by toggling on the `prefix` setting. + +**Only** in Impact is `.b` also a valid prefix # API example From 529895f970dc8174edf49f9f850f76c6f8496f4c Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 5 Feb 2019 08:25:14 -0800 Subject: [PATCH 43/58] was only needed for freecam anyway --- src/launch/java/baritone/launch/mixins/MixinKeyBinding.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/launch/java/baritone/launch/mixins/MixinKeyBinding.java b/src/launch/java/baritone/launch/mixins/MixinKeyBinding.java index 6e215547..94e8bfd0 100644 --- a/src/launch/java/baritone/launch/mixins/MixinKeyBinding.java +++ b/src/launch/java/baritone/launch/mixins/MixinKeyBinding.java @@ -18,7 +18,6 @@ package baritone.launch.mixins; import baritone.api.BaritoneAPI; -import baritone.utils.Helper; import net.minecraft.client.settings.KeyBinding; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -49,7 +48,7 @@ public class MixinKeyBinding { } } - @Inject( + /*@Inject( method = "isPressed", at = @At("HEAD"), cancellable = true @@ -64,5 +63,5 @@ public class MixinKeyBinding { } cir.setReturnValue(force); // :sunglasses: } - } + }*/ } From fa7588062642b41e4f198f8e1650847b372d237e Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 5 Feb 2019 08:25:30 -0800 Subject: [PATCH 44/58] v1.1.1 --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 5c369408..1be05db5 100755 --- a/build.gradle +++ b/build.gradle @@ -16,7 +16,7 @@ */ group 'baritone' -version '1.1.0' +version '1.1.1' buildscript { repositories { From a9895479761eece7334b376016e558bf665cb2f0 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 5 Feb 2019 09:37:42 -0800 Subject: [PATCH 45/58] add proper setting for suppressing clicks --- src/api/java/baritone/api/Settings.java | 5 +++++ .../baritone/launch/mixins/MixinKeyBinding.java | 14 ++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 508af1cc..152c12b2 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -478,6 +478,11 @@ public final class Settings { */ public Setting cachedChunksOpacity = new Setting<>(0.5f); + /** + * If true, Baritone will not allow you to left or right click while pathing + */ + public Setting suppressClicks = new Setting<>(false); + /** * Whether or not to use the "#" command prefix */ diff --git a/src/launch/java/baritone/launch/mixins/MixinKeyBinding.java b/src/launch/java/baritone/launch/mixins/MixinKeyBinding.java index 94e8bfd0..9ef080bf 100644 --- a/src/launch/java/baritone/launch/mixins/MixinKeyBinding.java +++ b/src/launch/java/baritone/launch/mixins/MixinKeyBinding.java @@ -17,7 +17,9 @@ package baritone.launch.mixins; +import baritone.Baritone; import baritone.api.BaritoneAPI; +import baritone.utils.Helper; import net.minecraft.client.settings.KeyBinding; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -44,11 +46,14 @@ public class MixinKeyBinding { // only the primary baritone forces keys Boolean force = BaritoneAPI.getProvider().getPrimaryBaritone().getInputOverrideHandler().isInputForcedDown((KeyBinding) (Object) this); if (force != null) { + if (!force && !Baritone.settings().suppressClicks.get()) { + return; + } cir.setReturnValue(force); // :sunglasses: } } - /*@Inject( + @Inject( method = "isPressed", at = @At("HEAD"), cancellable = true @@ -56,12 +61,13 @@ public class MixinKeyBinding { private void isPressed(CallbackInfoReturnable cir) { // only the primary baritone forces keys Boolean force = BaritoneAPI.getProvider().getPrimaryBaritone().getInputOverrideHandler().isInputForcedDown((KeyBinding) (Object) this); - if (force != null && !force) { // <-- cursed + if (force != null && !force && Baritone.settings().suppressClicks.get()) { // <-- cursed if (pressTime > 0) { - Helper.HELPER.logDirect("You're trying to press this mouse button but I won't let you"); + Helper.HELPER.logDirect("You're trying to press this mouse button but I won't let you."); + Helper.HELPER.logDirect("Turn off the suppressClicks setting to allow clicking while pathing."); pressTime--; } cir.setReturnValue(force); // :sunglasses: } - }*/ + } } From c7ad235110b5aca13dac009987a0a6fe267856b6 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 5 Feb 2019 09:38:33 -0800 Subject: [PATCH 46/58] v1.1.2 --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 1be05db5..84fe06a8 100755 --- a/build.gradle +++ b/build.gradle @@ -16,7 +16,7 @@ */ group 'baritone' -version '1.1.1' +version '1.1.2' buildscript { repositories { From 7dd881aa9adc0dd8c39581540395279f21664dfb Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 5 Feb 2019 09:54:17 -0800 Subject: [PATCH 47/58] latest forge works yay --- SETUP.md | 4 +- .../baritone/launch/mixins/MixinEntity.java | 74 ------------------- .../launch/mixins/MixinEntityLivingBase.java | 21 ++++++ src/launch/resources/mixins.baritone.json | 1 - 4 files changed, 24 insertions(+), 76 deletions(-) delete mode 100644 src/launch/java/baritone/launch/mixins/MixinEntity.java diff --git a/SETUP.md b/SETUP.md index 2dc1eb47..dfbb1fa7 100644 --- a/SETUP.md +++ b/SETUP.md @@ -5,7 +5,9 @@ Not always completely up to date with latest features. -The forge release (currently `baritone-forge-1.1.0.jar`) can simply be added as a Forge mod. However, it is not fully compatible with the latest version of Forge. `freeLook` was broken in Forge 14.23.4.2744. You should use Forge 14.23.4.2743 or **older** with Baritone. Newer versions of Forge "work", sort of, but Baritone's movement becomes unreliable and `freeLook` must be off. +The forge release (currently `baritone-forge-1.1.3.jar`) can simply be added as a Forge mod. + +Previously (Baritone v1.1.2 and below), it was not fully compatible with the latest version of Forge. `freeLook` was broken in Forge 14.23.4.2744. Forge 14.23.4.2743 or **older** worked with Baritone v1.1.2 and lower. Newer versions of Forge "worked", sort of, but Baritone's movement became unreliable and `freeLook` must be off. ## Build it yourself - Clone or download Baritone diff --git a/src/launch/java/baritone/launch/mixins/MixinEntity.java b/src/launch/java/baritone/launch/mixins/MixinEntity.java deleted file mode 100644 index 83655783..00000000 --- a/src/launch/java/baritone/launch/mixins/MixinEntity.java +++ /dev/null @@ -1,74 +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 . - */ - -package baritone.launch.mixins; - -import baritone.api.BaritoneAPI; -import baritone.api.event.events.RotationMoveEvent; -import net.minecraft.client.entity.EntityPlayerSP; -import net.minecraft.entity.Entity; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import static org.spongepowered.asm.lib.Opcodes.GETFIELD; - -/** - * @author Brady - * @since 8/21/2018 - */ -@Mixin(Entity.class) -public class MixinEntity { - - @Shadow - public float rotationYaw; - - /** - * Event called to override the movement direction when walking - */ - private RotationMoveEvent motionUpdateRotationEvent; - - @Inject( - method = "moveRelative", - at = @At("HEAD") - ) - private void preMoveRelative(float strafe, float up, float forward, float friction, CallbackInfo ci) { - // noinspection ConstantConditions - if (EntityPlayerSP.class.isInstance(this)) { - this.motionUpdateRotationEvent = new RotationMoveEvent(RotationMoveEvent.Type.MOTION_UPDATE, this.rotationYaw); - BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this).getGameEventHandler().onPlayerRotationMove(this.motionUpdateRotationEvent); - } - } - - @Redirect( - method = "moveRelative", - at = @At( - value = "FIELD", - opcode = GETFIELD, - target = "net/minecraft/entity/Entity.rotationYaw:F" - ) - ) - private float overrideYaw(Entity self) { - if (self instanceof EntityPlayerSP) { - return this.motionUpdateRotationEvent.getYaw(); - } - return self.rotationYaw; - } -} diff --git a/src/launch/java/baritone/launch/mixins/MixinEntityLivingBase.java b/src/launch/java/baritone/launch/mixins/MixinEntityLivingBase.java index c6d76634..460d8a27 100644 --- a/src/launch/java/baritone/launch/mixins/MixinEntityLivingBase.java +++ b/src/launch/java/baritone/launch/mixins/MixinEntityLivingBase.java @@ -74,4 +74,25 @@ public abstract class MixinEntityLivingBase extends Entity { } return self.rotationYaw; } + + @Redirect( + method = "travel", + at = @At( + value = "INVOKE", + target = "net/minecraft/entity/EntityLivingBase.moveRelative(FFFF)V" + ) + ) + private void travel(EntityLivingBase self, float strafe, float up, float forward, float friction) { + // noinspection ConstantConditions + if (!EntityPlayerSP.class.isInstance(this)) { + moveRelative(strafe, up, forward, friction); + return; + } + RotationMoveEvent motionUpdateRotationEvent = new RotationMoveEvent(RotationMoveEvent.Type.MOTION_UPDATE, this.rotationYaw); + BaritoneAPI.getProvider().getBaritoneForPlayer((EntityPlayerSP) (Object) this).getGameEventHandler().onPlayerRotationMove(motionUpdateRotationEvent); + float originalYaw = this.rotationYaw; + this.rotationYaw = motionUpdateRotationEvent.getYaw(); + this.moveRelative(strafe, up, forward, friction); + this.rotationYaw = originalYaw; + } } diff --git a/src/launch/resources/mixins.baritone.json b/src/launch/resources/mixins.baritone.json index ddd3a718..fea9cca7 100644 --- a/src/launch/resources/mixins.baritone.json +++ b/src/launch/resources/mixins.baritone.json @@ -14,7 +14,6 @@ "MixinChunkProviderServer", "MixinChunkRenderContainer", "MixinChunkRenderWorker", - "MixinEntity", "MixinEntityLivingBase", "MixinEntityPlayerSP", "MixinEntityRenderer", From 1cae7ad6b10621facff805c147d4e85a825f62f6 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 5 Feb 2019 09:55:29 -0800 Subject: [PATCH 48/58] v1.1.3 --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 84fe06a8..a9f4c8ec 100755 --- a/build.gradle +++ b/build.gradle @@ -16,7 +16,7 @@ */ group 'baritone' -version '1.1.2' +version '1.1.3' buildscript { repositories { From b12fedb2d923b9079eb3c8c2026634dc7b0711d4 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 5 Feb 2019 11:08:12 -0800 Subject: [PATCH 49/58] help --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 16fc7090..e500d8f4 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,8 @@ Here are some links to help to get started: # Chat control [Defined Here](src/main/java/baritone/utils/ExampleBaritoneControl.java) +`help` for help. + Quick start example: `thisway 1000` or `goal 70` to set the goal, `path` to actually start pathing. Also try `mine diamond_ore`. `cancel` to cancel. On v1.1.0 and newer: Put a `#` in front so that if you make a typo it doesn't go into public chat (anything beginning with `#` isn't sent). From cd3ae2a7f555b2d620fd5194b280884e54d2b41f Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 5 Feb 2019 12:34:29 -0800 Subject: [PATCH 50/58] documentation overhaul --- FEATURES.md | 6 ++--- INSTALL.md | 4 +-- README.md | 11 +------- USAGE.md | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 83 insertions(+), 15 deletions(-) create mode 100644 USAGE.md diff --git a/FEATURES.md b/FEATURES.md index e3714a8c..09c932f0 100644 --- a/FEATURES.md +++ b/FEATURES.md @@ -22,9 +22,9 @@ Baritone uses A*, with some modifications: - **Backtrack cost favoring** While calculating the next segment, Baritone favors backtracking its current segment. The cost is decreased heavily, but is still positive (this won't cause it to backtrack if it doesn't need to). This allows it to splice and jump onto the next segment as early as possible, if the next segment begins with a backtrack of the current one. Example - **Backtrack detection and pausing** While path calculation happens on a separate thread, the main game thread has access to the latest node considered, and the best path so far (those are rendered light blue and dark blue respectively). When the current best path (rendered dark blue) passes through the player's current position on the current path segment, path execution is paused (if it's safe to do so), because there's no point continuing forward if we're about to turn around and go back that same way. Note that the current best path as reported by the path calculation thread takes into account the incremental cost backoff system, so it's accurate to what the path calculation thread will actually pick once it finishes. -# Configuring Baritone -All the settings and documentation are here. -To change a boolean setting, just say its name in chat (for example saying `allowBreak` toggles whether Baritone will consider breaking blocks). For a numeric setting, say its name then the new value (like `pathTimeoutMS 250`). It's case insensitive. +# Chat control + +- [Baritone chat control usage](USAGE.md) # Goals The pathing goal can be set to any of these options: diff --git a/INSTALL.md b/INSTALL.md index f05e0280..cb66440f 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -84,5 +84,5 @@ The final step is "registering" the Baritone library with Impact, so that it loa - You can now launch Impact 4.3 as normal, and Baritone should start up ## How to use Baritone - Instructions on how to use Baritone are limited, and you may have to read a little bit of code (Really nothing much - just plain English), you can view that here. + +- [Baritone chat control usage](USAGE.md) diff --git a/README.md b/README.md index e500d8f4..4c4b35a3 100644 --- a/README.md +++ b/README.md @@ -41,17 +41,8 @@ Here are some links to help to get started: - [Javadocs](https://baritone.leijurv.com/) # Chat control -[Defined Here](src/main/java/baritone/utils/ExampleBaritoneControl.java) -`help` for help. - -Quick start example: `thisway 1000` or `goal 70` to set the goal, `path` to actually start pathing. Also try `mine diamond_ore`. `cancel` to cancel. - -On v1.1.0 and newer: Put a `#` in front so that if you make a typo it doesn't go into public chat (anything beginning with `#` isn't sent). - -For older than v1.1.0, `#` must be enabled by toggling on the `prefix` setting. - -**Only** in Impact is `.b` also a valid prefix +- [Baritone chat control usage](USAGE.md) # API example diff --git a/USAGE.md b/USAGE.md new file mode 100644 index 00000000..43fda9a2 --- /dev/null +++ b/USAGE.md @@ -0,0 +1,77 @@ +# Prefix + +Baritone commands can by default be typed in the chatbox. However if you make a typo, like typing "gola 10000 10000" instead of goal it goes into public chat, which is bad. + +Therefore you can use a prefix before your messages. + +On Baritone v1.1.0 and newer: The prefix is `#` by default. Anything beginning with `#` isn't sent, and is only interpreted by Baritone. +For older than v1.1.0, `#` must be enabled by toggling on the `prefix` setting. + +**Only** in Impact 4.4 is `.b` also a valid prefix. In 4.4, `#` does **not** work, neither does saying the commands directly in chat. + +Other clients like Kami and Asuna have their own custom things (like `-path`), and can disable direct chat control entirely. + + + +# Commands + +**All** of these commands may need a prefix before them, as above ^. + +`help` for (rudimentary) help. You can see what it says [here](https://github.com/cabaletta/baritone/blob/master/src/main/java/baritone/utils/ExampleBaritoneControl.java#L53). + +To toggle a boolean setting, just say its name in chat (for example saying `allowBreak` toggles whether Baritone will consider breaking blocks). For a numeric setting, say its name then the new value (like `primaryTimeoutMS 250`). It's case insensitive. + + + + +Some common examples: +- `thisway 1000` then `path` to go in the direction you're facing for a thousand blocks +- `goal x y z` or `goal x z` or `goal y`, then `path` to go to a certain coordinate +- `goal` to set the goal to your player's feet +- `goal clear` to clear the goal +- `cancel` or `stop` to stop everything +- `goto portal` or `goto ender_chest` or `goto block_type` to go to a block. (in Impact, `.goto` is an alias for `.b goto` for the most part) +- `mine diamond_ore` to mine diamond ore (turn on the setting `legitMine` to only mine ores that it can actually see. It will explore randomly around y=11 until it finds them.) +- `follow playerName` to follow a player. `follow` to follow the entity you're looking at (only works if it hitting range). `followplayers` to follow any players in range (combine with Kill Aura for a fun time). +- `save waypointName` to save a waypoint. `goto waypointName` to go to it. +- `goto axis` to go to an axis or diagonal axis at y=120 (`axisHeight` is a configurable setting, defaults to 120). +- `invert` to invert the current goal and path. This gets as far away from it as possible, instead of as close as possible. For example, do `goal` then `invert` to run as far as possible from where you're standing at the start. +- `render` to rerender the world in case `renderCachedChunks` is being glitchy +- `damn` daniel + +For the rest of the commands, you can take a look at the code [here](https://github.com/cabaletta/baritone/blob/master/src/main/java/baritone/utils/ExampleBaritoneControl.java). + +All the settings and documentation are here. If you find HTML easier to read than Javadoc, you can look here and navigate to Settings in the left sidebar. + +There are about a hundred settings, but here are some fun / interesting / important ones that you might want to look at changing in normal usage of Baritone. The documentation for each can be found at the above links. +- `allowBreak` +- `allowSprint` +- `allowPlace` +- `allowParkour` +- `allowParkourPlace` +- `renderCachedChunks` (and `cachedChunksOpacity`) <-- very fun but you need a beefy computer +- `avoidance` +- `legitMine` +- `followRadius` + + + +# 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? +This could be one of many things. + +First, make sure it's actually installed. + +Second, make sure that you're using the prefix properly, and that chat control is enabled in the way you expect. + +For example, Impact disables direct chat control. (i.e. anything typed in chat without a prefix will be ignored and sent publicly). **This is a saved setting**, so if you run Impact once, `chatControl` will be off from then on, **even in other clients**. +So you'll need to use the `#` prefix or edit `baritone/settings.txt` in your Minecraft folder to undo that (specifically, remove the line `chatControl false` then restart your client). + + +## Why can I do `.goto x z` in Impact but nowhere else? Why can I do `-path to x z` in KAMI but nowhere else? +These are custom commands that they added; those aren't from Baritone. +The equivalent you're looking for is `goal x z` then `path`. From 920cb6556b5f7d6b4e8adcf0e58cc3997c1314f4 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 5 Feb 2019 12:38:39 -0800 Subject: [PATCH 51/58] a bit more --- SETUP.md | 2 +- USAGE.md | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/SETUP.md b/SETUP.md index dfbb1fa7..fbb6b22c 100644 --- a/SETUP.md +++ b/SETUP.md @@ -1,7 +1,7 @@ # Setup ## Prebuilt -[Releases](https://github.com/cabaletta/baritone/releases) +Download from the [Releases](https://github.com/cabaletta/baritone/releases) Not always completely up to date with latest features. diff --git a/USAGE.md b/USAGE.md index 43fda9a2..54bf9347 100644 --- a/USAGE.md +++ b/USAGE.md @@ -1,3 +1,5 @@ +(assuming you already have Baritone [set up](SETUP.md)) + # Prefix Baritone commands can by default be typed in the chatbox. However if you make a typo, like typing "gola 10000 10000" instead of goal it goes into public chat, which is bad. From d2bfd47039b01f6135630434b6c7bf295ba7a006 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 5 Feb 2019 12:41:30 -0800 Subject: [PATCH 52/58] how to check --- USAGE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/USAGE.md b/USAGE.md index 54bf9347..a763d400 100644 --- a/USAGE.md +++ b/USAGE.md @@ -66,7 +66,7 @@ Baritone is trying to right click to place a block there, but it can't since the ## Why doesn't Baritone respond to any of my chat commands? This could be one of many things. -First, make sure it's actually installed. +First, make sure it's actually installed. An easy way to check is seeing if it created the folder `baritone` in your Minecraft folder. Second, make sure that you're using the prefix properly, and that chat control is enabled in the way you expect. From 3cf944398f124800f64438d99b14848647805c16 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 5 Feb 2019 14:03:32 -0800 Subject: [PATCH 53/58] =?UTF-8?q?=F0=9F=98=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/java/baritone/api/Settings.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 152c12b2..28668ee2 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -460,7 +460,7 @@ public final class Settings { public final Setting pathThroughCachedOnly = new Setting<>(false); /** - * 😎 Render cached chunks as semitransparent. + * 😎 Render cached chunks as semitransparent. Doesn't work with OptiFine 😭 *

* 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 From efb316de1475a37fd0047e601d004c8cfcc41b1c Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 5 Feb 2019 18:11:33 -0800 Subject: [PATCH 54/58] codacy --- .../java/baritone/utils/ExampleBaritoneControl.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java index cca2bf3a..289ff936 100644 --- a/src/main/java/baritone/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java @@ -88,14 +88,12 @@ public class ExampleBaritoneControl extends Behavior implements Helper { @Override public void onSendChatMessage(ChatEvent event) { String msg = event.getMessage(); - if (Baritone.settings().prefixControl.get()) { - if (msg.startsWith(COMMAND_PREFIX)) { - if (!runCommand(msg.substring(COMMAND_PREFIX.length()))) { - logDirect("Invalid command"); - } - event.cancel(); // always cancel if using prefixControl - return; + if (Baritone.settings().prefixControl.get() && msg.startsWith(COMMAND_PREFIX)) { + if (!runCommand(msg.substring(COMMAND_PREFIX.length()))) { + logDirect("Invalid command"); } + event.cancel(); // always cancel if using prefixControl + return; } if (!Baritone.settings().chatControl.get() && !Baritone.settings().removePrefix.get()) { return; From 52cafbc7aa425d6bf6e6c05e82d9d71aa6d68b2e Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 5 Feb 2019 21:49:09 -0800 Subject: [PATCH 55/58] add a little version thingy --- build.gradle | 5 ++++- src/main/java/baritone/utils/ExampleBaritoneControl.java | 9 +++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index a9f4c8ec..0833e04d 100755 --- a/build.gradle +++ b/build.gradle @@ -116,7 +116,10 @@ jar { jar { manifest { attributes( - 'MixinConfigs': 'mixins.baritone.json' + 'MixinConfigs': 'mixins.baritone.json', + + 'Implementation-Title': 'Baritone', + 'Implementation-Version': version ) } } diff --git a/src/main/java/baritone/utils/ExampleBaritoneControl.java b/src/main/java/baritone/utils/ExampleBaritoneControl.java index 289ff936..a5b2b57e 100644 --- a/src/main/java/baritone/utils/ExampleBaritoneControl.java +++ b/src/main/java/baritone/utils/ExampleBaritoneControl.java @@ -227,6 +227,15 @@ public class ExampleBaritoneControl extends Behavior implements Helper { } return true; } + if (msg.equals("version")) { + String version = ExampleBaritoneControl.class.getPackage().getImplementationVersion(); + if (version == null) { + logDirect("No version detected. Either dev environment or broken install."); + } else { + logDirect("You are using Baritone v" + version); + } + return true; + } if (msg.equals("repack") || msg.equals("rescan")) { ChunkProviderClient cli = (ChunkProviderClient) ctx.world().getChunkProvider(); int playerChunkX = ctx.playerFeet().getX() >> 4; From 3326339263f6f07131e929747d90236ba220fc76 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 5 Feb 2019 22:17:28 -0800 Subject: [PATCH 56/58] lol that wasnt even right --- USAGE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/USAGE.md b/USAGE.md index a763d400..dab1edb1 100644 --- a/USAGE.md +++ b/USAGE.md @@ -36,7 +36,7 @@ Some common examples: - `mine diamond_ore` to mine diamond ore (turn on the setting `legitMine` to only mine ores that it can actually see. It will explore randomly around y=11 until it finds them.) - `follow playerName` to follow a player. `follow` to follow the entity you're looking at (only works if it hitting range). `followplayers` to follow any players in range (combine with Kill Aura for a fun time). - `save waypointName` to save a waypoint. `goto waypointName` to go to it. -- `goto axis` to go to an axis or diagonal axis at y=120 (`axisHeight` is a configurable setting, defaults to 120). +- `axis` to go to an axis or diagonal axis at y=120 (`axisHeight` is a configurable setting, defaults to 120). - `invert` to invert the current goal and path. This gets as far away from it as possible, instead of as close as possible. For example, do `goal` then `invert` to run as far as possible from where you're standing at the start. - `render` to rerender the world in case `renderCachedChunks` is being glitchy - `damn` daniel From 92ba76e7a1ee43406672fea768a4f0d1f27f725a Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 6 Feb 2019 10:23:01 -0800 Subject: [PATCH 57/58] since all settings are individually final, the class should be too --- src/api/java/baritone/api/Settings.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 28668ee2..e8e39792 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -667,7 +667,7 @@ public final class Settings { } } - public class Setting { + public final class Setting { public T value; public final T defaultValue; private String name; From bf9ee918f32bae4d6fbbbcc5151c8b88a7459e49 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 6 Feb 2019 12:50:42 -0800 Subject: [PATCH 58/58] 5 artifacts and documentation --- INSTALL.md | 12 ++++--- SETUP.md | 35 +++++++++++-------- .../gradle/task/BaritoneGradleTask.java | 32 +++++++---------- .../baritone/gradle/task/CreateDistTask.java | 20 ++++++----- .../baritone/gradle/task/ProguardTask.java | 7 ++-- 5 files changed, 53 insertions(+), 53 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index cb66440f..e66054b6 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -1,7 +1,9 @@ # Integration between Baritone and Impact Impact 4.4 has Baritone included. -These instructions apply to Impact 4.3 (and potentially other "hacked clients"). +These instructions apply to Impact 4.3. + +For Forge follow the instructions in [Setup](SETUP.md). To run Baritone on Vanilla, just follow the instructions in the README (it's `./gradlew runClient`). @@ -18,11 +20,11 @@ There are two methods of acquiring a build of Baritone ### Official Release (Not always up to date) https://github.com/cabaletta/baritone/releases -For Impact 4.3, there is no Baritone integration yet, so you will want `baritone-standalone-X.Y.Z.jar`. +For Impact 4.3, there is no Baritone integration yet, so you will want `baritone-standalone-X.Y.Z.jar`. **For the rest of this guide, replace `X.Y.Z` with the actual numeric version you are using.** Any official release will be GPG signed by leijurv (44A3EA646EADAC6A) and ZeroMemes (73A788379A197567). Please verify that the hash of the file you download is in `checksums.txt` and that `checksums_signed.asc` is a valid signature by those two public keys of `checksums.txt`. -The build is fully deterministic and reproducible, and you can verify Travis did it properly by running `docker build --no-cache -t cabaletta/baritone . && docker run --rm cabaletta/baritone cat /code/dist/checksums.txt` yourself and comparing the shasum. This works identically on Travis, Mac, and Linux (if you have docker on Windows, I'd be grateful if you could let me know if it works there too). +The build is fully deterministic and reproducible, and you can verify Travis did it properly by running `docker build --no-cache -t cabaletta/baritone .` yourself and comparing the shasum. This works identically on Travis, Mac, and Linux (if you have docker on Windows, I'd be grateful if you could let me know if it works there too). ### Building Baritone yourself You can either build Baritone through a command line or through IntelliJ's UI, information on that can be found [here](SETUP.md#building). @@ -36,7 +38,7 @@ putting baritone. - ``cabaletta`` - ``baritone`` - ``X.Y.Z`` - - Copy the build of Baritone that was acquired earlier, and place it into the ``X.Y.Z`` folder + - Copy the build of Baritone that was acquired earlier, and place it into the ``X.Y.Z`` folder, renamed like so: - The full path should look like ``/libraries/cabaletta/baritone/X.Y.Z/baritone-X.Y.Z.jar`` ## Modifying the Impact Profile JSON to run baritone @@ -79,7 +81,7 @@ The final step is "registering" the Baritone library with Impact, so that it loa ``` - Now find the ``"minecraftArguments": "..."`` text near the top. - At the very end of the quotes where it says ``--tweakClass clientapi.load.ClientTweaker"``, add on the following so it looks like: - - ``--tweakClass clientapi.load.ClientTweaker --tweakClass baritone.launch.BaritoneTweakerOptifine"`` + - ``--tweakClass clientapi.load.ClientTweaker --tweakClass baritone.launch.BaritoneTweaker"`` - If you didn't close your launcher for this step, restart it now. - You can now launch Impact 4.3 as normal, and Baritone should start up diff --git a/SETUP.md b/SETUP.md index fbb6b22c..6d50a85b 100644 --- a/SETUP.md +++ b/SETUP.md @@ -1,14 +1,31 @@ # Setup ## Prebuilt +(not always completely up to date with latest features) + Download from the [Releases](https://github.com/cabaletta/baritone/releases) -Not always completely up to date with latest features. +The Forge releases can simply be added as a Forge mod. -The forge release (currently `baritone-forge-1.1.3.jar`) can simply be added as a Forge mod. +If another one of your Forge mods has a Baritone integration, you want `baritone-api-forge-VERSION.jar`. Otherwise, you want `baritone-standalone-forge-VERSION.jar` Previously (Baritone v1.1.2 and below), it was not fully compatible with the latest version of Forge. `freeLook` was broken in Forge 14.23.4.2744. Forge 14.23.4.2743 or **older** worked with Baritone v1.1.2 and lower. Newer versions of Forge "worked", sort of, but Baritone's movement became unreliable and `freeLook` must be off. +## Artifacts + +Building Baritone will result in 5 artifacts created in the ``dist`` directory. These are the same as the artifacts created in the [releases](https://github.com/cabaletta/baritone/releases). + +- **API**: Only the non-api packages are obfuscated. This should be used in environments where other mods would like to use Baritone's features. +- **Forge API**: Same as API, but packaged for Forge. This should be used where another mod has a Baritone integration. +- **Standalone**: Everything is obfuscated. This should be used in environments where there are no other mods present that would like to use Baritone's features. +- **Forge Standalone**: Same as Standalone, but packaged for Forge. This should be used when Baritone is your only Forge mod, or none of your other Forge mods integrate with Baritone. +- **Unoptimized**: Nothing is obfuscated. This shouldn't be used ever in production. + +## More Info +To replace out Impact 4.4's Baritone build with a customized one, switch to the `impact4.4-compat` branch, build Baritone as above then copy `dist/baritone-api-$VERSION$.jar` into `minecraft/libraries/cabaletta/baritone-api/1.0.0/baritone-api-1.0.0.jar`, replacing the jar that was previously there. You also need to edit `minecraft/versions/1.12.2-Impact_4.4/1.12.2-Impact_4.4.json`, find the line `"name": "cabaletta:baritone-api:1.0.0"`, remove the comma from the end, and entirely remove the line that's immediately after (starts with `"url"`). + +Impact 4.4 **only** works with builds from the quite outdated `impact4.4-compat` branch. If you must have the latest Baritone features with Impact, and can't wait for 4.5, consider creating a standalone (non forge) build then adding it to Impact 4.**3** via the instructions in [Install](INSTALL.md). + ## Build it yourself - Clone or download Baritone @@ -75,16 +92,4 @@ $ gradlew build ![Image](https://i.imgur.com/PE6r9iN.png) -- Double click on **build** to run it - -## Artifacts - -Building Baritone will result in 4 artifacts created in the ``dist`` directory. - -- **Forge**: Forge mod -- **API**: Only the non-api packages are obfuscated. This should be used in environments where other mods would like to use Baritone's features. -- **Standalone**: Everything is obfuscated. This should be used in environments where there are no other mods present that would like to use Baritone's features. -- **Unoptimized**: Nothing is obfuscated. This shouldn't be used ever in production. - -## More Info -To replace out Impact 4.4's Baritone build with a customized one, switch to the `impact4.4-compat` branch, build Baritone as above then copy `dist/baritone-api-$VERSION$.jar` into `minecraft/libraries/cabaletta/baritone-api/1.0.0/baritone-api-1.0.0.jar`, replacing the jar that was previously there. You also need to edit `minecraft/versions/1.12.2-Impact_4.4/1.12.2-Impact_4.4.json`, find the line `"name": "cabaletta:baritone-api:1.0.0"`, remove the comma from the end, and entirely remove the line that's immediately after (starts with `"url"`). +- Double click on **build** to run it \ No newline at end of file diff --git a/buildSrc/src/main/java/baritone/gradle/task/BaritoneGradleTask.java b/buildSrc/src/main/java/baritone/gradle/task/BaritoneGradleTask.java index 384e99fe..4f7674f6 100644 --- a/buildSrc/src/main/java/baritone/gradle/task/BaritoneGradleTask.java +++ b/buildSrc/src/main/java/baritone/gradle/task/BaritoneGradleTask.java @@ -34,8 +34,6 @@ import java.util.List; */ class BaritoneGradleTask extends DefaultTask { - protected static final JsonParser PARSER = new JsonParser(); - protected static final String PROGUARD_ZIP = "proguard.zip", PROGUARD_JAR = "proguard.jar", @@ -45,28 +43,28 @@ class BaritoneGradleTask extends DefaultTask { PROGUARD_STANDALONE_CONFIG = "standalone.pro", PROGUARD_EXPORT_PATH = "proguard_out.jar", - VERSION_MANIFEST = "version_manifest.json", - TEMP_LIBRARY_DIR = "tempLibraries/", - 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_STANDARD = "%s-%s.jar", + ARTIFACT_UNOPTIMIZED = "%s-unoptimized-%s.jar", + ARTIFACT_API = "%s-api-%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 Path artifactPath, artifactUnoptimizedPath, artifactApiPath, artifactStandalonePath, artifactForgePath, proguardOut; + protected Path artifactPath, artifactUnoptimizedPath, artifactApiPath, artifactStandalonePath, artifactForgeApiPath, artifactForgeStandalonePath, proguardOut; protected void verifyArtifacts() throws IllegalStateException { this.artifactName = getProject().getName(); this.artifactVersion = getProject().getVersion().toString(); - this.artifactPath = this.getBuildFile(formatVersion(ARTIFACT_STANDARD)); - 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.artifactPath = this.getBuildFile(formatVersion(ARTIFACT_STANDARD)); + this.artifactUnoptimizedPath = this.getBuildFile(formatVersion(ARTIFACT_UNOPTIMIZED)); + this.artifactApiPath = this.getBuildFile(formatVersion(ARTIFACT_API)); + 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); @@ -97,8 +95,4 @@ class BaritoneGradleTask extends DefaultTask { protected Path getBuildFile(String file) { return getRelativeFile("build/libs/" + file); } - - protected JsonElement readJson(List lines) { - return PARSER.parse(String.join("\n", lines)); - } } diff --git a/buildSrc/src/main/java/baritone/gradle/task/CreateDistTask.java b/buildSrc/src/main/java/baritone/gradle/task/CreateDistTask.java index 5090a2ea..3ca935d1 100644 --- a/buildSrc/src/main/java/baritone/gradle/task/CreateDistTask.java +++ b/buildSrc/src/main/java/baritone/gradle/task/CreateDistTask.java @@ -42,10 +42,11 @@ public class CreateDistTask extends BaritoneGradleTask { super.verifyArtifacts(); // Define the distribution file paths - 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)); + Path api = getRelativeFile("dist/" + formatVersion(ARTIFACT_API)); + Path standalone = getRelativeFile("dist/" + formatVersion(ARTIFACT_STANDALONE)); + 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 Path dir = getRelativeFile("dist/"); @@ -54,13 +55,14 @@ public class CreateDistTask extends BaritoneGradleTask { } // Copy build jars to dist/ - 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); + Files.copy(this.artifactApiPath, api, REPLACE_EXISTING); + Files.copy(this.artifactStandalonePath, standalone, 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" - List shasum = Stream.of(api, standalone, unoptimized, forge) + List shasum = Stream.of(api, forgeApi, standalone, forgeStandalone, unoptimized) .map(path -> sha1(path) + " " + path.getFileName().toString()) .collect(Collectors.toList()); diff --git a/buildSrc/src/main/java/baritone/gradle/task/ProguardTask.java b/buildSrc/src/main/java/baritone/gradle/task/ProguardTask.java index 590211d5..30ffddfb 100644 --- a/buildSrc/src/main/java/baritone/gradle/task/ProguardTask.java +++ b/buildSrc/src/main/java/baritone/gradle/task/ProguardTask.java @@ -73,7 +73,6 @@ public class ProguardTask extends BaritoneGradleTask { acquireDependencies(); proguardApi(); proguardStandalone(); - createForge(); cleanup(); } @@ -274,15 +273,13 @@ 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.artifactForgeApiPath.toString(), Optional.of(mixin)); } 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.artifactForgeStandalonePath.toString(), Optional.of(mixin)); } private void cleanup() {