mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-12-22 16:09:33 +01:00
Remove get_structure_data_construct
the positions are available from the registered structure
This commit is contained in:
parent
c30e2c33b9
commit
9aaa13408a
3 changed files with 9 additions and 41 deletions
|
@ -87,7 +87,7 @@ minetest.register_craftitem("mcl_end:ender_eye", {
|
|||
end
|
||||
local origin = user:get_pos()
|
||||
origin.y = origin.y + 1.5
|
||||
local strongholds = mcl_structures.get_structure_data("stronghold")
|
||||
local strongholds = mcl_structures.registered_structures["end_shrine"].static_pos
|
||||
local dim = mcl_worlds.pos_to_dimension(origin)
|
||||
local is_creative = minetest.is_creative_enabled(user:get_player_name())
|
||||
|
||||
|
@ -105,7 +105,7 @@ minetest.register_craftitem("mcl_end:ender_eye", {
|
|||
local closest_stronghold
|
||||
local lowest_dist
|
||||
for s=1, #strongholds do
|
||||
local h_pos = table.copy(strongholds[s].pos)
|
||||
local h_pos = table.copy(strongholds[s])
|
||||
local h_origin = table.copy(origin)
|
||||
h_pos.y = 0
|
||||
h_origin.y = 0
|
||||
|
@ -128,14 +128,14 @@ minetest.register_craftitem("mcl_end:ender_eye", {
|
|||
if lowest_dist <= 25 then
|
||||
local velocity = 4
|
||||
-- Stronghold is close: Fly directly to stronghold and take Y into account.
|
||||
dir = vector.normalize(vector.direction(origin, closest_stronghold.pos))
|
||||
dir = vector.normalize(vector.direction(origin, closest_stronghold))
|
||||
obj:set_velocity({x=dir.x*velocity, y=dir.y*velocity, z=dir.z*velocity})
|
||||
else
|
||||
local velocity = 12
|
||||
-- Don't care about Y if stronghold is still far away.
|
||||
-- Fly to direction of X/Z, and always upwards so it can be seen easily.
|
||||
local o = {x=origin.x, y=0, z=origin.z}
|
||||
local s = {x=closest_stronghold.pos.x, y=0, z=closest_stronghold.pos.z}
|
||||
local s = {x=closest_stronghold.x, y=0, z=closest_stronghold.z}
|
||||
dir = vector.normalize(vector.direction(o, s))
|
||||
obj:set_acceleration({x=dir.x*-3, y=4, z=dir.z*-3})
|
||||
obj:set_velocity({x=dir.x*velocity, y=3, z=dir.z*velocity})
|
||||
|
|
|
@ -16,26 +16,17 @@ local stronghold_rings = {
|
|||
}
|
||||
|
||||
local strongholds = {}
|
||||
local stronghold_positions = {}
|
||||
local strongholds_inited = false
|
||||
|
||||
local mg_name = minetest.get_mapgen_setting("mg_name")
|
||||
local superflat = mg_name == "flat" and minetest.get_mapgen_setting("mcl_superflat_classic") == "true"
|
||||
local seed = tonumber(minetest.get_mapgen_setting("seed"))
|
||||
|
||||
-- Determine the stronghold positions and store them into the strongholds table.
|
||||
-- The stronghold positions are based on the world seed.
|
||||
-- The actual position might be offset by a few blocks because it might be shifted
|
||||
-- to make sure the end portal room is completely within the boundaries of a mapchunk.
|
||||
local function init_strongholds()
|
||||
if strongholds_inited then
|
||||
return
|
||||
end
|
||||
local stronghold_positions = {}
|
||||
-- Don't generate strongholds in singlenode
|
||||
if mg_name == "singlenode" then
|
||||
strongholds_inited = true
|
||||
return
|
||||
return {}
|
||||
end
|
||||
local seed = tonumber(minetest.get_mapgen_setting("seed"))
|
||||
local pr = PseudoRandom(seed)
|
||||
for s=1, #stronghold_rings do
|
||||
local ring = stronghold_rings[s]
|
||||
|
@ -54,7 +45,6 @@ local function init_strongholds()
|
|||
end
|
||||
local pos = { x = math.cos(angle) * dist, y = y, z = math.sin(angle) * dist }
|
||||
pos = vector.round(pos)
|
||||
table.insert(strongholds, { pos = pos, generated = false })
|
||||
table.insert(stronghold_positions, pos)
|
||||
|
||||
-- Rotate angle by (360 / amount) degrees.
|
||||
|
@ -62,10 +52,7 @@ local function init_strongholds()
|
|||
angle = math.fmod(angle + ((math.pi*2) / ring.amount), math.pi*2)
|
||||
end
|
||||
end
|
||||
|
||||
mcl_structures.register_structure_data("stronghold", table.copy(strongholds))
|
||||
|
||||
strongholds_inited = true
|
||||
return stronghold_positions
|
||||
end
|
||||
|
||||
-- Stronghold generation for register_on_generated.
|
||||
|
@ -103,10 +90,8 @@ local function generate_strongholds(minp, maxp, blockseed)
|
|||
end
|
||||
end
|
||||
|
||||
init_strongholds()
|
||||
|
||||
mcl_structures.register_structure("end_shrine",{
|
||||
static_pos = stronghold_positions,
|
||||
static_pos = init_strongholds(),
|
||||
filenames = {
|
||||
minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_end_portal_room_simple.mts"
|
||||
},
|
||||
|
|
|
@ -3,7 +3,6 @@ local S = minetest.get_translator(modname)
|
|||
local modpath = minetest.get_modpath(modname)
|
||||
|
||||
mcl_structures = {}
|
||||
local structure_data = {}
|
||||
|
||||
local rotations = {
|
||||
"0",
|
||||
|
@ -85,22 +84,6 @@ local function dir_to_rotation(dir)
|
|||
return "0"
|
||||
end
|
||||
|
||||
--this is only used by end shrines - find a better way eventually ...
|
||||
function mcl_structures.get_structure_data(structure_type)
|
||||
if structure_data[structure_type] then
|
||||
return table.copy(structure_data[structure_type])
|
||||
else
|
||||
return {}
|
||||
end
|
||||
end
|
||||
|
||||
-- Register a structures table for the given type. The table format is the same as for
|
||||
-- mcl_structures.get_structure_data.
|
||||
function mcl_structures.register_structure_data(structure_type, structures)
|
||||
structure_data[structure_type] = structures
|
||||
end
|
||||
|
||||
|
||||
dofile(modpath.."/api.lua")
|
||||
dofile(modpath.."/shipwrecks.lua")
|
||||
dofile(modpath.."/desert_temple.lua")
|
||||
|
|
Loading…
Reference in a new issue