summaryrefslogtreecommitdiff
path: root/src/main/java/ftbsc
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/ftbsc')
-rw-r--r--src/main/java/ftbsc/bscv/patches/BoatPatch.java49
-rw-r--r--src/main/java/ftbsc/bscv/patches/PacketPatch.java50
2 files changed, 46 insertions, 53 deletions
diff --git a/src/main/java/ftbsc/bscv/patches/BoatPatch.java b/src/main/java/ftbsc/bscv/patches/BoatPatch.java
index 1283b88..f035a50 100644
--- a/src/main/java/ftbsc/bscv/patches/BoatPatch.java
+++ b/src/main/java/ftbsc/bscv/patches/BoatPatch.java
@@ -1,6 +1,10 @@
package ftbsc.bscv.patches;
+import ftbsc.lll.processor.annotations.Injector;
+import ftbsc.lll.processor.annotations.Patch;
+import ftbsc.lll.processor.annotations.Target;
import net.minecraft.entity.Entity;
+import net.minecraft.entity.item.BoatEntity;
import net.minecraftforge.common.MinecraftForge;
import org.objectweb.asm.Opcodes;
@@ -36,14 +40,13 @@ public class BoatPatch {
}
}
- public static class BoatControlOverride implements IInjector, Opcodes {
- public String name() { return "BoatControlOverride"; }
- public String reason() { return "add hook to cancel vanilla boat controls"; }
- public String targetClass() { return "net.minecraft.entity.item.BoatEntity"; }
- public String methodName() { return "func_184443_x"; } // void controlBoat()
- public String methodDesc() { return "()V"; }
-
- public void inject(ClassNode clazz, MethodNode main) {
+ @Patch(value = BoatEntity.class, reason = "add hook to cancel vanilla boat controls")
+ public abstract static class BoatControlOverride implements Opcodes {
+ @Target
+ public abstract void controlBoat();
+
+ @Injector
+ public static void inject(ClassNode clazz, MethodNode main) {
// Hook at method start
LabelNode skip = new LabelNode();
InsnSequence is = new InsnSequence();
@@ -61,14 +64,13 @@ public class BoatPatch {
}
}
- public static class BoatClampOverride implements IInjector, Opcodes {
- public String name() { return "BoatClampOverride"; }
- public String reason() { return "add hook to cancel vanilla boat rotation clamping"; }
- public String targetClass() { return "net.minecraft.entity.item.BoatEntity"; }
- public String methodName() { return "func_184454_a"; } // void clampRotation(Entity e)
- public String methodDesc() { return "(Lnet/minecraft/entity/Entity;)V"; }
-
- public void inject(ClassNode clazz, MethodNode main) {
+ @Patch(value = BoatEntity.class, reason = "add hook to cancel vanilla boat rotation clamping")
+ public abstract static class BoatClampOverride implements Opcodes {
+ @Target
+ public abstract void clampRotation(Entity e);
+
+ @Injector
+ public static void inject(ClassNode clazz, MethodNode main) {
// Hook at method start
LabelNode skip = new LabelNode();
InsnSequence is = new InsnSequence();
@@ -86,14 +88,13 @@ public class BoatPatch {
}
}
- public static class BoatGravityOverride implements IInjector, Opcodes {
- public String name() { return "BoatGravityOverride"; }
- public String reason() { return "add hook to alter vanilla boat gravity"; }
- public String targetClass() { return "net.minecraft.entity.Entity"; }
- public String methodName() { return "func_189652_ae"; } // boolean isNoGravity()
- public String methodDesc() { return "()Z"; }
-
- public void inject(ClassNode clazz, MethodNode main) {
+ @Patch(value = Entity.class, reason = "add hook to alter vanilla boat gravity")
+ public abstract static class BoatGravityOverride implements Opcodes {
+ @Target
+ public abstract boolean isNoGravity();
+
+ @Injector
+ public static void inject(ClassNode clazz, MethodNode main) {
// Hook at method start
LabelNode skip = new LabelNode();
InsnSequence is = new InsnSequence();
diff --git a/src/main/java/ftbsc/bscv/patches/PacketPatch.java b/src/main/java/ftbsc/bscv/patches/PacketPatch.java
index 4c7292d..610638e 100644
--- a/src/main/java/ftbsc/bscv/patches/PacketPatch.java
+++ b/src/main/java/ftbsc/bscv/patches/PacketPatch.java
@@ -1,6 +1,12 @@
package ftbsc.bscv.patches;
+import ftbsc.lll.processor.annotations.Injector;
+import ftbsc.lll.processor.annotations.Patch;
+import ftbsc.lll.processor.annotations.Target;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.util.concurrent.GenericFutureListener;
import net.minecraft.network.IPacket;
+import net.minecraft.network.NetworkManager;
import net.minecraftforge.common.MinecraftForge;
import org.objectweb.asm.Opcodes;
@@ -31,21 +37,14 @@ public class PacketPatch {
}
}
- public static class IncomingPacketInterceptor implements IInjector, Opcodes {
- public String name() { return "IncomingPacketInterceptor"; }
- public String reason() { return "add hook to intercept and alter/cancel incoming packets"; }
- public String targetClass() { return "net.minecraft.network.NetworkManager"; }
- public String methodName() { return "channelRead0"; }
- public String methodDesc() {
- return
- new DescriptorBuilder()
- .setReturnType(void.class)
- .addParameter("io.netty.channel.ChannelHandlerContext")
- .addParameter("net.minecraft.network.IPacket")
- .build();
- }
-
- public void inject(ClassNode clazz, MethodNode main) {
+ @Patch(value = NetworkManager.class, reason = "add hook to intercept and alter/cancel incoming packets")
+ public abstract static class IncomingPacketInterceptor implements Opcodes {
+ @Target
+ @SuppressWarnings("rawtypes")
+ public abstract void channelRead0(ChannelHandlerContext ctx, IPacket pak);
+
+ @Injector
+ public static void inject(ClassNode clazz, MethodNode main) {
// ALOAD, GETFIELD, INVOKEINTERFACE, IFEQ
AbstractInsnNode found = PatternMatcher.builder()
.opcodes(ALOAD, GETFIELD, INVOKEINTERFACE, IFEQ)
@@ -73,21 +72,14 @@ public class PacketPatch {
}
}
- public static class OutgoingPacketInterceptor implements IInjector, Opcodes {
- public String name() { return "OutgoingPacketInterceptor"; }
- public String reason() { return "add hook to intercept and alter/cancel outgoing packets"; }
- public String targetClass() { return "net.minecraft.network.NetworkManager"; }
- public String methodName() { return "func_150732_b"; }
- public String methodDesc() {
- return
- new DescriptorBuilder()
- .setReturnType(void.class)
- .addParameter("net.minecraft.network.IPacket")
- .addParameter("io.netty.util.concurrent.GenericFutureListener")
- .build();
- }
+ @Patch(value = NetworkManager.class, reason = "add hook to intercept and alter/cancel outgoing packets")
+ public abstract static class OutgoingPacketInterceptor implements Opcodes {
+ @Target
+ @SuppressWarnings("rawtypes")
+ public abstract void sendPacket(IPacket pak, GenericFutureListener gfl);
- public void inject(ClassNode clazz, MethodNode main) {
+ @Injector
+ public static void inject(ClassNode clazz, MethodNode main) {
// hook at the top
LabelNode skip = new LabelNode();
InsnSequence is = new InsnSequence();