diff options
author | sunkid <sunkid@iminurnetz.com> | 2011-06-18 08:10:31 -0700 |
---|---|---|
committer | EvilSeph <evilseph@unaligned.org> | 2011-06-18 22:21:02 -0400 |
commit | 155874eec9cc307814dd658acba4e27a121ca9a5 (patch) | |
tree | b5537efc7e8768ec2fd286fe8affa971c5f85fe6 /src/main/java/net/minecraft/server/EntitySnowball.java | |
parent | 546e1306d88978fcad3ddcfadaa2df6945a106d8 (diff) | |
download | craftbukkit-155874eec9cc307814dd658acba4e27a121ca9a5.tar craftbukkit-155874eec9cc307814dd658acba4e27a121ca9a5.tar.gz craftbukkit-155874eec9cc307814dd658acba4e27a121ca9a5.tar.lz craftbukkit-155874eec9cc307814dd658acba4e27a121ca9a5.tar.xz craftbukkit-155874eec9cc307814dd658acba4e27a121ca9a5.zip |
Implemented the concept of a projectile.
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); |