summaryrefslogtreecommitdiffstats
path: root/nms-patches/EntityItemFrame.patch
blob: 19d544513852fc195811160f67777d991d3cd6e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
--- a/net/minecraft/server/EntityItemFrame.java
+++ b/net/minecraft/server/EntityItemFrame.java
@@ -95,6 +95,11 @@
             return false;
         } else if (!damagesource.isExplosion() && !this.getItem().isEmpty()) {
             if (!this.world.isClientSide) {
+                // CraftBukkit start - fire EntityDamageEvent
+                if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f, false) || this.dead) {
+                    return true;
+                }
+                // CraftBukkit end
                 this.b(damagesource.getEntity(), false);
                 this.a(SoundEffects.ENTITY_ITEM_FRAME_REMOVE_ITEM, 1.0F, 1.0F);
             }
@@ -168,6 +173,12 @@
     }
 
     public void setItem(ItemStack itemstack, boolean flag) {
+        // CraftBukkit start
+        this.setItem(itemstack, flag, true);
+    }
+
+    public void setItem(ItemStack itemstack, boolean flag, boolean playSound) {
+        // CraftBukkit end
         if (!itemstack.isEmpty()) {
             itemstack = itemstack.cloneItemStack();
             itemstack.setCount(1);
@@ -175,7 +186,7 @@
         }
 
         this.getDataWatcher().set(EntityItemFrame.e, itemstack);
-        if (!itemstack.isEmpty()) {
+        if (!itemstack.isEmpty() && playSound) { // CraftBukkit
             this.a(SoundEffects.ENTITY_ITEM_FRAME_ADD_ITEM, 1.0F, 1.0F);
         }