diff --git a/mods/MAPGEN/mcl_strongholds/API.md b/mods/MAPGEN/mcl_strongholds/API.md new file mode 100644 index 0000000000..f5d2edd014 --- /dev/null +++ b/mods/MAPGEN/mcl_strongholds/API.md @@ -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 = , generated = }, -- first stronghold + { pos = , generated = }, -- second stronghold + -- and so on … +} + +* pos: Position of stronghold, centered at the end portal room +* generated: `true` if this stronghold has already been generated diff --git a/mods/MAPGEN/mcl_strongholds/init.lua b/mods/MAPGEN/mcl_strongholds/init.lua index a9822ab8ad..a721dd5da4 100644 --- a/mods/MAPGEN/mcl_strongholds/init.lua +++ b/mods/MAPGEN/mcl_strongholds/init.lua @@ -52,7 +52,7 @@ local init_strongholds = function() end local pos = { x = math.cos(angle) * dist, y = y, z = math.sin(angle) * dist } pos = vector.round(pos) - table.insert(strongholds, { pos = pos }) + table.insert(strongholds, { pos = pos, generated = false }) -- Rotate angle by (360 / amount) degrees. -- 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 +-- Minimal API +mcl_strongholds = {} +mcl_strongholds.get_stronghold_positions = function() + return table.copy(strongholds) +end + init_strongholds()