From e275f727d035f86ef44127460d4e217d340dd543 Mon Sep 17 00:00:00 2001 From: Andrew Ardill Date: Tue, 18 Jan 2011 18:29:41 +1100 Subject: [PATCH] small change to block event with lava and cactus, to improve readability and consistency --- .../java/net/minecraft/server/BlockCactus.java | 14 ++++++++++---- src/main/java/net/minecraft/server/Entity.java | 3 ++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/minecraft/server/BlockCactus.java b/src/main/java/net/minecraft/server/BlockCactus.java index 2f0aa35f12..1d28821750 100644 --- a/src/main/java/net/minecraft/server/BlockCactus.java +++ b/src/main/java/net/minecraft/server/BlockCactus.java @@ -9,6 +9,7 @@ import org.bukkit.craftbukkit.entity.CraftPlayer; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.event.entity.EntityDamageByBlockEvent; import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; // CraftBukkit end import java.util.Random; @@ -100,16 +101,21 @@ public class BlockCactus extends Block { if(entity instanceof EntityLiving) { CraftServer server = ((WorldServer) world).getServer(); - CraftEntity toPassIn = new CraftLivingEntity(server, (EntityLiving) entity); - EntityDamageByBlockEvent edbbe = new EntityDamageByBlockEvent(((WorldServer) world).getWorld().getBlockAt(i, j, k), toPassIn, EntityDamageEvent.DamageCause.CONTACT, 1); + org.bukkit.block.Block damager = ((WorldServer) world).getWorld().getBlockAt(i, j, k); + org.bukkit.entity.Entity damagee = entity.getBukkitEntity(); + DamageCause damageType = EntityDamageEvent.DamageCause.CONTACT; + int damageDone = 1; + + EntityDamageByBlockEvent edbbe = new EntityDamageByBlockEvent(damager, damagee, damageType, damageDone); server.getPluginManager().callEvent(edbbe); if (!edbbe.isCancelled()){ entity.a(((Entity) (null)), edbbe.getDamage()); } return; + } else { + entity.a(((Entity) (null)), 1); } - // CraftBukkit end - entity.a(((Entity) (null)), 1); + // CraftBukkit end } } diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java index d56f1de977..69c619dc3d 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java @@ -256,11 +256,12 @@ public abstract class Entity { // CraftBukkit start if(this instanceof EntityLiving) { CraftServer server = ((WorldServer) l).getServer(); + org.bukkit.block.Block damager = null;//((WorldServer) l).getWorld().getBlockAt(i, j, k); org.bukkit.entity.Entity damagee = this.getBukkitEntity(); DamageCause damageType = EntityDamageEvent.DamageCause.LAVA; int damageDone = 4; - EntityDamageByBlockEvent ede = new EntityDamageByBlockEvent(null, damagee, damageType, damageDone); + EntityDamageByBlockEvent ede = new EntityDamageByBlockEvent(damager, damagee, damageType, damageDone); server.getPluginManager().callEvent(ede); if (!ede.isCancelled()){ a(((Entity) (null)), ede.getDamage());