From 30a382a6dc20299b2a36c8bf4079a95e39a54366 Mon Sep 17 00:00:00 2001 From: sunkid Date: Thu, 14 Jul 2011 10:46:02 -0700 Subject: [PATCH] Made ProjectileHitEvent fire instantly when projectiles don't hit entities. --- src/main/java/net/minecraft/server/Entity.java | 6 ------ src/main/java/net/minecraft/server/EntityArrow.java | 5 +++++ src/main/java/net/minecraft/server/EntityEgg.java | 4 ++++ src/main/java/net/minecraft/server/EntityFireball.java | 5 +++++ src/main/java/net/minecraft/server/EntitySnowball.java | 4 ++++ 5 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java index 1c8a031e32..8c767dbd09 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java @@ -141,12 +141,6 @@ public abstract class Entity { } public void die() { - // CraftBukkit start - if (this.getBukkitEntity() instanceof Projectile && !(this instanceof EntityFish)) { - ProjectileHitEvent event = new ProjectileHitEvent((Projectile) this.getBukkitEntity()); - this.world.getServer().getPluginManager().callEvent(event); - } - // CraftBukkit end this.dead = true; } diff --git a/src/main/java/net/minecraft/server/EntityArrow.java b/src/main/java/net/minecraft/server/EntityArrow.java index f07021689b..69d40dfe12 100644 --- a/src/main/java/net/minecraft/server/EntityArrow.java +++ b/src/main/java/net/minecraft/server/EntityArrow.java @@ -7,6 +7,7 @@ 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.ProjectileHitEvent; import org.bukkit.event.player.PlayerPickupItemEvent; // CraftBukkit end @@ -162,6 +163,10 @@ public class EntityArrow extends Entity { float f2; if (movingobjectposition != null) { + // CraftBukkit start + ProjectileHitEvent phe = new ProjectileHitEvent((Projectile) this.getBukkitEntity()); + this.world.getServer().getPluginManager().callEvent(phe); + // CraftBukkit end if (movingobjectposition.entity != null) { // CraftBukkit start boolean stick; diff --git a/src/main/java/net/minecraft/server/EntityEgg.java b/src/main/java/net/minecraft/server/EntityEgg.java index 1346ec2793..58a204d795 100644 --- a/src/main/java/net/minecraft/server/EntityEgg.java +++ b/src/main/java/net/minecraft/server/EntityEgg.java @@ -8,6 +8,7 @@ import org.bukkit.entity.Projectile; import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; import org.bukkit.event.entity.EntityDamageByProjectileEvent; import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.player.PlayerEggThrowEvent; // CraftBukkit end @@ -150,6 +151,9 @@ public class EntityEgg extends Entity { if (movingobjectposition != null) { // CraftBukkit start + ProjectileHitEvent phe = new ProjectileHitEvent((Projectile) this.getBukkitEntity()); + this.world.getServer().getPluginManager().callEvent(phe); + if (movingobjectposition.entity != null) { boolean stick; if (movingobjectposition.entity instanceof EntityLiving) { diff --git a/src/main/java/net/minecraft/server/EntityFireball.java b/src/main/java/net/minecraft/server/EntityFireball.java index 94acf4a54a..a025cbdb59 100644 --- a/src/main/java/net/minecraft/server/EntityFireball.java +++ b/src/main/java/net/minecraft/server/EntityFireball.java @@ -10,6 +10,7 @@ import org.bukkit.entity.Projectile; import org.bukkit.event.entity.EntityDamageByProjectileEvent; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.ExplosionPrimeEvent; +import org.bukkit.event.entity.ProjectileHitEvent; // CraftBukkit end public class EntityFireball extends Entity { @@ -127,6 +128,10 @@ public class EntityFireball extends Entity { } if (movingobjectposition != null) { + // CraftBukkit start + ProjectileHitEvent phe = new ProjectileHitEvent((Projectile) this.getBukkitEntity()); + this.world.getServer().getPluginManager().callEvent(phe); + // CraftBukkit end if (!this.world.isStatic) { // CraftBukkit start if (movingobjectposition.entity != null) { diff --git a/src/main/java/net/minecraft/server/EntitySnowball.java b/src/main/java/net/minecraft/server/EntitySnowball.java index 485b48db1f..d1e66f8c6e 100644 --- a/src/main/java/net/minecraft/server/EntitySnowball.java +++ b/src/main/java/net/minecraft/server/EntitySnowball.java @@ -7,6 +7,7 @@ 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.ProjectileHitEvent; // CraftBukkit end public class EntitySnowball extends Entity { @@ -148,6 +149,9 @@ public class EntitySnowball extends Entity { if (movingobjectposition != null) { // CraftBukkit start + ProjectileHitEvent phe = new ProjectileHitEvent((Projectile) this.getBukkitEntity()); + this.world.getServer().getPluginManager().callEvent(phe); + if (movingobjectposition.entity != null) { boolean stick; if (movingobjectposition.entity instanceof EntityLiving) {