ServerScoreboard

Server scoreboard: objective/team/score mutations broadcast S3B, S3C, S3D and S3E to all players.

net/minecraft/scoreboard/ServerScoreboard.java

Updated 2026-09-12

Deep Analysis

Scoreboard subclass broadcasting all objective, score, and team mutations globally. No distance or dimension gating; uses sendPacketToAllPlayers. Tracks dirty save data for persistence. Buffers create vs remove packet lists for late joiners.

Key Methods in Depth (9)

func_96536_a

Broadcast score value update for tracked objective.

This override broadcasts a score value change for a tracked objective. It first calls super to update the in-memory Score object. It then checks whether field_96553_b tracked set contains the score objective. Only tracked objectives produce network traffic, untracked ones stay local until burst. If tracked it calls sendPacketToAllPlayers with S3CPacketUpdateScore wrapping the Score. That fan-out has no distance or dimension gating and reaches every connected player. It finally calls markSaveDataDirty to persist the change via ScoreboardSaveData. This path handles score creation and value updates. Removal uses a different overload with name-only packet. The tracked set therefore filters global spam.

    public void func_96536_a(Score p_96536_1_)
    {
        super.func_96536_a(p_96536_1_);

        if (this.field_96553_b.contains(p_96536_1_.getObjective()))
        {
            this.scoreboardMCServer.getConfigurationManager().sendPacketToAllPlayers(new S3CPacketUpdateScore(p_96536_1_));
        }

        this.markSaveDataDirty();
    }

The signature takes the updated Score. The super call applies the local map change. The contains check gates networking on tracked status. The sendPacketToAllPlayers line builds S3CPacketUpdateScore from the Score. The markSaveDataDirty call flags persistence. This shows global ungated S3C fan-out for tracked scores.

setObjectiveInDisplaySlot

Sync sidebar, list, belowName display assignment.

This method synchronizes sidebar list and below-name display assignments. It caches the old slot objective then calls super to update the slot map. If the old objective differs and is non-null, it checks how many slots still reference it via func_96552_h. If still referenced elsewhere it sends S3DPacketDisplayScoreboard for that slot and new objective, otherwise it sends removal packets via sendDisplaySlotRemovalPackets. For the new objective, if non-null and already tracked it sends S3DPacketDisplayScoreboard globally. If new and untracked it calls func_96549_e to burst full state including S3B create, S3D slots, and S3C scores. It finally marks save data dirty. Slots 0 tab, 1 sidebar, and 2 below name map to the 19 internal slots. No radius or dimension gating applies.

    public void setObjectiveInDisplaySlot(int p_96530_1_, ScoreObjective p_96530_2_)
    {
        ScoreObjective scoreobjective = this.getObjectiveInDisplaySlot(p_96530_1_);
        super.setObjectiveInDisplaySlot(p_96530_1_, p_96530_2_);

        if (scoreobjective != p_96530_2_ && scoreobjective != null)
        {
            if (this.func_96552_h(scoreobjective) > 0)
            {
                this.scoreboardMCServer.getConfigurationManager().sendPacketToAllPlayers(new S3DPacketDisplayScoreboard(p_96530_1_, p_96530_2_));
            }
            else
            {
                this.sendDisplaySlotRemovalPackets(scoreobjective);
            }
        }

        if (p_96530_2_ != null)
        {
            if (this.field_96553_b.contains(p_96530_2_))
            {
                this.scoreboardMCServer.getConfigurationManager().sendPacketToAllPlayers(new S3DPacketDisplayScoreboard(p_96530_1_, p_96530_2_));
            }
            else
            {
                this.func_96549_e(p_96530_2_);
            }
        }

        this.markSaveDataDirty();
    }

The signature binds slot index and new objective. The cache plus super lines detect old versus new. The orphan check uses func_96552_h count to choose S3D update versus removal burst. The new objective branch sends S3D if tracked else bursts via func_96549_e. The S3DPacketDisplayScoreboard constructor packs slot and objective. The final dirty mark persists slot assignment.

addPlayerToTeam

Add member and notify all clients.

