From eabdc7ffa9d9062389cd7608768e021c04151a98 Mon Sep 17 00:00:00 2001 From: speakeasy Date: Thu, 20 Jan 2011 04:07:52 +0800 Subject: [PATCH] Fix for NPE with dispenser+arrow bug. --- src/main/java/net/minecraft/server/EntityArrow.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/minecraft/server/EntityArrow.java b/src/main/java/net/minecraft/server/EntityArrow.java index d05f3d4f07..11ae695470 100644 --- a/src/main/java/net/minecraft/server/EntityArrow.java +++ b/src/main/java/net/minecraft/server/EntityArrow.java @@ -176,7 +176,13 @@ public class EntityArrow extends Entity { //TODO decide if we should create DamageCause.ARROW, DamageCause.PROJECTILE // or leave as DamageCause.ENTITY_ATTACK - EntityDamageByProjectileEvent edbpe = new EntityDamageByProjectileEvent(b.getBukkitEntity(), entity.getBukkitEntity(), this.getBukkitEntity(), EntityDamageEvent.DamageCause.ENTITY_ATTACK, 4); + org.bukkit.entity.Entity shooter = null; + if ((EntityLiving)b != null) { + shooter = new org.bukkit.craftbukkit.entity.CraftLivingEntity(server, b); + } else if ((Entity)b != null) { + shooter = (org.bukkit.entity.Entity) b.getBukkitEntity(); + } + EntityDamageByProjectileEvent edbpe = new EntityDamageByProjectileEvent(shooter, entity.getBukkitEntity(), this.getBukkitEntity(), EntityDamageEvent.DamageCause.ENTITY_ATTACK, 4); server.getPluginManager().callEvent(edbpe); if(!edbpe.isCancelled()) {