summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/ftbsc/bscv/events/BoatEvent.java22
-rw-r--r--src/main/java/ftbsc/bscv/modules/motion/BoatFly.java5
-rw-r--r--src/main/java/ftbsc/bscv/patches/BoatPatch.java47
3 files changed, 31 insertions, 43 deletions
diff --git a/src/main/java/ftbsc/bscv/events/BoatEvent.java b/src/main/java/ftbsc/bscv/events/BoatEvent.java
deleted file mode 100644
index 1bef3a6..0000000
--- a/src/main/java/ftbsc/bscv/events/BoatEvent.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package ftbsc.bscv.events;
-
-import net.minecraftforge.eventbus.api.Cancelable;
-import net.minecraftforge.eventbus.api.Event;
-
-public class BoatEvent {
-
- @Cancelable
- public static class Control extends Event {
- public Control() { super(); }
- }
-
- @Cancelable
- public static class ClampRotation extends Event {
- public ClampRotation() { super(); }
- }
-
- @Cancelable
- public static class Gravity extends Event {
- public Gravity() { super(); }
- }
-}
diff --git a/src/main/java/ftbsc/bscv/modules/motion/BoatFly.java b/src/main/java/ftbsc/bscv/modules/motion/BoatFly.java
index c8f2c98..920d827 100644
--- a/src/main/java/ftbsc/bscv/modules/motion/BoatFly.java
+++ b/src/main/java/ftbsc/bscv/modules/motion/BoatFly.java
@@ -1,10 +1,9 @@
package ftbsc.bscv.modules.motion;
import com.google.auto.service.AutoService;
-import ftbsc.bscv.ICommons;
import ftbsc.bscv.api.ILoadable;
-import ftbsc.bscv.events.BoatEvent;
import ftbsc.bscv.modules.AbstractModule;
+import ftbsc.bscv.patches.BoatPatch.BoatEvent;
import ftbsc.bscv.tools.Keyboard;
import ftbsc.bscv.tools.Setting;
import net.minecraft.entity.Entity;
@@ -15,7 +14,7 @@ import net.minecraftforge.event.TickEvent.Phase;
import net.minecraftforge.eventbus.api.SubscribeEvent;
@AutoService(ILoadable.class)
-public class BoatFly extends AbstractModule implements ICommons {
+public class BoatFly extends AbstractModule {
public final ForgeConfigSpec.ConfigValue<Double> speed;
public final ForgeConfigSpec.ConfigValue<Double> rise;
diff --git a/src/main/java/ftbsc/bscv/patches/BoatPatch.java b/src/main/java/ftbsc/bscv/patches/BoatPatch.java
index 8c55a85..5356645 100644
--- a/src/main/java/ftbsc/bscv/patches/BoatPatch.java
+++ b/src/main/java/ftbsc/bscv/patches/BoatPatch.java
@@ -1,7 +1,6 @@
package ftbsc.bscv.patches;
import ftbsc.bscv.ICommons;
-import ftbsc.bscv.events.BoatEvent;
import ftbsc.lll.processor.annotations.Injector;
import ftbsc.lll.processor.annotations.Patch;
import ftbsc.lll.processor.annotations.Target;
@@ -9,26 +8,38 @@ import ftbsc.lll.tools.InsnSequence;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.BoatEntity;
import net.minecraftforge.common.MinecraftForge;
+import net.minecraftforge.eventbus.api.Cancelable;
+import net.minecraftforge.eventbus.api.Event;
+
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.*;
-public class BoatPatch {
+public class BoatPatch implements ICommons {
- public static class BoatHook implements ICommons {
- public static boolean boatControl() {
- return MinecraftForge.EVENT_BUS.post(new BoatEvent.Control());
- }
+ public static class BoatEvent {
+ @Cancelable
+ public static class Control extends Event { }
+
+ @Cancelable
+ public static class ClampRotation extends Event { }
+
+ @Cancelable
+ public static class Gravity extends Event { }
+ }
- public static boolean boatClampRotation() {
- return MinecraftForge.EVENT_BUS.post(new BoatEvent.ClampRotation());
- }
+ public static boolean boatControl() {
+ return MinecraftForge.EVENT_BUS.post(new BoatEvent.Control());
+ }
- public static boolean boatGravityCheck(Entity entity) {
- if (MC.player == null) return false;
- if (MC.player.getVehicle() == null) return false;
- if (MC.player.getVehicle() != entity) return false;
- return MinecraftForge.EVENT_BUS.post(new BoatEvent.Gravity());
- }
+ public static boolean boatClampRotation() {
+ return MinecraftForge.EVENT_BUS.post(new BoatEvent.ClampRotation());
+ }
+
+ public static boolean boatGravityCheck(Entity entity) {
+ if (MC.player == null) return false;
+ if (MC.player.getVehicle() == null) return false;
+ if (MC.player.getVehicle() != entity) return false;
+ return MinecraftForge.EVENT_BUS.post(new BoatEvent.Gravity());
}
@Patch(value = BoatEntity.class, reason = "add hook to cancel vanilla boat controls")
@@ -43,7 +54,7 @@ public class BoatPatch {
InsnSequence is = new InsnSequence();
is.add(new MethodInsnNode(
INVOKESTATIC,
- "ftbsc/bscv/patches/BoatPatch$BoatHook",
+ "ftbsc/bscv/patches/BoatPatch",
"boatControl",
"()Z"
));
@@ -67,7 +78,7 @@ public class BoatPatch {
InsnSequence is = new InsnSequence();
is.add(new MethodInsnNode(
INVOKESTATIC,
- "ftbsc/bscv/patches/BoatPatch$BoatHook",
+ "ftbsc/bscv/patches/BoatPatch",
"boatClampRotation",
"()Z"
));
@@ -92,7 +103,7 @@ public class BoatPatch {
is.add(new VarInsnNode(ALOAD, 0));
is.add(new MethodInsnNode(
INVOKESTATIC,
- "ftbsc/bscv/patches/BoatPatch$BoatHook",
+ "ftbsc/bscv/patches/BoatPatch",
"boatGravityCheck",
"(Lnet/minecraft/entity/Entity;)Z"
));