This method adds a member to a team and notifies all clients. It first calls super.addPlayerToTeam to update the membership map. If super returns false because the player is already on that team, it returns false with no packet. On success it resolves the ScorePlayerTeam via getTeam for the new team name. It then sends S3EPacketTeams globally via sendPacketToAllPlayers with team, singleton player list, and action 3 join. Action 3 means add players to existing team without resending full fields. The fan-out is global with no 16.0D or 64.0D radius and no dimension filter. It marks save data dirty for persistence and returns true. Clients then render nametag and friendly-fire rules accordingly.

    public boolean addPlayerToTeam(String player, String newTeam)
    {
        if (super.addPlayerToTeam(player, newTeam))
        {
            ScorePlayerTeam scoreplayerteam = this.getTeam(newTeam);
            this.scoreboardMCServer.getConfigurationManager().sendPacketToAllPlayers(new S3EPacketTeams(scoreplayerteam, Arrays.asList(new String[] {player}), 3));
            this.markSaveDataDirty();
            return true;
        }
        else
        {
            return false;
        }
    }

The signature takes player name and team name. The super if gates networking on membership change. The getTeam line resolves the team object. The sendPacketToAllPlayers line builds S3EPacketTeams with action 3 and single-player list. The dirty mark plus true return confirms persistence. The else returns false with no broadcast. This is global S3E join fan-out.

removePlayerFromTeam

Remove member and notify all clients.

This method removes a member from a team and broadcasts the leave. It first calls super.removePlayerFromTeam to update the server map, which throws if the player is not on that team. It then sends S3EPacketTeams globally with team, singleton list, and action 4 leave. Action 4 tells clients to drop that entry from the team roster. Delivery uses sendPacketToAllPlayers with no distance or dimension gating. It finally marks save data dirty for disk persistence. The packet carries only the affected player, not the full roster. If multiple leaves occur each generates its own packet with no batching. This keeps team rosters consistent for tab list and collisions.

     * Removes the given username from the given ScorePlayerTeam. If the player is not on the team then an
     * IllegalStateException is thrown.
     */
    public void removePlayerFromTeam(String p_96512_1_, ScorePlayerTeam p_96512_2_)
    {
        super.removePlayerFromTeam(p_96512_1_, p_96512_2_);
        this.scoreboardMCServer.getConfigurationManager().sendPacketToAllPlayers(new S3EPacketTeams(p_96512_2_, Arrays.asList(new String[] {p_96512_1_}), 4));
        this.markSaveDataDirty();
    }

The comment warns about IllegalStateException for non-members. The signature binds player name and team object. The super call mutates the roster or throws. The sendPacketToAllPlayers line builds S3EPacketTeams action 4 leave. The markSaveDataDirty call persists removal. This is global ungated single-player S3E update.

broadcastTeamCreated

Register new team on all clients.

This callback registers a newly created team on all clients. It first calls super.broadcastTeamCreated to add the team to the server map. It then sends S3EPacketTeams with the team object and action 0 create via sendPacketToAllPlayers. Action 0 carries full team fields including display name, prefix, suffix, friendly fire, and visibility. The broadcast is global with no radius or dimension filtering. It marks save data dirty to persist the new team. The paired removal uses func_96513_c with action 1. Without this packet clients would not know the team exists for later join actions. Late joiners receive teams again via burst logic.

    /**
     * This packet will notify the players that this team is created, and that will register it on the client
     */
    public void broadcastTeamCreated(ScorePlayerTeam playerTeam)
    {
        super.broadcastTeamCreated(playerTeam);
        this.scoreboardMCServer.getConfigurationManager().sendPacketToAllPlayers(new S3EPacketTeams(playerTeam, 0));
        this.markSaveDataDirty();
    }

The comment states client registration intent. The signature takes the new ScorePlayerTeam. The super call stores it server side. The sendPacketToAllPlayers line builds S3EPacketTeams action 0 create. The dirty mark persists creation. This is global full-state S3E fan-out.

sendTeamUpdate

Push team display property change.

