package net.minecraft.network.protocol.game; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.codec.StreamCodec; import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.PacketType; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.Level; public class ClientboundRotateHeadPacket implements Packet { public static final StreamCodec STREAM_CODEC = Packet.codec( ClientboundRotateHeadPacket::write, ClientboundRotateHeadPacket::new ); private final int entityId; private final byte yHeadRot; public ClientboundRotateHeadPacket(Entity entity, byte yHeadRot) { this.entityId = entity.getId(); this.yHeadRot = yHeadRot; } private ClientboundRotateHeadPacket(FriendlyByteBuf buffer) { this.entityId = buffer.readVarInt(); this.yHeadRot = buffer.readByte(); } /** * Writes the raw packet data to the data stream. */ private void write(FriendlyByteBuf buffer) { buffer.writeVarInt(this.entityId); buffer.writeByte(this.yHeadRot); } @Override public PacketType type() { return GamePacketTypes.CLIENTBOUND_ROTATE_HEAD; } /** * Passes this Packet on to the NetHandler for processing. */ public void handle(ClientGamePacketListener handler) { handler.handleRotateMob(this); } public Entity getEntity(Level level) { return level.getEntity(this.entityId); } public byte getYHeadRot() { return this.yHeadRot; } }