Merge branch 'processor5' into dev
This commit is contained in:
commit
954a8c806f
12 changed files with 161 additions and 152 deletions
|
@ -66,7 +66,7 @@ dependencies {
|
|||
}
|
||||
|
||||
compileJava { //mappings for lillero-processor
|
||||
options.compilerArgs << '-AmappingsFile=https://data.fantabos.co/output.tsrg'
|
||||
options.compilerArgs << '-AmappingsFile=https://data.fantabos.co/1.16.5.tsrg'
|
||||
}
|
||||
|
||||
jar {
|
||||
|
|
|
@ -4,8 +4,8 @@ gitVersion = "0.13.0"
|
|||
minecraft = "1.16.5"
|
||||
forge = "1.16.5-36.2.34"
|
||||
autoService = "1.0.1"
|
||||
lillero = "0.3.4"
|
||||
lilleroProcessor = "0.4.2"
|
||||
lillero = "0.4.1"
|
||||
lilleroProcessor = "0.5.2"
|
||||
checkerFramework = "0.6.24"
|
||||
|
||||
[plugins]
|
||||
|
|
|
@ -5,7 +5,7 @@ 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.proxies.impl.MethodProxy;
|
||||
import ftbsc.lll.tools.InsnSequence;
|
||||
import ftbsc.lll.tools.PatternMatcher;
|
||||
import ftbsc.lll.tools.nodes.MethodProxyInsnNode;
|
||||
|
@ -20,11 +20,6 @@ import org.objectweb.asm.tree.*;
|
|||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
||||
public class BackgroundPatch implements ICommons {
|
||||
|
||||
public static boolean shouldDrawBackground(Screen screen) {
|
||||
return MinecraftForge.EVENT_BUS.post(new RenderBackgroundEvent(screen));
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class RenderBackgroundEvent extends Event {
|
||||
public final Screen screen;
|
||||
|
@ -34,15 +29,21 @@ public class BackgroundPatch implements ICommons {
|
|||
}
|
||||
}
|
||||
|
||||
@Patch(value = Screen.class, reason = "add hook to cancel background on some screens")
|
||||
@Patch(Screen.class)
|
||||
public abstract static class BackgroundOverride implements Opcodes {
|
||||
@Find(parent = BackgroundPatch.class)
|
||||
abstract MethodProxy shouldDrawBackground();
|
||||
@Target
|
||||
@Find(BackgroundOverride.class)
|
||||
MethodProxy shouldDrawBackground;
|
||||
|
||||
@Target(of = "shouldDrawBackground")
|
||||
public static boolean shouldDrawBackground(Screen screen) {
|
||||
return MinecraftForge.EVENT_BUS.post(new RenderBackgroundEvent(screen));
|
||||
}
|
||||
|
||||
@Target(of = "injectCancelBackgroundHook")
|
||||
abstract void renderBackground(MatrixStack stack, int x);
|
||||
|
||||
@Injector
|
||||
public void inject(ClassNode clazz, MethodNode main) {
|
||||
@Injector(reason = "add hook to cancel background on some screens")
|
||||
public void injectCancelBackgroundHook(ClassNode clazz, MethodNode main) {
|
||||
AbstractInsnNode found = PatternMatcher.builder()
|
||||
.opcodes(ALOAD, ALOAD, ICONST_0, ICONST_0)
|
||||
.ignoreFrames()
|
||||
|
@ -55,7 +56,7 @@ public class BackgroundPatch implements ICommons {
|
|||
LabelNode skip = new LabelNode();
|
||||
InsnSequence is = new InsnSequence();
|
||||
is.add(new VarInsnNode(ALOAD, 0));
|
||||
is.add(new MethodProxyInsnNode(INVOKESTATIC, shouldDrawBackground()));
|
||||
is.add(new MethodProxyInsnNode(INVOKESTATIC, shouldDrawBackground));
|
||||
is.add(new JumpInsnNode(IFEQ, skip));
|
||||
is.add(new InsnNode(RETURN));
|
||||
is.add(skip);
|
||||
|
|
|
@ -4,7 +4,7 @@ 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.proxies.impl.MethodProxy;
|
||||
import ftbsc.lll.tools.InsnSequence;
|
||||
import ftbsc.lll.tools.nodes.MethodProxyInsnNode;
|
||||
import net.minecraft.client.entity.player.ClientPlayerEntity;
|
||||
|
@ -20,23 +20,24 @@ public class BlockPushPatch {
|
|||
@Cancelable
|
||||
public static class PlayerBlockPushEvent extends Event {}
|
||||
|
||||
public static boolean shouldCancelBlockCollisions() {
|
||||
return MinecraftForge.EVENT_BUS.post(new PlayerBlockPushEvent());
|
||||
}
|
||||
|
||||
@Patch(value = ClientPlayerEntity.class, reason = "add hook to cancel block collisions")
|
||||
@Patch(ClientPlayerEntity.class)
|
||||
public abstract static class BlockCollisionsOverride implements Opcodes {
|
||||
@Find(parent = BlockPushPatch.class)
|
||||
abstract MethodProxy shouldCancelBlockCollisions();
|
||||
@Find(BlockCollisionsOverride.class)
|
||||
MethodProxy shouldCancelBlockCollisions;
|
||||
|
||||
@Target
|
||||
@Target(of = "shouldCancelBlockCollisions")
|
||||
public static boolean shouldCancelBlockCollisions() {
|
||||
return MinecraftForge.EVENT_BUS.post(new PlayerBlockPushEvent());
|
||||
}
|
||||
|
||||
@Target(of = "injectCancelCollisionsHook")
|
||||
abstract void moveTowardsClosestSpace(double x, double z);
|
||||
|
||||
@Injector
|
||||
public void inject(ClassNode clazz, MethodNode main) {
|
||||
@Injector(reason = "add hook to cancel block collisions")
|
||||
public void injectCancelCollisionsHook(ClassNode clazz, MethodNode main) {
|
||||
LabelNode skip = new LabelNode();
|
||||
InsnSequence is = new InsnSequence();
|
||||
is.add(new MethodProxyInsnNode(INVOKESTATIC, shouldCancelBlockCollisions()));
|
||||
is.add(new MethodProxyInsnNode(INVOKESTATIC, shouldCancelBlockCollisions));
|
||||
is.add(new JumpInsnNode(IFEQ, skip));
|
||||
is.add(new InsnNode(RETURN));
|
||||
is.add(skip);
|
||||
|
|
|
@ -5,7 +5,7 @@ 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.proxies.impl.MethodProxy;
|
||||
import ftbsc.lll.tools.InsnSequence;
|
||||
import ftbsc.lll.tools.nodes.MethodProxyInsnNode;
|
||||
import net.minecraft.entity.Entity;
|
||||
|
@ -30,35 +30,25 @@ public class BoatPatch implements ICommons {
|
|||
public static class Gravity extends Event { }
|
||||
}
|
||||
|
||||
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(BoatEntity.class)
|
||||
public abstract static class BoatControlOverride implements Opcodes {
|
||||
@Find(parent = BoatPatch.class)
|
||||
abstract MethodProxy boatControl();
|
||||
@Find(BoatControlOverride.class)
|
||||
MethodProxy boatControl;
|
||||
|
||||
@Target
|
||||
@Target(of = "boatControl")
|
||||
public static boolean boatControl() {
|
||||
return MinecraftForge.EVENT_BUS.post(new BoatEvent.Control());
|
||||
}
|
||||
|
||||
@Target(of = "injectBoatControlHook")
|
||||
public abstract void controlBoat();
|
||||
|
||||
@Injector
|
||||
public void inject(ClassNode clazz, MethodNode main) {
|
||||
@Injector(reason = "add hook to cancel vanilla boat controls")
|
||||
public void injectBoatControlHook(ClassNode clazz, MethodNode main) {
|
||||
// Hook at method start
|
||||
LabelNode skip = new LabelNode();
|
||||
InsnSequence is = new InsnSequence();
|
||||
is.add(new MethodProxyInsnNode(INVOKESTATIC, boatControl()));
|
||||
is.add(new MethodProxyInsnNode(INVOKESTATIC, boatControl));
|
||||
is.add(new JumpInsnNode(IFEQ, skip));
|
||||
is.add(new InsnNode(RETURN));
|
||||
is.add(skip);
|
||||
|
@ -67,20 +57,25 @@ public class BoatPatch implements ICommons {
|
|||
}
|
||||
}
|
||||
|
||||
@Patch(value = BoatEntity.class, reason = "add hook to cancel vanilla boat rotation clamping")
|
||||
@Patch(BoatEntity.class)
|
||||
public abstract static class BoatClampOverride implements Opcodes {
|
||||
@Find(parent = BoatPatch.class)
|
||||
abstract MethodProxy boatClampRotation();
|
||||
@Find(BoatClampOverride.class)
|
||||
MethodProxy boatClampRotation;
|
||||
|
||||
@Target
|
||||
@Target(of = "boatClampRotation")
|
||||
public static boolean boatClampRotation() {
|
||||
return MinecraftForge.EVENT_BUS.post(new BoatEvent.ClampRotation());
|
||||
}
|
||||
|
||||
@Target(of = "injectRotationClampingHook")
|
||||
public abstract void clampRotation(Entity e);
|
||||
|
||||
@Injector
|
||||
public void inject(ClassNode clazz, MethodNode main) {
|
||||
@Injector(reason = "add hook to cancel vanilla boat rotation clamping")
|
||||
public void injectRotationClampingHook(ClassNode clazz, MethodNode main) {
|
||||
// Hook at method start
|
||||
LabelNode skip = new LabelNode();
|
||||
InsnSequence is = new InsnSequence();
|
||||
is.add(new MethodProxyInsnNode(INVOKESTATIC, boatClampRotation()));
|
||||
is.add(new MethodProxyInsnNode(INVOKESTATIC, boatClampRotation));
|
||||
is.add(new JumpInsnNode(IFEQ, skip));
|
||||
is.add(new InsnNode(RETURN));
|
||||
is.add(skip);
|
||||
|
@ -89,21 +84,29 @@ public class BoatPatch implements ICommons {
|
|||
}
|
||||
}
|
||||
|
||||
@Patch(value = Entity.class, reason = "add hook to alter vanilla boat gravity")
|
||||
@Patch(Entity.class)
|
||||
public abstract static class BoatGravityOverride implements Opcodes {
|
||||
@Find(parent = BoatPatch.class)
|
||||
abstract MethodProxy boatGravityCheck();
|
||||
@Find(BoatGravityOverride.class)
|
||||
MethodProxy boatGravityCheck;
|
||||
|
||||
@Target
|
||||
@Target(of = "boatGravityCheck")
|
||||
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());
|
||||
}
|
||||
|
||||
@Target(of = "injectGravityHook")
|
||||
public abstract boolean isNoGravity();
|
||||
|
||||
@Injector
|
||||
public void inject(ClassNode clazz, MethodNode main) {
|
||||
@Injector(reason = "add hook to alter vanilla boat gravity")
|
||||
public void injectGravityHook(ClassNode clazz, MethodNode main) {
|
||||
// Hook at method start
|
||||
LabelNode skip = new LabelNode();
|
||||
InsnSequence is = new InsnSequence();
|
||||
is.add(new VarInsnNode(ALOAD, 0));
|
||||
is.add(new MethodProxyInsnNode(INVOKESTATIC, boatGravityCheck()));
|
||||
is.add(new MethodProxyInsnNode(INVOKESTATIC, boatGravityCheck));
|
||||
is.add(new JumpInsnNode(IFEQ, skip));
|
||||
is.add(new InsnNode(ICONST_1));
|
||||
is.add(new InsnNode(IRETURN));
|
||||
|
|
|
@ -14,16 +14,16 @@ import org.objectweb.asm.tree.*;
|
|||
|
||||
public class ChatPatch {
|
||||
|
||||
@Patch(value = Minecraft.class, reason = "add hook to prevent chat from being cleared")
|
||||
@Patch(Minecraft.class)
|
||||
public abstract static class ChatClearInterceptor implements Opcodes {
|
||||
|
||||
// TODO this should be optional
|
||||
|
||||
@Target
|
||||
@Target(of = "injectClearChatHook")
|
||||
abstract void setScreen(Screen screen);
|
||||
|
||||
@Injector
|
||||
public void inject(ClassNode clazz, MethodNode main) {
|
||||
@Injector(reason = "skips chat clearing")
|
||||
public void injectClearChatHook(ClassNode clazz, MethodNode main) {
|
||||
InsnSequence match = PatternMatcher.builder()
|
||||
.opcodes(ALOAD, GETFIELD, INVOKEVIRTUAL, ICONST_1, INVOKEVIRTUAL)
|
||||
.ignoreLineNumbers()
|
||||
|
|
|
@ -4,7 +4,7 @@ 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.proxies.impl.MethodProxy;
|
||||
import ftbsc.lll.tools.InsnSequence;
|
||||
import ftbsc.lll.tools.PatternMatcher;
|
||||
import ftbsc.lll.tools.debug.BytecodePrinter;
|
||||
|
@ -30,21 +30,21 @@ public class CommandsPatch {
|
|||
}
|
||||
}
|
||||
|
||||
public static void cmdBuilt(CommandDispatcher<CommandSource> dispatcher) {
|
||||
MinecraftForge.EVENT_BUS.post(new CommandsBuiltEvent(dispatcher));
|
||||
}
|
||||
|
||||
@Patch(value = ClientPlayNetHandler.class, reason = "add hook to insert our command suggestions")
|
||||
@Patch(ClientPlayNetHandler.class)
|
||||
public abstract static class CommandsDispatcherCatcher implements Opcodes {
|
||||
@Find(parent = CommandsPatch.class)
|
||||
abstract MethodProxy cmdBuilt();
|
||||
@Find(CommandsDispatcherCatcher.class)
|
||||
MethodProxy cmdBuilt;
|
||||
|
||||
@Target
|
||||
@Target(of = "cmdBuilt")
|
||||
public static void cmdBuilt(CommandDispatcher<CommandSource> dispatcher) {
|
||||
MinecraftForge.EVENT_BUS.post(new CommandsBuiltEvent(dispatcher));
|
||||
}
|
||||
|
||||
@Target(of = "injectCommandHandler")
|
||||
abstract void handleCommands(SCommandListPacket pkt);
|
||||
|
||||
@Injector
|
||||
public void inject(ClassNode clazz, MethodNode main) {
|
||||
BytecodePrinter.logAsmMethod(main, "pre.log");
|
||||
@Injector(reason = "add hook to insert our command suggestions")
|
||||
public void injectCommandHandler(ClassNode clazz, MethodNode main) {
|
||||
AbstractInsnNode found = PatternMatcher.builder()
|
||||
.opcodes(ALOAD, INVOKEVIRTUAL, INVOKESPECIAL)
|
||||
.ignoreFrames()
|
||||
|
@ -56,10 +56,9 @@ public class CommandsPatch {
|
|||
|
||||
InsnSequence is = new InsnSequence();
|
||||
is.add(new InsnNode(DUP));
|
||||
is.add(new MethodProxyInsnNode(INVOKESTATIC, cmdBuilt()));
|
||||
is.add(new MethodProxyInsnNode(INVOKESTATIC, cmdBuilt));
|
||||
|
||||
main.instructions.insert(found, is);
|
||||
BytecodePrinter.logAsmMethod(main, "post.log");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ 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.proxies.impl.MethodProxy;
|
||||
import ftbsc.lll.tools.InsnSequence;
|
||||
import ftbsc.lll.tools.nodes.MethodProxyInsnNode;
|
||||
import net.minecraft.entity.Entity;
|
||||
|
@ -21,27 +21,28 @@ public class EntityPushPatch implements ICommons {
|
|||
@Cancelable
|
||||
public static class PlayerEntityPushEvent extends Event {}
|
||||
|
||||
public static boolean shouldCancelEntityCollisions(Entity e) {
|
||||
if (e.equals(MC.player)) {
|
||||
return MinecraftForge.EVENT_BUS.post(new PlayerEntityPushEvent());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Patch(value = Entity.class, reason = "add hook to cancel entity collisions")
|
||||
@Patch(Entity.class)
|
||||
public abstract static class EntityCollisionsOverride implements Opcodes {
|
||||
@Find(parent = EntityPushPatch.class)
|
||||
abstract MethodProxy shouldCancelEntityCollisions();
|
||||
@Find(EntityCollisionsOverride.class)
|
||||
MethodProxy shouldCancelEntityCollisions;
|
||||
|
||||
@Target
|
||||
@Target(of = "shouldCancelEntityCollisions")
|
||||
public static boolean shouldCancelEntityCollisions(Entity e) {
|
||||
if (e.equals(MC.player)) {
|
||||
return MinecraftForge.EVENT_BUS.post(new PlayerEntityPushEvent());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Target(of = "injectEntityCollisionHook")
|
||||
abstract void push(double x, double y, double z);
|
||||
|
||||
@Injector
|
||||
public void inject(ClassNode clazz, MethodNode main) {
|
||||
@Injector(reason = "add hook to cancel entity collisions")
|
||||
public void injectEntityCollisionHook(ClassNode clazz, MethodNode main) {
|
||||
LabelNode skip = new LabelNode();
|
||||
InsnSequence is = new InsnSequence();
|
||||
is.add(new VarInsnNode(ALOAD, 0));
|
||||
is.add(new MethodProxyInsnNode(INVOKESTATIC, shouldCancelEntityCollisions()));
|
||||
is.add(new MethodProxyInsnNode(INVOKESTATIC, shouldCancelEntityCollisions));
|
||||
is.add(new JumpInsnNode(IFEQ, skip));
|
||||
is.add(new InsnNode(RETURN));
|
||||
is.add(skip);
|
||||
|
|
|
@ -5,7 +5,7 @@ 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.proxies.impl.MethodProxy;
|
||||
import ftbsc.lll.tools.InsnSequence;
|
||||
import ftbsc.lll.tools.nodes.MethodProxyInsnNode;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
|
@ -21,27 +21,28 @@ public class LiquidPushPatch implements ICommons {
|
|||
@Cancelable
|
||||
public static class PlayerLiquidPushEvent extends Event {}
|
||||
|
||||
public static boolean shouldCancelLiquidCollisions(PlayerEntity player) {
|
||||
if (player.equals(MC.player)) {
|
||||
return MinecraftForge.EVENT_BUS.post(new PlayerLiquidPushEvent());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Patch(value = PlayerEntity.class, reason = "add hook to cancel liquid collisions")
|
||||
@Patch(PlayerEntity.class)
|
||||
public abstract static class LiquidCollisionsOverride implements Opcodes {
|
||||
@Find(parent = LiquidPushPatch.class)
|
||||
abstract MethodProxy shouldCancelLiquidCollisions();
|
||||
@Find(LiquidCollisionsOverride.class)
|
||||
MethodProxy shouldCancelLiquidCollisions;
|
||||
|
||||
@Target
|
||||
@Target(of = "shouldCancelLiquidCollisions")
|
||||
public static boolean shouldCancelLiquidCollisions(PlayerEntity player) {
|
||||
if (player.equals(MC.player)) {
|
||||
return MinecraftForge.EVENT_BUS.post(new PlayerLiquidPushEvent());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Target(of = "injectLiquidCollisionHook")
|
||||
abstract boolean isPushedByFluid();
|
||||
|
||||
@Injector
|
||||
public void inject(ClassNode clazz, MethodNode main) {
|
||||
@Injector(reason = "add hook to cancel liquid collisions")
|
||||
public void injectLiquidCollisionHook(ClassNode clazz, MethodNode main) {
|
||||
LabelNode skip = new LabelNode();
|
||||
InsnSequence is = new InsnSequence();
|
||||
is.add(new VarInsnNode(ALOAD, 0));
|
||||
is.add(new MethodProxyInsnNode(INVOKESTATIC, shouldCancelLiquidCollisions()));
|
||||
is.add(new MethodProxyInsnNode(INVOKESTATIC, shouldCancelLiquidCollisions));
|
||||
is.add(new JumpInsnNode(IFEQ, skip));
|
||||
is.add(new InsnNode(ICONST_0));
|
||||
is.add(new InsnNode(IRETURN));
|
||||
|
|
|
@ -4,7 +4,7 @@ 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.proxies.impl.MethodProxy;
|
||||
import ftbsc.lll.tools.InsnSequence;
|
||||
import ftbsc.lll.tools.PatternMatcher;
|
||||
import ftbsc.lll.tools.nodes.MethodProxyInsnNode;
|
||||
|
@ -21,21 +21,22 @@ public class NoSlowPatch {
|
|||
@Cancelable
|
||||
public static class PlayerSlowDownEvent extends Event { }
|
||||
|
||||
public static boolean shouldSlowPlayer() {
|
||||
return MinecraftForge.EVENT_BUS.post(new PlayerSlowDownEvent());
|
||||
}
|
||||
|
||||
@Patch(value = ClientPlayerEntity.class, reason = "add hook to cancel slowing down effect of using items")
|
||||
@Patch(ClientPlayerEntity.class)
|
||||
public abstract static class SlowDownOverride implements Opcodes {
|
||||
|
||||
@Find(parent = NoSlowPatch.class)
|
||||
abstract MethodProxy shouldSlowPlayer();
|
||||
@Find(SlowDownOverride.class)
|
||||
MethodProxy shouldSlowPlayer;
|
||||
|
||||
@Target
|
||||
@Target(of = "shouldSlowPlayer")
|
||||
public static boolean shouldSlowPlayer() {
|
||||
return MinecraftForge.EVENT_BUS.post(new PlayerSlowDownEvent());
|
||||
}
|
||||
|
||||
@Target(of = "injectNoSlowHook")
|
||||
abstract void aiStep();
|
||||
|
||||
@Injector
|
||||
public void inject(ClassNode clazz, MethodNode main) {
|
||||
@Injector(reason = "add hook to cancel slowing down effect of using items")
|
||||
public void injectNoSlowHook(ClassNode clazz, MethodNode main) {
|
||||
AbstractInsnNode found = PatternMatcher.builder()
|
||||
.opcodes(ALOAD, INVOKEVIRTUAL, IFEQ, ALOAD, INVOKEVIRTUAL, IFNE)
|
||||
.ignoreFrames()
|
||||
|
@ -56,7 +57,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 MethodProxyInsnNode(INVOKESTATIC, shouldSlowPlayer()));
|
||||
is.add(new MethodProxyInsnNode(INVOKESTATIC, shouldSlowPlayer));
|
||||
is.add(new JumpInsnNode(IFNE, skip));
|
||||
|
||||
main.instructions.insert(found, is);
|
||||
|
|
|
@ -4,7 +4,7 @@ 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.proxies.impl.MethodProxy;
|
||||
import ftbsc.lll.tools.InsnSequence;
|
||||
import ftbsc.lll.tools.PatternMatcher;
|
||||
import ftbsc.lll.tools.debug.BytecodePrinter;
|
||||
|
@ -43,24 +43,21 @@ public class PacketPatch {
|
|||
}
|
||||
}
|
||||
|
||||
public static boolean pktIn(IPacket<?> pkt) {
|
||||
return MinecraftForge.EVENT_BUS.post(new PacketEvent.Incoming(pkt));
|
||||
}
|
||||
|
||||
public static boolean pktOut(IPacket<?> pkt) {
|
||||
return MinecraftForge.EVENT_BUS.post(new PacketEvent.Outgoing(pkt));
|
||||
}
|
||||
|
||||
@Patch(value = NetworkManager.class, reason = "add hook to intercept and alter/cancel incoming packets")
|
||||
@Patch(NetworkManager.class)
|
||||
public abstract static class IncomingPacketInterceptor implements Opcodes {
|
||||
@Find(parent = PacketPatch.class)
|
||||
abstract MethodProxy pktIn();
|
||||
@Find(IncomingPacketInterceptor.class)
|
||||
MethodProxy pktIn;
|
||||
|
||||
@Target
|
||||
public abstract void channelRead0(ChannelHandlerContext ctx, IPacket<?> pak);
|
||||
@Target(of = "pktIn")
|
||||
public static boolean pktIn(IPacket<?> pkt) {
|
||||
return MinecraftForge.EVENT_BUS.post(new PacketEvent.Incoming(pkt));
|
||||
}
|
||||
|
||||
@Injector
|
||||
public void inject(ClassNode clazz, MethodNode main) {
|
||||
@Target(of = "injectIncomingInterceptor")
|
||||
abstract void channelRead0(ChannelHandlerContext ctx, IPacket<?> pak);
|
||||
|
||||
@Injector(reason = "add hook to intercept and alter/cancel incoming packets")
|
||||
public void injectIncomingInterceptor(ClassNode clazz, MethodNode main) {
|
||||
AbstractInsnNode found = PatternMatcher.builder()
|
||||
.opcodes(ALOAD, GETFIELD, INVOKEINTERFACE, IFEQ)
|
||||
.ignoreFrames()
|
||||
|
@ -73,7 +70,7 @@ public class PacketPatch {
|
|||
LabelNode skip = new LabelNode();
|
||||
InsnSequence is = new InsnSequence();
|
||||
is.add(new VarInsnNode(ALOAD, 2));
|
||||
is.add(new MethodProxyInsnNode(INVOKESTATIC, pktIn()));
|
||||
is.add(new MethodProxyInsnNode(INVOKESTATIC, pktIn));
|
||||
is.add(new JumpInsnNode(IFEQ, skip));
|
||||
is.add(new InsnNode(RETURN));
|
||||
is.add(skip);
|
||||
|
@ -82,21 +79,26 @@ public class PacketPatch {
|
|||
}
|
||||
}
|
||||
|
||||
@Patch(value = NetworkManager.class, reason = "add hook to intercept and alter/cancel outgoing packets")
|
||||
@Patch(NetworkManager.class)
|
||||
public abstract static class OutgoingPacketInterceptor implements Opcodes {
|
||||
@Find(parent = PacketPatch.class)
|
||||
abstract MethodProxy pktOut();
|
||||
@Find(OutgoingPacketInterceptor.class)
|
||||
MethodProxy pktOut;
|
||||
|
||||
@Target
|
||||
@Target(of = "pktOut")
|
||||
public static boolean pktOut(IPacket<?> pkt) {
|
||||
return MinecraftForge.EVENT_BUS.post(new PacketEvent.Outgoing(pkt));
|
||||
}
|
||||
|
||||
@Target(of = "injectOutgoingInterceptor")
|
||||
public abstract void sendPacket(IPacket<?> pak, GenericFutureListener<? extends Future<? super Void>> gfl);
|
||||
|
||||
@Injector
|
||||
public void inject(ClassNode clazz, MethodNode main) {
|
||||
@Injector(reason = "add hook to intercept and alter/cancel outgoing packets")
|
||||
public void injectOutgoingInterceptor(ClassNode clazz, MethodNode main) {
|
||||
// hook at the top
|
||||
LabelNode skip = new LabelNode();
|
||||
InsnSequence is = new InsnSequence();
|
||||
is.add(new VarInsnNode(ALOAD, 1));
|
||||
is.add(new MethodProxyInsnNode(INVOKESTATIC, pktOut()));
|
||||
is.add(new MethodProxyInsnNode(INVOKESTATIC, pktOut));
|
||||
is.add(new JumpInsnNode(IFEQ, skip));
|
||||
is.add(new InsnNode(RETURN));
|
||||
is.add(skip);
|
||||
|
|
|
@ -13,12 +13,12 @@ import ftbsc.lll.processor.annotations.Target;
|
|||
import ftbsc.lll.tools.PatternMatcher;
|
||||
import net.minecraft.client.entity.player.ClientPlayerEntity;
|
||||
|
||||
@Patch(value = ClientPlayerEntity.class, reason = "prevent minecraft from force closing guis when entering portals")
|
||||
@Patch(ClientPlayerEntity.class)
|
||||
public abstract class PortalGuiPatch implements Opcodes {
|
||||
@Target
|
||||
@Target(of = "inject")
|
||||
abstract void handleNetherPortalClient();
|
||||
|
||||
@Injector
|
||||
@Injector(reason = "prevent minecraft from force closing guis when entering portals")
|
||||
public void inject(ClassNode clazz, MethodNode main) {
|
||||
LabelNode skip = new LabelNode();
|
||||
|
||||
|
|
Loading…
Reference in a new issue