How to spawn particles?

Discussion in 'Spigot Plugin Development' started by VojtaCRV, Oct 13, 2017.

  1. Hi.
    I wanna ask you, how can I spawn a particle effect? Just simple particle effect, not complex helixs or these..
    I want it to spawn all the time the player wears a specific item.

    So just how to spawn particles, which wont stop spawning until player unwears the armor item?
     
  2. Make a runnable, start if when the item switches to that specific item. Now, spawn particles using the world (world.spawnParticle) or whatever. If the player is no longer holding the item, stop the runnable.
     
  3. If you are using 1.9+, there is an API for spawning particles directly from the spigot API ((World/Player)#spawnParticle(Particle particle, double x, double y, double z, int count).
    If you are using 1.8, you'll need NMS. If you want to maintain the compatibility through versions, you'll need to switch to reflections
     
  4. Wait whuut? You don't have to use NMS to spawn particles in 1.8?
     
  5. You could use Player#playEffect, but still, when doing particles in 1.8 I prefer NMS.
     
  6. Yeah, there are not many options.
    You could use EffectLib, I believe it has all you need to spawn particles.
     
  7. When on 1.8 or older, consider using Darkblade's particlelib.
     
  8. Yeah, looks fine, but, how to do the
    ?


    Im doing this first time. Idk what exactly should i do.

    Ill better prefer the EffectLib. :p
     
  9. You'll need a runnable anyway. If you are new to java, tons of tutorials out there. EffectLib only helps you spawning the particle.
     
  10. Code (Text):
            for (Player hrac : Bukkit.getOnlinePlayers()) {
                ItemStack boty = new ItemStack(Material.CHAINMAIL_BOOTS, 1);
                if (boty == null) continue;
                if (boty.getType() == Material.CHAINMAIL_BOOTS) {
                    if (boty.getItemMeta() != null) {
                        if (boty.getItemMeta().getDisplayName() != null
                                && boty.getItemMeta().getDisplayName().equals(shoesn)) {
                            player.playEffect(player.getLocation(), Effect.DRAGON_BREATH, 0);
                        }

                    } else if (boty.getItemMeta() == null) {
                        return true;
                    } else if (!(boty.getItemMeta().getDisplayName() != null && boty.getItemMeta().getDisplayName().equals(shoesn))) {
                        return true;
                    }
                }
            }
    My piece of code, which should run the effect.
     

Share This Page