ClientboundRemoveEntitiesPacket 0x4E

ClientboundRemoveEntitiesPacket: Minecraft 26.3 packet (0x4E Play clientbound). Wire name 'remove_entities', fields: entityIds, handled

Minecraft 26.3PlayClientboundnet.minecraft.network.protocol.game

Protocol slots (1)

IDdecStateDirectionRegistry
0x4E78PLAYClientboundGamePacketTypes.CLIENTBOUND_REMOVE_ENTITIES: "remove_entities"

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

FieldType
entityIdsIntList

Fields are the components of the packet record.

Stream codec

static final StreamCodec<ByteBuf, IntList> ID_LIST_STREAM_CODEC = ByteBufCodecs.VAR_INT.apply(ByteBufCodecs.collection(IntArrayList::new));

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

Handling

Resolved on the ClientGamePacketListener packet-listener interface by void handleRemoveEntities(ClientboundRemoveEntitiesPacket clientboundremoveentitiespacket). The implementation in the game is ClientPacketListener.

Full Source

ClientboundRemoveEntitiesPacket.java30 lines · Minecraft 26.3 · verbatimSource page ↗
1
package net.minecraft.network.protocol.game;
2
3
import io.netty.buffer.ByteBuf;
4
import it.unimi.dsi.fastutil.ints.IntArrayList;
5
import it.unimi.dsi.fastutil.ints.IntList;
6
import net.minecraft.network.codec.ByteBufCodecs;
7
import net.minecraft.network.codec.StreamCodec;
8
import net.minecraft.network.protocol.Packet;
9
import net.minecraft.network.protocol.PacketType;
10
11
public record ClientboundRemoveEntitiesPacket(IntList entityIds) implements Packet<ClientGamePacketListener> {
12
	private static final StreamCodec<ByteBuf, IntList> ID_LIST_STREAM_CODEC = ByteBufCodecs.VAR_INT.apply(ByteBufCodecs.collection(IntArrayList::new));
13
	public static final StreamCodec<ByteBuf, ClientboundRemoveEntitiesPacket> STREAM_CODEC = StreamCodec.composite(
14
		ID_LIST_STREAM_CODEC, ClientboundRemoveEntitiesPacket::entityIds, ClientboundRemoveEntitiesPacket::new
15
	);
16
17
	public ClientboundRemoveEntitiesPacket(final int... ids) {
18
		this(IntList.of(ids));
19
	}
20
21
	@Override
22
	public PacketType<ClientboundRemoveEntitiesPacket> type() {
23
		return GamePacketTypes.CLIENTBOUND_REMOVE_ENTITIES;
24
	}
25
26
	public void handle(final ClientGamePacketListener listener) {
27
		listener.handleRemoveEntities(this);
28
	}
29
}
30