epic movement input
This commit is contained in:
parent
7d572d748b
commit
85ea21e83b
@ -380,7 +380,8 @@ public class PathExecutor implements IPathExecutor, Helper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if the movement requested sprinting, then we're done
|
// 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()) {
|
if (!ctx.player().isSprinting()) {
|
||||||
ctx.player().setSprinting(true);
|
ctx.player().setSprinting(true);
|
||||||
}
|
}
|
||||||
|
@ -18,11 +18,14 @@
|
|||||||
package baritone.utils;
|
package baritone.utils;
|
||||||
|
|
||||||
import baritone.Baritone;
|
import baritone.Baritone;
|
||||||
|
import baritone.api.BaritoneAPI;
|
||||||
import baritone.api.event.events.TickEvent;
|
import baritone.api.event.events.TickEvent;
|
||||||
import baritone.api.utils.IInputOverrideHandler;
|
import baritone.api.utils.IInputOverrideHandler;
|
||||||
import baritone.api.utils.input.Input;
|
import baritone.api.utils.input.Input;
|
||||||
import baritone.behavior.Behavior;
|
import baritone.behavior.Behavior;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.settings.KeyBinding;
|
import net.minecraft.client.settings.KeyBinding;
|
||||||
|
import net.minecraft.util.MovementInputFromOptions;
|
||||||
import org.lwjgl.input.Keyboard;
|
import org.lwjgl.input.Keyboard;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -58,7 +61,13 @@ public final class InputOverrideHandler extends Behavior implements IInputOverri
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final boolean isInputForcedDown(KeyBinding key) {
|
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));
|
boolean stillClick = blockBreakHelper.tick(isInputForcedDown(Input.CLICK_LEFT));
|
||||||
setInputForceState(Input.CLICK_LEFT, stillClick);
|
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() {
|
public BlockBreakHelper getBlockBreakHelper() {
|
||||||
|
57
src/main/java/baritone/utils/PlayerMovementInput.java
Normal file
57
src/main/java/baritone/utils/PlayerMovementInput.java
Normal file
@ -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 <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user