diff options
Diffstat (limited to 'src/main/java/net/minecraft/server/EntitySnowball.java')
-rw-r--r-- | src/main/java/net/minecraft/server/EntitySnowball.java | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/main/java/net/minecraft/server/EntitySnowball.java b/src/main/java/net/minecraft/server/EntitySnowball.java index 96613630..1957ed93 100644 --- a/src/main/java/net/minecraft/server/EntitySnowball.java +++ b/src/main/java/net/minecraft/server/EntitySnowball.java @@ -4,6 +4,8 @@ import java.util.List; // CraftBukkit start import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.craftbukkit.entity.CraftLivingEntity; +import org.bukkit.entity.Projectile; import org.bukkit.event.entity.EntityDamageByProjectileEvent; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; @@ -17,7 +19,7 @@ public class EntitySnowball extends Entity { private int e = 0; private boolean f = false; public int a = 0; - private EntityLiving shooter; + public EntityLiving shooter; // CraftBukkit private -> public private int h; private int i = 0; @@ -151,23 +153,22 @@ public class EntitySnowball extends Entity { if (movingobjectposition.entity != null) { boolean stick; if (movingobjectposition.entity instanceof EntityLiving) { - CraftServer server = ((WorldServer) this.world).getServer(); - org.bukkit.entity.Entity shooter = (this.shooter == null) ? null : this.shooter.getBukkitEntity(); + CraftServer server = this.world.getServer(); org.bukkit.entity.Entity damagee = movingobjectposition.entity.getBukkitEntity(); - org.bukkit.entity.Entity projectile = this.getBukkitEntity(); + Projectile projectile = (Projectile) this.getBukkitEntity(); DamageCause damageCause = EntityDamageEvent.DamageCause.ENTITY_ATTACK; int damage = 0; // TODO @see EntityArrow#162 - EntityDamageByProjectileEvent event = new EntityDamageByProjectileEvent(shooter, damagee, projectile, damageCause, damage); + EntityDamageByProjectileEvent event = new EntityDamageByProjectileEvent(damagee, projectile, damageCause, damage); server.getPluginManager().callEvent(event); + this.shooter = (projectile.getShooter() == null) ? null : ((CraftLivingEntity) projectile.getShooter()).getHandle(); - if (!event.isCancelled()) { - // this function returns if the snowball should stick or not, i.e. !bounce - stick = movingobjectposition.entity.damageEntity(this.shooter, event.getDamage()); - } else { - // event was cancelled, get if the snowball should bounce or not + if (event.isCancelled()) { stick = !event.getBounce(); + } else { + // this function returns if the snowball should stick in or not, i.e. !bounce + stick = movingobjectposition.entity.damageEntity(this.shooter, event.getDamage()); } } else { stick = movingobjectposition.entity.damageEntity(this.shooter, 0); |