From 55778ab375e8e1abce0410f23fae0dec438b619b Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sun, 10 Dec 2017 18:48:34 +0100 Subject: [PATCH] Add function to query stronghold positions --- mods/MAPGEN/mcl_strongholds/API.md | 17 +++++++++++++++++ mods/MAPGEN/mcl_strongholds/init.lua | 8 +++++++- 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 mods/MAPGEN/mcl_strongholds/API.md diff --git a/mods/MAPGEN/mcl_strongholds/API.md b/mods/MAPGEN/mcl_strongholds/API.md new file mode 100644 index 000000000..f5d2edd01 --- /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 a9822ab8a..a721dd5da 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()