Mojira Archive
MC-266537

Disparity between the read/write logic of the explosion packet

The current implementation of the explosion packet has a disparity between the data that is read from and the data that is written to the network.

More specifically, the part concerning the small and large explosion particles:

net.minecraft.network.protocol.game.ClientboundExplodePacket
public ClientboundExplodePacket(FriendlyByteBuf buf) {
    /* snip */
    
    this.smallExplosionParticles = ClientboundExplodePacket.readParticle(buf, buf.readById(BuiltInRegistries.PARTICLE_TYPE));
    this.largeExplosionParticles = ClientboundExplodePacket.readParticle(buf, buf.readById(BuiltInRegistries.PARTICLE_TYPE));
    
    /* snip */
}

private static <T extends ParticleOptions> T readParticle(FriendlyByteBuf buf, ParticleType<T> particleType) {
    return particleType.getDeserializer().fromNetwork(particleType, buf);
}

@Override
public void write(FriendlyByteBuf buf) {
    /* snip */
    
    buf.writeId(BuiltInRegistries.PARTICLE_TYPE, this.smallExplosionParticles.getType());
    buf.writeId(BuiltInRegistries.PARTICLE_TYPE, this.largeExplosionParticles.getType());
    
    /* snip */
}

The write logic serializes only the id of the two particles, while the read logic expects the id and whatever extra data is required for the particle (such as colors for the dust particle, block state id for the block particle etc.).

Although there's currently no way to trigger an explosion packet with customized particle types in the Vanilla implementation (only gust and generic types are used as of now), it will break if the behavior is implemented in the future.

Fixed

WinX64

2023-11-09, 02:18 PM

2023-11-29, 08:53 PM

2023-11-29, 12:36 PM

6

5

Plausible

Important

1139857

Expansion B

Networking, Particles

network, packets

23w45a, 23w46a, 1.20.3 Pre-Release 1, 1.20.3 Pre-Release 2

1.20.3 Release Candidate 1