minecraft like lanterns placement limitations

This commit is contained in:
AFCMS 2022-02-09 22:11:50 +01:00
parent 9b375aa9e8
commit 8817d51d64
1 changed files with 56 additions and 30 deletions

View File

@ -9,6 +9,33 @@ TODO:
- remove the hack arround walmounted nodes - remove the hack arround walmounted nodes
]] ]]
local allowed_non_solid_nodes_floor = {
"mcl_core:ice",
"mcl_nether:soul_sand",
"mcl_mobspawners:spawner",
"mcl_core:barrier",
"mcl_end:chorus_flower",
"mcl_end:chorus_flower_dead",
"mcl_end:end_rod",
"mcl_end:dragon_egg",
"mcl_portals:end_portal_frame_eye",
}
local allowed_non_solid_groups_floor = {"anvil", "wall", "glass", "fence", "fence_gate", "pane"}
local allowed_non_solid_nodes_ceiling = {
"mcl_core:ice",
"mcl_nether:soul_sand",
"mcl_mobspawners:spawner",
"mcl_core:barrier",
"mcl_end:chorus_flower",
"mcl_end:chorus_flower_dead",
"mcl_end:end_rod",
"mcl_core:grass_path",
}
local allowed_non_solid_groups_ceiling = {"anvil", "wall", "glass", "fence", "fence_gate", "soil", "pane", "end_portal_frame"}
local function check_placement(node, wdir) local function check_placement(node, wdir)
local nn = node.name local nn = node.name
local def = minetest.registered_nodes[nn] local def = minetest.registered_nodes[nn]
@ -16,43 +43,42 @@ local function check_placement(node, wdir)
if not def then if not def then
return false return false
else else
--wdir:
--0: ceiling
--1: floor
if wdir == 0 then if wdir == 0 then
if nn ~= "mcl_core:ice" and if def.groups.solid or def.groups.opaque then
nn ~= "mcl_nether:soul_sand" and return true
nn ~= "mcl_mobspawners:spawner" and
nn ~= "mcl_core:barrier" and
nn ~= "mcl_end:chorus_flower" and
nn ~= "mcl_end:chorus_flower_dead" and
(not def.groups.anvil) and
(not def.groups.wall) and
(not def.groups.glass) and
((not def.groups.solid) or (not def.groups.opaque)) then
return false
else else
for _,i in ipairs(allowed_non_solid_nodes_ceiling) do
if nn == i then
return true return true
end end
else --assuming wdir == 1 end
if nn ~= "mcl_core:ice" and for _,j in ipairs(allowed_non_solid_groups_ceiling) do
nn ~= "mcl_nether:soul_sand" and if def.groups[j] then
nn ~= "mcl_mobspawners:spawner" and
nn ~= "mcl_core:barrier" and
nn ~= "mcl_end:chorus_flower" and
nn ~= "mcl_end:chorus_flower_dead" and
nn ~= "mcl_end:end_rod" and
nn ~= "mcl_core:grass_path" and
(not def.groups.anvil) and
(not def.groups.wall) and
(not def.groups.glass) and
(not def.groups.fence) and
(not def.groups.fence_gate) and
(not def.groups.soil) and
(not def.groups.pane) and
((not def.groups.solid) or (not def.groups.opaque)) then
return false
else
return true return true
end end
end end
return false
end
else --assuming wdir == 1
if def.groups.solid or def.groups.opaque then
return true
else
for _,i in ipairs(allowed_non_solid_nodes_floor) do
if nn == i then
return true
end
end
for _,j in ipairs(allowed_non_solid_groups_floor) do
if def.groups[j] then
return true
end
end
return false
end
end
end end
end end