Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-266537

Disparity between the read/write logic of the explosion packet

XMLWordPrintable

    • Plausible
    • Networking, Particles
    • Important
    • 1139857
    • Expansion B

      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.

            Unassigned Unassigned
            WinX64 WinX64
            Votes:
            6 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: