From 4f2baf8506ab03f9cea0f5212913d2310fb2946c Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sat, 9 Mar 2019 08:52:47 +0100 Subject: [PATCH] Play place sound if falling node hit the bottom --- mods/ENTITIES/mcl_falling_nodes/init.lua | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/mods/ENTITIES/mcl_falling_nodes/init.lua b/mods/ENTITIES/mcl_falling_nodes/init.lua index dfbf198e7..753f7c8c8 100644 --- a/mods/ENTITIES/mcl_falling_nodes/init.lua +++ b/mods/ENTITIES/mcl_falling_nodes/init.lua @@ -200,15 +200,19 @@ minetest.register_entity(":__builtin:falling_node", { for _, callback in pairs(minetest.registered_on_dignodes) do callback(np, n2) end - if minetest.registered_nodes[self.node.name] then + local def = minetest.registered_nodes[self.node.name] + if def then minetest.add_node(np, self.node) - if minetest.registered_nodes[self.node.name]._mcl_after_falling then - minetest.registered_nodes[self.node.name]._mcl_after_falling(np, get_falling_depth(self)) + if def._mcl_after_falling then + def._mcl_after_falling(np, get_falling_depth(self)) end if self.meta then local meta = minetest.get_meta(np) meta:from_table(self.meta) end + if def.sounds and def.sounds.place and def.sounds.place.name then + minetest.sound_play(def.sounds.place, {pos = np}) + end end else -- Drop the *falling node* as an item if the destination node is NOT buildable to @@ -238,8 +242,14 @@ minetest.register_entity(":__builtin:falling_node", { local npos3 = table.copy(npos) npos3.y = npos3.y - 1 minetest.add_node(npos3, self.node) - if minetest.registered_nodes[self.node.name]._mcl_after_falling then - minetest.registered_nodes[self.node.name]._mcl_after_falling(npos3, get_falling_depth(self)) + local def = minetest.registered_nodes[self.node.name] + if def then + if def._mcl_after_falling then + def._mcl_after_falling(npos3, get_falling_depth(self)) + end + if def.sounds and def.sounds.place and def.sounds.place.name then + minetest.sound_play(def.sounds.place, {pos = np}) + end end deal_falling_damage(self, dtime) self.object:remove()