LegacyProtocolUtils .java

net.minecraft.server.network.LegacyProtocolUtils (class): members: CUSTOM_PAYLOAD_PACKET_PING_CHANNEL, GET_INFO_PACKET_VERSION_1, CUSTOM_PAYLOAD_PACKET_ID.

net.minecraft.server.networkclass27 linesserver941 B

API Surface (2)

void writeLegacyString(final ByteBuf toSend, final String str)
String readLegacyString(final ByteBuf msg)

Fields & Constants (6)

CUSTOM_PAYLOAD_PACKET_ID
CUSTOM_PAYLOAD_PACKET_PING_CHANNEL
GET_INFO_PACKET_ID
GET_INFO_PACKET_VERSION_1
DISCONNECT_PACKET_ID
FAKE_PROTOCOL_VERSION

String literals (1)

"MC|PingHost"

Full Source

LegacyProtocolUtils.java27 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.server.network;
2
3
import io.netty.buffer.ByteBuf;
4
import java.nio.charset.StandardCharsets;
5
6
public class LegacyProtocolUtils {
7
	public static final int CUSTOM_PAYLOAD_PACKET_ID = 250;
8
	public static final String CUSTOM_PAYLOAD_PACKET_PING_CHANNEL = "MC|PingHost";
9
	public static final int GET_INFO_PACKET_ID = 254;
10
	public static final int GET_INFO_PACKET_VERSION_1 = 1;
11
	public static final int DISCONNECT_PACKET_ID = 255;
12
	public static final int FAKE_PROTOCOL_VERSION = 127;
13
14
	public static void writeLegacyString(final ByteBuf toSend, final String str) {
15
		toSend.writeShort(str.length());
16
		toSend.writeCharSequence(str, StandardCharsets.UTF_16BE);
17
	}
18
19
	public static String readLegacyString(final ByteBuf msg) {
20
		int charCount = msg.readShort();
21
		int byteCount = charCount * 2;
22
		String str = msg.toString(msg.readerIndex(), byteCount, StandardCharsets.UTF_16BE);
23
		msg.skipBytes(byteCount);
24
		return str;
25
	}
26
}
27

Decompiled Minecraft 26.3 source of LegacyProtocolUtils (net/minecraft/server/network/LegacyProtocolUtils.java) with Mojang official mappings, stored verbatim on the site.