chore: updated to lillero-processor 0.4, updated patches to new system

This commit is contained in:
zaaarf 2023-03-18 22:54:59 +01:00
parent a1d538f299
commit 7119da1cc2
No known key found for this signature in database
GPG key ID: 82240E075E31FA4C
10 changed files with 80 additions and 72 deletions

View file

@ -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 {

View file

@ -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]

View file

@ -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);

View file

@ -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);

View file

@ -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));

View file

@ -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");
}
}
}

View file

@ -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);

View file

@ -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));

View file

@ -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);

View file

@ -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);