Particles not shown

Discussion in 'Plugin Development' started by TheNewTao, Nov 21, 2015.

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

    TheNewTao

    Hi,
    I am creating a plugin in which you right click a "wand" it shoots a snowball, sets it to invisible and displays a bunch of particles on the player that took damage from the projectile. My code is:

    On damage by projectile
    Code:
        @EventHandler
        public void onDamage(EntityDamageByEntityEvent e) {
            if (e.getDamager() instanceof Snowball && e.getDamager().getName().equals("5")) {
                Location snowballLoc = e.getEntity().getLocation();
                List<Player> onlineP = new ArrayList<Player>();
                for (Player lol : Bukkit.getOnlinePlayers()) {
                    onlineP.add(lol);
                }
                for (int x = 0; x < 30; x++) {
                    ParticleEffect.FIREWORKS_SPARK.display(0, 0, 0, 1, 3, snowballLoc, onlineP);
                }
                if (e.getEntity() instanceof Player) {
                    Player snowballed = (Player) e.getEntity();
                    snowballed.setHealth(snowballed.getHealth() - 10);
                }
            }
    
        }
    Checking for wand and right click
    Code:
        @EventHandler
        public void onInteract(PlayerInteractEvent e) {
    if (e.getPlayer() != null && rigthClick.contains("light") && rigthClick.size() == 1) {
                e.getPlayer().sendMessage("nope");
                if (e.getPlayer().getItemInHand().equals(wand)) {
                    Player p = e.getPlayer();
                    p.sendMessage("wand is good");
                    Vector standard = p.getLocation().getDirection().multiply(4);
                    Snowball snowball = p.launchProjectile(Snowball.class, standard);
                    snowball.setCustomName("5");
                    for (Player players : Bukkit.getOnlinePlayers()) {
                        ((CraftPlayer) players).getHandle().playerConnection
                                .sendPacket(new PacketPlayOutEntityDestroy(((CraftSnowball) snowball).getHandle().getId()));
                    }
                }
            }
        }
    
    Everything works perfectly, almost. However, when I shoot a snowball from more than like 20 blocks (rough estimate) the particles do not display in the shooters screen, but they do in the player that was shot. It is as if you could only see the particles if the player was within a certain distance. How can I increase that distance?
     
  2. Offline

    EvilWitchdoctor

    Someone correct me if I'm wrong, but I believe particle display based on relative distance is handled client side
    (i.e., it won't show rain droplets more then 20 blocks away as that might cause lag)
    In other words, I don't think it's possible to let the shooter see the effects from long-range. Maybe play a sound instead?
     
    Zombie_Striker likes this.
Thread Status:
Not open for further replies.

Share This Page