summaryrefslogtreecommitdiff
path: root/src/main/java/ftbsc/bscv/modules/motion/BoatFly.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/ftbsc/bscv/modules/motion/BoatFly.java')
-rw-r--r--src/main/java/ftbsc/bscv/modules/motion/BoatFly.java34
1 files changed, 28 insertions, 6 deletions
diff --git a/src/main/java/ftbsc/bscv/modules/motion/BoatFly.java b/src/main/java/ftbsc/bscv/modules/motion/BoatFly.java
index 9506e5a..d158f9a 100644
--- a/src/main/java/ftbsc/bscv/modules/motion/BoatFly.java
+++ b/src/main/java/ftbsc/bscv/modules/motion/BoatFly.java
@@ -1,6 +1,7 @@
package ftbsc.bscv.modules.motion;
import com.mojang.brigadier.CommandDispatcher;
+import com.mojang.brigadier.arguments.BoolArgumentType;
import com.mojang.brigadier.arguments.DoubleArgumentType;
import ftbsc.bscv.ICommons;
@@ -9,16 +10,18 @@ import ftbsc.bscv.modules.Module;
import ftbsc.bscv.tools.Keyboard;
import net.minecraft.command.CommandSource;
import net.minecraft.entity.Entity;
-import net.minecraft.entity.item.BoatEntity;
import net.minecraft.util.math.vector.Vector2f;
+import net.minecraft.util.math.vector.Vector3d;
import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.event.TickEvent;
+import net.minecraftforge.event.TickEvent.Phase;
import net.minecraftforge.eventbus.api.SubscribeEvent;
public class BoatFly extends Module implements ICommons {
public final ForgeConfigSpec.ConfigValue<Double> speed;
public final ForgeConfigSpec.ConfigValue<Double> rise;
+ public final ForgeConfigSpec.ConfigValue<Boolean> gravity;
public BoatFly(ForgeConfigSpec.Builder builder, CommandDispatcher<CommandSource> dispatcher) {
super("BoatFly", Group.MOTION, builder, dispatcher);
@@ -34,6 +37,12 @@ public class BoatFly extends Module implements ICommons {
DoubleArgumentType.doubleArg(), Double.class,
builder, dispatcher
);
+
+ this.gravity = this.option(
+ "gravity", "toggle boat gravity", true,
+ BoolArgumentType.bool(), Boolean.class,
+ builder, dispatcher
+ );
}
@SubscribeEvent
@@ -44,23 +53,36 @@ public class BoatFly extends Module implements ICommons {
}
@SubscribeEvent
+ public void onBoatClampRotation(BoatEvent.ClampRotation event) {
+ if (MC.player != null && MC.player.getVehicle() != null) {
+ event.setCanceled(true);
+ }
+ }
+
+ @SubscribeEvent
+ public void onBoatGravity(BoatEvent.Gravity event) {
+ if (!this.gravity.get() && MC.player != null && MC.player.getVehicle() != null) {
+ event.setCanceled(true);
+ }
+ }
+
+ @SubscribeEvent
public void onTick(TickEvent.ClientTickEvent event) {
- // if (event.phase == Phase.END) return;
+ if (event.phase == Phase.END) return;
if (MC.player == null) {
this.disable();
return;
}
Entity vehicle = MC.player.getVehicle();
if (vehicle == null) return;
- if (vehicle instanceof BoatEntity) {
- }
+ vehicle.yRot = MC.player.yRot;
if (Keyboard.isMoving()) {
Vector2f motion = MC.player.input.getMoveVector();
- double rise = MC.options.keyJump.isDown() ? this.rise.get() : 0.;
double speed = this.speed.get();
- vehicle.setDeltaMovement(motion.x * speed, rise, motion.y * speed);
+ 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))));
}
}