1
0
mirror of https://github.com/mt-mods/plantlife_modpack.git synced 2024-12-26 02:20:20 +01:00

When a vine is destroyed, ensure the remaining part of the vine ends with a vine end node.

This commit is contained in:
Jordan Leppert 2021-12-04 15:05:06 +00:00
parent 6df36da4e1
commit ba98359dd0

View File

@ -42,6 +42,17 @@ local function dig_down(pos, node, digger)
end end
end end
local function ensure_vine_end(pos, oldnode)
local np = {x = pos.x, y = pos.y + 1, z = pos.z}
local nn = minetest.get_node(np)
vine_name_end = oldnode.name:gsub("_middle", "_end")
if minetest.get_item_group(nn.name, "vines") > 0 then
minetest.swap_node(np, { name = vine_name_end, param2 = oldnode.param2 })
end
end
vines.register_vine = function( name, defs, biome ) vines.register_vine = function( name, defs, biome )
@ -130,6 +141,10 @@ vines.register_vine = function( name, defs, biome )
after_dig_node = function(pos, node, metadata, digger) after_dig_node = function(pos, node, metadata, digger)
dig_down(pos, node, digger) dig_down(pos, node, digger)
end, end,
after_destruct = function(pos, oldnode)
ensure_vine_end(pos, oldnode)
end,
}) })
minetest.register_node( vine_name_middle, { minetest.register_node( vine_name_middle, {
@ -152,6 +167,10 @@ vines.register_vine = function( name, defs, biome )
after_dig_node = function(pos, node, metadata, digger) after_dig_node = function(pos, node, metadata, digger)
dig_down(pos, node, digger) dig_down(pos, node, digger)
end, end,
after_destruct = function(pos, oldnode)
ensure_vine_end(pos, oldnode)
end,
}) })
biome_lib.register_on_generate(biome, spawn_plants) biome_lib.register_on_generate(biome, spawn_plants)