From bc5982b994eea763495c57e6397a17cc5c55f377 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 8 Jan 2019 20:45:35 -0800 Subject: [PATCH 1/8] fine lol --- src/main/java/baritone/utils/PathingControlManager.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/baritone/utils/PathingControlManager.java b/src/main/java/baritone/utils/PathingControlManager.java index 79a36695..f28655e6 100644 --- a/src/main/java/baritone/utils/PathingControlManager.java +++ b/src/main/java/baritone/utils/PathingControlManager.java @@ -170,12 +170,11 @@ public class PathingControlManager implements IPathingControlManager { public PathingCommand doTheStuff() { - List inContention = processes.stream().filter(IBaritoneProcess::isActive).sorted(Comparator.comparingDouble(IBaritoneProcess::priority)).collect(Collectors.toList()); + List inContention = processes.stream().filter(IBaritoneProcess::isActive).sorted(Comparator.comparingDouble(IBaritoneProcess::priority).reversed()).collect(Collectors.toList()); boolean found = false; boolean cancelOthers = false; PathingCommand exec = null; - for (int i = inContention.size() - 1; i >= 0; --i) { // truly a gamer moment - IBaritoneProcess proc = inContention.get(i); + for (IBaritoneProcess proc : inContention) { if (found) { if (cancelOthers) { proc.onLostControl(); From ae1e229619704b76f29931615621bcd86089a86b Mon Sep 17 00:00:00 2001 From: babbaj Date: Wed, 9 Jan 2019 05:39:37 -0500 Subject: [PATCH 2/8] fix garbage code --- .../baritone/utils/PathingControlManager.java | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/main/java/baritone/utils/PathingControlManager.java b/src/main/java/baritone/utils/PathingControlManager.java index f28655e6..32788433 100644 --- a/src/main/java/baritone/utils/PathingControlManager.java +++ b/src/main/java/baritone/utils/PathingControlManager.java @@ -26,10 +26,10 @@ import baritone.api.process.IBaritoneProcess; import baritone.api.process.PathingCommand; import baritone.behavior.PathingBehavior; import baritone.pathing.path.PathExecutor; +import java.util.stream.Stream; import net.minecraft.util.math.BlockPos; import java.util.*; -import java.util.stream.Collectors; public class PathingControlManager implements IPathingControlManager { private final Baritone baritone; @@ -170,30 +170,30 @@ public class PathingControlManager implements IPathingControlManager { public PathingCommand doTheStuff() { - List inContention = processes.stream().filter(IBaritoneProcess::isActive).sorted(Comparator.comparingDouble(IBaritoneProcess::priority).reversed()).collect(Collectors.toList()); - boolean found = false; - boolean cancelOthers = false; - PathingCommand exec = null; - for (IBaritoneProcess proc : inContention) { - if (found) { - if (cancelOthers) { - proc.onLostControl(); + Stream inContention = processes.stream() + .filter(IBaritoneProcess::isActive) + .sorted(Comparator.comparingDouble(IBaritoneProcess::priority).reversed()); + + + Iterator iterator = inContention.iterator(); + while(iterator.hasNext()) { + IBaritoneProcess proc = iterator.next(); + + PathingCommand exec = proc.onTick(Objects.equals(proc, inControlLastTick) && baritone.getPathingBehavior().calcFailedLastTick(), baritone.getPathingBehavior().isSafeToCancel()); + if (exec == null) { + if (proc.isActive()) { + throw new IllegalStateException(proc.displayName() + " returned null PathingCommand"); } + proc.onLostControl(); } else { - exec = proc.onTick(Objects.equals(proc, inControlLastTick) && baritone.getPathingBehavior().calcFailedLastTick(), baritone.getPathingBehavior().isSafeToCancel()); - if (exec == null) { - if (proc.isActive()) { - throw new IllegalStateException(proc.displayName()); - } - proc.onLostControl(); - continue; - } - //System.out.println("Executing command " + exec.commandType + " " + exec.goal + " from " + proc.displayName()); inControlThisTick = proc; - found = true; - cancelOthers = !proc.isTemporary(); + if (!proc.isTemporary()) { + iterator.forEachRemaining(IBaritoneProcess::onLostControl); + } + + return exec; } } - return exec; + return null; } } From a4495ce80abc80951087a7466cb375f49f8ddb5f Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 8 Jan 2019 22:00:33 -0800 Subject: [PATCH 3/8] tweaks --- .../java/baritone/utils/PathingControlManager.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main/java/baritone/utils/PathingControlManager.java b/src/main/java/baritone/utils/PathingControlManager.java index 32788433..d1cb4f61 100644 --- a/src/main/java/baritone/utils/PathingControlManager.java +++ b/src/main/java/baritone/utils/PathingControlManager.java @@ -26,10 +26,10 @@ import baritone.api.process.IBaritoneProcess; import baritone.api.process.PathingCommand; import baritone.behavior.PathingBehavior; import baritone.pathing.path.PathExecutor; -import java.util.stream.Stream; import net.minecraft.util.math.BlockPos; import java.util.*; +import java.util.stream.Stream; public class PathingControlManager implements IPathingControlManager { private final Baritone baritone; @@ -82,7 +82,7 @@ public class PathingControlManager implements IPathingControlManager { public void preTick() { inControlLastTick = inControlThisTick; - command = doTheStuff(); + command = executeProcesses(); if (command == null) { return; } @@ -169,14 +169,14 @@ public class PathingControlManager implements IPathingControlManager { } - public PathingCommand doTheStuff() { + public PathingCommand executeProcesses() { Stream inContention = processes.stream() - .filter(IBaritoneProcess::isActive) - .sorted(Comparator.comparingDouble(IBaritoneProcess::priority).reversed()); + .filter(IBaritoneProcess::isActive) + .sorted(Comparator.comparingDouble(IBaritoneProcess::priority).reversed()); Iterator iterator = inContention.iterator(); - while(iterator.hasNext()) { + while (iterator.hasNext()) { IBaritoneProcess proc = iterator.next(); PathingCommand exec = proc.onTick(Objects.equals(proc, inControlLastTick) && baritone.getPathingBehavior().calcFailedLastTick(), baritone.getPathingBehavior().isSafeToCancel()); @@ -190,7 +190,6 @@ public class PathingControlManager implements IPathingControlManager { if (!proc.isTemporary()) { iterator.forEachRemaining(IBaritoneProcess::onLostControl); } - return exec; } } From fbcae10f961bf289bb826512172cae4fb84bc9db Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 9 Jan 2019 15:13:09 -0800 Subject: [PATCH 4/8] cherry picked fix from builder --- src/main/java/baritone/behavior/PathingBehavior.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/baritone/behavior/PathingBehavior.java b/src/main/java/baritone/behavior/PathingBehavior.java index 6f0cf32b..8c5fb8a4 100644 --- a/src/main/java/baritone/behavior/PathingBehavior.java +++ b/src/main/java/baritone/behavior/PathingBehavior.java @@ -499,7 +499,7 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior, Goal transformed = goal; if (Baritone.settings().simplifyUnloadedYCoord.get() && goal instanceof IGoalRenderPos) { BlockPos pos = ((IGoalRenderPos) goal).getGoalPos(); - if (context.world.getChunk(pos) instanceof EmptyChunk) { + if (!context.bsi.worldContainsLoadedChunk(pos.getX(), pos.getZ())) { transformed = new GoalXZ(pos.getX(), pos.getZ()); } } From 7d572d748b56362e7702b25206030bfc86f49bae Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 9 Jan 2019 15:13:48 -0800 Subject: [PATCH 5/8] shouldnt be needed actually --- .../java/baritone/pathing/movement/CalculationContext.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/CalculationContext.java b/src/main/java/baritone/pathing/movement/CalculationContext.java index 725ab569..55933038 100644 --- a/src/main/java/baritone/pathing/movement/CalculationContext.java +++ b/src/main/java/baritone/pathing/movement/CalculationContext.java @@ -43,7 +43,6 @@ public class CalculationContext { private static final ItemStack STACK_BUCKET_WATER = new ItemStack(Items.WATER_BUCKET); public final IBaritone baritone; - public final EntityPlayerSP player; public final World world; public final WorldData worldData; public final BlockStateInterface bsi; @@ -72,7 +71,7 @@ public class CalculationContext { public CalculationContext(IBaritone baritone, boolean forUseOnAnotherThread) { this.baritone = baritone; - this.player = baritone.getPlayerContext().player(); + EntityPlayerSP player = baritone.getPlayerContext().player(); this.world = baritone.getPlayerContext().world(); this.worldData = (WorldData) baritone.getWorldProvider().getCurrentWorld(); this.bsi = new BlockStateInterface(world, worldData, forUseOnAnotherThread); // TODO TODO TODO From 85ea21e83b24ac4d290728a5097114bf97e59878 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 9 Jan 2019 18:22:34 -0800 Subject: [PATCH 6/8] epic movement input --- .../baritone/pathing/path/PathExecutor.java | 3 +- .../baritone/utils/InputOverrideHandler.java | 16 +++++- .../baritone/utils/PlayerMovementInput.java | 57 +++++++++++++++++++ 3 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 src/main/java/baritone/utils/PlayerMovementInput.java diff --git a/src/main/java/baritone/pathing/path/PathExecutor.java b/src/main/java/baritone/pathing/path/PathExecutor.java index 8d841e46..cad144aa 100644 --- a/src/main/java/baritone/pathing/path/PathExecutor.java +++ b/src/main/java/baritone/pathing/path/PathExecutor.java @@ -380,7 +380,8 @@ public class PathExecutor implements IPathExecutor, Helper { } // if the movement requested sprinting, then we're done - if (behavior.baritone.getInputOverrideHandler().isInputForcedDown(mc.gameSettings.keyBindSprint)) { + if (behavior.baritone.getInputOverrideHandler().isInputForcedDown(Input.SPRINT)) { + behavior.baritone.getInputOverrideHandler().setInputForceState(Input.SPRINT, false); if (!ctx.player().isSprinting()) { ctx.player().setSprinting(true); } diff --git a/src/main/java/baritone/utils/InputOverrideHandler.java b/src/main/java/baritone/utils/InputOverrideHandler.java index c6e19c15..654ab10e 100755 --- a/src/main/java/baritone/utils/InputOverrideHandler.java +++ b/src/main/java/baritone/utils/InputOverrideHandler.java @@ -18,11 +18,14 @@ package baritone.utils; import baritone.Baritone; +import baritone.api.BaritoneAPI; import baritone.api.event.events.TickEvent; import baritone.api.utils.IInputOverrideHandler; import baritone.api.utils.input.Input; import baritone.behavior.Behavior; +import net.minecraft.client.Minecraft; import net.minecraft.client.settings.KeyBinding; +import net.minecraft.util.MovementInputFromOptions; import org.lwjgl.input.Keyboard; import java.util.HashMap; @@ -58,7 +61,13 @@ public final class InputOverrideHandler extends Behavior implements IInputOverri */ @Override public final boolean isInputForcedDown(KeyBinding key) { - return isInputForcedDown(Input.getInputForBind(key)); + Input input = Input.getInputForBind(key); + if (input == null || (input != Input.CLICK_LEFT && input != Input.CLICK_RIGHT)) { + // TODO handle left and right better + // ideally we wouldn't force any keybinds and would do everything directly for real + return false; + } + return isInputForcedDown(input); } /** @@ -114,6 +123,11 @@ public final class InputOverrideHandler extends Behavior implements IInputOverri } boolean stillClick = blockBreakHelper.tick(isInputForcedDown(Input.CLICK_LEFT)); setInputForceState(Input.CLICK_LEFT, stillClick); + if (baritone.getPathingBehavior().isPathing() || baritone != BaritoneAPI.getProvider().getPrimaryBaritone()) { + ctx.player().movementInput = new PlayerMovementInput(this); + } else { + ctx.player().movementInput = new MovementInputFromOptions(Minecraft.getMinecraft().gameSettings); + } } public BlockBreakHelper getBlockBreakHelper() { diff --git a/src/main/java/baritone/utils/PlayerMovementInput.java b/src/main/java/baritone/utils/PlayerMovementInput.java new file mode 100644 index 00000000..4ffbef2b --- /dev/null +++ b/src/main/java/baritone/utils/PlayerMovementInput.java @@ -0,0 +1,57 @@ +/* + * 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.api.utils.input.Input; +import net.minecraft.util.MovementInput; + +public class PlayerMovementInput extends MovementInput { + private final InputOverrideHandler handler; + + public PlayerMovementInput(InputOverrideHandler handler) { + this.handler = handler; + } + + public void updatePlayerMoveState() { + this.moveStrafe = 0.0F; + this.moveForward = 0.0F; + + jump = handler.isInputForcedDown(Input.JUMP); // oppa + + if (this.forwardKeyDown = handler.isInputForcedDown(Input.MOVE_FORWARD)) { + this.moveForward++; + } + + if (this.backKeyDown = handler.isInputForcedDown(Input.MOVE_BACK)) { + this.moveForward--; + } + + if (this.leftKeyDown = handler.isInputForcedDown(Input.MOVE_LEFT)) { + this.moveStrafe++; + } + + if (this.rightKeyDown = handler.isInputForcedDown(Input.MOVE_RIGHT)) { + this.moveStrafe--; + } + + if (this.sneak = handler.isInputForcedDown(Input.SNEAK)) { + this.moveStrafe *= 0.3D; + this.moveForward *= 0.3D; + } + } +} From 5ca214534dba85e8c87c44be851810cfd34794a9 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 9 Jan 2019 19:11:53 -0800 Subject: [PATCH 7/8] mouse stuff --- .../listener/AbstractGameEventListener.java | 3 -- .../event/listener/IGameEventListener.java | 5 -- .../api/utils/IInputOverrideHandler.java | 4 +- .../launch/mixins/MixinKeyBinding.java | 27 +++++++++- .../launch/mixins/MixinMinecraft.java | 9 ---- .../java/baritone/event/GameEventHandler.java | 5 -- .../java/baritone/utils/BlockBreakHelper.java | 23 +-------- .../baritone/utils/InputOverrideHandler.java | 51 +++++++++---------- 8 files changed, 50 insertions(+), 77 deletions(-) diff --git a/src/api/java/baritone/api/event/listener/AbstractGameEventListener.java b/src/api/java/baritone/api/event/listener/AbstractGameEventListener.java index c11f926d..135c29a7 100644 --- a/src/api/java/baritone/api/event/listener/AbstractGameEventListener.java +++ b/src/api/java/baritone/api/event/listener/AbstractGameEventListener.java @@ -36,9 +36,6 @@ public interface AbstractGameEventListener extends IGameEventListener { @Override default void onPlayerUpdate(PlayerUpdateEvent event) {} - @Override - default void onProcessKeyBinds() {} - @Override default void onSendChatMessage(ChatEvent event) {} diff --git a/src/api/java/baritone/api/event/listener/IGameEventListener.java b/src/api/java/baritone/api/event/listener/IGameEventListener.java index 9308ab4c..0572cbe9 100644 --- a/src/api/java/baritone/api/event/listener/IGameEventListener.java +++ b/src/api/java/baritone/api/event/listener/IGameEventListener.java @@ -49,11 +49,6 @@ public interface IGameEventListener { */ void onPlayerUpdate(PlayerUpdateEvent event); - /** - * Run once per game tick from before keybinds are processed. - */ - void onProcessKeyBinds(); - /** * Runs whenever the client player sends a message to the server. * diff --git a/src/api/java/baritone/api/utils/IInputOverrideHandler.java b/src/api/java/baritone/api/utils/IInputOverrideHandler.java index 69dbbbeb..03f6e4dd 100644 --- a/src/api/java/baritone/api/utils/IInputOverrideHandler.java +++ b/src/api/java/baritone/api/utils/IInputOverrideHandler.java @@ -27,9 +27,7 @@ import net.minecraft.client.settings.KeyBinding; */ public interface IInputOverrideHandler extends IBehavior { - default boolean isInputForcedDown(KeyBinding key) { - return isInputForcedDown(Input.getInputForBind(key)); - } + Boolean isInputForcedDown(KeyBinding key); boolean isInputForcedDown(Input input); diff --git a/src/launch/java/baritone/launch/mixins/MixinKeyBinding.java b/src/launch/java/baritone/launch/mixins/MixinKeyBinding.java index 5859d3c5..cf832533 100644 --- a/src/launch/java/baritone/launch/mixins/MixinKeyBinding.java +++ b/src/launch/java/baritone/launch/mixins/MixinKeyBinding.java @@ -18,8 +18,10 @@ 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; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @@ -31,6 +33,9 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(KeyBinding.class) public class MixinKeyBinding { + @Shadow + public int pressTime; + @Inject( method = "isKeyDown", at = @At("HEAD"), @@ -38,8 +43,26 @@ public class MixinKeyBinding { ) private void isKeyDown(CallbackInfoReturnable cir) { // only the primary baritone forces keys - if (BaritoneAPI.getProvider().getPrimaryBaritone().getInputOverrideHandler().isInputForcedDown((KeyBinding) (Object) this)) { - cir.setReturnValue(true); + Boolean force = BaritoneAPI.getProvider().getPrimaryBaritone().getInputOverrideHandler().isInputForcedDown((KeyBinding) (Object) this); + if (force != null) { + cir.setReturnValue(force); // :sunglasses: + } + } + + @Inject( + method = "isPressed", + at = @At("HEAD"), + cancellable = true + ) + 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 == false) { // <-- cursed + if (pressTime > 0) { + Helper.HELPER.logDirect("You're trying to press this mouse button but I won't let you"); + pressTime--; + } + cir.setReturnValue(force); // :sunglasses: } } } diff --git a/src/launch/java/baritone/launch/mixins/MixinMinecraft.java b/src/launch/java/baritone/launch/mixins/MixinMinecraft.java index 7e30d9a0..6ee1a79b 100644 --- a/src/launch/java/baritone/launch/mixins/MixinMinecraft.java +++ b/src/launch/java/baritone/launch/mixins/MixinMinecraft.java @@ -96,15 +96,6 @@ public class MixinMinecraft { } - @Inject( - method = "processKeyBinds", - at = @At("HEAD") - ) - private void runTickKeyboard(CallbackInfo ci) { - // keyboard input is only the primary baritone - BaritoneAPI.getProvider().getPrimaryBaritone().getGameEventHandler().onProcessKeyBinds(); - } - @Inject( method = "loadWorld(Lnet/minecraft/client/multiplayer/WorldClient;Ljava/lang/String;)V", at = @At("HEAD") diff --git a/src/main/java/baritone/event/GameEventHandler.java b/src/main/java/baritone/event/GameEventHandler.java index 9f16283e..e85c46de 100644 --- a/src/main/java/baritone/event/GameEventHandler.java +++ b/src/main/java/baritone/event/GameEventHandler.java @@ -54,11 +54,6 @@ public final class GameEventHandler implements IEventBus, Helper { listeners.forEach(l -> l.onPlayerUpdate(event)); } - @Override - public final void onProcessKeyBinds() { - listeners.forEach(IGameEventListener::onProcessKeyBinds); - } - @Override public final void onSendChatMessage(ChatEvent event) { listeners.forEach(l -> l.onSendChatMessage(event)); diff --git a/src/main/java/baritone/utils/BlockBreakHelper.java b/src/main/java/baritone/utils/BlockBreakHelper.java index 36f31c6d..b410e6b3 100644 --- a/src/main/java/baritone/utils/BlockBreakHelper.java +++ b/src/main/java/baritone/utils/BlockBreakHelper.java @@ -17,8 +17,6 @@ package baritone.utils; -import baritone.Baritone; -import baritone.api.BaritoneAPI; import baritone.api.utils.IPlayerContext; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; @@ -52,26 +50,8 @@ public final class BlockBreakHelper implements Helper { } } - private boolean fakeBreak() { - if (playerContext != BaritoneAPI.getProvider().getPrimaryBaritone().getPlayerContext()) { - // for a non primary player, we need to fake break always, CLICK_LEFT has no effect - return true; - } - if (!Baritone.settings().leftClickWorkaround.get()) { - // if this setting is false, we CLICK_LEFT regardless of gui status - return false; - } - return mc.currentScreen != null; - } - - public boolean tick(boolean isLeftClick) { - if (!fakeBreak()) { - if (didBreakLastTick) { - stopBreakingBlock(); - } - return isLeftClick; - } + public void tick(boolean isLeftClick) { RayTraceResult trace = playerContext.objectMouseOver(); boolean isBlockTrace = trace != null && trace.typeOfHit == RayTraceResult.Type.BLOCK; @@ -82,6 +62,5 @@ public final class BlockBreakHelper implements Helper { stopBreakingBlock(); didBreakLastTick = false; } - return false; // fakeBreak is true so no matter what we aren't forcing CLICK_LEFT } } diff --git a/src/main/java/baritone/utils/InputOverrideHandler.java b/src/main/java/baritone/utils/InputOverrideHandler.java index 654ab10e..93fbe875 100755 --- a/src/main/java/baritone/utils/InputOverrideHandler.java +++ b/src/main/java/baritone/utils/InputOverrideHandler.java @@ -25,8 +25,8 @@ import baritone.api.utils.input.Input; import baritone.behavior.Behavior; import net.minecraft.client.Minecraft; import net.minecraft.client.settings.KeyBinding; +import net.minecraft.util.MovementInput; import net.minecraft.util.MovementInputFromOptions; -import org.lwjgl.input.Keyboard; import java.util.HashMap; import java.util.Map; @@ -60,14 +60,18 @@ public final class InputOverrideHandler extends Behavior implements IInputOverri * @return Whether or not it is being forced down */ @Override - public final boolean isInputForcedDown(KeyBinding key) { + public final Boolean isInputForcedDown(KeyBinding key) { Input input = Input.getInputForBind(key); - if (input == null || (input != Input.CLICK_LEFT && input != Input.CLICK_RIGHT)) { - // TODO handle left and right better - // ideally we wouldn't force any keybinds and would do everything directly for real + if (input == null || !inControl()) { + return null; + } + if (input == Input.CLICK_LEFT) { return false; } - return isInputForcedDown(input); + if (input == Input.CLICK_RIGHT) { + return isInputForcedDown(Input.CLICK_RIGHT); + } + return null; } /** @@ -100,36 +104,27 @@ public final class InputOverrideHandler extends Behavior implements IInputOverri this.inputForceStateMap.clear(); } - @Override - public final void onProcessKeyBinds() { - // Simulate the key being held down this tick - for (Input input : Input.values()) { - KeyBinding keyBinding = input.getKeyBinding(); - - if (isInputForcedDown(keyBinding) && !keyBinding.isKeyDown()) { - int keyCode = keyBinding.getKeyCode(); - - if (keyCode < Keyboard.KEYBOARD_SIZE) { - KeyBinding.onTick(keyCode < 0 ? keyCode + 100 : keyCode); - } - } - } - } - @Override public final void onTick(TickEvent event) { if (event.getType() == TickEvent.Type.OUT) { return; } - boolean stillClick = blockBreakHelper.tick(isInputForcedDown(Input.CLICK_LEFT)); - setInputForceState(Input.CLICK_LEFT, stillClick); - if (baritone.getPathingBehavior().isPathing() || baritone != BaritoneAPI.getProvider().getPrimaryBaritone()) { - ctx.player().movementInput = new PlayerMovementInput(this); - } else { - ctx.player().movementInput = new MovementInputFromOptions(Minecraft.getMinecraft().gameSettings); + blockBreakHelper.tick(isInputForcedDown(Input.CLICK_LEFT)); + + MovementInput desired = inControl() + ? new PlayerMovementInput(this) + : new MovementInputFromOptions(Minecraft.getMinecraft().gameSettings); + + if (ctx.player().movementInput.getClass() != desired.getClass()) { + ctx.player().movementInput = desired; // only set it if it was previously incorrect + // gotta do it this way, or else it constantly thinks you're beginning a double tap W sprint lol } } + private boolean inControl() { + return baritone.getPathingBehavior().isPathing() || baritone != BaritoneAPI.getProvider().getPrimaryBaritone(); + } + public BlockBreakHelper getBlockBreakHelper() { return blockBreakHelper; } From 200211c186189a894af299c2627f5ab395c626ce Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 10 Jan 2019 13:52:52 -0800 Subject: [PATCH 8/8] dont continue walking if there is no process in charge --- src/main/java/baritone/utils/PathingControlManager.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/baritone/utils/PathingControlManager.java b/src/main/java/baritone/utils/PathingControlManager.java index d1cb4f61..e748042e 100644 --- a/src/main/java/baritone/utils/PathingControlManager.java +++ b/src/main/java/baritone/utils/PathingControlManager.java @@ -82,11 +82,12 @@ public class PathingControlManager implements IPathingControlManager { public void preTick() { inControlLastTick = inControlThisTick; + PathingBehavior p = baritone.getPathingBehavior(); command = executeProcesses(); if (command == null) { + p.cancelSegmentIfSafe(); return; } - PathingBehavior p = baritone.getPathingBehavior(); switch (command.commandType) { case REQUEST_PAUSE: p.requestPause();