aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/HellFlatLevelSource.cpp
diff options
context:
space:
mode:
authorLoki Rautio <lokirautio@gmail.com>2026-03-04 03:56:03 -0600
committerLoki Rautio <lokirautio@gmail.com>2026-03-04 03:56:03 -0600
commit42aec6dac53dffa6afe072560a7e1d4986112538 (patch)
tree0836426857391df1b6a83f6368a183f83ec9b104 /Minecraft.World/HellFlatLevelSource.cpp
parentc9d58eeac7c72f0b3038e084667b4d89a6249fce (diff)
parentef9b6fd500dfabd9463267b0dd9e29577eea8a2b (diff)
Merge branch 'main' into pr/win64-world-saves
# Conflicts: # Minecraft.Client/MinecraftServer.cpp # README.md
Diffstat (limited to 'Minecraft.World/HellFlatLevelSource.cpp')
-rw-r--r--Minecraft.World/HellFlatLevelSource.cpp104
1 files changed, 54 insertions, 50 deletions
diff --git a/Minecraft.World/HellFlatLevelSource.cpp b/Minecraft.World/HellFlatLevelSource.cpp
index 0b1c4359..4957f617 100644
--- a/Minecraft.World/HellFlatLevelSource.cpp
+++ b/Minecraft.World/HellFlatLevelSource.cpp
@@ -10,15 +10,15 @@ HellFlatLevelSource::HellFlatLevelSource(Level *level, __int64 seed)
int hellScale = level->getLevelData()->getHellScale();
m_XZSize = ceil((float)xzSize / hellScale);
- this->level = level;
+ this->level = level;
- random = new Random(seed);
+ random = new Random(seed);
pprandom = new Random(seed);
}
HellFlatLevelSource::~HellFlatLevelSource()
{
- delete random;
+ delete random;
delete pprandom;
}
@@ -35,7 +35,7 @@ void HellFlatLevelSource::prepareHeights(int xOffs, int zOffs, byteArray blocks)
int block = 0;
if ( (yc <= 6) || ( yc >= 121 ) )
{
- block = Tile::hellRock_Id;
+ block = Tile::netherRack_Id;
}
blocks[xc << 11 | zc << 7 | yc] = (byte) block;
@@ -46,13 +46,13 @@ void HellFlatLevelSource::prepareHeights(int xOffs, int zOffs, byteArray blocks)
void HellFlatLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks)
{
- for (int x = 0; x < 16; x++)
+ for (int x = 0; x < 16; x++)
{
- for (int z = 0; z < 16; z++)
+ for (int z = 0; z < 16; z++)
{
- for (int y = Level::genDepthMinusOne; y >= 0; y--)
+ for (int y = Level::genDepthMinusOne; y >= 0; y--)
{
- int offs = (z * 16 + x) * Level::genDepth + y;
+ int offs = (z * 16 + x) * Level::genDepth + y;
// 4J Build walls around the level
bool blockSet = false;
@@ -93,15 +93,15 @@ void HellFlatLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks)
if (y >= Level::genDepthMinusOne - random->nextInt(5))
{
- blocks[offs] = (byte) Tile::unbreakable_Id;
- }
+ blocks[offs] = (byte) Tile::unbreakable_Id;
+ }
else if (y <= 0 + random->nextInt(5))
{
- blocks[offs] = (byte) Tile::unbreakable_Id;
-}
- }
- }
- }
+ blocks[offs] = (byte) Tile::unbreakable_Id;
+ }
+ }
+ }
+ }
}
LevelChunk *HellFlatLevelSource::create(int x, int z)
@@ -111,28 +111,28 @@ LevelChunk *HellFlatLevelSource::create(int x, int z)
LevelChunk *HellFlatLevelSource::getChunk(int xOffs, int zOffs)
{
- random->setSeed(xOffs * 341873128712l + zOffs * 132897987541l);
+ random->setSeed(xOffs * 341873128712l + zOffs * 132897987541l);
// 4J - now allocating this with a physical alloc & bypassing general memory management so that it will get cleanly freed
int chunksSize = Level::genDepth * 16 * 16;
byte *tileData = (byte *)XPhysicalAlloc(chunksSize, MAXULONG_PTR, 4096, PAGE_READWRITE);
XMemSet128(tileData,0,chunksSize);
byteArray blocks = byteArray(tileData,chunksSize);
-// byteArray blocks = byteArray(16 * level->depth * 16);
+ // byteArray blocks = byteArray(16 * level->depth * 16);
- prepareHeights(xOffs, zOffs, blocks);
- buildSurfaces(xOffs, zOffs, blocks);
+ prepareHeights(xOffs, zOffs, blocks);
+ buildSurfaces(xOffs, zOffs, blocks);
-// caveFeature->apply(this, level, xOffs, zOffs, blocks);
- // townFeature.apply(this, level, xOffs, zOffs, blocks);
- // addCaves(xOffs, zOffs, blocks);
- // addTowns(xOffs, zOffs, blocks);
+ // caveFeature->apply(this, level, xOffs, zOffs, blocks);
+ // townFeature.apply(this, level, xOffs, zOffs, blocks);
+ // addCaves(xOffs, zOffs, blocks);
+ // addTowns(xOffs, zOffs, blocks);
// 4J - this now creates compressed block data from the blocks array passed in, so needs to be after data is finalised.
// Also now need to free the passed in blocks as the LevelChunk doesn't use the passed in allocation anymore.
- LevelChunk *levelChunk = new LevelChunk(level, blocks, xOffs, zOffs);
+ LevelChunk *levelChunk = new LevelChunk(level, blocks, xOffs, zOffs);
XPhysicalFree(tileData);
- return levelChunk;
+ return levelChunk;
}
// 4J - removed & moved into its own method from getChunk, so we can call recalcHeightmap after the chunk is added into the cache. Without
@@ -151,9 +151,9 @@ bool HellFlatLevelSource::hasChunk(int x, int y)
void HellFlatLevelSource::postProcess(ChunkSource *parent, int xt, int zt)
{
- HeavyTile::instaFall = true;
- int xo = xt * 16;
- int zo = zt * 16;
+ HeavyTile::instaFall = true;
+ int xo = xt * 16;
+ int zo = zt * 16;
// 4J - added. The original java didn't do any setting of the random seed here. We'll be running our postProcess in parallel with getChunk etc. so
// we need to use a separate random - have used the same initialisation code as used in RandomLevelSource::postProcess to make sure this random value
@@ -163,26 +163,26 @@ void HellFlatLevelSource::postProcess(ChunkSource *parent, int xt, int zt)
__int64 zScale = pprandom->nextLong() / 2 * 2 + 1;
pprandom->setSeed(((xt * xScale) + (zt * zScale)) ^ level->getSeed());
- int count = pprandom->nextInt(pprandom->nextInt(10) + 1) + 1;
+ int count = pprandom->nextInt(pprandom->nextInt(10) + 1) + 1;
- for (int i = 0; i < count; i++)
+ for (int i = 0; i < count; i++)
{
- int x = xo + pprandom->nextInt(16) + 8;
- int y = pprandom->nextInt(Level::genDepth - 8) + 4;
- int z = zo + pprandom->nextInt(16) + 8;
- HellFireFeature().place(level, pprandom, x, y, z);
- }
-
- count = pprandom->nextInt(pprandom->nextInt(10) + 1);
- for (int i = 0; i < count; i++)
+ int x = xo + pprandom->nextInt(16) + 8;
+ int y = pprandom->nextInt(Level::genDepth - 8) + 4;
+ int z = zo + pprandom->nextInt(16) + 8;
+ HellFireFeature().place(level, pprandom, x, y, z);
+ }
+
+ count = pprandom->nextInt(pprandom->nextInt(10) + 1);
+ for (int i = 0; i < count; i++)
{
- int x = xo + pprandom->nextInt(16) + 8;
- int y = pprandom->nextInt(Level::genDepth - 8) + 4;
- int z = zo + pprandom->nextInt(16) + 8;
- LightGemFeature().place(level, pprandom, x, y, z);
- }
+ int x = xo + pprandom->nextInt(16) + 8;
+ int y = pprandom->nextInt(Level::genDepth - 8) + 4;
+ int z = zo + pprandom->nextInt(16) + 8;
+ LightGemFeature().place(level, pprandom, x, y, z);
+ }
- HeavyTile::instaFall = false;
+ HeavyTile::instaFall = false;
app.processSchematics(parent->getChunk(xt,zt));
@@ -210,15 +210,19 @@ wstring HellFlatLevelSource::gatherStats()
vector<Biome::MobSpawnerData *> *HellFlatLevelSource::getMobsAt(MobCategory *mobCategory, int x, int y, int z)
{
- Biome *biome = level->getBiome(x, z);
- if (biome == NULL)
- {
- return NULL;
- }
- return biome->getMobs(mobCategory);
+ Biome *biome = level->getBiome(x, z);
+ if (biome == NULL)
+ {
+ return NULL;
+ }
+ return biome->getMobs(mobCategory);
}
TilePos *HellFlatLevelSource::findNearestMapFeature(Level *level, const wstring& featureName, int x, int y, int z)
{
return NULL;
}
+
+void HellFlatLevelSource::recreateLogicStructuresForChunk(int chunkX, int chunkZ)
+{
+} \ No newline at end of file