diff --git a/mods/ebiome/textures/ebiome_oak_leaves.png b/mods/ebiome/textures/ebiome_oak_leaves.png new file mode 100644 index 0000000..ef106bc Binary files /dev/null and b/mods/ebiome/textures/ebiome_oak_leaves.png differ diff --git a/mods/ebiome/textures/ebiome_oak_leaves_simple.png b/mods/ebiome/textures/ebiome_oak_leaves_simple.png new file mode 100644 index 0000000..a1a18f5 Binary files /dev/null and b/mods/ebiome/textures/ebiome_oak_leaves_simple.png differ diff --git a/mods/ebiome/textures/ebiome_oak_trunk_growing_top.png b/mods/ebiome/textures/ebiome_oak_trunk_growing_top.png new file mode 100644 index 0000000..a5e9ae9 Binary files /dev/null and b/mods/ebiome/textures/ebiome_oak_trunk_growing_top.png differ diff --git a/mods/ebiome/textures/ebiome_oak_trunk_normal_top.png b/mods/ebiome/textures/ebiome_oak_trunk_normal_top.png new file mode 100644 index 0000000..da03bb0 Binary files /dev/null and b/mods/ebiome/textures/ebiome_oak_trunk_normal_top.png differ diff --git a/mods/ebiome/textures/ebiome_oak_trunk_normal_xjunction.png.kra b/mods/ebiome/textures/ebiome_oak_trunk_normal_xjunction.png.kra new file mode 100644 index 0000000..ede2379 Binary files /dev/null and b/mods/ebiome/textures/ebiome_oak_trunk_normal_xjunction.png.kra differ diff --git a/mods/ebiometrees/sapling.lua b/mods/ebiometrees/sapling.lua index cbaf2ce..7249fcc 100644 --- a/mods/ebiometrees/sapling.lua +++ b/mods/ebiometrees/sapling.lua @@ -1,19 +1,26 @@ ebiometrees = {} -function ebiometrees.get_sapling_grower(sprout_name) - local function rooter(pos) - minetest.set_node(pos, {name=sprout_name}) - end - return rooter +function ebiometrees.is_leaves_can_grow_here(pos) + return false end -function ebiometrees.get_sprout_grower(trunk_name, apex_name) - local function grower(pos) - minetest.set_node(pos, {name=trunk_name}) - local upper = {x=pos.x, y=pos.y+1, z=pos.z} - minetest.set_node(upper, {name=apex_name}) +function ebiometrees.grow_closure(nextstage) + local function growtree(pos) + minetest.set_node(pos, {name=nextstage}) end - return grower + return growtree +end + +function ebiometrees.leaves_grower(leaves_name) + local function grow_leaves(pos) + local free_node = minetest.find_node_near(pos, 1, "air") + if free_node + then + minetest.set_node(free_node, {name=leaves_name}) + end + return true + end + return grow_leaves end function ebiometrees.root_sapling(pos) @@ -21,8 +28,3 @@ function ebiometrees.root_sapling(pos) return false end -function ebiometrees.set_rooting_sapling(itemstack, placer, pointed_thing) - itemstack = minetest.item_place(itemstack, placer, pointed_thing) - minetest.get_node_timer(pointed_thing.above):start(3) - return itemstack -end diff --git a/mods/ebiometrees/tree.lua b/mods/ebiometrees/tree.lua index ce55c77..e6515c9 100644 --- a/mods/ebiometrees/tree.lua +++ b/mods/ebiometrees/tree.lua @@ -21,7 +21,9 @@ function ebiometrees.register_tree(modname, basename, data) drawtype = "plantlike", tiles = { modname.."_"..basename.."_sapling.png"}, paramtype = "light", - on_timer = ebiometrees.get_sapling_grower(sprout_name), + on_timer = ebiometrees.grow_closure( + modname..":"..basename.."_sprout" + ), sunlight_propagates = true, walkable = false, groups = sapling_groups, @@ -35,13 +37,28 @@ function ebiometrees.register_tree(modname, basename, data) paramtype = "light", sunlight_propagates = true, walkable = false, - on_timer = ebiometrees.get_sprout_grower( - modname..":"..basename.."_trunk_growing_straight", - modname..":"..basename.."_trunk_growing_terminal"), + on_timer = ebiometrees.grow_closure( + modname..":"..basename.."_trunk_growing_terminal" + ), groups = sprout_groups, on_construct = growth_timer }) - -- registers tree and corresponding nodes + -- register tree leaves + local leaves_groups = table.copy(data.groups) + leaves_groups.leaves = 1 + leaves_groups.leafdecay = 3 + leaves_groups.snappy = 3 + minetest.register_node(modname..":"..basename.."_leaves", { + description = S(data.description.." leaves"), + drawtype = "allfaces_optional", + waving = 1, + tiles = { modname.."_"..basename.."_leaves.png" }, + special_tiles = { modname.."_"..basename.."_leaves_simple.png" }, + paramtype = "light", + is_ground_content = false, + groups = leaves_groups + }) + -- registers corresponding trunk nodes local trunk_groups = table.copy(data.groups) trunk_groups.choppy = 2 -- TODO: customizations local trunk_types = {"growing", "normal"} @@ -54,7 +71,7 @@ function ebiometrees.register_tree(modname, basename, data) local texture_basename = modname.."_"..basename.."_trunk_"..trunk_type.."_" local subtype_tiles = { terminal = { - texture_basename.."terminal.png", + texture_basename.."top.png", texture_basename.."slice.png", texture_basename.."terminal.png" }, @@ -109,19 +126,23 @@ function ebiometrees.register_tree(modname, basename, data) } for _, trunk_subtype in ipairs(trunk_subtypes) do - minetest.register_node( - modname..":"..basename.."_trunk_"..trunk_type.."_"..trunk_subtype, { + local nodespec = { description = S(data.description.." "..trunk_type.." "..trunk_subtype), groups = trunk_groups, tiles = subtype_tiles[trunk_subtype], paramtype2 = "facedir", is_ground_content = false, on_place = minetest.rotate_node, - on_timer = function(pos) - return true - end, on_construct = growth_timer - }) + } + if trunk_type == "growing" + then + nodespec.on_timer = ebiometrees.leaves_grower( + modname..":"..basename.."_leaves") + end + minetest.register_node( + modname..":"..basename.."_trunk_"..trunk_type.."_"..trunk_subtype, + nodespec) end end end