mirror of
https://github.com/FabricMC/fabric.git
synced 2024-11-30 11:27:30 -05:00
Always get the latest ServerPlayerEntity from ServerPlayNetworkHandler (#3735)
(cherry picked from commit 0dca0349ce
)
This commit is contained in:
parent
d18c2535c2
commit
bd46f3a075
1 changed files with 8 additions and 3 deletions
|
@ -48,7 +48,7 @@ public final class ServerPlayNetworkAddon extends AbstractChanneledNetworkAddon<
|
|||
super(ServerNetworkingImpl.PLAY, connection, "ServerPlayNetworkAddon for " + handler.player.getDisplayName());
|
||||
this.handler = handler;
|
||||
this.server = server;
|
||||
this.context = new ContextImpl(handler.player, this);
|
||||
this.context = new ContextImpl(handler, this);
|
||||
|
||||
// Must register pending channels via lateinit
|
||||
this.registerPendingChannels((ChannelInfoHolder) this.connection, NetworkPhase.PLAY);
|
||||
|
@ -129,10 +129,15 @@ public final class ServerPlayNetworkAddon extends AbstractChanneledNetworkAddon<
|
|||
return NetworkingImpl.isReservedCommonChannel(channelName);
|
||||
}
|
||||
|
||||
private record ContextImpl(ServerPlayerEntity player, PacketSender responseSender) implements ServerPlayNetworking.Context {
|
||||
private record ContextImpl(ServerPlayNetworkHandler handler, PacketSender responseSender) implements ServerPlayNetworking.Context {
|
||||
private ContextImpl {
|
||||
Objects.requireNonNull(player, "player");
|
||||
Objects.requireNonNull(handler, "handler");
|
||||
Objects.requireNonNull(responseSender, "responseSender");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerPlayerEntity player() {
|
||||
return handler.getPlayer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue