|
5 | 5 | import net.minecraft.network.protocol.PacketUtils;
|
6 | 6 | import net.minecraft.network.protocol.common.ServerboundCustomPayloadPacket;
|
7 | 7 | import net.minecraft.network.protocol.game.ServerGamePacketListener;
|
8 |
| -import net.minecraft.server.network.ServerCommonPacketListenerImpl; |
| 8 | +import net.minecraft.server.level.ServerPlayer; |
9 | 9 | import net.minecraft.server.network.ServerGamePacketListenerImpl;
|
10 | 10 | import org.spongepowered.asm.mixin.Mixin;
|
| 11 | +import org.spongepowered.asm.mixin.Shadow; |
11 | 12 | import org.spongepowered.asm.mixin.injection.At;
|
12 | 13 | import org.spongepowered.asm.mixin.injection.Inject;
|
13 | 14 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
14 | 15 |
|
15 |
| -@Mixin(ServerCommonPacketListenerImpl.class) |
16 |
| -public class ServerCommonPacketListenerimpl_connectionMixin |
| 16 | +@Mixin(ServerGamePacketListenerImpl.class) |
| 17 | +public class ServerGamePacketListenerimpl_connectionMixin |
17 | 18 | {
|
| 19 | + @Shadow |
| 20 | + public ServerPlayer player; |
| 21 | + |
18 | 22 | @Inject(method = "handleCustomPayload", at = @At("HEAD"), cancellable = true)
|
19 | 23 | private void onCustomCarpetPayload(ServerboundCustomPayloadPacket serverboundCustomPayloadPacket, CallbackInfo ci)
|
20 | 24 | {
|
21 |
| - Object thiss = this; |
22 |
| - if (thiss instanceof ServerGamePacketListenerImpl impl && serverboundCustomPayloadPacket.payload() instanceof CarpetClient.CarpetPayload cpp) { |
| 25 | + if (serverboundCustomPayloadPacket.payload() instanceof CarpetClient.CarpetPayload cpp) { |
23 | 26 | // We should force onto the main thread here
|
24 | 27 | // ServerNetworkHandler.handleData can possibly mutate data that isn't
|
25 | 28 | // thread safe, and also allows for client commands to be executed
|
26 |
| - PacketUtils.ensureRunningOnSameThread(serverboundCustomPayloadPacket, (ServerGamePacketListener) this, impl.player.serverLevel()); |
27 |
| - ServerNetworkHandler.onClientData(impl.player, cpp.data()); |
| 29 | + PacketUtils.ensureRunningOnSameThread(serverboundCustomPayloadPacket, (ServerGamePacketListener) this, player.serverLevel()); |
| 30 | + ServerNetworkHandler.onClientData(player, cpp.data()); |
28 | 31 | ci.cancel();
|
29 | 32 | }
|
30 | 33 | }
|
|
0 commit comments