diff options
| author | daoge <3523206925@qq.com> | 2026-03-03 03:04:10 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-03 03:04:10 +0800 |
| commit | b3feddfef372618c8a9d7a0abcaf18cfad866c18 (patch) | |
| tree | 267761c3bb39241ba5c347bfbe2254d06686e287 /Minecraft.World/CaveFeature.cpp | |
| parent | 84c31a2331f7a0ec85b9d438992e244f60e5020f (diff) | |
feat: TU19 (Dec 2014) Features & Content (#155)
* try to resolve merge conflict
* feat: TU19 (Dec 2014) Features & Content (#32)
* December 2014 files
* Working release build
* Fix compilation issues
* Add sound to Windows64Media
* Add DLC content and force Tutorial DLC
* Revert "Add DLC content and force Tutorial DLC"
This reverts commit 97a43994725008e35fceb984d5549df9c8cea470.
* Disable broken light packing
* Disable breakpoint during DLC texture map load
Allows DLC loading but the DLC textures are still broken
* Fix post build not working
* ...
* fix vs2022 build
* fix cmake build
---------
Co-authored-by: Loki <lokirautio@gmail.com>
Diffstat (limited to 'Minecraft.World/CaveFeature.cpp')
| -rw-r--r-- | Minecraft.World/CaveFeature.cpp | 104 |
1 files changed, 52 insertions, 52 deletions
diff --git a/Minecraft.World/CaveFeature.cpp b/Minecraft.World/CaveFeature.cpp index aad92805..698ee3da 100644 --- a/Minecraft.World/CaveFeature.cpp +++ b/Minecraft.World/CaveFeature.cpp @@ -4,35 +4,35 @@ #include "net.minecraft.world.level.tile.h" using namespace std; - bool CaveFeature::place(Level *level, Random *random, int x, int y, int z) - { - float dir = random->nextFloat() * PI; - double rd = 8; +bool CaveFeature::place(Level *level, Random *random, int x, int y, int z) +{ + float dir = random->nextFloat() * PI; + double rd = 8; - double x0 = x + 8 + Mth::sin(dir) * rd; - double x1 = x + 8 - Mth::sin(dir) * rd; - double z0 = z + 8 + Mth::cos(dir) * rd; - double z1 = z + 8 - Mth::cos(dir) * rd; + double x0 = x + 8 + Mth::sin(dir) * rd; + double x1 = x + 8 - Mth::sin(dir) * rd; + double z0 = z + 8 + Mth::cos(dir) * rd; + double z1 = z + 8 - Mth::cos(dir) * rd; - double y0 = y + random->nextInt(8) + 2; - double y1 = y + random->nextInt(8) + 2; + double y0 = y + random->nextInt(8) + 2; + double y1 = y + random->nextInt(8) + 2; - double radius = random->nextDouble() * 4 + 2; - double fuss = random->nextDouble() * 0.6; + double radius = random->nextDouble() * 4 + 2; + double fuss = random->nextDouble() * 0.6; - __int64 seed = random->nextLong(); - random->setSeed(seed); - vector<TilePos *> toRemove; + __int64 seed = random->nextLong(); + random->setSeed(seed); + vector<TilePos *> toRemove; - for (int d = 0; d <= 16; d++) + for (int d = 0; d <= 16; d++) { - double xx = x0 + (x1 - x0) * d / 16; - double yy = y0 + (y1 - y0) * d / 16; - double zz = z0 + (z1 - z0) * d / 16; + double xx = x0 + (x1 - x0) * d / 16; + double yy = y0 + (y1 - y0) * d / 16; + double zz = z0 + (z1 - z0) * d / 16; - double ss = random->nextDouble(); - double r = (Mth::sin(d / 16.0f * PI) * radius + 1) * ss + 1; - double hr = (Mth::sin(d / 16.0f * PI) * radius + 1) * ss + 1; + double ss = random->nextDouble(); + double r = (Mth::sin(d / 16.0f * PI) * radius + 1) * ss + 1; + double hr = (Mth::sin(d / 16.0f * PI) * radius + 1) * ss + 1; // 4J Stu Added to stop cave features generating areas previously place by game rule generation if(app.getLevelGenerationOptions() != NULL) @@ -46,47 +46,47 @@ using namespace std; } } - for (int x2 = (int) (xx - r / 2); x2 <= (int) (xx + r / 2); x2++) - for (int y2 = (int) (yy - hr / 2); y2 <= (int) (yy + hr / 2); y2++) - for (int z2 = (int) (zz - r / 2); z2 <= (int) (zz + r / 2); z2++) + for (int x2 = (int) (xx - r / 2); x2 <= (int) (xx + r / 2); x2++) + for (int y2 = (int) (yy - hr / 2); y2 <= (int) (yy + hr / 2); y2++) + for (int z2 = (int) (zz - r / 2); z2 <= (int) (zz + r / 2); z2++) { - double xd = ((x2 + 0.5) - xx) / (r / 2); - double yd = ((y2 + 0.5) - yy) / (hr / 2); - double zd = ((z2 + 0.5) - zz) / (r / 2); - if (xd * xd + yd * yd + zd * zd < random->nextDouble() * fuss + (1 - fuss)) + double xd = ((x2 + 0.5) - xx) / (r / 2); + double yd = ((y2 + 0.5) - yy) / (hr / 2); + double zd = ((z2 + 0.5) - zz) / (r / 2); + if (xd * xd + yd * yd + zd * zd < random->nextDouble() * fuss + (1 - fuss)) { - if (!level->isEmptyTile(x2, y2, z2)) + if (!level->isEmptyTile(x2, y2, z2)) { - for (int x3 = (x2 - 2); x3 <= (x2 + 1); x3++) - for (int y3 = (y2 - 1); y3 <= (y2 + 1); y3++) - for (int z3 = (z2 - 1); z3 <= (z2 + 1); z3++) + for (int x3 = (x2 - 2); x3 <= (x2 + 1); x3++) + for (int y3 = (y2 - 1); y3 <= (y2 + 1); y3++) + for (int z3 = (z2 - 1); z3 <= (z2 + 1); z3++) { - if (x3 <= x || z3 <= z || x3 >= x + 16 - 1 || z3 >= z + 16 - 1) return false; - if (level->getMaterial(x3, y3, z3)->isLiquid()) return false; - } - toRemove.push_back(new TilePos(x2, y2, z2)); - } - } - } - } - + if (x3 <= x || z3 <= z || x3 >= x + 16 - 1 || z3 >= z + 16 - 1) return false; + if (level->getMaterial(x3, y3, z3)->isLiquid()) return false; + } + toRemove.push_back(new TilePos(x2, y2, z2)); + } + } + } + } + AUTO_VAR(itEnd, toRemove.end()); for (AUTO_VAR(it, toRemove.begin()); it != itEnd; it++) { - TilePos *p = *it; //toRemove[i]; - level->setTileNoUpdate(p->x, p->y, p->z, 0); - } - + TilePos *p = *it; //toRemove[i]; + level->setTileAndData(p->x, p->y, p->z, 0, 0, Tile::UPDATE_CLIENTS); + } + itEnd = toRemove.end(); for (AUTO_VAR(it, toRemove.begin()); it != itEnd; it++) { - TilePos *p = *it; //toRemove[i]; - if (level->getTile(p->x, p->y - 1, p->z) == Tile::dirt_Id && level->getDaytimeRawBrightness(p->x, p->y, p->z) > 8) + TilePos *p = *it; //toRemove[i]; + if (level->getTile(p->x, p->y - 1, p->z) == Tile::dirt_Id && level->getDaytimeRawBrightness(p->x, p->y, p->z) > 8) { - level->setTileNoUpdate(p->x, p->y - 1, p->z, Tile::grass_Id); - } + level->setTileAndData(p->x, p->y - 1, p->z, Tile::grass_Id, 0, Tile::UPDATE_CLIENTS); + } delete p; - } + } - return true; + return true; }
\ No newline at end of file |
