summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author zaaarf <zaaarf@proton.me>2023-03-18 22:54:59 +0100
committer zaaarf <zaaarf@proton.me>2023-03-18 22:55:46 +0100
commit7119da1cc258cf271155dad71d248a96d3a60589 (patch)
tree829c4508b3ee419c7e1e748a4ccb0da1d168872b
parenta1d538f2999539edc1af5eae754e7e292aeeb498 (diff)
chore: updated to lillero-processor 0.4, updated patches to new system
-rw-r--r--build.gradle4
-rw-r--r--gradle/libs.versions.toml2
-rw-r--r--src/main/java/ftbsc/bscv/patches/BackgroundPatch.java12
-rw-r--r--src/main/java/ftbsc/bscv/patches/BlockPushPatch.java13
-rw-r--r--src/main/java/ftbsc/bscv/patches/BoatPatch.java33
-rw-r--r--src/main/java/ftbsc/bscv/patches/CommandsPatch.java16
-rw-r--r--src/main/java/ftbsc/bscv/patches/EntityPushPatch.java13
-rw-r--r--src/main/java/ftbsc/bscv/patches/LiquidPushPatch.java13
-rw-r--r--src/main/java/ftbsc/bscv/patches/NoSlowPatch.java14
-rw-r--r--src/main/java/ftbsc/bscv/patches/PacketPatch.java32
10 files changed, 80 insertions, 72 deletions
diff --git a/build.gradle b/build.gradle
index ba78b16..0f30ca8 100644
--- a/build.gradle
+++ b/build.gradle
@@ -65,6 +65,10 @@ dependencies {
annotationProcessor libs.autoService
}
+compileJava { //mappings for lillero-processor
+ options.compilerArgs << '-AmappingsFile=https://data.fantabos.co/output.tsrg'
+}
+
jar {
archiveFileName = "${jar.archiveBaseName.get()}-${shortVersion}.${jar.archiveExtension.get()}"
manifest {
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index d4d142e..ca57f6f 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -5,7 +5,7 @@ minecraft = "1.16.5"
forge = "1.16.5-36.2.34"
autoService = "1.0.1"
lillero = "0.3.4"
-lilleroProcessor = "0.3.0"
+lilleroProcessor = "0.4.2"
checkerFramework = "0.6.24"
[plugins]
diff --git a/src/main/java/ftbsc/bscv/patches/BackgroundPatch.java b/src/main/java/ftbsc/bscv/patches/BackgroundPatch.java
index 5fd234c..5a5a8a7 100644
--- a/src/main/java/ftbsc/bscv/patches/BackgroundPatch.java
+++ b/src/main/java/ftbsc/bscv/patches/BackgroundPatch.java
@@ -1,11 +1,14 @@
package ftbsc.bscv.patches;
import ftbsc.bscv.ICommons;
+import ftbsc.lll.processor.annotations.Find;
import ftbsc.lll.processor.annotations.Injector;
import ftbsc.lll.processor.annotations.Patch;
import ftbsc.lll.processor.annotations.Target;
+import ftbsc.lll.proxies.MethodProxy;
import ftbsc.lll.tools.InsnSequence;
import ftbsc.lll.tools.PatternMatcher;
+import ftbsc.lll.tools.nodes.MethodProxyInsnNode;
import net.minecraft.client.gui.screen.Screen;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.Cancelable;
@@ -33,6 +36,8 @@ public class BackgroundPatch implements ICommons {
@Patch(value = Screen.class, reason = "add hook to cancel background on some screens")
public abstract static class BackgroundOverride implements Opcodes {
+ @Find(parent = BackgroundPatch.class)
+ abstract MethodProxy shouldDrawBackground();
@Target
abstract void renderBackground(MatrixStack stack, int x);
@@ -50,12 +55,7 @@ public class BackgroundPatch implements ICommons {
LabelNode skip = new LabelNode();
InsnSequence is = new InsnSequence();
is.add(new VarInsnNode(ALOAD, 0));
- is.add(new MethodInsnNode(
- INVOKESTATIC,
- "ftbsc/bscv/patches/BackgroundPatch",
- "shouldDrawBackground",
- "(Lnet/minecraft/client/gui/screen/Screen;)Z"
- ));
+ is.add(new MethodProxyInsnNode(INVOKESTATIC, shouldDrawBackground()));
is.add(new JumpInsnNode(IFEQ, skip));
is.add(new InsnNode(RETURN));
is.add(skip);
diff --git a/src/main/java/ftbsc/bscv/patches/BlockPushPatch.java b/src/main/java/ftbsc/bscv/patches/BlockPushPatch.java
index 50fb677..26745d5 100644
--- a/src/main/java/ftbsc/bscv/patches/BlockPushPatch.java
+++ b/src/main/java/ftbsc/bscv/patches/BlockPushPatch.java
@@ -1,9 +1,12 @@
package ftbsc.bscv.patches;
+import ftbsc.lll.processor.annotations.Find;
import ftbsc.lll.processor.annotations.Injector;
import ftbsc.lll.processor.annotations.Patch;
import ftbsc.lll.processor.annotations.Target;
+import ftbsc.lll.proxies.MethodProxy;
import ftbsc.lll.tools.InsnSequence;
+import ftbsc.lll.tools.nodes.MethodProxyInsnNode;
import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.Cancelable;
@@ -23,6 +26,9 @@ public class BlockPushPatch {
@Patch(value = ClientPlayerEntity.class, reason = "add hook to cancel block collisions")
public abstract static class BlockCollisionsOverride implements Opcodes {
+ @Find(parent = BlockPushPatch.class)
+ abstract MethodProxy shouldCancelBlockCollisions();
+
@Target
abstract void moveTowardsClosestSpace(double x, double z);
@@ -30,12 +36,7 @@ public class BlockPushPatch {
public void inject(ClassNode clazz, MethodNode main) {
LabelNode skip = new LabelNode();
InsnSequence is = new InsnSequence();
- is.add(new MethodInsnNode(
- INVOKESTATIC,
- "ftbsc/bscv/patches/BlockPushPatch",
- "shouldCancelBlockCollisions",
- "()Z"
- ));
+ is.add(new MethodProxyInsnNode(INVOKESTATIC, shouldCancelBlockCollisions()));
is.add(new JumpInsnNode(IFEQ, skip));
is.add(new InsnNode(RETURN));
is.add(skip);
diff --git a/src/main/java/ftbsc/bscv/patches/BoatPatch.java b/src/main/java/ftbsc/bscv/patches/BoatPatch.java
index 5356645..7c35e9a 100644
--- a/src/main/java/ftbsc/bscv/patches/BoatPatch.java
+++ b/src/main/java/ftbsc/bscv/patches/BoatPatch.java
@@ -1,10 +1,13 @@
package ftbsc.bscv.patches;
import ftbsc.bscv.ICommons;
+import ftbsc.lll.processor.annotations.Find;
import ftbsc.lll.processor.annotations.Injector;
import ftbsc.lll.processor.annotations.Patch;
import ftbsc.lll.processor.annotations.Target;
+import ftbsc.lll.proxies.MethodProxy;
import ftbsc.lll.tools.InsnSequence;
+import ftbsc.lll.tools.nodes.MethodProxyInsnNode;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.BoatEntity;
import net.minecraftforge.common.MinecraftForge;
@@ -44,6 +47,9 @@ public class BoatPatch implements ICommons {
@Patch(value = BoatEntity.class, reason = "add hook to cancel vanilla boat controls")
public abstract static class BoatControlOverride implements Opcodes {
+ @Find(parent = BoatPatch.class)
+ abstract MethodProxy boatControl();
+
@Target
public abstract void controlBoat();
@@ -52,12 +58,7 @@ public class BoatPatch implements ICommons {
// Hook at method start
LabelNode skip = new LabelNode();
InsnSequence is = new InsnSequence();
- is.add(new MethodInsnNode(
- INVOKESTATIC,
- "ftbsc/bscv/patches/BoatPatch",
- "boatControl",
- "()Z"
- ));
+ is.add(new MethodProxyInsnNode(INVOKESTATIC, boatControl()));
is.add(new JumpInsnNode(IFEQ, skip));
is.add(new InsnNode(RETURN));
is.add(skip);
@@ -68,6 +69,9 @@ public class BoatPatch implements ICommons {
@Patch(value = BoatEntity.class, reason = "add hook to cancel vanilla boat rotation clamping")
public abstract static class BoatClampOverride implements Opcodes {
+ @Find(parent = BoatPatch.class)
+ abstract MethodProxy boatClampRotation();
+
@Target
public abstract void clampRotation(Entity e);
@@ -76,12 +80,7 @@ public class BoatPatch implements ICommons {
// Hook at method start
LabelNode skip = new LabelNode();
InsnSequence is = new InsnSequence();
- is.add(new MethodInsnNode(
- INVOKESTATIC,
- "ftbsc/bscv/patches/BoatPatch",
- "boatClampRotation",
- "()Z"
- ));
+ is.add(new MethodProxyInsnNode(INVOKESTATIC, boatClampRotation()));
is.add(new JumpInsnNode(IFEQ, skip));
is.add(new InsnNode(RETURN));
is.add(skip);
@@ -92,6 +91,9 @@ public class BoatPatch implements ICommons {
@Patch(value = Entity.class, reason = "add hook to alter vanilla boat gravity")
public abstract static class BoatGravityOverride implements Opcodes {
+ @Find(parent = BoatPatch.class)
+ abstract MethodProxy boatGravityCheck();
+
@Target
public abstract boolean isNoGravity();
@@ -101,12 +103,7 @@ public class BoatPatch implements ICommons {
LabelNode skip = new LabelNode();
InsnSequence is = new InsnSequence();
is.add(new VarInsnNode(ALOAD, 0));
- is.add(new MethodInsnNode(
- INVOKESTATIC,
- "ftbsc/bscv/patches/BoatPatch",
- "boatGravityCheck",
- "(Lnet/minecraft/entity/Entity;)Z"
- ));
+ is.add(new MethodProxyInsnNode(INVOKESTATIC, boatGravityCheck()));
is.add(new JumpInsnNode(IFEQ, skip));
is.add(new InsnNode(ICONST_1));
is.add(new InsnNode(IRETURN));
diff --git a/src/main/java/ftbsc/bscv/patches/CommandsPatch.java b/src/main/java/ftbsc/bscv/patches/CommandsPatch.java
index 505e50f..d819cbd 100644
--- a/src/main/java/ftbsc/bscv/patches/CommandsPatch.java
+++ b/src/main/java/ftbsc/bscv/patches/CommandsPatch.java
@@ -1,10 +1,14 @@
package ftbsc.bscv.patches;
+import ftbsc.lll.processor.annotations.Find;
import ftbsc.lll.processor.annotations.Injector;
import ftbsc.lll.processor.annotations.Patch;
import ftbsc.lll.processor.annotations.Target;
+import ftbsc.lll.proxies.MethodProxy;
import ftbsc.lll.tools.InsnSequence;
import ftbsc.lll.tools.PatternMatcher;
+import ftbsc.lll.tools.debug.BytecodePrinter;
+import ftbsc.lll.tools.nodes.MethodProxyInsnNode;
import net.minecraft.client.network.play.ClientPlayNetHandler;
import net.minecraft.command.CommandSource;
import net.minecraft.network.play.server.SCommandListPacket;
@@ -32,11 +36,15 @@ public class CommandsPatch {
@Patch(value = ClientPlayNetHandler.class, reason = "add hook to insert our command suggestions")
public abstract static class CommandsDispatcherCatcher implements Opcodes {
+ @Find(parent = CommandsPatch.class)
+ abstract MethodProxy cmdBuilt();
+
@Target
abstract void handleCommands(SCommandListPacket pkt);
@Injector
public void inject(ClassNode clazz, MethodNode main) {
+ BytecodePrinter.logAsmMethod(main, "pre.log");
AbstractInsnNode found = PatternMatcher.builder()
.opcodes(ALOAD, INVOKEVIRTUAL, INVOKESPECIAL)
.ignoreFrames()
@@ -48,14 +56,10 @@ public class CommandsPatch {
InsnSequence is = new InsnSequence();
is.add(new InsnNode(DUP));
- is.add(new MethodInsnNode(
- INVOKESTATIC,
- "ftbsc/bscv/patches/CommandsPatch",
- "cmdBuilt",
- "(Lcom/mojang/brigadier/CommandDispatcher;)V"
- ));
+ is.add(new MethodProxyInsnNode(INVOKESTATIC, cmdBuilt()));
main.instructions.insert(found, is);
+ BytecodePrinter.logAsmMethod(main, "post.log");
}
}
}
diff --git a/src/main/java/ftbsc/bscv/patches/EntityPushPatch.java b/src/main/java/ftbsc/bscv/patches/EntityPushPatch.java
index cbb63c6..9cf74bd 100644
--- a/src/main/java/ftbsc/bscv/patches/EntityPushPatch.java
+++ b/src/main/java/ftbsc/bscv/patches/EntityPushPatch.java
@@ -1,10 +1,13 @@
package ftbsc.bscv.patches;
import ftbsc.bscv.ICommons;
+import ftbsc.lll.processor.annotations.Find;
import ftbsc.lll.processor.annotations.Injector;
import ftbsc.lll.processor.annotations.Patch;
import ftbsc.lll.processor.annotations.Target;
+import ftbsc.lll.proxies.MethodProxy;
import ftbsc.lll.tools.InsnSequence;
+import ftbsc.lll.tools.nodes.MethodProxyInsnNode;
import net.minecraft.entity.Entity;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.Cancelable;
@@ -27,6 +30,9 @@ public class EntityPushPatch implements ICommons {
@Patch(value = Entity.class, reason = "add hook to cancel entity collisions")
public abstract static class EntityCollisionsOverride implements Opcodes {
+ @Find(parent = EntityPushPatch.class)
+ abstract MethodProxy shouldCancelEntityCollisions();
+
@Target
abstract void push(double x, double y, double z);
@@ -35,12 +41,7 @@ public class EntityPushPatch implements ICommons {
LabelNode skip = new LabelNode();
InsnSequence is = new InsnSequence();
is.add(new VarInsnNode(ALOAD, 0));
- is.add(new MethodInsnNode(
- INVOKESTATIC,
- "ftbsc/bscv/patches/EntityPushPatch",
- "shouldCancelEntityCollisions",
- "(Lnet/minecraft/entity/Entity;)Z"
- ));
+ is.add(new MethodProxyInsnNode(INVOKESTATIC, shouldCancelEntityCollisions()));
is.add(new JumpInsnNode(IFEQ, skip));
is.add(new InsnNode(RETURN));
is.add(skip);
diff --git a/src/main/java/ftbsc/bscv/patches/LiquidPushPatch.java b/src/main/java/ftbsc/bscv/patches/LiquidPushPatch.java
index 838bea3..a800878 100644
--- a/src/main/java/ftbsc/bscv/patches/LiquidPushPatch.java
+++ b/src/main/java/ftbsc/bscv/patches/LiquidPushPatch.java
@@ -1,10 +1,13 @@
package ftbsc.bscv.patches;
import ftbsc.bscv.ICommons;
+import ftbsc.lll.processor.annotations.Find;
import ftbsc.lll.processor.annotations.Injector;
import ftbsc.lll.processor.annotations.Patch;
import ftbsc.lll.processor.annotations.Target;
+import ftbsc.lll.proxies.MethodProxy;
import ftbsc.lll.tools.InsnSequence;
+import ftbsc.lll.tools.nodes.MethodProxyInsnNode;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.Cancelable;
@@ -27,6 +30,9 @@ public class LiquidPushPatch implements ICommons {
@Patch(value = PlayerEntity.class, reason = "add hook to cancel liquid collisions")
public abstract static class LiquidCollisionsOverride implements Opcodes {
+ @Find(parent = LiquidPushPatch.class)
+ abstract MethodProxy shouldCancelLiquidCollisions();
+
@Target
abstract boolean isPushedByFluid();
@@ -35,12 +41,7 @@ public class LiquidPushPatch implements ICommons {
LabelNode skip = new LabelNode();
InsnSequence is = new InsnSequence();
is.add(new VarInsnNode(ALOAD, 0));
- is.add(new MethodInsnNode(
- INVOKESTATIC,
- "ftbsc/bscv/patches/LiquidPushPatch",
- "shouldCancelLiquidCollisions",
- "(Lnet/minecraft/entity/player/PlayerEntity;)Z"
- ));
+ is.add(new MethodProxyInsnNode(INVOKESTATIC, shouldCancelLiquidCollisions()));
is.add(new JumpInsnNode(IFEQ, skip));
is.add(new InsnNode(ICONST_0));
is.add(new InsnNode(IRETURN));
diff --git a/src/main/java/ftbsc/bscv/patches/NoSlowPatch.java b/src/main/java/ftbsc/bscv/patches/NoSlowPatch.java
index 98400ef..c9ce730 100644
--- a/src/main/java/ftbsc/bscv/patches/NoSlowPatch.java
+++ b/src/main/java/ftbsc/bscv/patches/NoSlowPatch.java
@@ -1,10 +1,13 @@
package ftbsc.bscv.patches;
+import ftbsc.lll.processor.annotations.Find;
import ftbsc.lll.processor.annotations.Injector;
import ftbsc.lll.processor.annotations.Patch;
import ftbsc.lll.processor.annotations.Target;
+import ftbsc.lll.proxies.MethodProxy;
import ftbsc.lll.tools.InsnSequence;
import ftbsc.lll.tools.PatternMatcher;
+import ftbsc.lll.tools.nodes.MethodProxyInsnNode;
import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.Cancelable;
@@ -24,6 +27,10 @@ public class NoSlowPatch {
@Patch(value = ClientPlayerEntity.class, reason = "add hook to cancel slowing down effect of using items")
public abstract static class SlowDownOverride implements Opcodes {
+
+ @Find(parent = NoSlowPatch.class)
+ abstract MethodProxy shouldSlowPlayer();
+
@Target
abstract void aiStep();
@@ -49,12 +56,7 @@ public class NoSlowPatch {
LabelNode skip = new LabelNode(); // TODO can we get the label that the original IF is jumping to without adding one ourselves?
InsnSequence is = new InsnSequence();
- is.add(new MethodInsnNode(
- INVOKESTATIC,
- "ftbsc/bscv/patches/NoSlowPatch",
- "shouldSlowPlayer",
- "()Z"
- ));
+ is.add(new MethodProxyInsnNode(INVOKESTATIC, shouldSlowPlayer()));
is.add(new JumpInsnNode(IFNE, skip));
main.instructions.insert(found, is);
diff --git a/src/main/java/ftbsc/bscv/patches/PacketPatch.java b/src/main/java/ftbsc/bscv/patches/PacketPatch.java
index 7d93625..603dd09 100644
--- a/src/main/java/ftbsc/bscv/patches/PacketPatch.java
+++ b/src/main/java/ftbsc/bscv/patches/PacketPatch.java
@@ -1,11 +1,16 @@
package ftbsc.bscv.patches;
+import ftbsc.lll.processor.annotations.Find;
import ftbsc.lll.processor.annotations.Injector;
import ftbsc.lll.processor.annotations.Patch;
import ftbsc.lll.processor.annotations.Target;
+import ftbsc.lll.proxies.MethodProxy;
import ftbsc.lll.tools.InsnSequence;
import ftbsc.lll.tools.PatternMatcher;
+import ftbsc.lll.tools.debug.BytecodePrinter;
+import ftbsc.lll.tools.nodes.MethodProxyInsnNode;
import io.netty.channel.ChannelHandlerContext;
+import io.netty.util.concurrent.Future;
import io.netty.util.concurrent.GenericFutureListener;
import net.minecraft.network.IPacket;
import net.minecraft.network.NetworkManager;
@@ -48,13 +53,14 @@ public class PacketPatch {
@Patch(value = NetworkManager.class, reason = "add hook to intercept and alter/cancel incoming packets")
public abstract static class IncomingPacketInterceptor implements Opcodes {
+ @Find(parent = PacketPatch.class)
+ abstract MethodProxy pktIn();
+
@Target
- @SuppressWarnings("rawtypes")
- public abstract void channelRead0(ChannelHandlerContext ctx, IPacket pak);
+ public abstract void channelRead0(ChannelHandlerContext ctx, IPacket<?> pak);
@Injector
public void inject(ClassNode clazz, MethodNode main) {
- // ALOAD, GETFIELD, INVOKEINTERFACE, IFEQ
AbstractInsnNode found = PatternMatcher.builder()
.opcodes(ALOAD, GETFIELD, INVOKEINTERFACE, IFEQ)
.ignoreFrames()
@@ -67,12 +73,7 @@ public class PacketPatch {
LabelNode skip = new LabelNode();
InsnSequence is = new InsnSequence();
is.add(new VarInsnNode(ALOAD, 2));
- is.add(new MethodInsnNode(
- INVOKESTATIC,
- "ftbsc/bscv/patches/PacketPatch",
- "pktIn",
- "(Lnet/minecraft/network/IPacket;)Z"
- ));
+ is.add(new MethodProxyInsnNode(INVOKESTATIC, pktIn()));
is.add(new JumpInsnNode(IFEQ, skip));
is.add(new InsnNode(RETURN));
is.add(skip);
@@ -83,9 +84,11 @@ public class PacketPatch {
@Patch(value = NetworkManager.class, reason = "add hook to intercept and alter/cancel outgoing packets")
public abstract static class OutgoingPacketInterceptor implements Opcodes {
+ @Find(parent = PacketPatch.class)
+ abstract MethodProxy pktOut();
+
@Target
- @SuppressWarnings("rawtypes")
- public abstract void sendPacket(IPacket pak, GenericFutureListener gfl);
+ public abstract void sendPacket(IPacket<?> pak, GenericFutureListener<? extends Future<? super Void>> gfl);
@Injector
public void inject(ClassNode clazz, MethodNode main) {
@@ -93,12 +96,7 @@ public class PacketPatch {
LabelNode skip = new LabelNode();
InsnSequence is = new InsnSequence();
is.add(new VarInsnNode(ALOAD, 1));
- is.add(new MethodInsnNode(
- INVOKESTATIC,
- "ftbsc/bscv/patches/PacketPatch",
- "pktOut",
- "(Lnet/minecraft/network/IPacket;)Z"
- ));
+ is.add(new MethodProxyInsnNode(INVOKESTATIC, pktOut()));
is.add(new JumpInsnNode(IFEQ, skip));
is.add(new InsnNode(RETURN));
is.add(skip);