From aa1bf87abe64c60152bea58a2e4f777ceec6339f Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Fri, 30 Jun 2023 14:05:31 +0200 Subject: [PATCH] Don't play painting place sound if place failed --- src/nodes.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/nodes.lua b/src/nodes.lua index d4cf43d..9e5e9ad 100644 --- a/src/nodes.lua +++ b/src/nodes.lua @@ -624,16 +624,20 @@ xdecor.register("painting_1", { node_placement_prediction = "", on_place = function(itemstack, placer, pointed_thing) local num = math.random(4) - local leftover = minetest.item_place_node( + local leftover, place_pos = minetest.item_place_node( ItemStack("xdecor:painting_" .. num), placer, pointed_thing) + if not place_pos then + return itemstack + end + if leftover:get_count() == 0 and not minetest.setting_getbool("creative_mode") then itemstack:take_item() end -- Play 'place' sound manually - minetest.sound_play(default.node_sound_wood_defaults().place, {pos=pointed_thing.above}, true) + minetest.sound_play(default.node_sound_wood_defaults().place, {pos=place_pos}, true) return itemstack end,