1
0
Fork 0

Add End Spikes

testing
cora 2022-09-11 00:45:20 +02:00
parent f72626bf40
commit 2e1e04d499
1 changed files with 43 additions and 0 deletions

View File

@ -28,3 +28,46 @@ mcl_structures.register_structure("end_exit_portal_open",{
modpath.."/schematics/mcl_structures_end_exit_portal.mts" modpath.."/schematics/mcl_structures_end_exit_portal.mts"
}, },
}) })
local function get_tower(p,h,tbl)
for i = 1,h do
table.insert(tbl,vector.offset(p,0,i,0))
end
end
local function make_endspike(pos,width,height)
local nn = minetest.find_nodes_in_area(vector.offset(pos,-width/2,0,-width/2),vector.offset(pos,width/2,0,width/2),{"air","group:solid"})
table.sort(nn,function(a, b)
return vector.distance(pos, a) < vector.distance(pos, b)
end)
local nodes = {}
for i = 1,math.ceil(#nn*0.55) do
get_tower(nn[i],height,nodes)
end
minetest.bulk_set_node(nodes,{ name="mcl_core:obsidian"} )
return vector.offset(pos,0,height,0)
end
local function get_points_on_circle(pos,r,n)
local rt = {}
for i=1, n do
table.insert(rt,vector.offset(pos,r * math.cos(((i-1)/n) * (2*math.pi)),0, r* math.sin(((i-1)/n) * (2*math.pi)) ))
end
return rt
end
mcl_structures.register_structure("end_spike",{
static_pos =get_points_on_circle(vector.offset(mcl_vars.mg_end_exit_portal_pos,0,-20,0),43,10),
place_func = function(pos,def,pr)
local d = pr:next(6,12)
local h = d * pr:next(4,6)
local p1 = vector.add(pos,-d/2,0,-d/2)
local p2 = vector.add(pos,d/2,h+5,d/2)
minetest.emerge_area(p1, p2, function(blockpos, action, calls_remaining, param)
if calls_remaining ~= 0 then return end
local s = make_endspike(pos,d,h)
minetest.set_node(vector.offset(s,0,1,0),{name="mcl_core:bedrock"})
minetest.add_entity(vector.offset(s,0,2,0),"mcl_end:crystal")
end)
end,
})