diff options
author | feildmaster <admin@feildmaster.com> | 2012-11-18 18:48:21 -0600 |
---|---|---|
committer | feildmaster <admin@feildmaster.com> | 2012-11-20 17:16:30 -0600 |
commit | 5f5dd727b6892eae5504578876bb3673151efc5f (patch) | |
tree | b2147c57e0d3b3d7a0f78c80c4791e966df335ec /src/main/java/net | |
parent | d039986be7d79b1edb706f15d77c6a94ca7041a9 (diff) | |
download | craftbukkit-5f5dd727b6892eae5504578876bb3673151efc5f.tar craftbukkit-5f5dd727b6892eae5504578876bb3673151efc5f.tar.gz craftbukkit-5f5dd727b6892eae5504578876bb3673151efc5f.tar.lz craftbukkit-5f5dd727b6892eae5504578876bb3673151efc5f.tar.xz craftbukkit-5f5dd727b6892eae5504578876bb3673151efc5f.zip |
Add a DamageEvent for falling blocks which can damage entities. Fixes BUKKIT-2781
Diffstat (limited to 'src/main/java/net')
-rw-r--r-- | src/main/java/net/minecraft/server/EntityFallingBlock.java | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/main/java/net/minecraft/server/EntityFallingBlock.java b/src/main/java/net/minecraft/server/EntityFallingBlock.java index dd8b64f4..4142650a 100644 --- a/src/main/java/net/minecraft/server/EntityFallingBlock.java +++ b/src/main/java/net/minecraft/server/EntityFallingBlock.java @@ -3,6 +3,8 @@ package net.minecraft.server; import java.util.ArrayList; import java.util.Iterator; +import org.bukkit.event.entity.EntityDamageEvent; // CraftBukkit + public class EntityFallingBlock extends Entity { public int id; @@ -124,7 +126,16 @@ public class EntityFallingBlock extends Entity { while (iterator.hasNext()) { Entity entity = (Entity) iterator.next(); - entity.damageEntity(damagesource, Math.min(MathHelper.d((float) i * this.fallHurtAmount), this.fallHurtMax)); + // CraftBukkit start + int damage = Math.min(MathHelper.d((float) i * this.fallHurtAmount), this.fallHurtMax); + + EntityDamageEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDamageEvent(this, entity, EntityDamageEvent.DamageCause.FALLING_BLOCK, damage); + if (event.isCancelled()) { + continue; + } + + entity.damageEntity(damagesource, event.getDamage()); + // CraftBukkit end } if (this.id == Block.ANVIL.id && (double) this.random.nextFloat() < 0.05000000074505806D + (double) i * 0.05D) { |