ClientboundPlayerLookAtPacket.java
net.minecraft.network.protocol.game.ClientboundPlayerLookAtPacket
信息
- 全限定名:net.minecraft.network.protocol.game.ClientboundPlayerLookAtPacket
- 类型:public class
- 包:net.minecraft.network.protocol.game
- 源码路径:src/main/java/net/minecraft/network/protocol/game/ClientboundPlayerLookAtPacket.java
- 起始行号:L13
- 实现:Packet
- 职责:
TODO
字段/常量
-
STREAM_CODEC- 类型:
StreamCodec<FriendlyByteBuf,ClientboundPlayerLookAtPacket> - 修饰符:
public static final - 源码定位:
L14 - 说明:
TODO
- 类型:
-
x- 类型:
double - 修饰符:
private final - 源码定位:
L17 - 说明:
TODO
- 类型:
-
y- 类型:
double - 修饰符:
private final - 源码定位:
L18 - 说明:
TODO
- 类型:
-
z- 类型:
double - 修饰符:
private final - 源码定位:
L19 - 说明:
TODO
- 类型:
-
entity- 类型:
int - 修饰符:
private final - 源码定位:
L20 - 说明:
TODO
- 类型:
-
fromAnchor- 类型:
EntityAnchorArgument.Anchor - 修饰符:
private final - 源码定位:
L21 - 说明:
TODO
- 类型:
-
toAnchor- 类型:
EntityAnchorArgument.Anchor - 修饰符:
private final - 源码定位:
L22 - 说明:
TODO
- 类型:
-
atEntity- 类型:
boolean - 修饰符:
private final - 源码定位:
L23 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
public ClientboundPlayerLookAtPacket(EntityAnchorArgument.Anchor fromAnchor, double x, double y, double z) @ L25
- 构造器名:ClientboundPlayerLookAtPacket
- 源码定位:L25
- 修饰符:public
参数:
- fromAnchor: EntityAnchorArgument.Anchor
- x: double
- y: double
- z: double
说明:
TODO
public ClientboundPlayerLookAtPacket(EntityAnchorArgument.Anchor fromAnchor, Entity entity, EntityAnchorArgument.Anchor toAnchor) @ L35
- 构造器名:ClientboundPlayerLookAtPacket
- 源码定位:L35
- 修饰符:public
参数:
- fromAnchor: EntityAnchorArgument.Anchor
- entity: Entity
- toAnchor: EntityAnchorArgument.Anchor
说明:
TODO
private ClientboundPlayerLookAtPacket(FriendlyByteBuf input) @ L46
- 构造器名:ClientboundPlayerLookAtPacket
- 源码定位:L46
- 修饰符:private
参数:
- input: FriendlyByteBuf
说明:
TODO
方法
下面的方法块按源码顺序生成。
private void write(FriendlyByteBuf output) @ L61
- 方法名:write
- 源码定位:L61
- 返回类型:void
- 修饰符:private
参数:
- output: FriendlyByteBuf
说明:
TODO
public PacketType<ClientboundPlayerLookAtPacket> type() @ L73
- 方法名:type
- 源码定位:L73
- 返回类型:PacketType
- 修饰符:public
参数:
- 无
说明:
TODO
public void handle(ClientGamePacketListener listener) @ L78
- 方法名:handle
- 源码定位:L78
- 返回类型:void
- 修饰符:public
参数:
- listener: ClientGamePacketListener
说明:
TODO
public EntityAnchorArgument.Anchor getFromAnchor() @ L82
- 方法名:getFromAnchor
- 源码定位:L82
- 返回类型:EntityAnchorArgument.Anchor
- 修饰符:public
参数:
- 无
说明:
TODO
public Vec3 getPosition(Level level) @ L86
- 方法名:getPosition
- 源码定位:L86
- 返回类型:Vec3
- 修饰符:public
参数:
- level: Level
说明:
TODO
代码
public class ClientboundPlayerLookAtPacket implements Packet<ClientGamePacketListener> {
public static final StreamCodec<FriendlyByteBuf, ClientboundPlayerLookAtPacket> STREAM_CODEC = Packet.codec(
ClientboundPlayerLookAtPacket::write, ClientboundPlayerLookAtPacket::new
);
private final double x;
private final double y;
private final double z;
private final int entity;
private final EntityAnchorArgument.Anchor fromAnchor;
private final EntityAnchorArgument.Anchor toAnchor;
private final boolean atEntity;
public ClientboundPlayerLookAtPacket(EntityAnchorArgument.Anchor fromAnchor, double x, double y, double z) {
this.fromAnchor = fromAnchor;
this.x = x;
this.y = y;
this.z = z;
this.entity = 0;
this.atEntity = false;
this.toAnchor = null;
}
public ClientboundPlayerLookAtPacket(EntityAnchorArgument.Anchor fromAnchor, Entity entity, EntityAnchorArgument.Anchor toAnchor) {
this.fromAnchor = fromAnchor;
this.entity = entity.getId();
this.toAnchor = toAnchor;
Vec3 pos = toAnchor.apply(entity);
this.x = pos.x;
this.y = pos.y;
this.z = pos.z;
this.atEntity = true;
}
private ClientboundPlayerLookAtPacket(FriendlyByteBuf input) {
this.fromAnchor = input.readEnum(EntityAnchorArgument.Anchor.class);
this.x = input.readDouble();
this.y = input.readDouble();
this.z = input.readDouble();
this.atEntity = input.readBoolean();
if (this.atEntity) {
this.entity = input.readVarInt();
this.toAnchor = input.readEnum(EntityAnchorArgument.Anchor.class);
} else {
this.entity = 0;
this.toAnchor = null;
}
}
private void write(FriendlyByteBuf output) {
output.writeEnum(this.fromAnchor);
output.writeDouble(this.x);
output.writeDouble(this.y);
output.writeDouble(this.z);
output.writeBoolean(this.atEntity);
if (this.atEntity) {
output.writeVarInt(this.entity);
output.writeEnum(this.toAnchor);
}
}
@Override
public PacketType<ClientboundPlayerLookAtPacket> type() {
return GamePacketTypes.CLIENTBOUND_PLAYER_LOOK_AT;
}
public void handle(ClientGamePacketListener listener) {
listener.handleLookAt(this);
}
public EntityAnchorArgument.Anchor getFromAnchor() {
return this.fromAnchor;
}
public @Nullable Vec3 getPosition(Level level) {
if (this.atEntity) {
Entity entity = level.getEntity(this.entity);
return entity == null ? new Vec3(this.x, this.y, this.z) : this.toAnchor.apply(entity);
} else {
return new Vec3(this.x, this.y, this.z);
}
}
}引用的其他类
-
- 引用位置:
参数/字段/返回值
- 引用位置:
-
- 引用位置:
参数/字段
- 引用位置:
-
- 引用位置:
字段
- 引用位置:
-
- 引用位置:
实现/方法调用 - 关联成员:
Packet.codec()
- 引用位置:
-
- 引用位置:
返回值
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
构造调用/返回值 - 关联成员:
Vec3()
- 引用位置: