diff --git a/.luacheckrc b/.luacheckrc index d49673e44..03ba296bb 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -197,12 +197,12 @@ globals = { "mcl_armor_trims", "mcl_villages", "AreaStore", + "vector", } read_globals = { "DIR_DELIM", "dump", "dump2", - "vector", "VoxelManip", "VoxelArea", "PseudoRandom", "PcgRandom", "PerlinNoise", "PerlinNoiseMap", "ItemStack", diff --git a/mods/CORE/mcl_util/init.lua b/mods/CORE/mcl_util/init.lua index 890c96abb..11c5a7c83 100644 --- a/mods/CORE/mcl_util/init.lua +++ b/mods/CORE/mcl_util/init.lua @@ -1423,3 +1423,11 @@ if not minetest.objects_inside_radius then --polyfill for pre minetest 5.9 return valid_object_iterator(core.get_objects_in_area(min_pos, max_pos)) end end + +if not vector.in_area then + function vector.in_area(pos, min, max) + return (pos.x >= min.x) and (pos.x <= max.x) and + (pos.y >= min.y) and (pos.y <= max.y) and + (pos.z >= min.z) and (pos.z <= max.z) + end +end diff --git a/mods/MAPGEN/mcl_mapgen_core/init.lua b/mods/MAPGEN/mcl_mapgen_core/init.lua index 4a825e227..4bea03bb0 100644 --- a/mods/MAPGEN/mcl_mapgen_core/init.lua +++ b/mods/MAPGEN/mcl_mapgen_core/init.lua @@ -286,21 +286,9 @@ if mg_name ~= "singlenode" or end_fixes_in_singlenode then end -- This should be moved to mcl_structures eventually if the dependencies can be sorted out. -local function between(x, y, z) -- x is between y and z (inclusive) - return y <= x and x <= z -end - local function in_cube(tpos, wpos1, wpos2) - local xmax = math.max(wpos1.x, wpos2.x) - local xmin = math.min(wpos1.x, wpos2.x) - - local ymax = math.max(wpos1.y, wpos2.y) - local ymin = math.min(wpos1.y, wpos2.y) - - local zmax = math.max(wpos1.z, wpos2.z) - local zmin = math.min(wpos1.z, wpos2.z) - - return between(tpos.x, xmin, xmax) and between(tpos.y, ymin, ymax) and between(tpos.z, zmin, zmax) + local minp, maxp = vector.sort(wpos1, wpos2) + return vector.in_area(tpos, minp, maxp) end mcl_mapgen_core.register_generator("structures",nil, function(minp, maxp, blockseed)