Skip to content

Commit

Permalink
don't trust ClientboundLoginPacket to be sent only in valid PLAY
Browse files Browse the repository at this point in the history
…stage

closes badasintended/wthit#230
  • Loading branch information
deirn committed Sep 3, 2023
1 parent fbfbf7e commit 18ec659
Showing 1 changed file with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.chat.Component;
import net.minecraft.network.protocol.game.ClientboundCustomPayloadPacket;
import net.minecraft.network.protocol.game.ClientboundLoginPacket;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
Expand Down Expand Up @@ -39,13 +38,10 @@ private void badpackets_removeClientPacketHandler(Component reason, CallbackInfo
badpacket_packetHandler.onDisconnect();
}

@Inject(method = "handleLogin", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/Connection;send(Lnet/minecraft/network/protocol/Packet;)V"))
private void badpackets_initClientPacketHandler(ClientboundLoginPacket packet, CallbackInfo ci) {
badpacket_packetHandler.sendInitialChannelSyncPacket();
}

@Inject(method = "handleCustomPayload", at = @At("HEAD"), cancellable = true)
private void badpackets_receiveS2CPacket(ClientboundCustomPayloadPacket packet, CallbackInfo ci) {
badpacket_packetHandler.sendInitialChannelSyncPacket();

if (!minecraft.isSameThread()) {
FriendlyByteBuf buf = packet.getData();
try {
Expand Down

0 comments on commit 18ec659

Please sign in to comment.