Snowball w/ Particles & Travel Distance

Discussion in 'Plugin Development' started by MrFrozen, Jun 16, 2015.

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

    MrFrozen

    Hey Bukkit,

    I have this simple code
    Code:
    Snowball snowball = p.getWorld().spawn(p.getEyeLocation(), Snowball.class);
                                snowball.setVelocity(p.getLocation().getDirection().multiply(5));
                                snowball.setShooter(p);
    To shoot a snowbal and speed it up now I only want to add particles to the snowball when it is going trough the air also I want to at something so I can set it can travel maxium 5 blocks in the air and then the snowball gets removed and if needed I can execute some code at the snowball at that place before it gets removed, How to?
     
  2. Make a repeating task (BukkitRunnable) and store the start location. Then display the particles at the snowballs location. When the startLocation.distance(snowballLocation) is greater than 5, cancel();
    Here is a BukkitRunnable:
    Code:
    new BukkitRunnable() {
    public void run() {
    //Code
    }
    }.runTaskTimer(this, 0, 5);
     
  3. Offline

    MrFrozen

    Thanks but the Runnable wasnt that hard but more a particle effect and the distance stuff but ill see
     
Thread Status:
Not open for further replies.

Share This Page