forked from MineClone5/MineClone5
Fix some mushroom placement bugs
This commit is contained in:
parent
e3106e5bfd
commit
59610e9d94
|
@ -13,22 +13,37 @@ local on_place = function(itemstack, placer, pointed_thing)
|
||||||
end
|
end
|
||||||
|
|
||||||
local a = pointed_thing.above
|
local a = pointed_thing.above
|
||||||
|
local u = pointed_thing.under
|
||||||
local node_above = minetest.get_node(a)
|
local node_above = minetest.get_node(a)
|
||||||
local node_below = minetest.get_node({x=a.x, y=a.y-1, z=a.z})
|
local node_under = minetest.get_node(u)
|
||||||
local def = minetest.registered_nodes[node_below.name]
|
local def_above = minetest.registered_nodes[node_above.name]
|
||||||
local def2 = minetest.registered_nodes[node_above.name]
|
local def_under = minetest.registered_nodes[node_under.name]
|
||||||
|
|
||||||
|
local place_pos, soil_node, place_node, soil_def, place_def
|
||||||
|
if def_under.buildable_to then
|
||||||
|
place_pos = u
|
||||||
|
place_node = node_under
|
||||||
|
place_def = def_under
|
||||||
|
elseif def_above.buildable_to then
|
||||||
|
place_pos = a
|
||||||
|
place_node = node_above
|
||||||
|
place_def = def_above
|
||||||
|
else
|
||||||
|
return itemstack
|
||||||
|
end
|
||||||
|
soil_node = minetest.get_node({x=place_pos.x, y=place_pos.y-1, z=place_pos.z})
|
||||||
|
soil_def = minetest.registered_nodes[soil_node.name]
|
||||||
|
|
||||||
-- Placement rules:
|
-- Placement rules:
|
||||||
-- * Always allowed on podzol or mycelimu
|
-- * Always allowed on podzol or mycelimu
|
||||||
-- * Otherwise, must be solid, opaque and have daylight light level <= 12
|
-- * Otherwise, must be solid, opaque and have daylight light level <= 12
|
||||||
local light = minetest.get_node_light(a, 0.5)
|
local light = minetest.get_node_light(place_pos, 0.5)
|
||||||
local light_ok = false
|
local light_ok = false
|
||||||
if light and light <= 12 then
|
if light and light <= 12 then
|
||||||
light_ok = true
|
light_ok = true
|
||||||
end
|
end
|
||||||
if (node_below.name == "mcl_core:podzol" or node_below.name == "mcl_core:mycelium") or
|
if (soil_node.name == "mcl_core:podzol" or soil_node.name == "mcl_core:mycelium") or
|
||||||
(light_ok and (def.groups and def.groups.solid and def.groups.opaque)) and
|
(light_ok and (soil_def.groups and soil_def.groups.solid and soil_def.groups.opaque)) then
|
||||||
def2.buildable_to then
|
|
||||||
local idef = itemstack:get_definition()
|
local idef = itemstack:get_definition()
|
||||||
local success = minetest.item_place_node(itemstack, placer, pointed_thing)
|
local success = minetest.item_place_node(itemstack, placer, pointed_thing)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue