-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8add60b
commit ec940e3
Showing
18 changed files
with
273 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
#pragma once | ||
|
||
enum eMinecraftColour {}; | ||
class MobCategory; | ||
|
||
class Biome { | ||
public: | ||
void setNameAndDescription(int, int); | ||
void setPreviewColor(eMinecraftColour); | ||
void setWaterSkyColor(eMinecraftColour, eMinecraftColour); | ||
|
||
void getMobs(MobCategory*); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
174 changes: 174 additions & 0 deletions
174
src/Minecraft.World/level/levelgen/NetherFlatLevelSource.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,174 @@ | ||
#include "Minecraft.World/level/levelgen/NetherFlatLevelSource.h" | ||
#include "Minecraft.Client/CMinecraftApp.h" | ||
#include "Minecraft.World/ArrayWithLength.h" | ||
#include "Minecraft.World/Random.h" | ||
#include "Minecraft.World/level/Level.h" | ||
#include "Minecraft.World/level/biome/Biome.h" | ||
#include "Minecraft.World/level/block/Blocks.h" | ||
#include "Minecraft.World/level/chunk/LevelChunk.h" | ||
#include "Minecraft.World/level/levelgen/ChunkPrimer.h" | ||
#include "Minecraft.World/level/levelgen/feature/HellFireFeature.h" | ||
#include "Minecraft.World/level/levelgen/feature/LightGemFeature.h" | ||
#include "Minecraft.World/level/storage/LevelData.h" | ||
#include "windows.h" | ||
|
||
// NON_MATCHING: Regswap | ||
NetherFlatLevelSource::NetherFlatLevelSource(Level* level, bool isGenerateMapFeatures, long long seed) { | ||
int xzSize = level->getLevelData()->getXZSize(); | ||
float hellScale = level->getLevelData()->getHellScale(); | ||
mSize = ceilf(xzSize / hellScale); | ||
mLevel = level; | ||
mIsGenerateMapFeatures = isGenerateMapFeatures; | ||
mSeed = new Random(seed); | ||
mRandom = new Random(seed); | ||
} | ||
|
||
NetherFlatLevelSource::~NetherFlatLevelSource() { | ||
delete mSeed; | ||
delete mRandom; | ||
} | ||
|
||
void NetherFlatLevelSource::prepareHeights(int x, int z, ChunkPrimer* primer) { | ||
for (int i = 0; i < 16; i++) { | ||
for (int j = 0; j < 16; j++) { | ||
for (int k = 0; k < 16; k++) { | ||
const BlockState* block = Blocks::AIR->defaultBlockState(); | ||
if (k <= 6) | ||
block = Blocks::NETHERRACK->defaultBlockState(); | ||
primer->setState((i << 11) | (j << 7) | k, block); | ||
} | ||
} | ||
} | ||
} | ||
|
||
// NON_MATCHING | ||
void NetherFlatLevelSource::buildSurfaces(int x, int z, ChunkPrimer* primer) { | ||
const BlockState* bedrock = Blocks::BEDROCK->defaultBlockState(); | ||
|
||
for (int chunkX = 0; chunkX < 16; ++chunkX) { | ||
for (int chunkZ = 0; chunkZ < 16; ++chunkZ) { | ||
int adjustedSize = (mSize >= 0) ? mSize : mSize + 1; | ||
int halfSize = adjustedSize >> 1; | ||
|
||
for (int y = 127; y > 0; --y) { | ||
if (-halfSize < x || (chunkX > mRandom->nextInt(4) && halfSize >= x)) { | ||
primer->setState((y << 11) | (chunkX << 7) | chunkZ, bedrock); | ||
} | ||
|
||
if (-halfSize >= z) { | ||
if (y <= mRandom->nextInt(4) || halfSize > z) { | ||
primer->setState((y << 11) | (chunkX << 7) | chunkZ, bedrock); | ||
} | ||
} | ||
|
||
if (halfSize - 1 <= x) { | ||
if (mRandom->nextInt(4) + chunkX > 14 || halfSize < x) { | ||
primer->setState((y << 11) | (chunkX << 7) | chunkZ, bedrock); | ||
} | ||
} | ||
|
||
if ((adjustedSize / 2 - 1 <= z && (mRandom->nextInt(4) + y > 14 || adjustedSize / 2 < z)) || (y >= (127 - mRandom->nextInt(5)) || y <= mRandom->nextInt(5))) { | ||
primer->setState((y << 11) | (chunkX << 7) | chunkZ, bedrock); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
LevelChunk* NetherFlatLevelSource::createChunk(int x, int z) { | ||
mSeed->setSeed(0x4F9939F508LL * x + 0x1EF1565BD5LL * z); | ||
|
||
void* ids = XPhysicalAlloc(0x8000, 0xFFFFFFFFFFFFFFFFLL, 0x1000uLL, 4u); | ||
XMemSet128(ids, 0, 0x8000u); | ||
arrayWithLength<uchar> blockIds((uchar*)ids, 0x8000u); | ||
|
||
void* data = XPhysicalAlloc(0x4000, 0xFFFFFFFFFFFFFFFFLL, 0x1000uLL, 4u); | ||
XMemSet128(data, 0, 0x4000u); | ||
arrayWithLength<uchar> blockData((uchar*)data, 0x4000); | ||
|
||
ChunkPrimer primer = ChunkPrimer(false, blockIds, blockData); | ||
prepareHeights(x, z, &primer); | ||
buildSurfaces(x, z, &primer); | ||
|
||
LevelChunk* chunk = new LevelChunk(mLevel, &primer, x, z); | ||
|
||
XPhysicalFree(ids); | ||
XPhysicalFree(data); | ||
|
||
return chunk; | ||
} | ||
|
||
// NON_MATCHING | ||
void NetherFlatLevelSource::postProcess(int x, int z) { | ||
inPostProcessStep = true; | ||
|
||
Random* r = mRandom; | ||
Level* l = mLevel; | ||
|
||
int testX = 16 * x; | ||
int testZ = 16 * z; | ||
|
||
long long seed = l->getSeed(); | ||
r->setSeed(seed); | ||
|
||
long seed1 = mRandom->nextLong() | 1; | ||
long seed2 = mRandom->nextLong() | 1; | ||
|
||
long long v16 = x * seed1 + z * seed2 ^ seed; | ||
|
||
mRandom->setSeed(v16); | ||
|
||
int v11 = mRandom->nextInt(10); | ||
int v12 = mRandom->nextInt(v11 + 1) + 1; | ||
|
||
if (v12 > 0) { | ||
for (int i = 0; i < v12; ++i) { | ||
int posX = mRandom->nextInt(16) + (testX | 8); | ||
int posY = mRandom->nextInt(120) + 4; | ||
int posZ = mRandom->nextInt(16) + (testZ | 8); | ||
|
||
HellFireFeature feature; | ||
feature.place(mLevel, *mRandom, BlockPos(posX, posY, posZ)); | ||
} | ||
} | ||
|
||
int v31 = mRandom->nextInt(mRandom->nextInt(10) + 1); | ||
|
||
for (int i = 0; i < v31; i++) { | ||
int posX = mRandom->nextInt(16) + (testX | 8); | ||
int posY = mRandom->nextInt(120) + 4; | ||
int posZ = mRandom->nextInt(16) + (testZ | 8); | ||
|
||
LightGemFeature feature; | ||
feature.place(mLevel, *mRandom, BlockPos(posX, posY, posZ)); | ||
} | ||
|
||
inPostProcessStep = false; | ||
CConsoleMinecraftApp::instance->processSchematics(mLevel->getChunk(x, z)); | ||
} | ||
|
||
void NetherFlatLevelSource::lightChunk(LevelChunk* chunk) { | ||
return chunk->recalcHeightmap(); | ||
} | ||
|
||
bool NetherFlatLevelSource::postProcessLoadedChunk(LevelChunk* chunk, int x, int z) { | ||
return false; | ||
} | ||
|
||
void NetherFlatLevelSource::getMobsAt(MobCategory* category, BlockPos const& pos) { | ||
Biome* biome = mLevel->getBiome(pos); | ||
if (biome) | ||
biome->getMobs(category); | ||
} | ||
|
||
void* NetherFlatLevelSource::findNearestMapFeature(Level* level, std::wstring const& name, BlockPos const& pos, bool flag) { | ||
return nullptr; | ||
} | ||
|
||
void NetherFlatLevelSource::recreateLogicStructuresForChunk(LevelChunk* chunk, int x, int z) { | ||
return; | ||
} | ||
|
||
bool NetherFlatLevelSource::isPosInFeature(Level* level, std::wstring const& name, BlockPos const& pos) { | ||
return false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.