ClientboundMoveEntityPacket.java

net.minecraft.network.protocol.game.ClientboundMoveEntityPacket

信息

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

    TODO

字段/常量

  • entityId

    • 类型: int
    • 修饰符: protected final
    • 源码定位: L13
    • 说明:

      TODO

  • xa

    • 类型: short
    • 修饰符: protected final
    • 源码定位: L14
    • 说明:

      TODO

  • ya

    • 类型: short
    • 修饰符: protected final
    • 源码定位: L15
    • 说明:

      TODO

  • za

    • 类型: short
    • 修饰符: protected final
    • 源码定位: L16
    • 说明:

      TODO

  • yRot

    • 类型: byte
    • 修饰符: protected final
    • 源码定位: L17
    • 说明:

      TODO

  • xRot

    • 类型: byte
    • 修饰符: protected final
    • 源码定位: L18
    • 说明:

      TODO

  • onGround

    • 类型: boolean
    • 修饰符: protected final
    • 源码定位: L19
    • 说明:

      TODO

  • hasRot

    • 类型: boolean
    • 修饰符: protected final
    • 源码定位: L20
    • 说明:

      TODO

  • hasPos

    • 类型: boolean
    • 修饰符: protected final
    • 源码定位: L21
    • 说明:

      TODO

内部类/嵌套类型

  • net.minecraft.network.protocol.game.ClientboundMoveEntityPacket.Pos

    • 类型: class
    • 修饰符: public static
    • 源码定位: L83
    • 说明:

      TODO

  • net.minecraft.network.protocol.game.ClientboundMoveEntityPacket.PosRot

    • 类型: class
    • 修饰符: public static
    • 源码定位: L115
    • 说明:

      TODO

  • net.minecraft.network.protocol.game.ClientboundMoveEntityPacket.Rot

    • 类型: class
    • 修饰符: public static
    • 源码定位: L151
    • 说明:

      TODO

构造器

protected ClientboundMoveEntityPacket(int entityId, short xa, short ya, short za, byte yRot, byte xRot, boolean onGround, boolean hasRot, boolean hasPos) @ L23

  • 构造器名:ClientboundMoveEntityPacket
  • 源码定位:L23
  • 修饰符:protected

参数:

  • entityId: int
  • xa: short
  • ya: short
  • za: short
  • yRot: byte
  • xRot: byte
  • onGround: boolean
  • hasRot: boolean
  • hasPos: boolean

说明:

TODO

方法

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

public abstract PacketType<?extends ClientboundMoveEntityPacket> type() @ L35

  • 方法名:type
  • 源码定位:L35
  • 返回类型:PacketType<?extends ClientboundMoveEntityPacket>
  • 修饰符:public abstract

参数:

说明:

TODO

public void handle(ClientGamePacketListener listener) @ L38

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

参数:

  • listener: ClientGamePacketListener

说明:

TODO

public String toString() @ L42

  • 方法名:toString
  • 源码定位:L42
  • 返回类型:String
  • 修饰符:public

参数:

说明:

TODO

public Entity getEntity(Level level) @ L47

  • 方法名:getEntity
  • 源码定位:L47
  • 返回类型:Entity
  • 修饰符:public

参数:

  • level: Level

说明:

TODO

public short getXa() @ L51

  • 方法名:getXa
  • 源码定位:L51
  • 返回类型:short
  • 修饰符:public

参数:

说明:

TODO

public short getYa() @ L55

  • 方法名:getYa
  • 源码定位:L55
  • 返回类型:short
  • 修饰符:public

参数:

说明:

TODO

public short getZa() @ L59

  • 方法名:getZa
  • 源码定位:L59
  • 返回类型:short
  • 修饰符:public

参数:

说明:

TODO

public float getYRot() @ L63

  • 方法名:getYRot
  • 源码定位:L63
  • 返回类型:float
  • 修饰符:public

参数:

说明:

TODO

public float getXRot() @ L67

  • 方法名:getXRot
  • 源码定位:L67
  • 返回类型:float
  • 修饰符:public

参数:

说明:

TODO

public boolean hasRotation() @ L71

  • 方法名:hasRotation
  • 源码定位:L71
  • 返回类型:boolean
  • 修饰符:public

参数:

说明:

TODO

public boolean hasPosition() @ L75

  • 方法名:hasPosition
  • 源码定位:L75
  • 返回类型:boolean
  • 修饰符:public

参数:

说明:

TODO

public boolean isOnGround() @ L79

  • 方法名:isOnGround
  • 源码定位:L79
  • 返回类型:boolean
  • 修饰符:public

参数:

说明:

TODO

代码

public abstract class ClientboundMoveEntityPacket implements Packet<ClientGamePacketListener> {
    protected final int entityId;
    protected final short xa;
    protected final short ya;
    protected final short za;
    protected final byte yRot;
    protected final byte xRot;
    protected final boolean onGround;
    protected final boolean hasRot;
    protected final boolean hasPos;
 
    protected ClientboundMoveEntityPacket(int entityId, short xa, short ya, short za, byte yRot, byte xRot, boolean onGround, boolean hasRot, boolean hasPos) {
        this.entityId = entityId;
        this.xa = xa;
        this.ya = ya;
        this.za = za;
        this.yRot = yRot;
        this.xRot = xRot;
        this.onGround = onGround;
        this.hasRot = hasRot;
        this.hasPos = hasPos;
    }
 
    @Override
    public abstract PacketType<? extends ClientboundMoveEntityPacket> type();
 
    public void handle(ClientGamePacketListener listener) {
        listener.handleMoveEntity(this);
    }
 
    @Override
    public String toString() {
        return "Entity_" + super.toString();
    }
 
    public @Nullable Entity getEntity(Level level) {
        return level.getEntity(this.entityId);
    }
 
    public short getXa() {
        return this.xa;
    }
 
    public short getYa() {
        return this.ya;
    }
 
    public short getZa() {
        return this.za;
    }
 
    public float getYRot() {
        return Mth.unpackDegrees(this.yRot);
    }
 
    public float getXRot() {
        return Mth.unpackDegrees(this.xRot);
    }
 
    public boolean hasRotation() {
        return this.hasRot;
    }
 
    public boolean hasPosition() {
        return this.hasPos;
    }
 
    public boolean isOnGround() {
        return this.onGround;
    }
 
    public static class Pos extends ClientboundMoveEntityPacket {
        public static final StreamCodec<FriendlyByteBuf, ClientboundMoveEntityPacket.Pos> STREAM_CODEC = Packet.codec(
            ClientboundMoveEntityPacket.Pos::write, ClientboundMoveEntityPacket.Pos::read
        );
 
        public Pos(int id, short xa, short ya, short za, boolean onGround) {
            super(id, xa, ya, za, (byte)0, (byte)0, onGround, false, true);
        }
 
        private static ClientboundMoveEntityPacket.Pos read(FriendlyByteBuf input) {
            int entityId = input.readVarInt();
            short xa = input.readShort();
            short ya = input.readShort();
            short za = input.readShort();
            boolean onGround = input.readBoolean();
            return new ClientboundMoveEntityPacket.Pos(entityId, xa, ya, za, onGround);
        }
 
        private void write(FriendlyByteBuf output) {
            output.writeVarInt(this.entityId);
            output.writeShort(this.xa);
            output.writeShort(this.ya);
            output.writeShort(this.za);
            output.writeBoolean(this.onGround);
        }
 
        @Override
        public PacketType<ClientboundMoveEntityPacket.Pos> type() {
            return GamePacketTypes.CLIENTBOUND_MOVE_ENTITY_POS;
        }
    }
 
    public static class PosRot extends ClientboundMoveEntityPacket {
        public static final StreamCodec<FriendlyByteBuf, ClientboundMoveEntityPacket.PosRot> STREAM_CODEC = Packet.codec(
            ClientboundMoveEntityPacket.PosRot::write, ClientboundMoveEntityPacket.PosRot::read
        );
 
        public PosRot(int id, short xa, short ya, short za, byte yRot, byte xRot, boolean onGround) {
            super(id, xa, ya, za, yRot, xRot, onGround, true, true);
        }
 
        private static ClientboundMoveEntityPacket.PosRot read(FriendlyByteBuf input) {
            int entityId = input.readVarInt();
            short xa = input.readShort();
            short ya = input.readShort();
            short za = input.readShort();
            byte yRot = input.readByte();
            byte xRot = input.readByte();
            boolean onGround = input.readBoolean();
            return new ClientboundMoveEntityPacket.PosRot(entityId, xa, ya, za, yRot, xRot, onGround);
        }
 
        private void write(FriendlyByteBuf output) {
            output.writeVarInt(this.entityId);
            output.writeShort(this.xa);
            output.writeShort(this.ya);
            output.writeShort(this.za);
            output.writeByte(this.yRot);
            output.writeByte(this.xRot);
            output.writeBoolean(this.onGround);
        }
 
        @Override
        public PacketType<ClientboundMoveEntityPacket.PosRot> type() {
            return GamePacketTypes.CLIENTBOUND_MOVE_ENTITY_POS_ROT;
        }
    }
 
    public static class Rot extends ClientboundMoveEntityPacket {
        public static final StreamCodec<FriendlyByteBuf, ClientboundMoveEntityPacket.Rot> STREAM_CODEC = Packet.codec(
            ClientboundMoveEntityPacket.Rot::write, ClientboundMoveEntityPacket.Rot::read
        );
 
        public Rot(int id, byte yRot, byte xRot, boolean onGround) {
            super(id, (short)0, (short)0, (short)0, yRot, xRot, onGround, true, false);
        }
 
        private static ClientboundMoveEntityPacket.Rot read(FriendlyByteBuf input) {
            int entityId = input.readVarInt();
            byte yRot = input.readByte();
            byte xRot = input.readByte();
            boolean onGround = input.readBoolean();
            return new ClientboundMoveEntityPacket.Rot(entityId, yRot, xRot, onGround);
        }
 
        private void write(FriendlyByteBuf output) {
            output.writeVarInt(this.entityId);
            output.writeByte(this.yRot);
            output.writeByte(this.xRot);
            output.writeBoolean(this.onGround);
        }
 
        @Override
        public PacketType<ClientboundMoveEntityPacket.Rot> type() {
            return GamePacketTypes.CLIENTBOUND_MOVE_ENTITY_ROT;
        }
    }
}

引用的其他类

  • Packet

    • 引用位置: 实现/方法调用
    • 关联成员: Packet.codec()
  • PacketType

    • 引用位置: 返回值
  • ClientGamePacketListener

    • 引用位置: 参数
  • Mth

    • 引用位置: 方法调用
    • 关联成员: Mth.unpackDegrees()
  • Entity

    • 引用位置: 返回值
  • Level

    • 引用位置: 参数