This callback pushes team property edits to all clients. It first calls super.sendTeamUpdate to update the server team object. It then sends S3EPacketTeams with the team and action 2 update via sendPacketToAllPlayers. Action 2 carries prefix, suffix, friendly fire, see friendly invisibles, and name tag visibility changes. The fan-out is global with no distance or dimension gate. It marks save data dirty for persistence. Membership is unchanged, so no player list is included unlike actions 3 and 4. Clients apply the new display fields immediately to tab and overhead names. Frequent prefix changes each generate a packet without coalescing.

    /**
     * This packet will notify the players that this team is updated
     */
    public void sendTeamUpdate(ScorePlayerTeam playerTeam)
    {
        super.sendTeamUpdate(playerTeam);
        this.scoreboardMCServer.getConfigurationManager().sendPacketToAllPlayers(new S3EPacketTeams(playerTeam, 2));
        this.markSaveDataDirty();
    }

The comment identifies property update intent. The signature takes the edited team. The super call applies local fields. The sendPacketToAllPlayers line builds S3EPacketTeams action 2. The dirty mark persists the edit. This is global S3E property sync without roster payload.

onObjectiveDisplayNameChanged

Rename tracked objective on clients.

This callback renames a tracked objective on all clients. It first calls super.onObjectiveDisplayNameChanged to update the server display string. It then checks whether field_96553_b tracked set contains the objective. Only tracked objectives broadcast, untracked renames remain local until a later burst. If tracked it sends S3BPacketScoreboardObjective with the objective and action 2 update via sendPacketToAllPlayers. Action 2 means update display text without recreating scores. The send is global with no radius or dimension gating. It finally marks save data dirty. Clients update sidebar and tab headers on receipt. Creation uses action 0 and removal uses action 1 elsewhere.

    public void onObjectiveDisplayNameChanged(ScoreObjective p_96532_1_)
    {
        super.onObjectiveDisplayNameChanged(p_96532_1_);

        if (this.field_96553_b.contains(p_96532_1_))
        {
            this.scoreboardMCServer.getConfigurationManager().sendPacketToAllPlayers(new S3BPacketScoreboardObjective(p_96532_1_, 2));
        }

        this.markSaveDataDirty();
    }

The signature takes the renamed ScoreObjective. The super call updates the server name. The contains check filters to tracked objectives only. The sendPacketToAllPlayers line builds S3B action 2 rename. The dirty mark persists the new name. This shows conditional global S3B fan-out.

func_96549_e

Burst full objective state to late joiners or new objective.

This method bursts full objective state to all players for late joiners or new objectives. It builds the packet list via func_96550_d, which creates S3BPacketScoreboardObjective action 0 create, plus S3DPacketDisplayScoreboard for each of 19 slots referencing it, plus S3CPacketUpdateScore per sorted score. It then loops over every EntityPlayerMP in the configuration manager player list. For each player it loops the list and sends each Packet via playerNetServerHandler.sendPacket. After the fan-out it adds the objective to field_96553_b tracked set so future deltas broadcast incrementally. Delivery is global with no distance or dimension gating. This is the heaviest scoreboard burst, proportional to score count. It pairs with sendDisplaySlotRemovalPackets for teardown.

    public void func_96549_e(ScoreObjective p_96549_1_)
    {
        List<Packet> list = this.func_96550_d(p_96549_1_);

        for (EntityPlayerMP entityplayermp : this.scoreboardMCServer.getConfigurationManager().getPlayerList())
        {
            for (Packet packet : list)
            {
                entityplayermp.playerNetServerHandler.sendPacket(packet);
            }
        }

        this.field_96553_b.add(p_96549_1_);
    }

The signature takes the new ScoreObjective to publish. The func_96550_d call builds S3B plus S3D plus S3C list. The outer loop visits every online player. The inner loop sends each packet in order via playerNetServerHandler. The add call marks the objective tracked. This is ordered global burst for synchronization.

sendDisplaySlotRemovalPackets

Remove objective everywhere including display slots.

