Solved Need help with particle

Discussion in 'Spigot Plugin Development' started by Peepersoak, Jun 14, 2021.

?

Is it possible to reduce the lifespan of the particle? like despawn it after maybe 5 ticks?

  1. Yes

    0 vote(s)
    0.0%
  2. No

    0 vote(s)
    0.0%
  1. Is there any way to remove the "explosive" animation of some particles like the FIREWORKS_SPARK?

    I want it to stay on a single location just like the red stone particle.

    Thank you

    This is what the Fire Works Spark looks like, it has this explosive animation
    upload_2021-6-14_17-36-15.png


    This is what I want it to look like, it stays on 1 location
    upload_2021-6-14_17-39-6.png
     
  2. set speed to 0
     
    • Winner Winner x 1
  3. Oh wow, so that's what the "extra" parameter is for, thankss
     
  4. I wrote a description of how particles works in vanilla, if you need it :

    How it works in vanilla :
    1. A classic particle has a dx dy dz parameters, the offset of where it can spawn around the given location, then a speed (extra) and a count, the number or particle to be displayed. In short, this is : /particle <particle> x y z dx dy dz speed count.

    2. Some particles can be directional, like flame, nautilus, end rod, totem, ... it means that when the count is 0, that is we want to spawn "0" particles, it will display one but with a velocity. The velocity is given by dx dy dz. The command becomes : /particle <particle> x y z velocityX velocityY velocityZ speed 0. For example, a single flame particle that goes east will have a dx = 1, dy = 0, dz = 0. Higher the velocity is, more speed the particle has (in addition to the speed parameter). Note that a directional particle spawns at the exact given location without any offset, because the offset becomes the velocity.

    3. Other specific particles directly modify the particle command syntax. It is the case of
    • dust (REDSTONE) : /particle dust red green blue size x y z dx dy dz speed count normal (Sadly, dust particles cannot be directional, a count of 0 result to a single motionless particle.
    • item (ITEM_CRACK) : /particle item <item name> x y z ...
    • block (BLOCK_CRACK and BLOCK_DUST) : /particle block <block name> x y z ...
    • falling_dust (FALLING_DUST) : /particle block <block name> x y z ...
    4. And last, we have some really weird particles, like effect (SPELL), entity_effect (MOB_SPELL) and ambient_entity_effect (SPELL_MOB_AMBIENT). If you want to use colored mob spell particle in vanilla, you have to use directional particles : /particle entity_effect x y z <red> <green> <blue> <saturation 0 to 1> 0 <normal|force> <viewers>. Here the offset is color, the speed is the saturation and the count has to be to 0. Actually :
    • effect is the raw effect particle, everything white. Nothing particular here.
    • entity_effect is the potion particle, when you throw it somewhere. Offset is color and speed is saturation (0 is black, 1 is the realy color)
    • ambient_entity_effect is the ambient potion particle when you have an effect. The syntax is the same than entity_effect but the particle will be much less visible.
    As you can see, the syntax of particles from 4. is the same than 1. or 2., but the bevavior is quite different.

    Bukkit API, implementation
    The Bukkit API (and spigot, and paper) works like the /particle command except for the 3. In the source code, five particles has a custom data type, this is the extra arguments added to the syntax and represented by the data parameter :
    REDSTONE(DustOptions.class),
    ITEM_CRACK(ItemStack.class),
    BLOCK_CRACK(BlockData.class),
    BLOCK_DUST(BlockData.class),
    FALLING_DUST(BlockData.class)

    There is no extra datas for spell mob of effects but also for directional particles. Those two lines are similar, offset of 0 1 0, speed of 1, count of 0 :
    Bukkit : world.spawnParticle(Particle.FLAME, location, 0, 0, 1, 0, 1);
    In game : /particle flame <loc> 0 1 0 1 0

    But also for spell mob :
    Bukkit : world.spawnParticle(Particle.SPELL_MOB, location, 0, 0.404, 1, 0.310, 1);
    In game : /particle entity_effect <loc> 0.404 1 0.310 1 0

    This is exactly the same for XParticle. You have to create a particle display instance with a specific offset, count of 0 and extra represents the saturation, here an example of a ParticleDisplay spell mob in red with high saturation :
    ParticleDisplay display = new ParticleDisplay(Particle.SPELL_MOB, null, location, 0, 1, 0, 0, 1);
    Hope it helps you !
     
    • Winner Winner x 1
    • Useful Useful x 1