Skip to content

Commit

Permalink
fixed fabric packets not being detected by the event system
Browse files Browse the repository at this point in the history
  • Loading branch information
19MisterX98 authored and Wide-Cat committed May 22, 2024
1 parent 1b2144b commit fa00a6d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import meteordevelopment.meteorclient.systems.proxies.Proxy;
import net.minecraft.network.ClientConnection;
import net.minecraft.network.NetworkSide;
import net.minecraft.network.PacketCallbacks;
import net.minecraft.network.handler.PacketEncoderException;
import net.minecraft.network.handler.PacketSizeLogger;
import net.minecraft.network.listener.ClientPlayPacketListener;
Expand All @@ -30,6 +31,7 @@
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
Expand Down Expand Up @@ -66,7 +68,7 @@ private static void onConnect(InetSocketAddress address, boolean useEpoll, Clien
MeteorClient.EVENT_BUS.post(ServerConnectEndEvent.get(address));
}

@Inject(at = @At("HEAD"), method = "send(Lnet/minecraft/network/packet/Packet;)V", cancellable = true)
@Inject(at = @At("HEAD"), method = "send(Lnet/minecraft/network/packet/Packet;Lnet/minecraft/network/PacketCallbacks;)V", cancellable = true)
private void onSendPacketHead(CallbackInfo info, @Local LocalRef<Packet<?>> packet) {
PacketEvent.Send processedPacket = MeteorClient.EVENT_BUS.post(PacketEvent.Send.get(packet.get()));
if (processedPacket.isCancelled()) {
Expand All @@ -76,8 +78,8 @@ private void onSendPacketHead(CallbackInfo info, @Local LocalRef<Packet<?>> pack
}
}

@Inject(method = "send(Lnet/minecraft/network/packet/Packet;)V", at = @At("TAIL"))
private void onSendPacketTail(Packet<?> packet, CallbackInfo info) {
@Inject(method = "send(Lnet/minecraft/network/packet/Packet;Lnet/minecraft/network/PacketCallbacks;)V", at = @At("TAIL"))
private void onSendPacketTail(Packet<?> packet, @Nullable PacketCallbacks callbacks, CallbackInfo ci) {
MeteorClient.EVENT_BUS.post(PacketEvent.Sent.get(packet));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class PacketCanceller extends Module {

public PacketCanceller() {
super(Categories.Misc, "packet-canceller", "Allows you to cancel certain packets.");
runInMainMenu = true;
}

@EventHandler(priority = EventPriority.HIGHEST + 1)
Expand Down

0 comments on commit fa00a6d

Please sign in to comment.