Solved Display particles to near players with ParticleEffect

Discussion in 'Plugin Development' started by 4thegame3, Oct 30, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    4thegame3

    Code:
    import java.util.ArrayList;
    import java.util.List;
    import org.bukkit.Bukkit;
    import org.bukkit.entity.Entity;
    import org.bukkit.entity.Player;
    import org.bukkit.scheduler.BukkitRunnable;
    
    public class Task extends BukkitRunnable {
        Entity entity;
        ParticleEffect effect;
        EffectMeta effectMeta;
        int id;
        public Task(int id,Entity entity,ParticleEffect effect,EffectMeta effectMeta) {
            this.id = id;
            this.entity = entity;
            this.effect = effect;
            this.effectMeta = effectMeta;
        }
        @Override
        public void run() {
            if(entity.isDead())
                this.cancel();
            if(entity.getNearbyEntities(100, 100,100)==null)
                this.cancel();
            List<Entity> nearEntities = entity.getNearbyEntities(100,100,100);
            List<Player> nearPlayers = new ArrayList<Player>();
            for(Entity entity:nearEntities){
                if(entity instanceof Player)
                    nearPlayers.add((Player)entity);
            }
            effect.display(0F, 0F, 0F, effectMeta.getSpeed(), effectMeta.getAmount(), entity.getLocation(),nearPlayers);
            nearPlayers = new ArrayList<Player>();
            nearEntities = new ArrayList<Entity>();
        }
    }
    Does not works, the particles disappear after 20 blocks, any help?
     
  2. Offline

    Zombie_Striker

    @4thegame3
    Isn't that how particles work? I think there is a limit to how far the client will render the particles.
     
  3. Offline

    4thegame3

    The problem is if i set the numer 100 to 1000 works. but it goes too far. I need that after 100 blocks i can't longer see the particles.
     
  4. Offline

    Zombie_Striker

    @4thegame3
    If the 100 ends the to soon, and 1000 extends to far, why not try 500?
     
  5. Offline

    4thegame3

    Until 1000 the distance remains the same.
     
  6. Offline

    Scimiguy

    @4thegame3
    Then you need to be sending packets
     
  7. Offline

    4thegame3

    Problem solved thanks all. I needed to set the flag long distance to true in the library ParticleEffect
     
  8. Offline

    Zombie_Striker

Thread Status:
Not open for further replies.

Share This Page