use of org.spongepowered.common.accessor.network.protocol.game.ClientboundPlayerInfoPacketAccessor in project SpongeCommon by SpongePowered.
the class SpongeTabList method sendUpdate.
/**
* Send an entry update.
*
* @param entry The entry to update
* @param action The update action to perform
*/
@SuppressWarnings("ConstantConditions")
void sendUpdate(final TabListEntry entry, final ClientboundPlayerInfoPacket.Action action) {
final ClientboundPlayerInfoPacket packet = new ClientboundPlayerInfoPacket();
((ClientboundPlayerInfoPacketAccessor) packet).accessor$action(action);
final ClientboundPlayerInfoPacket.PlayerUpdate data = packet.new PlayerUpdate(SpongeGameProfile.toMcProfile(entry.profile()), entry.latency(), (GameType) (Object) entry.gameMode(), entry.displayName().isPresent() ? SpongeAdventure.asVanilla(entry.displayName().get()) : null);
((ClientboundPlayerInfoPacketAccessor) packet).accessor$entries().add(data);
this.player.connection.send(packet);
}
use of org.spongepowered.common.accessor.network.protocol.game.ClientboundPlayerInfoPacketAccessor in project SpongeCommon by SpongePowered.
the class PlayerListMixin method impl$onlySendAddPlayerForUnvanishedPlayers.
@Redirect(method = "placeNewPlayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/network/ServerGamePacketListenerImpl;send(Lnet/minecraft/network/protocol/Packet;)V"), slice = @Slice(from = @At(value = "INVOKE", target = "Ljava/util/List;size()I", remap = false), to = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerLevel;addNewPlayer(Lnet/minecraft/server/level/ServerPlayer;)V")))
private void impl$onlySendAddPlayerForUnvanishedPlayers(ServerGamePacketListenerImpl connection, Packet<?> packet) {
ClientboundPlayerInfoPacketAccessor playerInfoPacketAccessor = (ClientboundPlayerInfoPacketAccessor) packet;
// size is always 1
VanishableBridge p = (VanishableBridge) this.playersByUUID.get(playerInfoPacketAccessor.accessor$entries().get(0).getProfile().getId());
// Effectively, don't notify new players of vanished players
if (p.bridge$vanishState().invisible()) {
return;
}
connection.send(packet);
}
Aggregations