From c03f9abd184a74495ded0bc742bdae8e97e4ac4d Mon Sep 17 00:00:00 2001 From: William Goodspeed Date: Fri, 16 Aug 2024 22:52:58 +0000 Subject: [PATCH] Fix the placement check of ladder The old code takes the first return val of `minetest.item_place_node' which is `itemstack'. Therefore, the variable `success' in the old code is always true. The new code takes the second val which will be nil if an invalid node placement occured. This check is necessary since the ladder may be placed in the front of pointed block while there is a node with hole (slabs, fences etc.) at the same place resulting an invalid placement and sound played when it shouldn't be played. --- mods/ITEMS/mcl_core/nodes_climb.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mods/ITEMS/mcl_core/nodes_climb.lua b/mods/ITEMS/mcl_core/nodes_climb.lua index e7c66ed1a..88c5980b4 100644 --- a/mods/ITEMS/mcl_core/nodes_climb.lua +++ b/mods/ITEMS/mcl_core/nodes_climb.lua @@ -104,9 +104,10 @@ minetest.register_node("mcl_core:ladder", { return itemstack end local idef = itemstack:get_definition() - local success = minetest.item_place_node(itemstack, placer, pointed_thing) + local itemstack, pos = minetest.item_place_node(itemstack, placer, pointed_thing) - if success then + -- A non-nil pos indicates the node was placed in a valid position. + if pos then if idef.sounds and idef.sounds.place then minetest.sound_play(idef.sounds.place, { pos = above, gain = 1 }, true) end