LegacyProtocolUtils.java

net.minecraft.server.network.LegacyProtocolUtils

信息

  • 全限定名:net.minecraft.server.network.LegacyProtocolUtils
  • 类型:public class
  • 包:net.minecraft.server.network
  • 源码路径:src/main/java/net/minecraft/server/network/LegacyProtocolUtils.java
  • 起始行号:L6
  • 职责:

    TODO

字段/常量

  • CUSTOM_PAYLOAD_PACKET_ID

    • 类型: int
    • 修饰符: public static final
    • 源码定位: L7
    • 说明:

      TODO

  • CUSTOM_PAYLOAD_PACKET_PING_CHANNEL

    • 类型: String
    • 修饰符: public static final
    • 源码定位: L8
    • 说明:

      TODO

  • GET_INFO_PACKET_ID

    • 类型: int
    • 修饰符: public static final
    • 源码定位: L9
    • 说明:

      TODO

  • GET_INFO_PACKET_VERSION_1

    • 类型: int
    • 修饰符: public static final
    • 源码定位: L10
    • 说明:

      TODO

  • DISCONNECT_PACKET_ID

    • 类型: int
    • 修饰符: public static final
    • 源码定位: L11
    • 说明:

      TODO

  • FAKE_PROTOCOL_VERSION

    • 类型: int
    • 修饰符: public static final
    • 源码定位: L12
    • 说明:

      TODO

内部类/嵌套类型

构造器

方法

下面的方法块按源码顺序生成。

public static void writeLegacyString(ByteBuf toSend, String str) @ L14

  • 方法名:writeLegacyString
  • 源码定位:L14
  • 返回类型:void
  • 修饰符:public static

参数:

  • toSend: ByteBuf
  • str: String

说明:

TODO

public static String readLegacyString(ByteBuf msg) @ L19

  • 方法名:readLegacyString
  • 源码定位:L19
  • 返回类型:String
  • 修饰符:public static

参数:

  • msg: ByteBuf

说明:

TODO

代码

public class LegacyProtocolUtils {
    public static final int CUSTOM_PAYLOAD_PACKET_ID = 250;
    public static final String CUSTOM_PAYLOAD_PACKET_PING_CHANNEL = "MC|PingHost";
    public static final int GET_INFO_PACKET_ID = 254;
    public static final int GET_INFO_PACKET_VERSION_1 = 1;
    public static final int DISCONNECT_PACKET_ID = 255;
    public static final int FAKE_PROTOCOL_VERSION = 127;
 
    public static void writeLegacyString(ByteBuf toSend, String str) {
        toSend.writeShort(str.length());
        toSend.writeCharSequence(str, StandardCharsets.UTF_16BE);
    }
 
    public static String readLegacyString(ByteBuf msg) {
        int charCount = msg.readShort();
        int byteCount = charCount * 2;
        String str = msg.toString(msg.readerIndex(), byteCount, StandardCharsets.UTF_16BE);
        msg.skipBytes(byteCount);
        return str;
    }
}

引用的其他类