ServerboundClientCommandPacket.java

net.minecraft.network.protocol.game.ServerboundClientCommandPacket

信息

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

    TODO

字段/常量

  • STREAM_CODEC

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

      TODO

  • action

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

      TODO

内部类/嵌套类型

  • net.minecraft.network.protocol.game.ServerboundClientCommandPacket.Action
    • 类型: enum
    • 修饰符: public static
    • 源码定位: L39
    • 说明:

      TODO

构造器

public ServerboundClientCommandPacket(ServerboundClientCommandPacket.Action action) @ L14

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

参数:

  • action: ServerboundClientCommandPacket.Action

说明:

TODO

private ServerboundClientCommandPacket(FriendlyByteBuf input) @ L18

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

参数:

  • input: FriendlyByteBuf

说明:

TODO

方法

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

private void write(FriendlyByteBuf output) @ L22

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

参数:

  • output: FriendlyByteBuf

说明:

TODO

public PacketType<ServerboundClientCommandPacket> type() @ L26

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

参数:

说明:

TODO

public void handle(ServerGamePacketListener listener) @ L31

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

参数:

  • listener: ServerGamePacketListener

说明:

TODO

public ServerboundClientCommandPacket.Action getAction() @ L35

  • 方法名:getAction
  • 源码定位:L35
  • 返回类型:ServerboundClientCommandPacket.Action
  • 修饰符:public

参数:

说明:

TODO

代码

public class ServerboundClientCommandPacket implements Packet<ServerGamePacketListener> {
    public static final StreamCodec<FriendlyByteBuf, ServerboundClientCommandPacket> STREAM_CODEC = Packet.codec(
        ServerboundClientCommandPacket::write, ServerboundClientCommandPacket::new
    );
    private final ServerboundClientCommandPacket.Action action;
 
    public ServerboundClientCommandPacket(ServerboundClientCommandPacket.Action action) {
        this.action = action;
    }
 
    private ServerboundClientCommandPacket(FriendlyByteBuf input) {
        this.action = input.readEnum(ServerboundClientCommandPacket.Action.class);
    }
 
    private void write(FriendlyByteBuf output) {
        output.writeEnum(this.action);
    }
 
    @Override
    public PacketType<ServerboundClientCommandPacket> type() {
        return GamePacketTypes.SERVERBOUND_CLIENT_COMMAND;
    }
 
    public void handle(ServerGamePacketListener listener) {
        listener.handleClientCommand(this);
    }
 
    public ServerboundClientCommandPacket.Action getAction() {
        return this.action;
    }
 
    public static enum Action {
        PERFORM_RESPAWN,
        REQUEST_STATS,
        REQUEST_GAMERULE_VALUES;
    }
}

引用的其他类