diff options
author | alemi <me@alemi.dev> | 2023-02-27 03:41:56 +0100 |
---|---|---|
committer | alemi <me@alemi.dev> | 2023-02-27 03:50:31 +0100 |
commit | cc1ef1452d19e0895545a5c058c1cc08a84b939c (patch) | |
tree | 3ee9143c1b8cd6f866b57f1ad38f6caf6857c75a /src/main | |
parent | de9f23e856c39fdf8871130078ad56504f0cefef (diff) |
fix: moved util out
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/ftbsc/bscv/modules/motion/BoatFly.java | 23 | ||||
-rw-r--r-- | src/main/java/ftbsc/bscv/tools/Keyboard.java | 8 |
2 files changed, 24 insertions, 7 deletions
diff --git a/src/main/java/ftbsc/bscv/modules/motion/BoatFly.java b/src/main/java/ftbsc/bscv/modules/motion/BoatFly.java index d158f9a..deb6644 100644 --- a/src/main/java/ftbsc/bscv/modules/motion/BoatFly.java +++ b/src/main/java/ftbsc/bscv/modules/motion/BoatFly.java @@ -53,6 +53,15 @@ public class BoatFly extends Module implements ICommons { } @SubscribeEvent + public void onRender(RenderWorldLastEvent event) { + if (!this.rotation.get()) return; + if (MC.player == null) return; + Entity vehicle = MC.player.getVehicle(); + if (vehicle == null) return; + vehicle.yRot = MC.player.yRot; + } + + @SubscribeEvent public void onBoatClampRotation(BoatEvent.ClampRotation event) { if (MC.player != null && MC.player.getVehicle() != null) { event.setCanceled(true); @@ -69,20 +78,20 @@ public class BoatFly extends Module implements ICommons { @SubscribeEvent public void onTick(TickEvent.ClientTickEvent event) { if (event.phase == Phase.END) return; - if (MC.player == null) { - this.disable(); - return; - } + if (MC.player == null) return; Entity vehicle = MC.player.getVehicle(); if (vehicle == null) return; vehicle.yRot = MC.player.yRot; if (Keyboard.isMoving()) { - Vector2f motion = MC.player.input.getMoveVector(); double speed = this.speed.get(); - Vector3d delta = new Vector3d(motion.x * speed, MC.options.keyJump.isDown() ? this.rise.get() : 0., motion.y * speed); - vehicle.setDeltaMovement(delta.yRot((float) -(MC.player.yRot * (Math.PI / 180F)))); + if (this.sprint.get() && !MC.player.isSprinting()) speed /= 2.; + vehicle.setDeltaMovement( + Keyboard.getMotion().multiply(speed, this.rise.get(), speed) + ); + } else if (!this.drift.get()) { + vehicle.setDeltaMovement(0., 0., 0.); } } diff --git a/src/main/java/ftbsc/bscv/tools/Keyboard.java b/src/main/java/ftbsc/bscv/tools/Keyboard.java index 29a5a03..754e9b9 100644 --- a/src/main/java/ftbsc/bscv/tools/Keyboard.java +++ b/src/main/java/ftbsc/bscv/tools/Keyboard.java @@ -1,6 +1,8 @@ package ftbsc.bscv.tools; import ftbsc.bscv.ICommons; +import net.minecraft.util.math.vector.Vector2f; +import net.minecraft.util.math.vector.Vector3d; public class Keyboard implements ICommons { @@ -16,4 +18,10 @@ public class Keyboard implements ICommons { || MC.options.keyJump.isDown() || MC.options.keySprint.isDown(); } + + public static Vector3d getMotion() { + Vector2f motion = MC.player.input.getMoveVector(); + double vertical = MC.options.keyJump.isDown() ? 1.0 : (MC.options.keySprint.isDown() ? -1.0 : 0.0); + return new Vector3d(motion.x, vertical, motion.y).yRot((float) -(MC.player.yRot * (Math.PI / 180F))); + } } |