From 971329c42b2a4242da1f5789ce6759c810779a6f Mon Sep 17 00:00:00 2001 From: feildmaster Date: Sat, 2 Aug 2014 16:03:50 -0500 Subject: [PATCH] Fix removal of items from Item Frames. Fixes BUKKIT-5736 --- src/main/java/net/minecraft/server/EntityItemFrame.java | 2 +- .../org/bukkit/craftbukkit/event/CraftEventFactory.java | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/minecraft/server/EntityItemFrame.java b/src/main/java/net/minecraft/server/EntityItemFrame.java index 1edb6d3105..d1d73f91f3 100644 --- a/src/main/java/net/minecraft/server/EntityItemFrame.java +++ b/src/main/java/net/minecraft/server/EntityItemFrame.java @@ -24,7 +24,7 @@ public class EntityItemFrame extends EntityHanging { } else if (this.getItem() != null) { if (!this.world.isStatic) { // CraftBukkit start - fire EntityDamageEvent - if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f) || this.dead) { + if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f, false) || this.dead) { return true; } // CraftBukkit end diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index 2c0065df40..c6c7f23b2c 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -564,8 +564,12 @@ public class CraftEventFactory { return handleEntityDamageEvent(damagee, source, modifiers, modifierFunctions); } - // Non-Living Entities such as EntityEnderCrystal, EntityItemFrame, and EntityFireball need to call this + // Non-Living Entities such as EntityEnderCrystal and EntityFireball need to call this public static boolean handleNonLivingEntityDamageEvent(Entity entity, DamageSource source, double damage) { + return handleNonLivingEntityDamageEvent(entity, source, damage, true); + } + + public static boolean handleNonLivingEntityDamageEvent(Entity entity, DamageSource source, double damage, boolean cancelOnZeroDamage) { if (entity instanceof EntityEnderCrystal && !(source instanceof EntityDamageSource)) { return false; } @@ -580,7 +584,7 @@ public class CraftEventFactory { if (event == null) { return false; } - return event.isCancelled() || event.getDamage() == 0; + return event.isCancelled() || (cancelOnZeroDamage && event.getDamage() == 0); } public static PlayerLevelChangeEvent callPlayerLevelChangeEvent(Player player, int oldLevel, int newLevel) {