Skip to content

Commit

Permalink
fixed server spoof; PacketEvent.Send can replace packets now (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
19MisterX98 authored Apr 29, 2024
1 parent 94832d1 commit 653eadc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<?>> 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"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public class ServerSpoof extends Module {
private final Setting<List<String>> 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()
);
Expand Down

0 comments on commit 653eadc

Please sign in to comment.