Solved Egg particle trail

Discussion in 'Spigot Plugin Development' started by LoxleyShadow, Jan 1, 2020.

  1. I got spawn eggs to be throwable, and I want to get a particle trail behind it when it is thrown.
    This is what I have so far:
    Code (Java):
    new BukkitRunnable() {
                    @Override
                    public void run() {
                        event.getPlayer().getWorld().spawnParticle(Particle.CLOUD, egg.getLocation(), 2, 0, 0.5, 0, 0);
                        if (egg.isDead()) {
                            cancel();
                        }
                    }
                }.runTaskTimer(plugin, 0L, 5L);
    but it only spawns the particles where the egg lands.
     
  2. This is inside a listner to the PlayerEggThrowEvent, right?
     
  3. Yes it is. Does the problem have to do with the arguments to spawnParticle?
     
  4. Did you try decreasing the period?
     
  5. Instead of using PlayerEggThrowEvent, use ProjectileLaunchEvent. (Correct me if I'm wrong) I believe the first event is triggered when the egg hatches. When using the latter event, you can use event.getEntity().getShooter() for the player, and the Egg projectile will just be event.getEntity().

    Make sure you add checks to make sure the shooter is a player and the projectile is an Egg!
     
    • Informative Informative x 3
    • Agree Agree x 2
  6. What should I replace this with?

    event.setHatching(false);
     
  7. You’ll have to listen to both events for that as the PlayerEggThrowEvent is the only one that has that method.
     
    • Informative Informative x 1