How to set the speed and direction of a splash potion?

Discussion in 'Plugin Development' started by AussieBacom, Mar 31, 2012.

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


    Is it possible to edit the splash potions speed and direction when they are thrown, eg. Like a snowball.

    Some code I have pulled out of the arrow speed multiplier:
        public void playerThrowGrenade(ThrownPotion e) {
            Entity entity = e.getEntity();
            Vector speed = e.getVelocity()
            Entity projectile = e.getProjectile();
                Player p = (Player) entity;
                Vector vec = p.getLocation().getDirection();
                    projectile.setVelocity(new Vector
                    (vec.getX() * speed * 4.375,
                    vec.getY() * speed * 5,
                      vec.getZ() * speed * 4.375));

    Well more a less a bump, i think im getting closer to working it out.

    public void playerThrowGrenade(ThrownExpBottle e) {
    String le1 e.getShooter().toString();
    String le2 le1.replace("CraftPlayer{name=""");
    String player le2.replace("}""");
    Bukkit.broadcastMessage("GRENADE TEST");
    Player p Bukkit.getPlayer(player);
    Vector vec p.getLocation().getDirection();
    e.setVelocity(new Vector
    (vec.getX() + 4.375,
    vec.getY() + 5,
    vec.getZ() + 4.375));
    This code returns the error "Wrong method arguments used for event type registered", I'm assuming that its a simple fix

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 24, 2016
  2. I think you want to use the ProjectileLaunchEvent, because a ThroenExpBottle event does not exist (every event ends with event in the name). Then check if the projectile is a exp bottle.
    AussieBacom likes this.
  3. Offline


    Cheers that worked perfectly
Thread Status:
Not open for further replies.

Share This Page