ClientboundTeleportEntityPacket 0x80

ClientboundTeleportEntityPacket: Minecraft 26.3 packet (0x80 Play clientbound). Wire name 'teleport_entity', fields: id, change, relatives, onGround

Minecraft 26.3PlayClientboundnet.minecraft.network.protocol.game

Protocol slots (1)

IDdecStateDirectionRegistry
0x80128PLAYClientboundGamePacketTypes.CLIENTBOUND_TELEPORT_ENTITY: "teleport_entity"

Packet ids are positional: the id is the index of the addPacket call in the protocol builder (see ProtocolInfoBuilder.listPackets). Ids change between game versions.

Wire fields (4)

FieldType
idint
changePositionMoveRotation
relativesSet<Relative>
onGroundboolean

Fields are the components of the packet record.

Stream codec

static final StreamCodec<FriendlyByteBuf, ClientboundTeleportEntityPacket> STREAM_CODEC = StreamCodec.composite( ByteBufCodecs.VAR_INT, ClientboundTeleportEntityPacket::id, PositionMoveRotation.STREAM

Modern packets serialize through StreamCodecs instead of read/write methods.

Handling

Resolved on the ClientGamePacketListener packet-listener interface by void handleTeleportEntity(ClientboundTeleportEntityPacket clientboundteleportentitypacket). The implementation in the game is ClientPacketListener.

Full Source

ClientboundTeleportEntityPacket.java39 lines · Minecraft 26.3 · verbatimSource page ↗
1
package net.minecraft.network.protocol.game;
2
3
import java.util.Set;
4
import net.minecraft.network.FriendlyByteBuf;
5
import net.minecraft.network.codec.ByteBufCodecs;
6
import net.minecraft.network.codec.StreamCodec;
7
import net.minecraft.network.protocol.Packet;
8
import net.minecraft.network.protocol.PacketType;
9
import net.minecraft.world.entity.PositionMoveRotation;
10
import net.minecraft.world.entity.Relative;
11
12
public record ClientboundTeleportEntityPacket(int id, PositionMoveRotation change, Set<Relative> relatives, boolean onGround)
13
	implements Packet<ClientGamePacketListener> {
14
	public static final StreamCodec<FriendlyByteBuf, ClientboundTeleportEntityPacket> STREAM_CODEC = StreamCodec.composite(
15
		ByteBufCodecs.VAR_INT,
16
		ClientboundTeleportEntityPacket::id,
17
		PositionMoveRotation.STREAM_CODEC,
18
		ClientboundTeleportEntityPacket::change,
19
		Relative.SET_STREAM_CODEC,
20
		ClientboundTeleportEntityPacket::relatives,
21
		ByteBufCodecs.BOOL,
22
		ClientboundTeleportEntityPacket::onGround,
23
		ClientboundTeleportEntityPacket::new
24
	);
25
26
	public static ClientboundTeleportEntityPacket teleport(final int id, final PositionMoveRotation values, final Set<Relative> relatives, final boolean onGround) {
27
		return new ClientboundTeleportEntityPacket(id, values, relatives, onGround);
28
	}
29
30
	@Override
31
	public PacketType<ClientboundTeleportEntityPacket> type() {
32
		return GamePacketTypes.CLIENTBOUND_TELEPORT_ENTITY;
33
	}
34
35
	public void handle(final ClientGamePacketListener listener) {
36
		listener.handleTeleportEntity(this);
37
	}
38
}
39