fix: packetPatch should work with lll-loader0.1.1+
This commit is contained in:
parent
7ff227622d
commit
75e627c0cc
3 changed files with 12 additions and 30 deletions
|
@ -29,7 +29,6 @@ import java.util.List;
|
|||
|
||||
import ftbsc.bscv.module.Module;
|
||||
import ftbsc.bscv.module.vision.*;
|
||||
import ftbsc.bscv.patches.PacketPatch;
|
||||
import ftbsc.bscv.module.motion.*;
|
||||
import ftbsc.bscv.module.self.*;
|
||||
import ftbsc.bscv.module.hud.*;
|
||||
|
@ -62,8 +61,6 @@ public class BoSCoVicino {
|
|||
|
||||
ForgeConfigSpec.Builder builder = new ForgeConfigSpec.Builder();
|
||||
|
||||
PacketPatch.PacketHook hook = PacketPatch.PacketHook.packetHook(); // make sure Forge doesn't strip this
|
||||
|
||||
// TODO also push!
|
||||
// modules cannot easily pop from their builder, but here we can't easily get
|
||||
// the module name yet. We should push and pop the builder ourselves and not
|
||||
|
|
|
@ -10,15 +10,9 @@ public class PacketEvent extends Event {
|
|||
|
||||
public IPacket<?> packet;
|
||||
public boolean outgoing;
|
||||
public boolean canceled;
|
||||
|
||||
public PacketEvent(IPacket<?> pkt, boolean outgoing) {
|
||||
this.packet = pkt;
|
||||
this.canceled = false;
|
||||
this.outgoing = outgoing;
|
||||
}
|
||||
|
||||
public void cancel() {
|
||||
this.canceled = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@ import org.objectweb.asm.tree.MethodInsnNode;
|
|||
import org.objectweb.asm.tree.MethodNode;
|
||||
import org.objectweb.asm.tree.VarInsnNode;
|
||||
|
||||
import ftbsc.bscv.BoSCoVicino;
|
||||
import ftbsc.bscv.events.PacketEvent;
|
||||
import ftbsc.lll.IInjector;
|
||||
import ftbsc.lll.tools.DescriptorBuilder;
|
||||
|
@ -23,20 +22,12 @@ import ftbsc.lll.tools.PatternMatcher;
|
|||
public class PacketPatch {
|
||||
|
||||
public static class PacketHook {
|
||||
private static final PacketHook INSTANCE = new PacketHook();
|
||||
|
||||
public static PacketHook packetHook() {
|
||||
return PacketHook.INSTANCE;
|
||||
public static boolean pktIn(IPacket<?> pkt) {
|
||||
return MinecraftForge.EVENT_BUS.post(new PacketEvent(pkt, false));
|
||||
}
|
||||
|
||||
public static void pktIn(IPacket<?> pkt) {
|
||||
BoSCoVicino.LOGGER.info("<[pkt] {}", pkt);
|
||||
MinecraftForge.EVENT_BUS.post(new PacketEvent(pkt, false)); // return post()
|
||||
}
|
||||
|
||||
public static void pktOut(IPacket<?> pkt) {
|
||||
BoSCoVicino.LOGGER.info("[pkt]> {}", pkt);
|
||||
MinecraftForge.EVENT_BUS.post(new PacketEvent(pkt, true)); // return post()
|
||||
public static boolean pktOut(IPacket<?> pkt) {
|
||||
return MinecraftForge.EVENT_BUS.post(new PacketEvent(pkt, true));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -72,11 +63,11 @@ public class PacketPatch {
|
|||
INVOKESTATIC,
|
||||
"ftbsc/bscv/patches/PacketPatch$PacketHook",
|
||||
"pktIn",
|
||||
"(Lnet/minecraft/network/IPacket;)V" // Z for bool return
|
||||
"(Lnet/minecraft/network/IPacket;)Z"
|
||||
));
|
||||
// is.add(new JumpInsnNode(IFEQ, skip));
|
||||
// is.add(new InsnNode(RET));
|
||||
// is.add(skip);
|
||||
is.add(new JumpInsnNode(IFEQ, skip));
|
||||
is.add(new InsnNode(RETURN));
|
||||
is.add(skip);
|
||||
|
||||
main.instructions.insert(found, is);
|
||||
}
|
||||
|
@ -105,11 +96,11 @@ public class PacketPatch {
|
|||
INVOKESTATIC,
|
||||
"ftbsc/bscv/patches/PacketPatch$PacketHook",
|
||||
"pktOut",
|
||||
"(Lnet/minecraft/network/IPacket;)V" // Z for bool return
|
||||
"(Lnet/minecraft/network/IPacket;)Z"
|
||||
));
|
||||
// is.add(new JumpInsnNode(IFEQ, skip));
|
||||
// is.add(new InsnNode(RET));
|
||||
// is.add(skip);
|
||||
is.add(new JumpInsnNode(IFEQ, skip));
|
||||
is.add(new InsnNode(RETURN));
|
||||
is.add(skip);
|
||||
|
||||
main.instructions.insert(is);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue