Search in sources :

Example 1 with ClientboundSetPlayerTeamPacket

use of net.minecraft.network.protocol.game.ClientboundSetPlayerTeamPacket in project SpongeCommon by SpongePowered.

the class ServerScoreboardMixin method bridge$addPlayer.

@Override
public void bridge$addPlayer(final ServerPlayer player, final boolean sendPackets) {
    this.impl$players.add(player);
    if (sendPackets) {
        for (final PlayerTeam team : this.getPlayerTeams()) {
            player.connection.send(new ClientboundSetPlayerTeamPacket(team, 0));
        }
        for (final net.minecraft.world.scores.Objective objective : this.getObjectives()) {
            player.connection.send(new ClientboundSetObjectivePacket(objective, 0));
            for (int i = 0; i < 19; ++i) {
                if (this.getDisplayObjective(i) == objective) {
                    player.connection.send(new ClientboundSetDisplayObjectivePacket(i, objective));
                }
            }
            for (final Score score : this.getPlayerScores(objective)) {
                final ClientboundSetScorePacket packetIn = new ClientboundSetScorePacket(Method.CHANGE, score.getObjective().getName(), score.getOwner(), score.getScore());
                player.connection.send(packetIn);
            }
        }
    }
}
Also used : ClientboundSetScorePacket(net.minecraft.network.protocol.game.ClientboundSetScorePacket) Score(net.minecraft.world.scores.Score) SpongeScore(org.spongepowered.common.scoreboard.SpongeScore) PlayerTeam(net.minecraft.world.scores.PlayerTeam) ClientboundSetPlayerTeamPacket(net.minecraft.network.protocol.game.ClientboundSetPlayerTeamPacket) ClientboundSetDisplayObjectivePacket(net.minecraft.network.protocol.game.ClientboundSetDisplayObjectivePacket) ClientboundSetObjectivePacket(net.minecraft.network.protocol.game.ClientboundSetObjectivePacket)

Aggregations

ClientboundSetDisplayObjectivePacket (net.minecraft.network.protocol.game.ClientboundSetDisplayObjectivePacket)1 ClientboundSetObjectivePacket (net.minecraft.network.protocol.game.ClientboundSetObjectivePacket)1 ClientboundSetPlayerTeamPacket (net.minecraft.network.protocol.game.ClientboundSetPlayerTeamPacket)1 ClientboundSetScorePacket (net.minecraft.network.protocol.game.ClientboundSetScorePacket)1 PlayerTeam (net.minecraft.world.scores.PlayerTeam)1 Score (net.minecraft.world.scores.Score)1 SpongeScore (org.spongepowered.common.scoreboard.SpongeScore)1