ClientboundSetEntityLinkPacket 0x66

ClientboundSetEntityLinkPacket: Minecraft 26.3 packet (0x66 Play clientbound). Wire name 'set_entity_link', fields: sourceEntity, destEntity, handled

Minecraft 26.3PlayClientboundnet.minecraft.network.protocol.game

Protocol slots (1)

IDdecStateDirectionRegistry
0x66102PLAYClientboundGamePacketTypes.CLIENTBOUND_SET_ENTITY_LINK: "set_entity_link"

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
sourceEntityEntity
destEntity@Nullable Entity

Stream codec

static final StreamCodec<FriendlyByteBuf, ClientboundSetEntityLinkPacket> STREAM_CODEC = Packet.codec( ClientboundSetEntityLinkPacket::write, ClientboundSetEntityLinkPacket::new );

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

Handling

Resolved on the ClientGamePacketListener packet-listener interface by void handleEntityLinkPacket(ClientboundSetEntityLinkPacket clientboundsetentitylinkpacket). The implementation in the game is ClientPacketListener.

Full Source

ClientboundSetEntityLinkPacket.java49 lines · Minecraft 26.3 · verbatimSource page ↗
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.world.entity.Entity;
8
import org.jspecify.annotations.Nullable;
9
10
public class ClientboundSetEntityLinkPacket implements Packet<ClientGamePacketListener> {
11
	public static final StreamCodec<FriendlyByteBuf, ClientboundSetEntityLinkPacket> STREAM_CODEC = Packet.codec(
12
		ClientboundSetEntityLinkPacket::write, ClientboundSetEntityLinkPacket::new
13
	);
14
	private final int sourceId;
15
	private final int destId;
16
17
	public ClientboundSetEntityLinkPacket(final Entity sourceEntity, final @Nullable Entity destEntity) {
18
		this.sourceId = sourceEntity.getId();
19
		this.destId = destEntity != null ? destEntity.getId() : 0;
20
	}
21
22
	private ClientboundSetEntityLinkPacket(final FriendlyByteBuf input) {
23
		this.sourceId = input.readInt();
24
		this.destId = input.readInt();
25
	}
26
27
	private void write(final FriendlyByteBuf output) {
28
		output.writeInt(this.sourceId);
29
		output.writeInt(this.destId);
30
	}
31
32
	@Override
33
	public PacketType<ClientboundSetEntityLinkPacket> type() {
34
		return GamePacketTypes.CLIENTBOUND_SET_ENTITY_LINK;
35
	}
36
37
	public void handle(final ClientGamePacketListener listener) {
38
		listener.handleEntityLinkPacket(this);
39
	}
40
41
	public int getSourceId() {
42
		return this.sourceId;
43
	}
44
45
	public int getDestId() {
46
		return this.destId;
47
	}
48
}
49