mirror of
https://github.com/luanti-org/minetest_game.git
synced 2025-05-21 23:03:16 -04:00
correct node definition referencing
This commit is contained in:
parent
97d73f7358
commit
b4777f0394
1 changed files with 15 additions and 9 deletions
|
@ -102,17 +102,23 @@ minetest.register_node("bones:bones", {
|
||||||
})
|
})
|
||||||
|
|
||||||
local function may_replace(pos, player)
|
local function may_replace(pos, player)
|
||||||
local nodename = minetest.get_node(pos).name
|
local node_name = minetest.get_node(pos).name
|
||||||
|
local node_definition = minetest.registered_nodes[node_name]
|
||||||
|
|
||||||
-- allow replacing air and liquids
|
-- if the node is unknown, we let the protection mod decide
|
||||||
if nodename == "air" or minetest.registered_nodes[nodename].liquidtype ~= "none" then
|
-- unknown decoration would often be removed
|
||||||
return true
|
-- while unknown building materials in use would usually be left
|
||||||
end
|
if node_definition then
|
||||||
|
-- allow replacing air and liquids
|
||||||
|
if node_name == "air" or node_definition.liquidtype ~= "none" then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
-- don't replace filled chests and other nodes that don't allow it
|
-- don't replace filled chests and other nodes that don't allow it
|
||||||
if minetest.registered_nodes[nodename].can_dig and
|
local can_dig_func = node_definition.can_dig
|
||||||
not minetest.registered_nodes[nodename].can_dig(pos, player) then
|
if can_dig_func and not can_dig_func(pos, player) then
|
||||||
return false
|
return false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- only replace nodes that are not protected
|
-- only replace nodes that are not protected
|
||||||
|
|
Loading…
Add table
Reference in a new issue