From 953e1d601ac7cda4b5af375f82f13270f0a2a84e Mon Sep 17 00:00:00 2001 From: simpleauthority Date: Tue, 11 Sep 2018 00:09:10 -0700 Subject: [PATCH] SPIGOT-4314: Ability to change item in frame without playing sound --- nms-patches/EntityItemFrame.patch | 22 +++++++++++++++++++ .../craftbukkit/entity/CraftItemFrame.java | 6 ++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/nms-patches/EntityItemFrame.patch b/nms-patches/EntityItemFrame.patch index e15c81e42f..2a0031ff51 100644 --- a/nms-patches/EntityItemFrame.patch +++ b/nms-patches/EntityItemFrame.patch @@ -12,3 +12,25 @@ this.b(damagesource.getEntity(), false); this.a(SoundEffects.ENTITY_ITEM_FRAME_REMOVE_ITEM, 1.0F, 1.0F); } +@@ -170,6 +175,12 @@ + } + + private 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); +@@ -177,7 +188,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); + } + diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftItemFrame.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftItemFrame.java index 75812a5899..227a9ffa03 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftItemFrame.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftItemFrame.java @@ -57,7 +57,11 @@ public class CraftItemFrame extends CraftHanging implements ItemFrame { } public void setItem(org.bukkit.inventory.ItemStack item) { - getHandle().setItem(CraftItemStack.asNMSCopy(item)); + setItem(item, true); + } + + public void setItem(org.bukkit.inventory.ItemStack item, boolean playSound) { + getHandle().setItem(CraftItemStack.asNMSCopy(item), true, playSound); } public org.bukkit.inventory.ItemStack getItem() {