This method removes an objective everywhere including display slots. It builds the removal list via func_96548_f, which creates S3BPacketScoreboardObjective action 1 remove plus S3DPacketDisplayScoreboard entries for each occupied slot among 19. It then loops over every EntityPlayerMP in the player list. For each player it sends every Packet in that list via playerNetServerHandler.sendPacket. After delivery it removes the objective from field_96553_b tracked set so future score edits stay local. The fan-out is global with no radius or dimension gating. Clients clear sidebar, list, and below-name displays referencing the objective. This is the symmetric teardown to func_96549_e burst creation.

    public void sendDisplaySlotRemovalPackets(ScoreObjective p_96546_1_)
    {
        List<Packet> list = this.func_96548_f(p_96546_1_);

        for (EntityPlayerMP entityplayermp : this.scoreboardMCServer.getConfigurationManager().getPlayerList())
        {
            for (Packet packet : list)
            {
                entityplayermp.playerNetServerHandler.sendPacket(packet);
            }
        }

        this.field_96553_b.remove(p_96546_1_);
    }

The signature takes the objective to delete. The func_96548_f call builds S3B remove plus S3D clears. The outer loop covers all players globally. The inner loop delivers each removal packet in order. The remove call untracks the objective. This ensures clients drop both objective and slot bindings.

Packet Usage

PacketDirTrigger
S3Csentscore created, updated, or removed globally
S3Bsentobjective created, renamed action2, removed action1
S3Dsentdisplay slot assigned or cleared
S3Esentteam create0 remove1 update2 join3 leave4

Internal State

scoreboardMCServerSource of configuration manager for global sends
field_96553_bSet of tracked broadcast objectives vs local-only
scoreboardSaveDataDirty-marked persistence for scoreboard changes

Related Vanilla Internals

Full Source

