ServerboundMoveVehiclePacket 0x22

ServerboundMoveVehiclePacket: Minecraft 26.3 packet (0x22 Play serverbound). Wire name 'move_vehicle', fields: movingTo, onGround, handled

Minecraft 26.3PlayServerboundnet.minecraft.network.protocol.game

Protocol slots (1)

IDdecStateDirectionRegistry
0x2234PLAYServerboundGamePacketTypes.SERVERBOUND_MOVE_VEHICLE: "move_vehicle"

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
movingToPositionAndRotation
onGroundboolean

Fields are the components of the packet record.

Stream codec

static final StreamCodec<FriendlyByteBuf, ServerboundMoveVehiclePacket> STREAM_CODEC = StreamCodec.composite( PositionAndRotation.STREAM_CODEC, ServerboundMoveVehiclePacket::movingTo, ByteBufCodecs.BO

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

Handling

Resolved on the ServerGamePacketListener packet-listener interface by void handleMoveVehicle(ServerboundMoveVehiclePacket serverboundmovevehiclepacket). The implementation in the game is ServerGamePacketListenerImpl.

Full Source

ServerboundMoveVehiclePacket.java33 lines · Minecraft 26.3 · verbatimSource page ↗
1
package net.minecraft.network.protocol.game;
2
3
import net.minecraft.core.PositionAndRotation;
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.Entity;
10
11
public record ServerboundMoveVehiclePacket(PositionAndRotation movingTo, boolean onGround) implements Packet<ServerGamePacketListener> {
12
	public static final StreamCodec<FriendlyByteBuf, ServerboundMoveVehiclePacket> STREAM_CODEC = StreamCodec.composite(
13
		PositionAndRotation.STREAM_CODEC,
14
		ServerboundMoveVehiclePacket::movingTo,
15
		ByteBufCodecs.BOOL,
16
		ServerboundMoveVehiclePacket::onGround,
17
		ServerboundMoveVehiclePacket::new
18
	);
19
20
	public static ServerboundMoveVehiclePacket fromEntity(final Entity entity) {
21
		return new ServerboundMoveVehiclePacket(entity.getClientPositionAndRotation(), entity.onGround());
22
	}
23
24
	@Override
25
	public PacketType<ServerboundMoveVehiclePacket> type() {
26
		return GamePacketTypes.SERVERBOUND_MOVE_VEHICLE;
27
	}
28
29
	public void handle(final ServerGamePacketListener listener) {
30
		listener.handleMoveVehicle(this);
31
	}
32
}
33