aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
author alemi <me@alemi.dev>2023-02-13 01:20:25 +0100
committer alemi <me@alemi.dev>2023-02-13 01:20:25 +0100
commit75e627c0cca16ddb91b28b151358b1e3c42367ef (patch)
treee175c25cdc1776e0bdd7b1ee9b5f48a2a6a6e386 /src
parent7ff227622d7f5722e5fa8521a1e7018ed6b280c0 (diff)
fix: packetPatch should work with lll-loader0.1.1+
Diffstat (limited to 'src')
-rw-r--r--src/main/java/ftbsc/bscv/BoSCoVicino.java3
-rw-r--r--src/main/java/ftbsc/bscv/events/PacketEvent.java6
-rw-r--r--src/main/java/ftbsc/bscv/patches/PacketPatch.java33
3 files changed, 12 insertions, 30 deletions
diff --git a/src/main/java/ftbsc/bscv/BoSCoVicino.java b/src/main/java/ftbsc/bscv/BoSCoVicino.java
index 8290741..5ea29b1 100644
--- a/src/main/java/ftbsc/bscv/BoSCoVicino.java
+++ b/src/main/java/ftbsc/bscv/BoSCoVicino.java
@@ -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
diff --git a/src/main/java/ftbsc/bscv/events/PacketEvent.java b/src/main/java/ftbsc/bscv/events/PacketEvent.java
index 7c2e431..67808fd 100644
--- a/src/main/java/ftbsc/bscv/events/PacketEvent.java
+++ b/src/main/java/ftbsc/bscv/events/PacketEvent.java
@@ -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;
- }
}
diff --git a/src/main/java/ftbsc/bscv/patches/PacketPatch.java b/src/main/java/ftbsc/bscv/patches/PacketPatch.java
index 786f900..4c7292d 100644
--- a/src/main/java/ftbsc/bscv/patches/PacketPatch.java
+++ b/src/main/java/ftbsc/bscv/patches/PacketPatch.java
@@ -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 void pktIn(IPacket<?> pkt) {
- BoSCoVicino.LOGGER.info("<[pkt] {}", pkt);
- MinecraftForge.EVENT_BUS.post(new PacketEvent(pkt, false)); // return post()
+ public static boolean pktIn(IPacket<?> pkt) {
+ return MinecraftForge.EVENT_BUS.post(new PacketEvent(pkt, false));
}
- 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);
}