ServerScoreboard.java271 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.scoreboard;
2
3
import com.google.common.collect.Lists;
4
import com.google.common.collect.Sets;
5
import java.util.Arrays;
6
import java.util.List;
7
import java.util.Set;
8
import net.minecraft.entity.player.EntityPlayerMP;
9
import net.minecraft.network.Packet;
10
import net.minecraft.network.play.server.S3BPacketScoreboardObjective;
11
import net.minecraft.network.play.server.S3CPacketUpdateScore;
12
import net.minecraft.network.play.server.S3DPacketDisplayScoreboard;
13
import net.minecraft.network.play.server.S3EPacketTeams;
14
import net.minecraft.server.MinecraftServer;
15
16
public class ServerScoreboard extends Scoreboard
17
{
18
    private final MinecraftServer scoreboardMCServer;
19
    private final Set<ScoreObjective> field_96553_b = Sets.<ScoreObjective>newHashSet();
20
    private ScoreboardSaveData scoreboardSaveData;
21
22
    public ServerScoreboard(MinecraftServer mcServer)
23
    {
24
        this.scoreboardMCServer = mcServer;
25
    }
26
27
    public void func_96536_a(Score p_96536_1_)
28
    {
29
        super.func_96536_a(p_96536_1_);
30
31
        if (this.field_96553_b.contains(p_96536_1_.getObjective()))
32
        {
33
            this.scoreboardMCServer.getConfigurationManager().sendPacketToAllPlayers(new S3CPacketUpdateScore(p_96536_1_));
34
        }
35
36
        this.markSaveDataDirty();
37
    }
38
39
    public void func_96516_a(String p_96516_1_)
40
    {
41
        super.func_96516_a(p_96516_1_);
42
        this.scoreboardMCServer.getConfigurationManager().sendPacketToAllPlayers(new S3CPacketUpdateScore(p_96516_1_));
43
        this.markSaveDataDirty();
44
    }
45
46
    public void func_178820_a(String p_178820_1_, ScoreObjective p_178820_2_)
47
    {
48
        super.func_178820_a(p_178820_1_, p_178820_2_);
49
        this.scoreboardMCServer.getConfigurationManager().sendPacketToAllPlayers(new S3CPacketUpdateScore(p_178820_1_, p_178820_2_));
50
        this.markSaveDataDirty();
51
    }
52
53
    /**
54
     * 0 is tab menu, 1 is sidebar, 2 is below name
55
     */
56
    public void setObjectiveInDisplaySlot(int p_96530_1_, ScoreObjective p_96530_2_)
57
    {
58
        ScoreObjective scoreobjective = this.getObjectiveInDisplaySlot(p_96530_1_);
59
        super.setObjectiveInDisplaySlot(p_96530_1_, p_96530_2_);
60
61
        if (scoreobjective != p_96530_2_ && scoreobjective != null)
62
        {
63
            if (this.func_96552_h(scoreobjective) > 0)
64
            {
65
                this.scoreboardMCServer.getConfigurationManager().sendPacketToAllPlayers(new S3DPacketDisplayScoreboard(p_96530_1_, p_96530_2_));
66
            }
67
            else
68
            {
69
                this.sendDisplaySlotRemovalPackets(scoreobjective);
70
            }
71
        }
72
73
        if (p_96530_2_ != null)
74
        {
75
            if (this.field_96553_b.contains(p_96530_2_))
76
            {
77
                this.scoreboardMCServer.getConfigurationManager().sendPacketToAllPlayers(new S3DPacketDisplayScoreboard(p_96530_1_, p_96530_2_));
78
            }
79
            else
80
            {
81
                this.func_96549_e(p_96530_2_);
82
            }
83
        }
84
85
        this.markSaveDataDirty();
86
    }
87
88
    /**
89
     * Adds a player to the given team
90
     */
91
    public boolean addPlayerToTeam(String player, String newTeam)
92
    {
93
        if (super.addPlayerToTeam(player, newTeam))
94
        {
95
            ScorePlayerTeam scoreplayerteam = this.getTeam(newTeam);
96
            this.scoreboardMCServer.getConfigurationManager().sendPacketToAllPlayers(new S3EPacketTeams(scoreplayerteam, Arrays.asList(new String[] {player}), 3));
97
            this.markSaveDataDirty();
98
            return true;
99
        }
100
        else
101
        {
102
            return false;
103
        }
104
    }
105
106
    /**
107
     * Removes the given username from the given ScorePlayerTeam. If the player is not on the team then an
108
     * IllegalStateException is thrown.
109
     */
110
    public void removePlayerFromTeam(String p_96512_1_, ScorePlayerTeam p_96512_2_)
111
    {
112
        super.removePlayerFromTeam(p_96512_1_, p_96512_2_);
113
        this.scoreboardMCServer.getConfigurationManager().sendPacketToAllPlayers(new S3EPacketTeams(p_96512_2_, Arrays.asList(new String[] {p_96512_1_}), 4));
114
        this.markSaveDataDirty();
115
    }
116
117
    /**
118
     * Called when a score objective is added
119
     */
120
    public void onScoreObjectiveAdded(ScoreObjective scoreObjectiveIn)
121
    {
122
        super.onScoreObjectiveAdded(scoreObjectiveIn);
123
        this.markSaveDataDirty();
124
    }
125
126
    public void onObjectiveDisplayNameChanged(ScoreObjective p_96532_1_)
127
    {
128
        super.onObjectiveDisplayNameChanged(p_96532_1_);
129
130
        if (this.field_96553_b.contains(p_96532_1_))
131
        {
132
            this.scoreboardMCServer.getConfigurationManager().sendPacketToAllPlayers(new S3BPacketScoreboardObjective(p_96532_1_, 2));
133
        }
134
135
        this.markSaveDataDirty();
136
    }
137
138
    public void onScoreObjectiveRemoved(ScoreObjective p_96533_1_)
139
    {
140
        super.onScoreObjectiveRemoved(p_96533_1_);
141
142
        if (this.field_96553_b.contains(p_96533_1_))
143
        {
144
            this.sendDisplaySlotRemovalPackets(p_96533_1_);
145
        }
146
147
        this.markSaveDataDirty();
148
    }
149
150
    /**
151
     * This packet will notify the players that this team is created, and that will register it on the client
152
     */
153
    public void broadcastTeamCreated(ScorePlayerTeam playerTeam)
154
    {
155
        super.broadcastTeamCreated(playerTeam);
156
        this.scoreboardMCServer.getConfigurationManager().sendPacketToAllPlayers(new S3EPacketTeams(playerTeam, 0));
157
        this.markSaveDataDirty();
158
    }
159
160
    /**
161
     * This packet will notify the players that this team is updated
162
     */
163
    public void sendTeamUpdate(ScorePlayerTeam playerTeam)
164
    {
165
        super.sendTeamUpdate(playerTeam);
166
        this.scoreboardMCServer.getConfigurationManager().sendPacketToAllPlayers(new S3EPacketTeams(playerTeam, 2));
167
        this.markSaveDataDirty();
168
    }
169
170
    public void func_96513_c(ScorePlayerTeam playerTeam)
171
    {
172
        super.func_96513_c(playerTeam);
173
        this.scoreboardMCServer.getConfigurationManager().sendPacketToAllPlayers(new S3EPacketTeams(playerTeam, 1));
174
        this.markSaveDataDirty();
175
    }
176
177
    public void func_96547_a(ScoreboardSaveData p_96547_1_)
178
    {
179
        this.scoreboardSaveData = p_96547_1_;
180
    }
181
182
    protected void markSaveDataDirty()
183
    {
184
        if (this.scoreboardSaveData != null)
185
        {
186
            this.scoreboardSaveData.markDirty();
187
        }
188
    }
189
190
    public List<Packet> func_96550_d(ScoreObjective p_96550_1_)
191
    {
192
        List<Packet> list = Lists.<Packet>newArrayList();
193
        list.add(new S3BPacketScoreboardObjective(p_96550_1_, 0));
194
195
        for (int i = 0; i < 19; ++i)
196
        {
197
            if (this.getObjectiveInDisplaySlot(i) == p_96550_1_)
198
            {
199
                list.add(new S3DPacketDisplayScoreboard(i, p_96550_1_));
200
            }
201
        }
202
203
        for (Score score : this.getSortedScores(p_96550_1_))
204
        {
205
            list.add(new S3CPacketUpdateScore(score));
206
        }
207
208
        return list;
209
    }
210
211
    public void func_96549_e(ScoreObjective p_96549_1_)
212
    {
213
        List<Packet> list = this.func_96550_d(p_96549_1_);
214
215
        for (EntityPlayerMP entityplayermp : this.scoreboardMCServer.getConfigurationManager().getPlayerList())
216
        {
217
            for (Packet packet : list)
218
            {
219
                entityplayermp.playerNetServerHandler.sendPacket(packet);
220
            }
221
        }
222
223
        this.field_96553_b.add(p_96549_1_);
224
    }
225
226
    public List<Packet> func_96548_f(ScoreObjective p_96548_1_)
227
    {
228
        List<Packet> list = Lists.<Packet>newArrayList();
229
        list.add(new S3BPacketScoreboardObjective(p_96548_1_, 1));
230
231
        for (int i = 0; i < 19; ++i)
232
        {
233
            if (this.getObjectiveInDisplaySlot(i) == p_96548_1_)
234
            {
235
                list.add(new S3DPacketDisplayScoreboard(i, p_96548_1_));
236
            }
237
        }
238
239
        return list;
240
    }
241
242
    public void sendDisplaySlotRemovalPackets(ScoreObjective p_96546_1_)
243
    {
244
        List<Packet> list = this.func_96548_f(p_96546_1_);
245
246
        for (EntityPlayerMP entityplayermp : this.scoreboardMCServer.getConfigurationManager().getPlayerList())
247
        {
248
            for (Packet packet : list)
249
            {
250
                entityplayermp.playerNetServerHandler.sendPacket(packet);
251
            }
252
        }
253
254
        this.field_96553_b.remove(p_96546_1_);
255
    }
256
257
    public int func_96552_h(ScoreObjective p_96552_1_)
258
    {
259
        int i = 0;
260
261
        for (int j = 0; j < 19; ++j)
262
        {
263
            if (this.getObjectiveInDisplaySlot(j) == p_96552_1_)
264
            {
265
                ++i;
266
            }
267
        }
268
269
        return i;
270
    }
271
}

Deobfuscated MCP 1.8.9 source of ServerScoreboard from Marcelektro/MavenMCP-1.8.9 (net/minecraft/scoreboard/ServerScoreboard.java), stored verbatim.