OldServerPinger
Server-list prober: C00Handshake(47, STATUS) + C00 query + C01 ping sequence feeding the multiplayer latency readout.
Updated 2026-09-12
Packets Referenced (3)
Related Vanilla Internals
Deep Analysis
Client-side multiplayer list pinger owned by server-selection GUI. Opens a temporary STATUS connection, parses MOTD, version, player count and favicon, then measures ping. Falls back to pre-1.7 MC|PingHost legacy ping when modern handshake fails.
Key Methods in Depth (7)
Start modern STATUS ping against a ServerData entry
ping starts a modern STATUS ping from the multiplayer list against a ServerData entry. It resolves ServerAddress from serverIP, creates a NetworkManager with createNetworkManagerAndConnect, and adds it to pingDestinations for ticking. It initializes serverMOTD to Pinging, pingToServer to -1, and playerList to null as pending state. It installs an anonymous INetHandlerStatusClient whose handleServerInfo parses S00, handlePong computes latency, and onDisconnect triggers legacy fallback. After installing the handler it sends C00Handshake with protocol 47, host, port, and STATUS next state to switch the channel from HANDSHAKE to STATUS. It then sends C00PacketServerQuery to request ServerStatusResponse. The server replies with S00PacketServerInfo followed by S01PacketPong echo after the client C01PacketPing. Failures are logged without crashing the list thread.
try
{
networkmanager.sendPacket(new C00Handshake(47, serveraddress.getIP(), serveraddress.getPort(), EnumConnectionState.STATUS));
networkmanager.sendPacket(new C00PacketServerQuery());
}
catch (Throwable throwable)
{
logger.error((Object)throwable);
}
}
The try block sends the two-packet STATUS opening sequence on the fresh NetworkManager. C00Handshake carries protocol 47 plus host and port and requests STATUS state. C00PacketServerQuery then asks for MOTD, version, players, and favicon. Throwables are logged so a bad address does not break the server list. Replies arrive as S00 and S01 handled by the anonymous handler.
Parse S00 server info into ServerData display fields
handleServerInfo handles incoming S00PacketServerInfo and prepares the latency probe. It first rejects duplicate S00 with a Received unrequested status close to avoid double parsing. On first reply it marks field_183009_e true and extracts ServerStatusResponse via getResponse. It copies MOTD formatted text into serverMOTD, protocol name and number into gameVersion and version, and online versus max counts into populationInfo with gray formatting. It builds playerList tooltip from GameProfile names plus an and N more suffix when sampled players are fewer than online count. It validates favicon prefix data:image/png;base64 before storing base64 icon data else logs invalid icon. It records field_175092_e with Minecraft.getSystemTime and sends C01PacketPing with that timestamp. The server will echo it in S01PacketPong so handlePong can compute pingToServer. It sets field_147403_d true to suppress legacy fallback.
if (serverstatusresponse.getFavicon() != null)
{
String s = serverstatusresponse.getFavicon();
if (s.startsWith("data:image/png;base64,"))
{
server.setBase64EncodedIconData(s.substring("data:image/png;base64,".length()));
}
else
{
OldServerPinger.logger.error("Invalid server icon (unknown format)");
}
}
else
{
server.setBase64EncodedIconData((String)null);
}
this.field_175092_e = Minecraft.getSystemTime();
networkmanager.sendPacket(new C01PacketPing(this.field_175092_e));
this.field_147403_d = true;
The favicon branch validates the data URL prefix before caching icon bytes else logs an error. Clearing icon to null when absent removes stale images from the list. Recording system time in field_175092_e provides the latency baseline. Sending C01PacketPing with that value asks the server for an S01 echo. Setting field_147403_d marks the query complete to block compatibility ping.
Compute latency and close ping channel
handlePong handles incoming S01PacketPong and finalizes latency measurement. It reads the stored send time field_175092_e set when C01PacketPing was sent from handleServerInfo. It reads current time via Minecraft.getSystemTime as the receive time. It subtracts send from receive into server.pingToServer in milliseconds for the list display. It then closes the channel with Finished message to terminate the STATUS session cleanly. The outer pingPendingNetworks loop will later remove the closed NetworkManager and call checkDisconnected. No further packets are sent on this connection after close. Duplicate pongs are unlikely because the server closes after one S01.
public void handlePong(S01PacketPong packetIn)
{
long i = this.field_175092_e;
long j = Minecraft.getSystemTime();
server.pingToServer = j - i;
networkmanager.closeChannel(new ChatComponentText("Finished"));
}
public void onDisconnect(IChatComponent reason)
The handler ignores packetIn time and uses the stored send timestamp for consistency. Getting system time at receipt captures round-trip delay including server processing. Assigning j minus i to pingToServer updates the list column. Closing with Finished ends the STATUS connection so resources are freed.
Handle failed modern ping and trigger legacy fallback
onDisconnect runs when the STATUS channel closes and decides whether to try legacy ping. It checks field_147403_d which is set true only after a valid S00 plus C01PacketPing sequence completed. If true it does nothing because modern ping succeeded even if the close reason is Finished or Cancelled. If false it logs Can't ping plus server IP and reason text via OldServerPinger logger. It sets serverMOTD to dark red Can't connect to server and clears populationInfo. It then calls tryCompatibilityPing on the outer OldServerPinger to attempt a pre-1.7 0xFE MC|PingHost exchange over raw Netty. That fallback can populate version, MOTD, and counts for old servers. Modern servers that refused the handshake will show the error text if legacy also fails.
public void onDisconnect(IChatComponent reason)
{
if (!this.field_147403_d)
{
OldServerPinger.logger.error("Can\'t ping " + server.serverIP + ": " + reason.getUnformattedText());
server.serverMOTD = EnumChatFormatting.DARK_RED + "Can\'t connect to server.";
server.populationInfo = "";
OldServerPinger.this.tryCompatibilityPing(server);
}
}
The !field_147403_d guard distinguishes failed queries from normal Finished closes. Logging includes serverIP and disconnect text for diagnostics. Setting MOTD and populationInfo provides immediate list feedback. Delegating to tryCompatibilityPing opens a raw 0xFE channel for 1.6-era servers.
Legacy 1.6 Beta-style 0xFE ping over raw Netty
tryCompatibilityPing implements the legacy 1.6 Beta-style 0xFE server-list ping over raw Netty. It resolves ServerAddress and builds a Bootstrap on CLIENT_NIO_EVENTLOOP with NioSocketChannel and a ChannelInitializer. The initializer enables TCP_NODELAY and installs a SimpleChannelInboundHandler for ByteBuf. On channelActive it writes packet 0xFE, 1, 0xFA MC|PingHost with host string length, IP chars, and port integer, then flushes with CLOSE_ON_FAILURE. On channelRead0 it reads unsigned byte and expects 0xFF kick response, decodes UTF-16BE length-prefixed string, and splits on NUL with PING_RESPONSE_SPLITTER limit 6. If element zero equals section-1 it parses protocol, version, MOTD, online, and max with parseIntWithDefault into server fields. It then closes the context while exceptionCaught also closes on error. No modern C00 or S00 packets are used on this path.
public void channelActive(ChannelHandlerContext p_channelActive_1_) throws Exception
{
super.channelActive(p_channelActive_1_);
ByteBuf bytebuf = Unpooled.buffer();
try
{
bytebuf.writeByte(254);
bytebuf.writeByte(1);
bytebuf.writeByte(250);
char[] achar = "MC|PingHost".toCharArray();
bytebuf.writeShort(achar.length);
for (char c0 : achar)
{
bytebuf.writeChar(c0);
}
bytebuf.writeShort(7 + 2 * serveraddress.getIP().length());
bytebuf.writeByte(127);
achar = serveraddress.getIP().toCharArray();
bytebuf.writeShort(achar.length);
for (char c1 : achar)
{
bytebuf.writeChar(c1);
}
bytebuf.writeInt(serveraddress.getPort());
p_channelActive_1_.channel().writeAndFlush(bytebuf).addListener(ChannelFutureListener.CLOSE_ON_FAILURE);
}
channelActive fires when the raw TCP connection opens before any STATUS handshake. Allocating an Unpooled buffer lets the code manually encode the 0xFE plus MC|PingHost payload. Writing 254, 1, 250 plus length-prefixed chars reproduces the Beta 1.8 ping format. Appending IP chars and port tells legacy servers which virtual host is queried. Flushing with CLOSE_ON_FAILURE sends the probe while cleaning up on write error.
Pump pending ping connections each client tick
pingPendingNetworks pumps all outstanding server-list pings each client tick. It synchronizes on pingDestinations because ping and network threads can add or iterate concurrently. It obtains an iterator so closed channels can be removed safely during traversal. For each NetworkManager it checks isChannelOpen and if open calls processReceivedPackets to dispatch S00 to handleServerInfo and S01 to handlePong. If closed it removes the entry from the list and calls checkDisconnected to fire onDisconnect with the close reason. That disconnect step is what triggers legacy fallback when modern query never completed. It runs on the client thread from GuiMultiplayer update logic. Without this pump no STATUS replies would be processed.
public void pingPendingNetworks()
{
synchronized (this.pingDestinations)
{
Iterator<NetworkManager> iterator = this.pingDestinations.iterator();
while (iterator.hasNext())
{
NetworkManager networkmanager = (NetworkManager)iterator.next();
if (networkmanager.isChannelOpen())
{
networkmanager.processReceivedPackets();
}
else
{
iterator.remove();
networkmanager.checkDisconnected();
}
}
}
}
Synchronizing on pingDestinations prevents concurrent modification from ping creation. The iterator loop visits each pending NetworkManager once per tick. Open channels have processReceivedPackets decode and dispatch STATUS packets. Closed channels are removed and passed to checkDisconnected to deliver the disconnect reason. That callback completes latency display or legacy fallback.
Cancel all outstanding server-list pings
clearPendingNetworks cancels every outstanding server-list ping, typically when leaving multiplayer GUI. It synchronizes on pingDestinations for thread safety with concurrent ping adds. It iterates with an iterator to allow removal while traversing. For each NetworkManager it checks isChannelOpen and only acts on still-open connections. It removes the open entry from the list first to prevent pingPendingNetworks from processing it. It then calls closeChannel with Cancelled message to close TCP and fire onDisconnect. Already-closed entries are left for pingPendingNetworks cleanup rather than double-closed here. After return no modern STATUS or legacy 0xFE probes from this pinger remain active.
public void clearPendingNetworks()
{
synchronized (this.pingDestinations)
{
Iterator<NetworkManager> iterator = this.pingDestinations.iterator();
while (iterator.hasNext())
{
NetworkManager networkmanager = (NetworkManager)iterator.next();
if (networkmanager.isChannelOpen())
{
iterator.remove();
networkmanager.closeChannel(new ChatComponentText("Cancelled"));
}
}
}
}
The synchronized block guards the shared ping list during cancellation. The iterator with isChannelOpen filter targets only live connections. Removing before close avoids race with the tick pump. Closing with Cancelled terminates handshake, query, or ping waits and releases Netty resources.
Packet Usage
| Packet | Dir | Trigger |
|---|---|---|
| C00Handshake | sent | ping sends protocol 47 with STATUS next state |
| C00PacketServerQuery | sent | ping server query after handshake |
| C01PacketPing | sent | handleServerInfo timestamp echo for latency |
| S00PacketServerInfo | handled | handleServerInfo updates MOTD and player list |
| S01PacketPong | handled | handlePong computes pingToServer |
| 0xFE/0xFF | sent | tryCompatibilityPing legacy MC|PingHost exchange |
Internal State
Related Vanilla Internals
Full Source
| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | |
| 22 | |
| 23 | |
| 24 | |
| 25 | |
| 26 | |
| 27 | |
| 28 | |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | |
| 34 | |
| 35 | |
| 36 | |
| 37 | |
| 38 | |
| 39 | |
| 40 | |
| 41 | |
| 42 | |
| 43 | |
| 44 | |
| 45 | |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
| 50 | |
| 51 | |
| 52 | |
| 53 | |
| 54 | |
| 55 | |
| 56 | |
| 57 | |
| 58 | |
| 59 | |
| 60 | |
| 61 | |
| 62 | |
| 63 | |
| 64 | |
| 65 | |
| 66 | |
| 67 | |
| 68 | |
| 69 | |
| 70 | |
| 71 | |
| 72 | |
| 73 | |
| 74 | |
| 75 | |
| 76 | |
| 77 | |
| 78 | |
| 79 | |
| 80 | |
| 81 | |
| 82 | |
| 83 | |
| 84 | |
| 85 | |
| 86 | |
| 87 | |
| 88 | |
| 89 | |
| 90 | |
| 91 | |
| 92 | |
| 93 | |
| 94 | |
| 95 | |
| 96 | |
| 97 | |
| 98 | |
| 99 | |
| 100 | |
| 101 | |
| 102 | |
| 103 | |
| 104 | |
| 105 | |
| 106 | |
| 107 | |
| 108 | |
| 109 | |
| 110 | |
| 111 | |
| 112 | |
| 113 | |
| 114 | |
| 115 | |
| 116 | |
| 117 | |
| 118 | |
| 119 | |
| 120 | |
| 121 | |
| 122 | |
| 123 | |
| 124 | |
| 125 | |
| 126 | |
| 127 | |
| 128 | |
| 129 | |
| 130 | |
| 131 | |
| 132 | |
| 133 | |
| 134 | |
| 135 | |
| 136 | |
| 137 | |
| 138 | |
| 139 | |
| 140 | |
| 141 | |
| 142 | |
| 143 | |
| 144 | |
| 145 | |
| 146 | |
| 147 | |
| 148 | |
| 149 | |
| 150 | |
| 151 | |
| 152 | |
| 153 | |
| 154 | |
| 155 | |
| 156 | |
| 157 | |
| 158 | |
| 159 | |
| 160 | |
| 161 | |
| 162 | |
| 163 | |
| 164 | |
| 165 | |
| 166 | |
| 167 | |
| 168 | |
| 169 | |
| 170 | |
| 171 | |
| 172 | |
| 173 | |
| 174 | |
| 175 | |
| 176 | |
| 177 | |
| 178 | |
| 179 | |
| 180 | |
| 181 | |
| 182 | |
| 183 | |
| 184 | |
| 185 | |
| 186 | |
| 187 | |
| 188 | |
| 189 | |
| 190 | |
| 191 | |
| 192 | |
| 193 | |
| 194 | |
| 195 | |
| 196 | |
| 197 | |
| 198 | |
| 199 | |
| 200 | |
| 201 | |
| 202 | |
| 203 | |
| 204 | |
| 205 | |
| 206 | |
| 207 | |
| 208 | |
| 209 | |
| 210 | |
| 211 | |
| 212 | |
| 213 | |
| 214 | |
| 215 | |
| 216 | |
| 217 | |
| 218 | |
| 219 | |
| 220 | |
| 221 | |
| 222 | |
| 223 | |
| 224 | |
| 225 | |
| 226 | |
| 227 | |
| 228 | |
| 229 | |
| 230 | |
| 231 | |
| 232 | |
| 233 | |
| 234 | |
| 235 | |
| 236 | |
| 237 | |
| 238 | |
| 239 | |
| 240 | |
| 241 | |
| 242 | |
| 243 | |
| 244 | |
| 245 | |
| 246 | |
| 247 | |
| 248 | |
| 249 | |
| 250 | |
| 251 | |
| 252 | |
| 253 | |
| 254 | |
| 255 | |
| 256 | |
| 257 | |
| 258 | |
| 259 | |
| 260 | |
| 261 | |
| 262 | |
| 263 | |
| 264 | |
| 265 | |
| 266 | |
| 267 | |
| 268 | |
| 269 | |
| 270 | |
| 271 | |
| 272 | |
| 273 | |
| 274 | |
| 275 | |
| 276 | |
| 277 | |
| 278 | |
| 279 | |
| 280 | |
| 281 | |
| 282 | |
| 283 | |
| 284 | |
| 285 | |
| 286 | |
| 287 | |
| 288 | |
| 289 | |
| 290 | |
| 291 | |
| 292 | |
| 293 | |
| 294 | |
| 295 | |
| 296 | |
| 297 | |
| 298 | |
| 299 | |
| 300 | |
| 301 | |
| 302 | |
| 303 | |
| 304 | |
| 305 | |
| 306 | |
| 307 | |
| 308 | |
| 309 | |
| 310 | |
| 311 | |
| 312 | |
| 313 | |
| 314 | |
| 315 | |
Deobfuscated MCP 1.8.9 source of OldServerPinger from Marcelektro/MavenMCP-1.8.9 (net/minecraft/client/network/OldServerPinger.java), stored verbatim.