Turn grass to dirt below slabs and stairs

This commit is contained in:
Wuzzy 2019-09-04 14:18:57 +02:00
parent 22a9f7667b
commit 7810a7ed82
3 changed files with 12 additions and 4 deletions

View File

@ -246,8 +246,9 @@ minetest.register_abm( -- dirt and grass footsteps becomes dirt with grass if un
action = function(pos, node)
local above = {x=pos.x, y=pos.y+1, z=pos.z}
local name = minetest.get_node(above).name
local partialblock = minetest.get_item_group(name, "slab") ~= 0 or minetest.get_item_group(name, "stair") ~= 0
local nodedef = minetest.registered_nodes[name]
if nodedef and (nodedef.sunlight_propagates or nodedef.paramtype == "light") and nodedef.liquidtype == "none" and (minetest.get_node_light(above) or 0) >= 8 then
if nodedef and (not partialblock) and (nodedef.sunlight_propagates or nodedef.paramtype == "light") and nodedef.liquidtype == "none" and (minetest.get_node_light(above) or 0) >= 8 then
minetest.set_node(pos, {name = "default:dirt_with_grass"})
end
end
@ -262,8 +263,9 @@ minetest.register_abm( -- dirt with grass becomes dirt if covered
action = function(pos, node)
local above = {x=pos.x, y=pos.y+1, z=pos.z}
local name = minetest.get_node(above).name
local partialblock = minetest.get_item_group(name, "slab") ~= 0 or minetest.get_item_group(name, "stair") ~= 0
local nodedef = minetest.registered_nodes[name]
if name ~= "ignore" and nodedef and not ((nodedef.sunlight_propagates or nodedef.paramtype == "light") and nodedef.liquidtype == "none") then
if name ~= "ignore" and nodedef and (partialblock) or (not ((nodedef.sunlight_propagates or nodedef.paramtype == "light") and nodedef.liquidtype == "none")) then
minetest.set_node(pos, {name = "default:dirt"})
end
end

View File

@ -325,7 +325,7 @@ minetest.register_node(
fixed = {-0.5, -0.5, -0.5, 0.5, -2/16, 0.5}
},
tiles = {"default_dirt.png"},
groups = {crumbly = 3, fall_damage_add_percent = -10},
groups = {crumbly = 3, slab = 2, fall_damage_add_percent = -10},
is_ground_content = false,
sounds = default.node_sound_dirt_defaults(),
})

View File

@ -24,8 +24,11 @@ function partialblocks.register_material(name, desc_slab, desc_stair, node, grou
tiles = nodedef.tiles
end
if not groups then
groups = nodedef.groups
groups = table.copy(nodedef.groups)
else
groups = {}
end
groups.slab = 1
minetest.register_node(
"partialblocks:slab_" .. name,
@ -85,6 +88,9 @@ function partialblocks.register_material(name, desc_slab, desc_stair, node, grou
tiles = nodedef.tiles
end
groups.slab = nil
groups.stair = 1
minetest.register_node(
"partialblocks:stair_" .. name,
{