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/LevelData.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/LevelData.cpp')
| -rw-r--r-- | Minecraft.World/LevelData.cpp | 424 |
1 files changed, 284 insertions, 140 deletions
diff --git a/Minecraft.World/LevelData.cpp b/Minecraft.World/LevelData.cpp index 026dca70..91b72fe8 100644 --- a/Minecraft.World/LevelData.cpp +++ b/Minecraft.World/LevelData.cpp @@ -12,7 +12,7 @@ LevelData::LevelData() LevelData::LevelData(CompoundTag *tag) { - seed = tag->getLong(L"RandomSeed"); + seed = tag->getLong(L"RandomSeed"); m_pGenerator = LevelType::lvl_normal; if (tag->contains(L"generatorName")) { @@ -31,31 +31,41 @@ LevelData::LevelData(CompoundTag *tag) } m_pGenerator = m_pGenerator->getReplacementForVersion(generatorVersion); } + + if (tag->contains(L"generatorOptions")) generatorOptions = tag->getString(L"generatorOptions"); } gameType = GameType::byId(tag->getInt(L"GameType")); - if (tag->contains(L"MapFeatures")) + if (tag->contains(L"MapFeatures")) { - generateMapFeatures = tag->getBoolean(L"MapFeatures"); - } + generateMapFeatures = tag->getBoolean(L"MapFeatures"); + } else { generateMapFeatures = true; - } + } spawnBonusChest = tag->getBoolean(L"spawnBonusChest"); - xSpawn = tag->getInt(L"SpawnX"); - ySpawn = tag->getInt(L"SpawnY"); - zSpawn = tag->getInt(L"SpawnZ"); - time = tag->getLong(L"Time"); - lastPlayed = tag->getLong(L"LastPlayed"); - sizeOnDisk = tag->getLong(L"SizeOnDisk"); - levelName = tag->getString(L"LevelName"); - version = tag->getInt(L"version"); - rainTime = tag->getInt(L"rainTime"); - raining = tag->getBoolean(L"raining"); - thunderTime = tag->getInt(L"thunderTime"); - thundering = tag->getBoolean(L"thundering"); + xSpawn = tag->getInt(L"SpawnX"); + ySpawn = tag->getInt(L"SpawnY"); + zSpawn = tag->getInt(L"SpawnZ"); + gameTime = tag->getLong(L"Time"); + if (tag->contains(L"DayTime")) + { + dayTime = tag->getLong(L"DayTime"); + } + else + { + dayTime = gameTime; + } + lastPlayed = tag->getLong(L"LastPlayed"); + sizeOnDisk = tag->getLong(L"SizeOnDisk"); + levelName = tag->getString(L"LevelName"); + version = tag->getInt(L"version"); + rainTime = tag->getInt(L"rainTime"); + raining = tag->getBoolean(L"raining"); + thunderTime = tag->getInt(L"thunderTime"); + thundering = tag->getBoolean(L"thundering"); hardcore = tag->getBoolean(L"hardcore"); if (tag->contains(L"initialized")) @@ -76,6 +86,12 @@ LevelData::LevelData(CompoundTag *tag) allowCommands = gameType == GameType::CREATIVE; } + // 4J: Game rules are now stored with app game host options + /*if (tag->contains(L"GameRules")) + { + gameRules.loadFromTag(tag->getCompound(L"GameRules")); + }*/ + newSeaLevel = tag->getBoolean(L"newSeaLevel"); // 4J added - only use new sea level for newly created maps. This read defaults to false. (sea level changes in 1.8.2) hasBeenInCreative = tag->getBoolean(L"hasBeenInCreative"); // 4J added so we can not award achievements to levels modified in creative @@ -111,7 +127,33 @@ LevelData::LevelData(CompoundTag *tag) // 4J Added m_xzSize = tag->getInt(L"XZSize"); m_hellScale = tag->getInt(L"HellScale"); - + +#ifdef _LARGE_WORLDS + m_classicEdgeMoat = tag->getInt(L"ClassicMoat"); + m_smallEdgeMoat = tag->getInt(L"SmallMoat"); + m_mediumEdgeMoat = tag->getInt(L"MediumMoat"); + + int newWorldSize = app.GetGameNewWorldSize(); + int newHellScale = app.GetGameNewHellScale(); + m_hellScaleOld = m_hellScale; + m_xzSizeOld = m_xzSize; + if(newWorldSize > m_xzSize) + { + bool bUseMoat = app.GetGameNewWorldSizeUseMoat(); + switch (m_xzSize) + { + case LEVEL_WIDTH_CLASSIC: m_classicEdgeMoat = bUseMoat; break; + case LEVEL_WIDTH_SMALL: m_smallEdgeMoat = bUseMoat; break; + case LEVEL_WIDTH_MEDIUM: m_mediumEdgeMoat = bUseMoat; break; + default: assert(0); break; + } + assert(newWorldSize > m_xzSize); + m_xzSize = newWorldSize; + m_hellScale = newHellScale; + } +#endif + + m_xzSize = min(m_xzSize,LEVEL_MAX_WIDTH); m_xzSize = max(m_xzSize,LEVEL_MIN_WIDTH); @@ -125,15 +167,29 @@ LevelData::LevelData(CompoundTag *tag) hellXZSize = m_xzSize / m_hellScale; } +#ifdef _LARGE_WORLDS + // set the host option, in case it wasn't setup already + EGameHostOptionWorldSize hostOptionworldSize = e_worldSize_Unknown; + switch(m_xzSize) + { + case LEVEL_WIDTH_CLASSIC: hostOptionworldSize = e_worldSize_Classic; break; + case LEVEL_WIDTH_SMALL: hostOptionworldSize = e_worldSize_Small; break; + case LEVEL_WIDTH_MEDIUM: hostOptionworldSize = e_worldSize_Medium; break; + case LEVEL_WIDTH_LARGE: hostOptionworldSize = e_worldSize_Large; break; + default: assert(0); break; + } + app.SetGameHostOption(eGameHostOption_WorldSize, hostOptionworldSize ); +#endif + /* 4J - we don't store this anymore - if (tag->contains(L"Player")) + if (tag->contains(L"Player")) { - loadedPlayerTag = tag->getCompound(L"Player"); - dimension = loadedPlayerTag->getInt(L"Dimension"); - } + loadedPlayerTag = tag->getCompound(L"Player"); + dimension = loadedPlayerTag->getInt(L"Dimension"); + } else { - this->loadedPlayerTag = NULL; + this->loadedPlayerTag = NULL; } */ dimension = 0; @@ -141,45 +197,47 @@ LevelData::LevelData(CompoundTag *tag) LevelData::LevelData(LevelSettings *levelSettings, const wstring& levelName) { - this->seed = levelSettings->getSeed(); - this->gameType = levelSettings->getGameType(); - this->generateMapFeatures = levelSettings->isGenerateMapFeatures(); - this->spawnBonusChest = levelSettings->hasStartingBonusItems(); - this->levelName = levelName; - this->m_pGenerator = levelSettings->getLevelType(); - this->hardcore = levelSettings->isHardcore(); + seed = levelSettings->getSeed(); + gameType = levelSettings->getGameType(); + generateMapFeatures = levelSettings->isGenerateMapFeatures(); + spawnBonusChest = levelSettings->hasStartingBonusItems(); + this->levelName = levelName; + m_pGenerator = levelSettings->getLevelType(); + hardcore = levelSettings->isHardcore(); + generatorOptions = levelSettings->getLevelTypeOptions(); + allowCommands = levelSettings->getAllowCommands(); // 4J Stu - Default initers - this->xSpawn = 0; - this->ySpawn = 0; - this->zSpawn = 0; - this->time = -1; // 4J-JEV: Edited: To know when this is uninitialized. - this->lastPlayed = 0; - this->sizeOnDisk = 0; -// this->loadedPlayerTag = NULL; // 4J - we don't store this anymore - this->dimension = 0; - this->version = 0; - this->rainTime = 0; - this->raining = false; - this->thunderTime = 0; - this->thundering = false; - this->allowCommands = levelSettings->getAllowCommands(); - this->initialized = false; - this->newSeaLevel = levelSettings->useNewSeaLevel(); // 4J added - only use new sea level for newly created maps (sea level changes in 1.8.2) - this->hasBeenInCreative = levelSettings->getGameType() == GameType::CREATIVE; // 4J added + xSpawn = 0; + ySpawn = 0; + zSpawn = 0; + dayTime = -1; // 4J-JEV: Edited: To know when this is uninitialized. + gameTime = -1; + lastPlayed = 0; + sizeOnDisk = 0; + // this->loadedPlayerTag = NULL; // 4J - we don't store this anymore + dimension = 0; + version = 0; + rainTime = 0; + raining = false; + thunderTime = 0; + thundering = false; + initialized = false; + newSeaLevel = levelSettings->useNewSeaLevel(); // 4J added - only use new sea level for newly created maps (sea level changes in 1.8.2) + hasBeenInCreative = levelSettings->getGameType() == GameType::CREATIVE; // 4J added // 4J-PB for the stronghold position - this->bStronghold=false; - this->xStronghold = 0; - this->yStronghold = 0; - this->zStronghold = 0; - - this->xStrongholdEndPortal = 0; - this->zStrongholdEndPortal = 0; - this->bStrongholdEndPortal = false; + bStronghold=false; + xStronghold = 0; + yStronghold = 0; + zStronghold = 0; + + xStrongholdEndPortal = 0; + zStrongholdEndPortal = 0; + bStrongholdEndPortal = false; m_xzSize = levelSettings->getXZSize(); m_hellScale = levelSettings->getHellScale(); - + m_xzSize = min(m_xzSize,LEVEL_MAX_WIDTH); m_xzSize = max(m_xzSize,LEVEL_MIN_WIDTH); @@ -191,56 +249,74 @@ LevelData::LevelData(LevelSettings *levelSettings, const wstring& levelName) { ++m_hellScale; hellXZSize = m_xzSize / m_hellScale; -} + } +#ifdef _LARGE_WORLDS + m_hellScaleOld = m_hellScale; + m_xzSizeOld = m_xzSize; + m_classicEdgeMoat = false; + m_smallEdgeMoat = false; + m_mediumEdgeMoat = false; +#endif + } LevelData::LevelData(LevelData *copy) { - this->seed = copy->seed; - this->m_pGenerator = copy->m_pGenerator; - this->gameType = copy->gameType; - this->generateMapFeatures = copy->generateMapFeatures; - this->spawnBonusChest = copy->spawnBonusChest; - this->xSpawn = copy->xSpawn; - this->ySpawn = copy->ySpawn; - this->zSpawn = copy->zSpawn; - this->time = copy->time; - this->lastPlayed = copy->lastPlayed; - this->sizeOnDisk = copy->sizeOnDisk; -// this->loadedPlayerTag = copy->loadedPlayerTag; // 4J - we don't store this anymore - this->dimension = copy->dimension; - this->levelName = copy->levelName; - this->version = copy->version; - this->rainTime = copy->rainTime; - this->raining = copy->raining; - this->thunderTime = copy->thunderTime; - this->thundering = copy->thundering; - this->hardcore = copy->hardcore; - this->allowCommands = copy->allowCommands; - this->initialized = copy->initialized; - this->newSeaLevel = copy->newSeaLevel; - this->hasBeenInCreative = copy->hasBeenInCreative; + seed = copy->seed; + m_pGenerator = copy->m_pGenerator; + generatorOptions = copy->generatorOptions; + gameType = copy->gameType; + generateMapFeatures = copy->generateMapFeatures; + spawnBonusChest = copy->spawnBonusChest; + xSpawn = copy->xSpawn; + ySpawn = copy->ySpawn; + zSpawn = copy->zSpawn; + gameTime = copy->gameTime; + dayTime = copy->dayTime; + lastPlayed = copy->lastPlayed; + sizeOnDisk = copy->sizeOnDisk; + // this->loadedPlayerTag = copy->loadedPlayerTag; // 4J - we don't store this anymore + dimension = copy->dimension; + levelName = copy->levelName; + version = copy->version; + rainTime = copy->rainTime; + raining = copy->raining; + thunderTime = copy->thunderTime; + thundering = copy->thundering; + hardcore = copy->hardcore; + allowCommands = copy->allowCommands; + initialized = copy->initialized; + newSeaLevel = copy->newSeaLevel; + hasBeenInCreative = copy->hasBeenInCreative; + gameRules = copy->gameRules; // 4J-PB for the stronghold position - this->bStronghold=copy->bStronghold; - this->xStronghold = copy->xStronghold; - this->yStronghold = copy->yStronghold; - this->zStronghold = copy->zStronghold; - - this->xStrongholdEndPortal = copy->xStrongholdEndPortal; - this->zStrongholdEndPortal = copy->zStrongholdEndPortal; - this->bStrongholdEndPortal = copy->bStrongholdEndPortal; + bStronghold=copy->bStronghold; + xStronghold = copy->xStronghold; + yStronghold = copy->yStronghold; + zStronghold = copy->zStronghold; + + xStrongholdEndPortal = copy->xStrongholdEndPortal; + zStrongholdEndPortal = copy->zStrongholdEndPortal; + bStrongholdEndPortal = copy->bStrongholdEndPortal; m_xzSize = copy->m_xzSize; m_hellScale = copy->m_hellScale; +#ifdef _LARGE_WORLDS + m_classicEdgeMoat = copy->m_classicEdgeMoat; + m_smallEdgeMoat = copy->m_smallEdgeMoat; + m_mediumEdgeMoat = copy->m_mediumEdgeMoat; + m_xzSizeOld = copy->m_xzSizeOld; + m_hellScaleOld = copy->m_hellScaleOld; +#endif } CompoundTag *LevelData::createTag() { - CompoundTag *tag = new CompoundTag(); + CompoundTag *tag = new CompoundTag(); - setTagData(tag); + setTagData(tag); - return tag; + return tag; } CompoundTag *LevelData::createTag(vector<shared_ptr<Player> > *players) @@ -251,27 +327,31 @@ CompoundTag *LevelData::createTag(vector<shared_ptr<Player> > *players) void LevelData::setTagData(CompoundTag *tag) { - tag->putLong(L"RandomSeed", seed); + tag->putLong(L"RandomSeed", seed); tag->putString(L"generatorName", m_pGenerator->getGeneratorName()); tag->putInt(L"generatorVersion", m_pGenerator->getVersion()); - tag->putInt(L"GameType", gameType->getId()); - tag->putBoolean(L"MapFeatures", generateMapFeatures); + tag->putString(L"generatorOptions", generatorOptions); + tag->putInt(L"GameType", gameType->getId()); + tag->putBoolean(L"MapFeatures", generateMapFeatures); tag->putBoolean(L"spawnBonusChest",spawnBonusChest); - tag->putInt(L"SpawnX", xSpawn); - tag->putInt(L"SpawnY", ySpawn); - tag->putInt(L"SpawnZ", zSpawn); - tag->putLong(L"Time", time); - tag->putLong(L"SizeOnDisk", sizeOnDisk); - tag->putLong(L"LastPlayed", System::currentTimeMillis()); - tag->putString(L"LevelName", levelName); - tag->putInt(L"version", version); - tag->putInt(L"rainTime", rainTime); - tag->putBoolean(L"raining", raining); - tag->putInt(L"thunderTime", thunderTime); - tag->putBoolean(L"thundering", thundering); + tag->putInt(L"SpawnX", xSpawn); + tag->putInt(L"SpawnY", ySpawn); + tag->putInt(L"SpawnZ", zSpawn); + tag->putLong(L"Time", gameTime); + tag->putLong(L"DayTime", dayTime); + tag->putLong(L"SizeOnDisk", sizeOnDisk); + tag->putLong(L"LastPlayed", System::currentTimeMillis()); + tag->putString(L"LevelName", levelName); + tag->putInt(L"version", version); + tag->putInt(L"rainTime", rainTime); + tag->putBoolean(L"raining", raining); + tag->putInt(L"thunderTime", thunderTime); + tag->putBoolean(L"thundering", thundering); tag->putBoolean(L"hardcore", hardcore); tag->putBoolean(L"allowCommands", allowCommands); tag->putBoolean(L"initialized", initialized); + // 4J: Game rules are now stored with app game host options + //tag->putCompound(L"GameRules", gameRules.createTag()); tag->putBoolean(L"newSeaLevel", newSeaLevel); tag->putBoolean(L"hasBeenInCreative", hasBeenInCreative); // store the stronghold position @@ -284,27 +364,33 @@ void LevelData::setTagData(CompoundTag *tag) tag->putInt(L"StrongholdEndPortalX", xStrongholdEndPortal); tag->putInt(L"StrongholdEndPortalZ", zStrongholdEndPortal); tag->putInt(L"XZSize", m_xzSize); +#ifdef _LARGE_WORLDS + tag->putInt(L"ClassicMoat", m_classicEdgeMoat); + tag->putInt(L"SmallMoat", m_smallEdgeMoat); + tag->putInt(L"MediumMoat", m_mediumEdgeMoat); +#endif + tag->putInt(L"HellScale", m_hellScale); } __int64 LevelData::getSeed() { - return seed; + return seed; } int LevelData::getXSpawn() { - return xSpawn; + return xSpawn; } int LevelData::getYSpawn() { - return ySpawn; + return ySpawn; } int LevelData::getZSpawn() { - return zSpawn; + return zSpawn; } int LevelData::getXStronghold() @@ -329,19 +415,24 @@ int LevelData::getZStrongholdEndPortal() return zStrongholdEndPortal; } -__int64 LevelData::getTime() +__int64 LevelData::getGameTime() { - return time; + return gameTime; +} + +__int64 LevelData::getDayTime() +{ + return dayTime; } __int64 LevelData::getSizeOnDisk() { - return sizeOnDisk; + return sizeOnDisk; } CompoundTag *LevelData::getLoadedPlayerTag() { - return NULL; // 4J - we don't store this anymore + return NULL; // 4J - we don't store this anymore } // 4J Removed TU9 as it's never accurate due to the dimension never being set @@ -352,22 +443,22 @@ CompoundTag *LevelData::getLoadedPlayerTag() void LevelData::setSeed(__int64 seed) { - this->seed = seed; + this->seed = seed; } void LevelData::setXSpawn(int xSpawn) { - this->xSpawn = xSpawn; + this->xSpawn = xSpawn; } void LevelData::setYSpawn(int ySpawn) { - this->ySpawn = ySpawn; + this->ySpawn = ySpawn; } void LevelData::setZSpawn(int zSpawn) { - this->zSpawn = zSpawn; + this->zSpawn = zSpawn; } void LevelData::setHasStronghold() @@ -411,20 +502,25 @@ void LevelData::setZStrongholdEndPortal(int zStrongholdEndPortal) this->zStrongholdEndPortal = zStrongholdEndPortal; } -void LevelData::setTime(__int64 time) +void LevelData::setGameTime(__int64 time) +{ + gameTime = time; +} + +void LevelData::setDayTime(__int64 time) { - this->time = time; + dayTime = time; } void LevelData::setSizeOnDisk(__int64 sizeOnDisk) { - this->sizeOnDisk = sizeOnDisk; + this->sizeOnDisk = sizeOnDisk; } void LevelData::setLoadedPlayerTag(CompoundTag *loadedPlayerTag) { // 4J - we don't store this anymore -// this->loadedPlayerTag = loadedPlayerTag; + // this->loadedPlayerTag = loadedPlayerTag; } // 4J Remove TU9 as it's never used @@ -435,74 +531,74 @@ void LevelData::setLoadedPlayerTag(CompoundTag *loadedPlayerTag) void LevelData::setSpawn(int xSpawn, int ySpawn, int zSpawn) { - this->xSpawn = xSpawn; - this->ySpawn = ySpawn; - this->zSpawn = zSpawn; + this->xSpawn = xSpawn; + this->ySpawn = ySpawn; + this->zSpawn = zSpawn; } wstring LevelData::getLevelName() { - return levelName; + return levelName; } void LevelData::setLevelName(const wstring& levelName) { - this->levelName = levelName; + this->levelName = levelName; } int LevelData::getVersion() { - return version; + return version; } void LevelData::setVersion(int version) { - this->version = version; + this->version = version; } __int64 LevelData::getLastPlayed() { - return lastPlayed; + return lastPlayed; } bool LevelData::isThundering() { - return thundering; + return thundering; } void LevelData::setThundering(bool thundering) { - this->thundering = thundering; + this->thundering = thundering; } int LevelData::getThunderTime() { - return thunderTime; + return thunderTime; } void LevelData::setThunderTime(int thunderTime) { - this->thunderTime = thunderTime; + this->thunderTime = thunderTime; } bool LevelData::isRaining() { - return raining; + return raining; } void LevelData::setRaining(bool raining) { - this->raining = raining; + this->raining = raining; } int LevelData::getRainTime() { - return rainTime; + return rainTime; } void LevelData::setRainTime(int rainTime) { - this->rainTime = rainTime; + this->rainTime = rainTime; } GameType *LevelData::getGameType() @@ -525,7 +621,9 @@ void LevelData::setGameType(GameType *gameType) this->gameType = gameType; // 4J Added - hasBeenInCreative = hasBeenInCreative || (gameType == GameType::CREATIVE) || app.GetGameHostOption(eGameHostOption_CheatsEnabled) > 0; + hasBeenInCreative = hasBeenInCreative || + (gameType == GameType::CREATIVE) || + (app.GetGameHostOption(eGameHostOption_CheatsEnabled) > 0); } bool LevelData::useNewSeaLevel() @@ -553,6 +651,16 @@ void LevelData::setGenerator(LevelType *generator) m_pGenerator = generator; } +wstring LevelData::getGeneratorOptions() +{ + return generatorOptions; +} + +void LevelData::setGeneratorOptions(const wstring &options) +{ + generatorOptions = options; +} + bool LevelData::isHardcore() { return hardcore; @@ -578,11 +686,47 @@ void LevelData::setInitialized(bool initialized) this->initialized = initialized; } +GameRules *LevelData::getGameRules() +{ + return &gameRules; +} + int LevelData::getXZSize() { return m_xzSize; } +#ifdef _LARGE_WORLDS +int LevelData::getXZSizeOld() +{ + return m_xzSizeOld; +} + +void LevelData::getMoatFlags(bool* bClassicEdgeMoat, bool* bSmallEdgeMoat, bool* bMediumEdgeMoat) +{ + *bClassicEdgeMoat = m_classicEdgeMoat; + *bSmallEdgeMoat = m_smallEdgeMoat; + *bMediumEdgeMoat = m_mediumEdgeMoat; + +} + +int LevelData::getXZHellSizeOld() +{ + int hellXZSizeOld = ceil((float)m_xzSizeOld / m_hellScaleOld); + + while(hellXZSizeOld > HELL_LEVEL_MAX_WIDTH && m_hellScaleOld < HELL_LEVEL_MAX_SCALE) + { + assert(0); // should never get in here? + ++m_hellScaleOld; + hellXZSizeOld = m_xzSize / m_hellScale; + } + + return hellXZSizeOld; +} + + +#endif + int LevelData::getHellScale() { return m_hellScale; |
