From 163bd4a0214412c975c56315069d6a61e724100b Mon Sep 17 00:00:00 2001 From: HybridDog Date: Sun, 10 Jan 2016 12:28:15 +0100 Subject: [PATCH] update nether tree loop, @Ombridride l hope it works for you, and fix missing degrotate paramtype2 of leaves --- nether/init.lua | 87 +++++++++++++++++++++++++----------------------- nether/items.lua | 1 + 2 files changed, 46 insertions(+), 42 deletions(-) diff --git a/nether/init.lua b/nether/init.lua index bf93463..fcfc91a 100644 --- a/nether/init.lua +++ b/nether/init.lua @@ -741,50 +741,53 @@ function nether.grow_tree(pos, generated) local trunks = {} local trunk_corners = {} local h_stem = math.random(h_stem_min, h_stem_max) - local stems = {{x=pos.x, y=pos.y+h_stem, z=pos.z}} - local fi - while not fi do - for n,p in pairs(stems) do - local used_dirs = {} - for _,dir in pairs(dirs) do - if math.random(1,2) == 1 then - table.insert(used_dirs, dir) - end + local todo,n = {{x=pos.x, y=pos.y+h_stem, z=pos.z}},1 + while n do + local p = todo[n] + todo[n] = nil + n = next(todo) + + local used_dirs,u = {},1 + for _,dir in pairs(dirs) do + if math.random(1,2) == 1 then + used_dirs[u] = dir + u = u+1 end - if not used_dirs[1] then - local dir1 = math.random(4) - local dir2 = math.random(3) - if dir1 <= dir2 then - dir2 = dir2+1 - end - used_dirs[1] = dirs[dir1] - used_dirs[2] = dirs[dir2] - end - for _,dir in pairs(used_dirs) do - local p = vector.new(p) - local r = math.random(r_arm_min, r_arm_max) - for j = 1,r do - local x = p.x+j*dir[1] - local z = p.z+j*dir[2] - trunks[x.." "..p.y.." "..z] = dir[3] - end - r = r+1 - p.x = p.x+r*dir[1] - p.z = p.z+r*dir[2] - trunk_corners[p.x.." "..p.y.." "..p.z] = dir[4] or dir[3] - local h = math.random(h_arm_min, h_arm_max) - for i = 1,h do - trunks[p.x.." "..p.y+i.." "..p.z] = true - end - p.y = p.y+h - table.insert(stems, p) - end - if p.y > pos.y+h_trunk_max then - fi = true - break - end - stems[n] = nil end + if not used_dirs[1] then + local dir1 = math.random(4) + local dir2 = math.random(3) + if dir1 <= dir2 then + dir2 = dir2+1 + end + used_dirs[1] = dirs[dir1] + used_dirs[2] = dirs[dir2] + end + for _,dir in pairs(used_dirs) do + local p = vector.new(p) + local r = math.random(r_arm_min, r_arm_max) + for j = 1,r do + local x = p.x+j*dir[1] + local z = p.z+j*dir[2] + trunks[x.." "..p.y.." "..z] = dir[3] + end + r = r+1 + p.x = p.x+r*dir[1] + p.z = p.z+r*dir[2] + trunk_corners[p.x.." "..p.y.." "..p.z] = dir[4] or dir[3] + local h = math.random(h_arm_min, h_arm_max) + for i = 1,h do + trunks[p.x.." "..p.y+i.." "..p.z] = true + end + p.y = p.y+h + --n = #todo+1 -- causes small trees + todo[#todo+1] = p + end + if p.y > pos.y+h_trunk_max then + break + end + + n = n or next(todo) end local leaves = {} local fruits = {} diff --git a/nether/items.lua b/nether/items.lua index a963564..6b1d0b5 100644 --- a/nether/items.lua +++ b/nether/items.lua @@ -527,6 +527,7 @@ minetest.register_node("nether:leaves", { inventory_image = "nether_leaves.png", wield_image = "nether_leaves.png", paramtype = "light", + paramtype2 = "degrotate", is_ground_content = false, groups = {snappy=3, leafdecay=3, leaves=1}, drop = {