1
0
Fork 0

Add function to query stronghold positions

This commit is contained in:
Wuzzy 2017-12-10 18:48:34 +01:00
parent 2d8ad7ebf0
commit 55778ab375
2 changed files with 24 additions and 1 deletions

View File

@ -0,0 +1,17 @@
# Strongholds API
The API provides one function:
## `mcl_strongholds.get_stronghold_positions()`
Returns a table of the positions of all strongholds, centered at the end portal room.
This includes strongholds which have not been generated yet.
This table is a copy, changes to the table will have no effect on the stronghold generation.
Format of the returned table:
{
{ pos = <position>, generated = <true/false> }, -- first stronghold
{ pos = <position>, generated = <true/false> }, -- second stronghold
-- and so on …
}
* pos: Position of stronghold, centered at the end portal room
* generated: `true` if this stronghold has already been generated

View File

@ -52,7 +52,7 @@ local init_strongholds = function()
end end
local pos = { x = math.cos(angle) * dist, y = y, z = math.sin(angle) * dist } local pos = { x = math.cos(angle) * dist, y = y, z = math.sin(angle) * dist }
pos = vector.round(pos) pos = vector.round(pos)
table.insert(strongholds, { pos = pos }) table.insert(strongholds, { pos = pos, generated = false })
-- Rotate angle by (360 / amount) degrees. -- Rotate angle by (360 / amount) degrees.
-- This will cause the angles to be evenly distributed in the stronghold ring -- This will cause the angles to be evenly distributed in the stronghold ring
@ -90,6 +90,12 @@ local generate_strongholds = function(minp, maxp)
end end
end end
-- Minimal API
mcl_strongholds = {}
mcl_strongholds.get_stronghold_positions = function()
return table.copy(strongholds)
end
init_strongholds() init_strongholds()