ServerboundPingRequestPacket.java

net.minecraft.network.protocol.ping.ServerboundPingRequestPacket

信息

  • 全限定名:net.minecraft.network.protocol.ping.ServerboundPingRequestPacket
  • 类型:public class
  • 包:net.minecraft.network.protocol.ping
  • 源码路径:src/main/java/net/minecraft/network/protocol/ping/ServerboundPingRequestPacket.java
  • 起始行号:L8
  • 实现:Packet
  • 职责:

    TODO

字段/常量

  • STREAM_CODEC

    • 类型: StreamCodec<ByteBuf,ServerboundPingRequestPacket>
    • 修饰符: public static final
    • 源码定位: L9
    • 说明:

      TODO

  • time

    • 类型: long
    • 修饰符: private final
    • 源码定位: L12
    • 说明:

      TODO

内部类/嵌套类型

构造器

public ServerboundPingRequestPacket(long time) @ L14

  • 构造器名:ServerboundPingRequestPacket
  • 源码定位:L14
  • 修饰符:public

参数:

  • time: long

说明:

TODO

private ServerboundPingRequestPacket(ByteBuf input) @ L18

  • 构造器名:ServerboundPingRequestPacket
  • 源码定位:L18
  • 修饰符:private

参数:

  • input: ByteBuf

说明:

TODO

方法

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

private void write(ByteBuf output) @ L22

  • 方法名:write
  • 源码定位:L22
  • 返回类型:void
  • 修饰符:private

参数:

  • output: ByteBuf

说明:

TODO

public PacketType<ServerboundPingRequestPacket> type() @ L26

  • 方法名:type
  • 源码定位:L26
  • 返回类型:PacketType
  • 修饰符:public

参数:

说明:

TODO

public void handle(ServerPingPacketListener listener) @ L31

  • 方法名:handle
  • 源码定位:L31
  • 返回类型:void
  • 修饰符:public

参数:

  • listener: ServerPingPacketListener

说明:

TODO

public long getTime() @ L35

  • 方法名:getTime
  • 源码定位:L35
  • 返回类型:long
  • 修饰符:public

参数:

说明:

TODO

代码

public class ServerboundPingRequestPacket implements Packet<ServerPingPacketListener> {
    public static final StreamCodec<ByteBuf, ServerboundPingRequestPacket> STREAM_CODEC = Packet.codec(
        ServerboundPingRequestPacket::write, ServerboundPingRequestPacket::new
    );
    private final long time;
 
    public ServerboundPingRequestPacket(long time) {
        this.time = time;
    }
 
    private ServerboundPingRequestPacket(ByteBuf input) {
        this.time = input.readLong();
    }
 
    private void write(ByteBuf output) {
        output.writeLong(this.time);
    }
 
    @Override
    public PacketType<ServerboundPingRequestPacket> type() {
        return PingPacketTypes.SERVERBOUND_PING_REQUEST;
    }
 
    public void handle(ServerPingPacketListener listener) {
        listener.handlePingRequest(this);
    }
 
    public long getTime() {
        return this.time;
    }
}

引用的其他类