Colored Particles

Apr 20, 2017
Colored Particles
  • There are 3 types of particles that are colorizeable, however it is not so obvious how this works.

    The REDSTONE, SPELL_MOB and SPELL_MOB_AMBIENT particles can also use custom colors by providing some specific data when spawning them.

    You will need to use the method Player.spawnParticle which takes the full set of available particle parameters. Specifically you will need to adjust the offset X,Y,Z parameters to control color, "extra" for brightness and "count" to toggle colorization.

    What these parameters do in this specific case:
    • count: Must be set to 0, this enabled colorized particles. Note that this means you cannot spawn more than one colored particle at a time (via a single call/packet)
    • extra: This controls the brightness of the particle's color, generally you just want to set this to 1.
    • offsetX: Pass a value from 0 to 1 here to control the red component of the particle's color
    • offsetY: Pass a value from 0 to 1 here to control the green component of the particle's color
    • offsetZ: Pass a value from 0 to 1 here to control the blue component of the particle's color
    So to spawn a green redstone particle, you would make a call like this:

    Code (Text):
    player.spawnParticle(Particle.REDSTONE, x, y, z, 0, 0.001, 1, 0, 1);
    You may have noticed that the red component is not set to zero. This is to work-around some specific client behavior, if the red component is zero the particle will always render as red. (Naturally...)

    This only affects the REDSTONE particle. If you'd like no red at all, you can use Float.MIN_VALUE and it will be virtually red-free.
  • Loading...
  • Loading...