ClientboundAddEntityPacket.java
net.minecraft.network.protocol.game.ClientboundAddEntityPacket
信息
- 全限定名:net.minecraft.network.protocol.game.ClientboundAddEntityPacket
- 类型:public class
- 包:net.minecraft.network.protocol.game
- 源码路径:src/main/java/net/minecraft/network/protocol/game/ClientboundAddEntityPacket.java
- 起始行号:L17
- 实现:Packet
- 职责:
TODO
字段/常量
-
STREAM_CODEC- 类型:
StreamCodec<RegistryFriendlyByteBuf,ClientboundAddEntityPacket> - 修饰符:
public static final - 源码定位:
L18 - 说明:
TODO
- 类型:
-
id- 类型:
int - 修饰符:
private final - 源码定位:
L21 - 说明:
TODO
- 类型:
-
uuid- 类型:
UUID - 修饰符:
private final - 源码定位:
L22 - 说明:
TODO
- 类型:
-
type- 类型:
EntityType<?> - 修饰符:
private final - 源码定位:
L23 - 说明:
TODO
- 类型:
-
x- 类型:
double - 修饰符:
private final - 源码定位:
L24 - 说明:
TODO
- 类型:
-
y- 类型:
double - 修饰符:
private final - 源码定位:
L25 - 说明:
TODO
- 类型:
-
z- 类型:
double - 修饰符:
private final - 源码定位:
L26 - 说明:
TODO
- 类型:
-
movement- 类型:
Vec3 - 修饰符:
private final - 源码定位:
L27 - 说明:
TODO
- 类型:
-
xRot- 类型:
byte - 修饰符:
private final - 源码定位:
L28 - 说明:
TODO
- 类型:
-
yRot- 类型:
byte - 修饰符:
private final - 源码定位:
L29 - 说明:
TODO
- 类型:
-
yHeadRot- 类型:
byte - 修饰符:
private final - 源码定位:
L30 - 说明:
TODO
- 类型:
-
data- 类型:
int - 修饰符:
private final - 源码定位:
L31 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
public ClientboundAddEntityPacket(Entity entity, ServerEntity serverEntity) @ L33
- 构造器名:ClientboundAddEntityPacket
- 源码定位:L33
- 修饰符:public
参数:
- entity: Entity
- serverEntity: ServerEntity
说明:
TODO
public ClientboundAddEntityPacket(Entity entity, ServerEntity serverEntity, int data) @ L37
- 构造器名:ClientboundAddEntityPacket
- 源码定位:L37
- 修饰符:public
参数:
- entity: Entity
- serverEntity: ServerEntity
- data: int
说明:
TODO
public ClientboundAddEntityPacket(Entity entity, int data, BlockPos pos) @ L53
- 构造器名:ClientboundAddEntityPacket
- 源码定位:L53
- 修饰符:public
参数:
- entity: Entity
- data: int
- pos: BlockPos
说明:
TODO
public ClientboundAddEntityPacket(int id, UUID uuid, double x, double y, double z, float xRot, float yRot, EntityType<?> type, int data, Vec3 movement, double yHeadRot) @ L69
- 构造器名:ClientboundAddEntityPacket
- 源码定位:L69
- 修饰符:public
参数:
- id: int
- uuid: UUID
- x: double
- y: double
- z: double
- xRot: float
- yRot: float
- type: EntityType<?>
- data: int
- movement: Vec3
- yHeadRot: double
说明:
TODO
private ClientboundAddEntityPacket(RegistryFriendlyByteBuf input) @ L85
- 构造器名:ClientboundAddEntityPacket
- 源码定位:L85
- 修饰符:private
参数:
- input: RegistryFriendlyByteBuf
说明:
TODO
方法
下面的方法块按源码顺序生成。
private void write(RegistryFriendlyByteBuf output) @ L99
- 方法名:write
- 源码定位:L99
- 返回类型:void
- 修饰符:private
参数:
- output: RegistryFriendlyByteBuf
说明:
TODO
public PacketType<ClientboundAddEntityPacket> type() @ L113
- 方法名:type
- 源码定位:L113
- 返回类型:PacketType
- 修饰符:public
参数:
- 无
说明:
TODO
public void handle(ClientGamePacketListener listener) @ L118
- 方法名:handle
- 源码定位:L118
- 返回类型:void
- 修饰符:public
参数:
- listener: ClientGamePacketListener
说明:
TODO
public int getId() @ L122
- 方法名:getId
- 源码定位:L122
- 返回类型:int
- 修饰符:public
参数:
- 无
说明:
TODO
public UUID getUUID() @ L126
- 方法名:getUUID
- 源码定位:L126
- 返回类型:UUID
- 修饰符:public
参数:
- 无
说明:
TODO
public EntityType<?> getType() @ L130
- 方法名:getType
- 源码定位:L130
- 返回类型:EntityType<?>
- 修饰符:public
参数:
- 无
说明:
TODO
public double getX() @ L134
- 方法名:getX
- 源码定位:L134
- 返回类型:double
- 修饰符:public
参数:
- 无
说明:
TODO
public double getY() @ L138
- 方法名:getY
- 源码定位:L138
- 返回类型:double
- 修饰符:public
参数:
- 无
说明:
TODO
public double getZ() @ L142
- 方法名:getZ
- 源码定位:L142
- 返回类型:double
- 修饰符:public
参数:
- 无
说明:
TODO
public Vec3 getMovement() @ L146
- 方法名:getMovement
- 源码定位:L146
- 返回类型:Vec3
- 修饰符:public
参数:
- 无
说明:
TODO
public float getXRot() @ L150
- 方法名:getXRot
- 源码定位:L150
- 返回类型:float
- 修饰符:public
参数:
- 无
说明:
TODO
public float getYRot() @ L154
- 方法名:getYRot
- 源码定位:L154
- 返回类型:float
- 修饰符:public
参数:
- 无
说明:
TODO
public float getYHeadRot() @ L158
- 方法名:getYHeadRot
- 源码定位:L158
- 返回类型:float
- 修饰符:public
参数:
- 无
说明:
TODO
public int getData() @ L162
- 方法名:getData
- 源码定位:L162
- 返回类型:int
- 修饰符:public
参数:
- 无
说明:
TODO
代码
public class ClientboundAddEntityPacket implements Packet<ClientGamePacketListener> {
public static final StreamCodec<RegistryFriendlyByteBuf, ClientboundAddEntityPacket> STREAM_CODEC = Packet.codec(
ClientboundAddEntityPacket::write, ClientboundAddEntityPacket::new
);
private final int id;
private final UUID uuid;
private final EntityType<?> type;
private final double x;
private final double y;
private final double z;
private final Vec3 movement;
private final byte xRot;
private final byte yRot;
private final byte yHeadRot;
private final int data;
public ClientboundAddEntityPacket(Entity entity, ServerEntity serverEntity) {
this(entity, serverEntity, 0);
}
public ClientboundAddEntityPacket(Entity entity, ServerEntity serverEntity, int data) {
this(
entity.getId(),
entity.getUUID(),
serverEntity.getPositionBase().x(),
serverEntity.getPositionBase().y(),
serverEntity.getPositionBase().z(),
serverEntity.getLastSentXRot(),
serverEntity.getLastSentYRot(),
entity.getType(),
data,
serverEntity.getLastSentMovement(),
serverEntity.getLastSentYHeadRot()
);
}
public ClientboundAddEntityPacket(Entity entity, int data, BlockPos pos) {
this(
entity.getId(),
entity.getUUID(),
pos.getX(),
pos.getY(),
pos.getZ(),
entity.getXRot(),
entity.getYRot(),
entity.getType(),
data,
entity.getDeltaMovement(),
entity.getYHeadRot()
);
}
public ClientboundAddEntityPacket(
int id, UUID uuid, double x, double y, double z, float xRot, float yRot, EntityType<?> type, int data, Vec3 movement, double yHeadRot
) {
this.id = id;
this.uuid = uuid;
this.x = x;
this.y = y;
this.z = z;
this.movement = movement;
this.xRot = Mth.packDegrees(xRot);
this.yRot = Mth.packDegrees(yRot);
this.yHeadRot = Mth.packDegrees((float)yHeadRot);
this.type = type;
this.data = data;
}
private ClientboundAddEntityPacket(RegistryFriendlyByteBuf input) {
this.id = input.readVarInt();
this.uuid = input.readUUID();
this.type = ByteBufCodecs.registry(Registries.ENTITY_TYPE).decode(input);
this.x = input.readDouble();
this.y = input.readDouble();
this.z = input.readDouble();
this.movement = Vec3.LP_STREAM_CODEC.decode(input);
this.xRot = input.readByte();
this.yRot = input.readByte();
this.yHeadRot = input.readByte();
this.data = input.readVarInt();
}
private void write(RegistryFriendlyByteBuf output) {
output.writeVarInt(this.id);
output.writeUUID(this.uuid);
ByteBufCodecs.registry(Registries.ENTITY_TYPE).encode(output, this.type);
output.writeDouble(this.x);
output.writeDouble(this.y);
output.writeDouble(this.z);
Vec3.LP_STREAM_CODEC.encode(output, this.movement);
output.writeByte(this.xRot);
output.writeByte(this.yRot);
output.writeByte(this.yHeadRot);
output.writeVarInt(this.data);
}
@Override
public PacketType<ClientboundAddEntityPacket> type() {
return GamePacketTypes.CLIENTBOUND_ADD_ENTITY;
}
public void handle(ClientGamePacketListener listener) {
listener.handleAddEntity(this);
}
public int getId() {
return this.id;
}
public UUID getUUID() {
return this.uuid;
}
public EntityType<?> getType() {
return this.type;
}
public double getX() {
return this.x;
}
public double getY() {
return this.y;
}
public double getZ() {
return this.z;
}
public Vec3 getMovement() {
return this.movement;
}
public float getXRot() {
return Mth.unpackDegrees(this.xRot);
}
public float getYRot() {
return Mth.unpackDegrees(this.yRot);
}
public float getYHeadRot() {
return Mth.unpackDegrees(this.yHeadRot);
}
public int getData() {
return this.data;
}
}引用的其他类
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数/字段
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
ByteBufCodecs.registry()
- 引用位置:
-
- 引用位置:
字段
- 引用位置:
-
- 引用位置:
实现/方法调用 - 关联成员:
Packet.codec()
- 引用位置:
-
- 引用位置:
返回值
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Mth.packDegrees(), Mth.unpackDegrees()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数/字段/返回值
- 引用位置:
-
- 引用位置:
参数/字段/返回值
- 引用位置: