From 653eadc8964cf16aff50d6246a854cae9efa7960 Mon Sep 17 00:00:00 2001 From: 19MisterX98 <41451155+19MisterX98@users.noreply.github.com> Date: Mon, 29 Apr 2024 22:02:14 +0200 Subject: [PATCH] fixed server spoof; PacketEvent.Send can replace packets now (#2) --- .../meteorclient/events/packets/PacketEvent.java | 1 + .../meteorclient/mixin/ClientConnectionMixin.java | 11 +++++++++-- .../systems/modules/misc/ServerSpoof.java | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/main/java/meteordevelopment/meteorclient/events/packets/PacketEvent.java b/src/main/java/meteordevelopment/meteorclient/events/packets/PacketEvent.java index 2603e5dc5a..d525056c51 100644 --- a/src/main/java/meteordevelopment/meteorclient/events/packets/PacketEvent.java +++ b/src/main/java/meteordevelopment/meteorclient/events/packets/PacketEvent.java @@ -27,6 +27,7 @@ public static Receive get(Packet packet, ClientConnection connection) { public static class Send extends Cancellable { private static final Send INSTANCE = new Send(); + // overwriting this will overwrite the packet being sent public Packet packet; public static Send get(Packet packet) { diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/ClientConnectionMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/ClientConnectionMixin.java index 2803ef218c..b959abbe97 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/ClientConnectionMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/ClientConnectionMixin.java @@ -5,6 +5,8 @@ package meteordevelopment.meteorclient.mixin; +import com.llamalad7.mixinextras.sugar.Local; +import com.llamalad7.mixinextras.sugar.ref.LocalRef; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelPipeline; import io.netty.handler.proxy.Socks4ProxyHandler; @@ -65,8 +67,13 @@ private static void onConnect(InetSocketAddress address, boolean useEpoll, Clien } @Inject(at = @At("HEAD"), method = "send(Lnet/minecraft/network/packet/Packet;)V", cancellable = true) - private void onSendPacketHead(Packet packet, CallbackInfo info) { - if (MeteorClient.EVENT_BUS.post(PacketEvent.Send.get(packet)).isCancelled()) info.cancel(); + private void onSendPacketHead(CallbackInfo info, @Local LocalRef> packet) { + PacketEvent.Send processedPacket = MeteorClient.EVENT_BUS.post(PacketEvent.Send.get(packet.get())); + if (processedPacket.isCancelled()) { + info.cancel(); + } else { + packet.set(processedPacket.packet); + } } @Inject(method = "send(Lnet/minecraft/network/packet/Packet;)V", at = @At("TAIL")) diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/ServerSpoof.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/ServerSpoof.java index 81144a8ea7..1f20b8aaa8 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/ServerSpoof.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/ServerSpoof.java @@ -60,7 +60,7 @@ public class ServerSpoof extends Module { private final Setting> channels = sgGeneral.add(new StringListSetting.Builder() .name("channels") .description("If the channel contains the keyword, this outgoing channel will be blocked.") - .defaultValue("fabric", "minecraft:register", "minecraft:brand") + .defaultValue("fabric", "minecraft:register") .visible(blockChannels::get) .build() );