diff --git a/mapgens/superflat/LICENSE b/mapgens/superflat/LICENSE new file mode 100644 index 000000000..02eb4ad7c --- /dev/null +++ b/mapgens/superflat/LICENSE @@ -0,0 +1,23 @@ +Imported from 1042 with modifications + +MIT Licesnse: + +Copyright (c) 2024 Xeno333 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/mapgens/superflat/init.lua b/mapgens/superflat/init.lua new file mode 100644 index 000000000..d599cbbc5 --- /dev/null +++ b/mapgens/superflat/init.lua @@ -0,0 +1 @@ +core.register_mapgen_script(core.get_modpath("superflat") .. "/mapgen.lua") \ No newline at end of file diff --git a/mapgens/superflat/mapgen.conf b/mapgens/superflat/mapgen.conf new file mode 100644 index 000000000..9248a887a --- /dev/null +++ b/mapgens/superflat/mapgen.conf @@ -0,0 +1,4 @@ +name = superflat +title = Superflat +description = Example mapgen with superflat world. +author = TX_Miner/Xeno333 diff --git a/mapgens/superflat/mapgen.lua b/mapgens/superflat/mapgen.lua new file mode 100644 index 000000000..5d5136579 --- /dev/null +++ b/mapgens/superflat/mapgen.lua @@ -0,0 +1,26 @@ +local stone = core.get_content_id("mapgen_stone") + +core.register_on_generated(function(vm, minp, maxp, seed) + local emin, emax = vm:get_emerged_area() + local area = VoxelArea(emin, emax) + local data = vm:get_data() + + local ly = 0 + for y = minp.y, maxp.y do + ly = ly + 1 + local lz = 0 + for z = minp.z, maxp.z do + lz = lz + 1 + local vi = area:index(minp.x, y, z) + local lx = 0 + for x = minp.x, maxp.x do + if y == -1 then + data[vi] = stone + end + vi = vi + 1 + end + end + end + + vm:set_data(data) +end) \ No newline at end of file diff --git a/src/client/mapblock_mesh.cpp b/src/client/mapblock_mesh.cpp index a84747188..9903a38f0 100644 --- a/src/client/mapblock_mesh.cpp +++ b/src/client/mapblock_mesh.cpp @@ -626,7 +626,7 @@ MapBlockMesh::MapBlockMesh(Client *client, MeshMakeData *data): if (data->m_vmanip.getNodeNoEx(p).getContent() != CONTENT_IGNORE) { MinimapMapblock *block = new MinimapMapblock; m_minimap_mapblocks[mesh_grid.getOffsetIndex(ofs)] = block; - block->getMinimapNodes(&data->m_vmanip, p); + block->getMinimapNodes(data, p); } } } diff --git a/src/client/minimap.cpp b/src/client/minimap.cpp index 0d44f9d00..66fabcb56 100644 --- a/src/client/minimap.cpp +++ b/src/client/minimap.cpp @@ -713,9 +713,9 @@ void Minimap::updateActiveMarkers() //// MinimapMapblock //// -void MinimapMapblock::getMinimapNodes(VoxelManipulator *vmanip, const v3s16 &pos) +void MinimapMapblock::getMinimapNodes(MeshMakeData *meshdata, const v3s16 &pos) { - + VoxelManipulator *vmanip = &meshdata->m_vmanip; for (s16 x = 0; x < MAP_BLOCKSIZE; x++) for (s16 z = 0; z < MAP_BLOCKSIZE; z++) { s16 air_count = 0; @@ -725,11 +725,12 @@ void MinimapMapblock::getMinimapNodes(VoxelManipulator *vmanip, const v3s16 &pos for (s16 y = MAP_BLOCKSIZE -1; y >= 0; y--) { v3s16 p(x, y, z); MapNode n = vmanip->getNodeNoEx(pos + p); - if (!surface_found && n.getContent() != CONTENT_AIR) { + const ContentFeatures &f = meshdata->m_nodedef->get(n); + if (!surface_found && f.drawtype != NDT_AIRLIKE) { mmpixel->height = y; mmpixel->n = n; surface_found = true; - } else if (n.getContent() == CONTENT_AIR) { + } else if (f.drawtype == NDT_AIRLIKE) { air_count++; } } diff --git a/src/client/minimap.h b/src/client/minimap.h index 36c900134..5d5939c8c 100644 --- a/src/client/minimap.h +++ b/src/client/minimap.h @@ -9,6 +9,7 @@ #include "rect.h" #include "SMeshBuffer.h" +#include "mapblock_mesh.h" #include "../hud.h" #include "mapnode.h" #include "util/thread.h" @@ -66,7 +67,7 @@ struct MinimapPixel { }; struct MinimapMapblock { - void getMinimapNodes(VoxelManipulator *vmanip, const v3s16 &pos); + void getMinimapNodes(MeshMakeData *data, const v3s16 &pos); MinimapPixel data[MAP_BLOCKSIZE * MAP_BLOCKSIZE]; };