ClientboundRotateHeadPacket .java

net.minecraft.network.protocol.game.ClientboundRotateHeadPacket (class): members: getYHeadRot, yHeadRot, entityId, getEntity, handle, STREAM_CODEC, type.

net.minecraft.network.protocol.gameclass51 linescommon1.5 KB

Implements

API Surface (3)

PacketType<ClientboundRotateHeadPacket> type()
void handle(final ClientGamePacketListener listener)
float getYHeadRot()

Fields & Constants (3)

STREAM_CODEC
entityId
yHeadRot

Same Package (197)

Full Source

ClientboundRotateHeadPacket.java51 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.network.protocol.game;
2
3
import net.minecraft.network.FriendlyByteBuf;
4
import net.minecraft.network.codec.StreamCodec;
5
import net.minecraft.network.protocol.Packet;
6
import net.minecraft.network.protocol.PacketType;
7
import net.minecraft.util.Mth;
8
import net.minecraft.world.entity.Entity;
9
import net.minecraft.world.level.Level;
10
import org.jspecify.annotations.Nullable;
11
12
public class ClientboundRotateHeadPacket implements Packet<ClientGamePacketListener> {
13
	public static final StreamCodec<FriendlyByteBuf, ClientboundRotateHeadPacket> STREAM_CODEC = Packet.codec(
14
		ClientboundRotateHeadPacket::write, ClientboundRotateHeadPacket::new
15
	);
16
	private final int entityId;
17
	private final byte yHeadRot;
18
19
	public ClientboundRotateHeadPacket(final Entity entity, final byte yHeadRot) {
20
		this.entityId = entity.getId();
21
		this.yHeadRot = yHeadRot;
22
	}
23
24
	private ClientboundRotateHeadPacket(final FriendlyByteBuf input) {
25
		this.entityId = input.readVarInt();
26
		this.yHeadRot = input.readByte();
27
	}
28
29
	private void write(final FriendlyByteBuf output) {
30
		output.writeVarInt(this.entityId);
31
		output.writeByte(this.yHeadRot);
32
	}
33
34
	@Override
35
	public PacketType<ClientboundRotateHeadPacket> type() {
36
		return GamePacketTypes.CLIENTBOUND_ROTATE_HEAD;
37
	}
38
39
	public void handle(final ClientGamePacketListener listener) {
40
		listener.handleRotateMob(this);
41
	}
42
43
	public @Nullable Entity getEntity(final Level level) {
44
		return level.getEntity(this.entityId);
45
	}
46
47
	public float getYHeadRot() {
48
		return Mth.unpackDegrees(this.yHeadRot);
49
	}
50
}
51

Decompiled Minecraft 26.3 source of ClientboundRotateHeadPacket (net/minecraft/network/protocol/game/ClientboundRotateHeadPacket.java) with Mojang official mappings, stored verbatim on the site.