Don't remove node above door if it's not a doors:hidden node (#3045)

This commit is contained in:
fluxionary 2023-08-11 04:12:39 -07:00 committed by GitHub
parent 83c10f59e1
commit 08e057bf1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -19,6 +19,10 @@ local function replace_old_owner_information(pos)
end end
end end
local function is_doors_upper_node(pos)
return minetest.get_node(pos).name == "doors:hidden"
end
-- returns an object to a door object or nil -- returns an object to a door object or nil
function doors.get(pos) function doors.get(pos)
local node_name = minetest.get_node(pos).name local node_name = minetest.get_node(pos).name
@ -388,8 +392,11 @@ function doors.register(name, def)
end end
end end
def.after_dig_node = function(pos, node, meta, digger) def.after_dig_node = function(pos, node, meta, digger)
minetest.remove_node({x = pos.x, y = pos.y + 1, z = pos.z}) local above = pos:offset(0, 1, 0)
minetest.check_for_falling({x = pos.x, y = pos.y + 1, z = pos.z}) if is_doors_upper_node(above) then
minetest.remove_node(above)
end
minetest.check_for_falling(above)
end end
def.on_rotate = function(pos, node, user, mode, new_param2) def.on_rotate = function(pos, node, user, mode, new_param2)
return false return false
@ -427,14 +434,20 @@ function doors.register(name, def)
else else
def.on_blast = function(pos, intensity) def.on_blast = function(pos, intensity)
minetest.remove_node(pos) minetest.remove_node(pos)
local above = pos:offset(0, 1, 0)
-- hidden node doesn't get blasted away. -- hidden node doesn't get blasted away.
minetest.remove_node({x = pos.x, y = pos.y + 1, z = pos.z}) if is_doors_upper_node(above) then
minetest.remove_node(above)
end
return {name} return {name}
end end
end end
def.on_destruct = function(pos) def.on_destruct = function(pos)
minetest.remove_node({x = pos.x, y = pos.y + 1, z = pos.z}) local above = pos:offset(0, 1, 0)
if is_doors_upper_node(above) then
minetest.remove_node(above)
end
end end
def.drawtype = "mesh" def.drawtype = "mesh"