ClientboundSetEntityMotionPacket 0x67

ClientboundSetEntityMotionPacket: Minecraft 26.3 packet (0x67 Play clientbound). Wire name 'set_entity_motion', fields: id, movement, handled

Minecraft 26.3PlayClientboundnet.minecraft.network.protocol.game

Protocol slots (1)

IDdecStateDirectionRegistry
0x67103PLAYClientboundGamePacketTypes.CLIENTBOUND_SET_ENTITY_MOTION: "set_entity_motion"

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 (2)

FieldType
idint
movementVec3

Fields are the components of the packet record.

Stream codec

static final StreamCodec<ByteBuf, ClientboundSetEntityMotionPacket> STREAM_CODEC = StreamCodec.composite( ByteBufCodecs.VAR_INT, ClientboundSetEntityMotionPacket::id, Vec3.LP_STREAM_CODEC, Clientbound

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

Handling

Resolved on the ClientGamePacketListener packet-listener interface by void handleSetEntityMotion(ClientboundSetEntityMotionPacket clientboundsetentitymotionpacket). The implementation in the game is ClientPacketListener.

Full Source

ClientboundSetEntityMotionPacket.java33 lines · Minecraft 26.3 · verbatimSource page ↗
1
package net.minecraft.network.protocol.game;
2
3
import io.netty.buffer.ByteBuf;
4
import net.minecraft.network.codec.ByteBufCodecs;
5
import net.minecraft.network.codec.StreamCodec;
6
import net.minecraft.network.protocol.Packet;
7
import net.minecraft.network.protocol.PacketType;
8
import net.minecraft.world.entity.Entity;
9
import net.minecraft.world.phys.Vec3;
10
11
public record ClientboundSetEntityMotionPacket(int id, Vec3 movement) implements Packet<ClientGamePacketListener> {
12
	public static final StreamCodec<ByteBuf, ClientboundSetEntityMotionPacket> STREAM_CODEC = StreamCodec.composite(
13
		ByteBufCodecs.VAR_INT,
14
		ClientboundSetEntityMotionPacket::id,
15
		Vec3.LP_STREAM_CODEC,
16
		ClientboundSetEntityMotionPacket::movement,
17
		ClientboundSetEntityMotionPacket::new
18
	);
19
20
	public ClientboundSetEntityMotionPacket(final Entity entity) {
21
		this(entity.getId(), entity.getDeltaMovement());
22
	}
23
24
	@Override
25
	public PacketType<ClientboundSetEntityMotionPacket> type() {
26
		return GamePacketTypes.CLIENTBOUND_SET_ENTITY_MOTION;
27
	}
28
29
	public void handle(final ClientGamePacketListener listener) {
30
		listener.handleSetEntityMotion(this);
31
	}
32
}
33