From 5f5dd727b6892eae5504578876bb3673151efc5f Mon Sep 17 00:00:00 2001 From: feildmaster Date: Sun, 18 Nov 2012 18:48:21 -0600 Subject: [PATCH] Add a DamageEvent for falling blocks which can damage entities. Fixes BUKKIT-2781 --- .../net/minecraft/server/EntityFallingBlock.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/minecraft/server/EntityFallingBlock.java b/src/main/java/net/minecraft/server/EntityFallingBlock.java index dd8b64f43a..4142650ac8 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) {