fix: make GuiMove work with AutoWalk

This commit is contained in:
əlemi 2023-03-18 22:08:56 +01:00
parent a259fbcc33
commit ef1b212fd1
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -2,6 +2,7 @@ package ftbsc.bscv.modules.motion;
import com.google.auto.service.AutoService; import com.google.auto.service.AutoService;
import ftbsc.bscv.Boscovicino;
import ftbsc.bscv.api.ILoadable; import ftbsc.bscv.api.ILoadable;
import ftbsc.bscv.modules.AbstractModule; import ftbsc.bscv.modules.AbstractModule;
import ftbsc.bscv.patches.BackgroundPatch.RenderBackgroundEvent; import ftbsc.bscv.patches.BackgroundPatch.RenderBackgroundEvent;
@ -29,6 +30,8 @@ public class GuiMove extends AbstractModule {
public final ForgeConfigSpec.ConfigValue<Boolean> background; public final ForgeConfigSpec.ConfigValue<Boolean> background;
private AutoWalk autoWalk_mod;
public GuiMove() { public GuiMove() {
super(); super();
@ -39,6 +42,12 @@ public class GuiMove extends AbstractModule {
.build(this); .build(this);
} }
@Override
public void enable() {
this.autoWalk_mod = (AutoWalk) Boscovicino.modManager.get(AutoWalk.class);
super.enable();
}
private boolean isKeyDown(KeyBinding key) { private boolean isKeyDown(KeyBinding key) {
return InputMappings.isKeyDown(MC.getWindow().getWindow(), key.getKey().getValue()); return InputMappings.isKeyDown(MC.getWindow().getWindow(), key.getKey().getValue());
} }
@ -63,7 +72,7 @@ public class GuiMove extends AbstractModule {
private void forceMovementTick(MovementInput input) { private void forceMovementTick(MovementInput input) {
// TODO can we patch to make this always happen instead of duplicating code? // TODO can we patch to make this always happen instead of duplicating code?
input.up = this.isKeyDown(MC.options.keyUp); input.up = this.autoWalk_mod.isEnabled() || this.isKeyDown(MC.options.keyUp);
input.down = this.isKeyDown(MC.options.keyDown); input.down = this.isKeyDown(MC.options.keyDown);
input.left = this.isKeyDown(MC.options.keyLeft); input.left = this.isKeyDown(MC.options.keyLeft);
input.right = this.isKeyDown(MC.options.keyRight); input.right = this.isKeyDown(MC.options.keyRight);