1
0
mirror of https://github.com/HybridDog/nether-pack.git synced 2024-12-26 02:30:24 +01:00

update nether tree loop, @Ombridride l hope it works for you, and fix missing degrotate paramtype2 of leaves

This commit is contained in:
HybridDog 2016-01-10 12:28:15 +01:00
parent 9cee9d0ec6
commit 163bd4a021
2 changed files with 46 additions and 42 deletions

View File

@ -741,50 +741,53 @@ function nether.grow_tree(pos, generated)
local trunks = {} local trunks = {}
local trunk_corners = {} local trunk_corners = {}
local h_stem = math.random(h_stem_min, h_stem_max) 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 todo,n = {{x=pos.x, y=pos.y+h_stem, z=pos.z}},1
local fi while n do
while not fi do local p = todo[n]
for n,p in pairs(stems) do todo[n] = nil
local used_dirs = {} n = next(todo)
for _,dir in pairs(dirs) do
if math.random(1,2) == 1 then local used_dirs,u = {},1
table.insert(used_dirs, dir) for _,dir in pairs(dirs) do
end if math.random(1,2) == 1 then
used_dirs[u] = dir
u = u+1
end 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 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 end
local leaves = {} local leaves = {}
local fruits = {} local fruits = {}

View File

@ -527,6 +527,7 @@ minetest.register_node("nether:leaves", {
inventory_image = "nether_leaves.png", inventory_image = "nether_leaves.png",
wield_image = "nether_leaves.png", wield_image = "nether_leaves.png",
paramtype = "light", paramtype = "light",
paramtype2 = "degrotate",
is_ground_content = false, is_ground_content = false,
groups = {snappy=3, leafdecay=3, leaves=1}, groups = {snappy=3, leafdecay=3, leaves=1},
drop = { drop = {