chore: moved boatpatch stuff into boatpatch class
This commit is contained in:
parent
0a2609ac0c
commit
f0488fdd5d
3 changed files with 31 additions and 43 deletions
|
@ -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(); }
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,10 +1,9 @@
|
||||||
package ftbsc.bscv.modules.motion;
|
package ftbsc.bscv.modules.motion;
|
||||||
|
|
||||||
import com.google.auto.service.AutoService;
|
import com.google.auto.service.AutoService;
|
||||||
import ftbsc.bscv.ICommons;
|
|
||||||
import ftbsc.bscv.api.ILoadable;
|
import ftbsc.bscv.api.ILoadable;
|
||||||
import ftbsc.bscv.events.BoatEvent;
|
|
||||||
import ftbsc.bscv.modules.AbstractModule;
|
import ftbsc.bscv.modules.AbstractModule;
|
||||||
|
import ftbsc.bscv.patches.BoatPatch.BoatEvent;
|
||||||
import ftbsc.bscv.tools.Keyboard;
|
import ftbsc.bscv.tools.Keyboard;
|
||||||
import ftbsc.bscv.tools.Setting;
|
import ftbsc.bscv.tools.Setting;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
|
@ -15,7 +14,7 @@ import net.minecraftforge.event.TickEvent.Phase;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
|
|
||||||
@AutoService(ILoadable.class)
|
@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> speed;
|
||||||
public final ForgeConfigSpec.ConfigValue<Double> rise;
|
public final ForgeConfigSpec.ConfigValue<Double> rise;
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package ftbsc.bscv.patches;
|
package ftbsc.bscv.patches;
|
||||||
|
|
||||||
import ftbsc.bscv.ICommons;
|
import ftbsc.bscv.ICommons;
|
||||||
import ftbsc.bscv.events.BoatEvent;
|
|
||||||
import ftbsc.lll.processor.annotations.Injector;
|
import ftbsc.lll.processor.annotations.Injector;
|
||||||
import ftbsc.lll.processor.annotations.Patch;
|
import ftbsc.lll.processor.annotations.Patch;
|
||||||
import ftbsc.lll.processor.annotations.Target;
|
import ftbsc.lll.processor.annotations.Target;
|
||||||
|
@ -9,26 +8,38 @@ import ftbsc.lll.tools.InsnSequence;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.item.BoatEntity;
|
import net.minecraft.entity.item.BoatEntity;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
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.Opcodes;
|
||||||
import org.objectweb.asm.tree.*;
|
import org.objectweb.asm.tree.*;
|
||||||
|
|
||||||
public class BoatPatch {
|
public class BoatPatch implements ICommons {
|
||||||
|
|
||||||
public static class BoatHook implements ICommons {
|
public static class BoatEvent {
|
||||||
public static boolean boatControl() {
|
@Cancelable
|
||||||
return MinecraftForge.EVENT_BUS.post(new BoatEvent.Control());
|
public static class Control extends Event { }
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean boatClampRotation() {
|
@Cancelable
|
||||||
return MinecraftForge.EVENT_BUS.post(new BoatEvent.ClampRotation());
|
public static class ClampRotation extends Event { }
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean boatGravityCheck(Entity entity) {
|
@Cancelable
|
||||||
if (MC.player == null) return false;
|
public static class Gravity extends Event { }
|
||||||
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 boatControl() {
|
||||||
}
|
return MinecraftForge.EVENT_BUS.post(new BoatEvent.Control());
|
||||||
|
}
|
||||||
|
|
||||||
|
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")
|
@Patch(value = BoatEntity.class, reason = "add hook to cancel vanilla boat controls")
|
||||||
|
@ -43,7 +54,7 @@ public class BoatPatch {
|
||||||
InsnSequence is = new InsnSequence();
|
InsnSequence is = new InsnSequence();
|
||||||
is.add(new MethodInsnNode(
|
is.add(new MethodInsnNode(
|
||||||
INVOKESTATIC,
|
INVOKESTATIC,
|
||||||
"ftbsc/bscv/patches/BoatPatch$BoatHook",
|
"ftbsc/bscv/patches/BoatPatch",
|
||||||
"boatControl",
|
"boatControl",
|
||||||
"()Z"
|
"()Z"
|
||||||
));
|
));
|
||||||
|
@ -67,7 +78,7 @@ public class BoatPatch {
|
||||||
InsnSequence is = new InsnSequence();
|
InsnSequence is = new InsnSequence();
|
||||||
is.add(new MethodInsnNode(
|
is.add(new MethodInsnNode(
|
||||||
INVOKESTATIC,
|
INVOKESTATIC,
|
||||||
"ftbsc/bscv/patches/BoatPatch$BoatHook",
|
"ftbsc/bscv/patches/BoatPatch",
|
||||||
"boatClampRotation",
|
"boatClampRotation",
|
||||||
"()Z"
|
"()Z"
|
||||||
));
|
));
|
||||||
|
@ -92,7 +103,7 @@ public class BoatPatch {
|
||||||
is.add(new VarInsnNode(ALOAD, 0));
|
is.add(new VarInsnNode(ALOAD, 0));
|
||||||
is.add(new MethodInsnNode(
|
is.add(new MethodInsnNode(
|
||||||
INVOKESTATIC,
|
INVOKESTATIC,
|
||||||
"ftbsc/bscv/patches/BoatPatch$BoatHook",
|
"ftbsc/bscv/patches/BoatPatch",
|
||||||
"boatGravityCheck",
|
"boatGravityCheck",
|
||||||
"(Lnet/minecraft/entity/Entity;)Z"
|
"(Lnet/minecraft/entity/Entity;)Z"
|
||||||
));
|
));
|
||||||
|
|
Loading…
Reference in a new issue