diff options
author | alemi <me@alemi.dev> | 2023-03-12 00:16:41 +0100 |
---|---|---|
committer | alemi <me@alemi.dev> | 2023-03-12 00:16:41 +0100 |
commit | adb72b9c58aa710b6ba33c225667ed4b62411808 (patch) | |
tree | 0c2f9e90dd079c30dc8855ab2c0d0563656ad1d1 /src/main | |
parent | 53e24b2e088da2e8e8ca3132bf1e3bcf568436ed (diff) |
fix: should also work with boats
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/ftbsc/bscv/modules/motion/GuiMove.java | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/src/main/java/ftbsc/bscv/modules/motion/GuiMove.java b/src/main/java/ftbsc/bscv/modules/motion/GuiMove.java index 193d77a..4d769a1 100644 --- a/src/main/java/ftbsc/bscv/modules/motion/GuiMove.java +++ b/src/main/java/ftbsc/bscv/modules/motion/GuiMove.java @@ -15,6 +15,8 @@ import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.inventory.ContainerScreen; import net.minecraft.client.settings.KeyBinding; import net.minecraft.client.util.InputMappings; +import net.minecraft.entity.Entity; +import net.minecraft.util.MovementInput; import net.minecraftforge.client.event.InputUpdateEvent; import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.eventbus.api.SubscribeEvent; @@ -59,19 +61,19 @@ public class GuiMove extends AbstractModule { CustomizeSkinScreen.class, }; - private void forceMovementTick() { + private void forceMovementTick(MovementInput input) { // TODO can we patch to make this always happen instead of duplicating code? - MC.player.input.up = this.isKeyDown(MC.options.keyUp); - MC.player.input.down = this.isKeyDown(MC.options.keyDown); - MC.player.input.left = this.isKeyDown(MC.options.keyLeft); - MC.player.input.right = this.isKeyDown(MC.options.keyRight); - MC.player.input.jumping = this.isKeyDown(MC.options.keyJump); - MC.player.input.shiftKeyDown = this.isKeyDown(MC.options.keyShift); + input.up = this.isKeyDown(MC.options.keyUp); + input.down = this.isKeyDown(MC.options.keyDown); + input.left = this.isKeyDown(MC.options.keyLeft); + input.right = this.isKeyDown(MC.options.keyRight); + input.jumping = this.isKeyDown(MC.options.keyJump); + input.shiftKeyDown = this.isKeyDown(MC.options.keyShift); - MC.player.input.forwardImpulse = MC.player.input.up == MC.player.input.down ? 0.0F : (MC.player.input.up ? 1.0F : -1.0F); - MC.player.input.leftImpulse = MC.player.input.left == MC.player.input.right ? 0.0F : (MC.player.input.left ? 1.0F : -1.0F); + input.forwardImpulse = input.up == input.down ? 0.0F : (input.up ? 1.0F : -1.0F); + input.leftImpulse = input.left == input.right ? 0.0F : (input.left ? 1.0F : -1.0F); - if (MC.player.input.shiftKeyDown && !MC.player.isSprinting()) { + if (input.shiftKeyDown && !MC.player.isSprinting()) { MC.player.setSprinting(true); } } @@ -92,10 +94,18 @@ public class GuiMove extends AbstractModule { } } + private boolean overrideEntityInput(Entity in) { + if (MC.player == null) return false; + if (MC.player.getVehicle() != null) { + if (in.equals(MC.player.getVehicle())) return true; + } + if (in.equals(MC.player)) return true; + return false; + } + @SubscribeEvent public void onInputUpdate(InputUpdateEvent event) { - if (MC.player == null) return; - if (event.getEntityLiving() != MC.player) return; + if (!this.overrideEntityInput(event.getEntityLiving())) return; if (this.allowMovementOnThisScreen(MC.screen)) { for (KeyBinding key : this.keys) { @@ -105,7 +115,7 @@ public class GuiMove extends AbstractModule { key.setDown(state); } } - this.forceMovementTick(); + this.forceMovementTick(MC.player.input); } } } |