mirror of
https://github.com/HybridDog/nether-pack.git
synced 2025-01-12 19:00:24 +01:00
Do not use old vector_extras functions
This commit is contained in:
parent
acdf694356
commit
6019bbce66
@ -692,9 +692,8 @@ function nether.grow_netherstructure(pos, generated)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local set = vector.set_data_to_pos
|
local poshash = minetest.hash_node_position
|
||||||
local get = vector.get_data_from_pos
|
local pos_from_hash = minetest.get_position_from_hash
|
||||||
local remove = vector.remove_data_from_pos
|
|
||||||
|
|
||||||
local function soft_node(id)
|
local function soft_node(id)
|
||||||
return id == c.air or id == c.ignore
|
return id == c.air or id == c.ignore
|
||||||
@ -775,15 +774,17 @@ function nether.grow_tree(pos, generated)
|
|||||||
for j = 1,r do
|
for j = 1,r do
|
||||||
local x = p.x+j*dir[1]
|
local x = p.x+j*dir[1]
|
||||||
local z = p.z+j*dir[2]
|
local z = p.z+j*dir[2]
|
||||||
set(trunks, z,p.y,x, dir[3])
|
trunks[poshash{x=x, y=p.y, z=z}] = dir[3]
|
||||||
end
|
end
|
||||||
r = r+1
|
r = r+1
|
||||||
p.x = p.x+r*dir[1]
|
p.x = p.x+r*dir[1]
|
||||||
p.z = p.z+r*dir[2]
|
p.z = p.z+r*dir[2]
|
||||||
set(trunk_corners, p.z,p.y,p.x, dir[4] or dir[3])
|
trunk_corners[poshash(p)] = dir[4] or dir[3]
|
||||||
local h = math.random(h_arm_min, h_arm_max)
|
local h = math.random(h_arm_min, h_arm_max)
|
||||||
for i = 1,h do
|
for i = 1,h do
|
||||||
set(trunks, p.z,p.y+i,p.x, true)
|
p.y = p.y + i
|
||||||
|
trunks[poshash(p)] = true
|
||||||
|
p.y = p.y - i
|
||||||
end
|
end
|
||||||
p.y = p.y+h
|
p.y = p.y+h
|
||||||
--n = #todo+1 -- caused small trees
|
--n = #todo+1 -- caused small trees
|
||||||
@ -799,10 +800,16 @@ function nether.grow_tree(pos, generated)
|
|||||||
local fruits = {}
|
local fruits = {}
|
||||||
local trunk_ps = {}
|
local trunk_ps = {}
|
||||||
local count = 0
|
local count = 0
|
||||||
local ps, trmin, trmax, trunk_count = vector.get_data_pos_table(trunks)
|
|
||||||
|
|
||||||
update_minmax(min, max, trmin)
|
local ps = {}
|
||||||
update_minmax(min, max, trmax)
|
local trunk_count = 0
|
||||||
|
for i,par2 in pairs(trunks) do
|
||||||
|
local pos = pos_from_hash(i)
|
||||||
|
update_minmax(min, max, pos)
|
||||||
|
local z,y,x = pos.z, pos.y, pos.x
|
||||||
|
trunk_count = trunk_count+1
|
||||||
|
ps[trunk_count] = {z,y,x, par2}
|
||||||
|
end
|
||||||
|
|
||||||
for _,d in pairs(ps) do
|
for _,d in pairs(ps) do
|
||||||
if d[4] == true then
|
if d[4] == true then
|
||||||
@ -823,13 +830,14 @@ function nether.grow_tree(pos, generated)
|
|||||||
local x = x+px
|
local x = x+px
|
||||||
local y = y+py
|
local y = y+py
|
||||||
local z = z+pz
|
local z = z+pz
|
||||||
if not get(trunks, z,y,x) then
|
local vi = poshash{x=x, y=y, z=z}
|
||||||
|
if not trunks[vi] then
|
||||||
if fruit_chance
|
if fruit_chance
|
||||||
and math.random(1, fruit_rarity) == 1
|
and math.random(1, fruit_rarity) == 1
|
||||||
and math.random(1, fruit_chance) == 1 then
|
and math.random(1, fruit_chance) == 1 then
|
||||||
set(fruits, z,y,x, true)
|
fruits[vi] = true
|
||||||
else
|
else
|
||||||
set(leaves, z,y,x, true)
|
leaves[vi] = true
|
||||||
end
|
end
|
||||||
update_minmax(min, max, {x=x, z=z})
|
update_minmax(min, max, {x=x, z=z})
|
||||||
end
|
end
|
||||||
@ -853,8 +861,8 @@ function nether.grow_tree(pos, generated)
|
|||||||
local nodes = manip:get_data()
|
local nodes = manip:get_data()
|
||||||
local param2s = manip:get_param2_data()
|
local param2s = manip:get_param2_data()
|
||||||
|
|
||||||
for _,p in pairs(vector.get_data_pos_table(leaves)) do
|
for i in pairs(leaves) do
|
||||||
p = area:index(p[3], p[2], p[1])
|
local p = area:indexp(pos_from_hash(i))
|
||||||
if soft_node(nodes[p]) then
|
if soft_node(nodes[p]) then
|
||||||
nodes[p] = c.nether_leaves
|
nodes[p] = c.nether_leaves
|
||||||
param2s[p] = math.random(0,179)
|
param2s[p] = math.random(0,179)
|
||||||
@ -862,14 +870,15 @@ function nether.grow_tree(pos, generated)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for _,p in pairs(vector.get_data_pos_table(fruits)) do
|
for i in pairs(fruits) do
|
||||||
p = area:index(p[3], p[2], p[1])
|
local p = area:indexp(pos_from_hash(i))
|
||||||
if soft_node(nodes[p]) then
|
if soft_node(nodes[p]) then
|
||||||
nodes[p] = c.nether_apple
|
nodes[p] = c.nether_apple
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for _,p in pairs(trunk_ps) do
|
for i = 1,#trunk_ps do
|
||||||
|
local p = trunk_ps[i]
|
||||||
local par = p[4]
|
local par = p[4]
|
||||||
p = area:index(p[3], p[2], p[1])
|
p = area:index(p[3], p[2], p[1])
|
||||||
if par then
|
if par then
|
||||||
@ -878,10 +887,10 @@ function nether.grow_tree(pos, generated)
|
|||||||
nodes[p] = c.nether_tree
|
nodes[p] = c.nether_tree
|
||||||
end
|
end
|
||||||
|
|
||||||
for _,p in pairs(vector.get_data_pos_table(trunk_corners)) do
|
for i,par2 in pairs(trunk_corners) do
|
||||||
local vi = area:index(p[3], p[2], p[1])
|
local vi = area:indexp(pos_from_hash(i))
|
||||||
nodes[vi] = c.nether_tree_corner
|
nodes[vi] = c.nether_tree_corner
|
||||||
param2s[vi] = p[4]
|
param2s[vi] = par2
|
||||||
end
|
end
|
||||||
|
|
||||||
manip:set_data(nodes)
|
manip:set_data(nodes)
|
||||||
|
Loading…
Reference in New Issue
Block a user