ServerboundPlayerActionPacket.java

net.minecraft.network.protocol.game.ServerboundPlayerActionPacket

信息

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

    TODO

字段/常量

  • STREAM_CODEC

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

      TODO

  • pos

    • 类型: BlockPos
    • 修饰符: private final
    • 源码定位: L14
    • 说明:

      TODO

  • direction

    • 类型: Direction
    • 修饰符: private final
    • 源码定位: L15
    • 说明:

      TODO

  • action

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

      TODO

  • sequence

    • 类型: int
    • 修饰符: private final
    • 源码定位: L17
    • 说明:

      TODO

内部类/嵌套类型

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

      TODO

构造器

public ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action action, BlockPos pos, Direction direction, int sequence) @ L19

  • 构造器名:ServerboundPlayerActionPacket
  • 源码定位:L19
  • 修饰符:public

参数:

  • action: ServerboundPlayerActionPacket.Action
  • pos: BlockPos
  • direction: Direction
  • sequence: int

说明:

TODO

public ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action action, BlockPos pos, Direction direction) @ L26

  • 构造器名:ServerboundPlayerActionPacket
  • 源码定位:L26
  • 修饰符:public

参数:

  • action: ServerboundPlayerActionPacket.Action
  • pos: BlockPos
  • direction: Direction

说明:

TODO

private ServerboundPlayerActionPacket(FriendlyByteBuf input) @ L30

  • 构造器名:ServerboundPlayerActionPacket
  • 源码定位:L30
  • 修饰符:private

参数:

  • input: FriendlyByteBuf

说明:

TODO

方法

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

private void write(FriendlyByteBuf output) @ L37

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

参数:

  • output: FriendlyByteBuf

说明:

TODO

public PacketType<ServerboundPlayerActionPacket> type() @ L44

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

参数:

说明:

TODO

public void handle(ServerGamePacketListener listener) @ L49

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

参数:

  • listener: ServerGamePacketListener

说明:

TODO

public BlockPos getPos() @ L53

  • 方法名:getPos
  • 源码定位:L53
  • 返回类型:BlockPos
  • 修饰符:public

参数:

说明:

TODO

public Direction getDirection() @ L57

  • 方法名:getDirection
  • 源码定位:L57
  • 返回类型:Direction
  • 修饰符:public

参数:

说明:

TODO

public ServerboundPlayerActionPacket.Action getAction() @ L61

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

参数:

说明:

TODO

public int getSequence() @ L65

  • 方法名:getSequence
  • 源码定位:L65
  • 返回类型:int
  • 修饰符:public

参数:

说明:

TODO

代码

public class ServerboundPlayerActionPacket implements Packet<ServerGamePacketListener> {
    public static final StreamCodec<FriendlyByteBuf, ServerboundPlayerActionPacket> STREAM_CODEC = Packet.codec(
        ServerboundPlayerActionPacket::write, ServerboundPlayerActionPacket::new
    );
    private final BlockPos pos;
    private final Direction direction;
    private final ServerboundPlayerActionPacket.Action action;
    private final int sequence;
 
    public ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action action, BlockPos pos, Direction direction, int sequence) {
        this.action = action;
        this.pos = pos.immutable();
        this.direction = direction;
        this.sequence = sequence;
    }
 
    public ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action action, BlockPos pos, Direction direction) {
        this(action, pos, direction, 0);
    }
 
    private ServerboundPlayerActionPacket(FriendlyByteBuf input) {
        this.action = input.readEnum(ServerboundPlayerActionPacket.Action.class);
        this.pos = input.readBlockPos();
        this.direction = Direction.from3DDataValue(input.readUnsignedByte());
        this.sequence = input.readVarInt();
    }
 
    private void write(FriendlyByteBuf output) {
        output.writeEnum(this.action);
        output.writeBlockPos(this.pos);
        output.writeByte(this.direction.get3DDataValue());
        output.writeVarInt(this.sequence);
    }
 
    @Override
    public PacketType<ServerboundPlayerActionPacket> type() {
        return GamePacketTypes.SERVERBOUND_PLAYER_ACTION;
    }
 
    public void handle(ServerGamePacketListener listener) {
        listener.handlePlayerAction(this);
    }
 
    public BlockPos getPos() {
        return this.pos;
    }
 
    public Direction getDirection() {
        return this.direction;
    }
 
    public ServerboundPlayerActionPacket.Action getAction() {
        return this.action;
    }
 
    public int getSequence() {
        return this.sequence;
    }
 
    public static enum Action {
        START_DESTROY_BLOCK,
        ABORT_DESTROY_BLOCK,
        STOP_DESTROY_BLOCK,
        DROP_ALL_ITEMS,
        DROP_ITEM,
        RELEASE_USE_ITEM,
        SWAP_ITEM_WITH_OFFHAND,
        STAB;
    }
}

引用的其他类