MCPcopy Create free account
hub / github.com/ElyPrismLauncher/Launcher / loadFromLevelDat

Method loadFromLevelDat

launcher/minecraft/World.cpp:438–486  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

436}
437
438void World::loadFromLevelDat(QByteArray data)
439{
440 auto levelData = parseLevelDat(data);
441 if (!levelData) {
442 m_isValid = false;
443 return;
444 }
445
446 nbt::value* valPtr = nullptr;
447 try {
448 valPtr = &levelData->at("Data");
449 } catch (const std::out_of_range& e) {
450 qWarning().nospace() << "Unable to read NBT tags from " << m_folderName << ": " << e.what();
451 m_isValid = false;
452 return;
453 }
454 nbt::value& val = *valPtr;
455
456 m_isValid = val.get_type() == nbt::tag_type::Compound;
457 if (!m_isValid)
458 return;
459
460 auto name = read_string(val, "LevelName");
461 m_actualName = name ? *name : m_folderName;
462
463 auto timestamp = read_long(val, "LastPlayed");
464 m_lastPlayed = timestamp ? QDateTime::fromMSecsSinceEpoch(*timestamp) : m_levelDatTime;
465
466 m_gameType = read_gametype(val, "GameType");
467
468 optional<int64_t> randomSeed;
469 try {
470 auto& WorldGen_val = val.at("WorldGenSettings");
471 randomSeed = read_long(WorldGen_val, "seed");
472 } catch (const std::out_of_range&) {
473 }
474 if (!randomSeed) {
475 randomSeed = read_long(val, "RandomSeed");
476 }
477 m_randomSeed = randomSeed ? *randomSeed : 0;
478
479 qDebug() << "World Name:" << m_actualName;
480 qDebug() << "Last Played:" << m_lastPlayed.toString();
481 if (randomSeed) {
482 qDebug() << "Seed:" << *randomSeed;
483 }
484 qDebug() << "Size:" << m_size;
485 qDebug() << "GameType:" << m_gameType.toLogString();
486}
487
488bool World::replace(World& with)
489{

Callers

nothing calls this directly

Calls 8

parseLevelDatFunction · 0.85
read_stringFunction · 0.85
read_longFunction · 0.85
read_gametypeFunction · 0.85
whatMethod · 0.80
toLogStringMethod · 0.80
atMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected