Play place sound if falling node hit the bottom

This commit is contained in:
Wuzzy 2019-03-09 08:52:47 +01:00
parent 2f88b42210
commit 4f2baf8506

View file

@ -200,15 +200,19 @@ minetest.register_entity(":__builtin:falling_node", {
for _, callback in pairs(minetest.registered_on_dignodes) do for _, callback in pairs(minetest.registered_on_dignodes) do
callback(np, n2) callback(np, n2)
end 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) minetest.add_node(np, self.node)
if minetest.registered_nodes[self.node.name]._mcl_after_falling then if def._mcl_after_falling then
minetest.registered_nodes[self.node.name]._mcl_after_falling(np, get_falling_depth(self)) def._mcl_after_falling(np, get_falling_depth(self))
end end
if self.meta then if self.meta then
local meta = minetest.get_meta(np) local meta = minetest.get_meta(np)
meta:from_table(self.meta) meta:from_table(self.meta)
end end
if def.sounds and def.sounds.place and def.sounds.place.name then
minetest.sound_play(def.sounds.place, {pos = np})
end
end end
else else
-- Drop the *falling node* as an item if the destination node is NOT buildable to -- 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) local npos3 = table.copy(npos)
npos3.y = npos3.y - 1 npos3.y = npos3.y - 1
minetest.add_node(npos3, self.node) minetest.add_node(npos3, self.node)
if minetest.registered_nodes[self.node.name]._mcl_after_falling then local def = minetest.registered_nodes[self.node.name]
minetest.registered_nodes[self.node.name]._mcl_after_falling(npos3, get_falling_depth(self)) 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 end
deal_falling_damage(self, dtime) deal_falling_damage(self, dtime)
self.object:remove() self.object:remove()