How to make mobs a projectile.

Discussion in 'Plugin Development' started by MavenDisrrpt, Jun 20, 2021.

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

    MavenDisrrpt

    As the title suggests, I want to be able to shoot mobs like a sheep or a cow for example. My first thought was to use the launchProjectile(Projectile.class) method, but I then had a look and mobs don't fall under the subinterfaces for the Projectile class. From my attempt of researching around looking for answers, I have come to think that this is a unique thing to want to create. So what I am wanting to know is if anyone knows how I could achieve this.

    I have this, but this uses Wither Skulls which are in that list of Projectiles (I'll leave a link to this below)

    Code:
        @EventHandler
        public void onPlayerInteract(PlayerInteractEvent e) {
            if (!(e.getAction() == Action.RIGHT_CLICK_AIR)) return;
    
            if (!(e.getItem().getType() == Material.STICK)) return;
    
            WitherSkull witherSkull = e.getPlayer().launchProjectile(WitherSkull.class);
            witherSkull.setIsIncendiary(false); // does it set fire to things?
            witherSkull.setYield(0); //  radius of the explosion
        }
    Link to Projectile page -
    https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/Projectile.html
     
  2. Offline

    KarimAKL

  3. Offline

    Strahan

Thread Status:
Not open for further replies.

Share This Page