ClientboundExplodePacket 0x24

ClientboundExplodePacket: Minecraft 26.3 packet (0x24 Play clientbound). Wire name 'explode', fields: center, radius, blockCount, playerKnockback

Minecraft 26.3PlayClientboundnet.minecraft.network.protocol.game

Protocol slots (1)

IDdecStateDirectionRegistry
0x2436PLAYClientboundGamePacketTypes.CLIENTBOUND_EXPLODE: "explode"

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

FieldType
centerVec3
radiusfloat
blockCountint
playerKnockbackOptional<Vec3>
explosionParticleParticleOptions
explosionSoundHolder<SoundEvent>
blockParticlesWeightedList<ExplosionParticleInfo>
playSoundboolean

Fields are the components of the packet record.

Stream codec

static final StreamCodec<RegistryFriendlyByteBuf, ClientboundExplodePacket> STREAM_CODEC = StreamCodec.composite( Vec3.STREAM_CODEC, ClientboundExplodePacket::center, ByteBufCodecs.FLOAT, ClientboundE

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

Handling

Resolved on the ClientGamePacketListener packet-listener interface by void handleExplosion(ClientboundExplodePacket clientboundexplodepacket). The implementation in the game is ClientPacketListener.

Full Source

ClientboundExplodePacket.java56 lines · Minecraft 26.3 · verbatimSource page ↗
1
package net.minecraft.network.protocol.game;
2
3
import java.util.Optional;
4
import net.minecraft.core.Holder;
5
import net.minecraft.core.particles.ExplosionParticleInfo;
6
import net.minecraft.core.particles.ParticleOptions;
7
import net.minecraft.core.particles.ParticleTypes;
8
import net.minecraft.network.RegistryFriendlyByteBuf;
9
import net.minecraft.network.codec.ByteBufCodecs;
10
import net.minecraft.network.codec.StreamCodec;
11
import net.minecraft.network.protocol.Packet;
12
import net.minecraft.network.protocol.PacketType;
13
import net.minecraft.sounds.SoundEvent;
14
import net.minecraft.util.random.WeightedList;
15
import net.minecraft.world.phys.Vec3;
16
17
public record ClientboundExplodePacket(
18
	Vec3 center,
19
	float radius,
20
	int blockCount,
21
	Optional<Vec3> playerKnockback,
22
	ParticleOptions explosionParticle,
23
	Holder<SoundEvent> explosionSound,
24
	WeightedList<ExplosionParticleInfo> blockParticles,
25
	boolean playSound
26
) implements Packet<ClientGamePacketListener> {
27
	public static final StreamCodec<RegistryFriendlyByteBuf, ClientboundExplodePacket> STREAM_CODEC = StreamCodec.composite(
28
		Vec3.STREAM_CODEC,
29
		ClientboundExplodePacket::center,
30
		ByteBufCodecs.FLOAT,
31
		ClientboundExplodePacket::radius,
32
		ByteBufCodecs.INT,
33
		ClientboundExplodePacket::blockCount,
34
		Vec3.STREAM_CODEC.apply(ByteBufCodecs::optional),
35
		ClientboundExplodePacket::playerKnockback,
36
		ParticleTypes.STREAM_CODEC,
37
		ClientboundExplodePacket::explosionParticle,
38
		SoundEvent.STREAM_CODEC,
39
		ClientboundExplodePacket::explosionSound,
40
		WeightedList.streamCodec(ExplosionParticleInfo.STREAM_CODEC),
41
		ClientboundExplodePacket::blockParticles,
42
		ByteBufCodecs.BOOL,
43
		ClientboundExplodePacket::playSound,
44
		ClientboundExplodePacket::new
45
	);
46
47
	@Override
48
	public PacketType<ClientboundExplodePacket> type() {
49
		return GamePacketTypes.CLIENTBOUND_EXPLODE;
50
	}
51
52
	public void handle(final ClientGamePacketListener listener) {
53
		listener.handleExplosion(this);
54
	}
55
}
56