This site works best with JavaScript enabled. Please enable JavaScript to get the best experience from this site.
An arrow, which is an implementation of projectile can return the shooter of the projectile.
In this case, you can use the projectile instance to find out whether the entity that threw the projectile is a player or not.
Note that I've specifically said projectile, and not arrow. This means any projectile, e.g. snowball, egg, fireball, arrow, can be thrown and allowed to damage the entity shooting it isn't a player.
The code for such would be as follows:
else if(e.getDamager() instanceof Projectile) { Projectile proj = (Projectile) e.getDamager(); if (proj.getShooter() instanceof Player) { e.setCancelled(true); } }
I hope this helps squish one of your bugs. :)
To post a comment, please login or register a new account.