-
-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: first complete custom dimension
- Loading branch information
Showing
7 changed files
with
178 additions
and
48 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
|
||
#include "FakeDimensionID.h" |
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,6 @@ | ||
#pragma once | ||
|
||
|
||
class FakeDimensionID {}; | ||
|
||
|
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,40 @@ | ||
|
||
#include "MoreDimensionConfig.h" | ||
|
||
#include "ll/api/Config.h" | ||
#include "ll/api/service/GlobalService.h" | ||
#include "mc/world/level/Level.h" | ||
#include "mc/world/level/LevelSeed64.h" | ||
#include "mc/world/level/storage/LevelData.h" | ||
|
||
namespace MoreDimensionConfig { | ||
|
||
std::string dimensionConfigPath = R"(worlds\Bedrock level\dimension_config.json)"; | ||
Config dimConfig{}; | ||
|
||
void setDimensionConfigPath() { | ||
auto levelName = ll::Global<Level>->getLevelData().getLevelName(); | ||
dimensionConfigPath.replace(dimensionConfigPath.find("Bedrock level"), 13, levelName); | ||
} | ||
|
||
bool loadConfigFile() { | ||
setDimensionConfigPath(); // set real world path | ||
if (!ll::config::loadConfig(dimConfig, dimensionConfigPath, false)) { | ||
if (ll::config::saveConfig(dimConfig, dimensionConfigPath)) { | ||
logger.warn("Config file rewrite success!"); | ||
} else { | ||
logger.warn("Config file rewrite fail!"); | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
|
||
bool saveConfigFile() { | ||
if (!ll::config::saveConfig(dimConfig, dimensionConfigPath)) { | ||
logger.error("Config file save fail!"); | ||
return false; | ||
} | ||
return true; | ||
} | ||
} // namespace MoreDimensionConfig |
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,30 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
#include <unordered_map> | ||
|
||
#include "ll/api/Logger.h" | ||
#include "ll/api/base/StdInt.h" | ||
#include "mc/world/level/levelgen/GeneratorType.h" | ||
|
||
namespace MoreDimensionConfig { | ||
namespace { | ||
ll::Logger logger("MoreDimensionConfig"); | ||
} | ||
|
||
struct Config { | ||
struct dimensionInfo { | ||
int id = -1; | ||
uint seed = 123; | ||
GeneratorType generatorType = GeneratorType::Void; | ||
}; | ||
int version = 1; | ||
std::unordered_map<std::string, dimensionInfo> dimensionList = {}; | ||
}; | ||
extern std::string dimensionConfigPath; | ||
extern Config dimConfig; | ||
|
||
void setDimensionConfigPath(); | ||
bool loadConfigFile(); | ||
bool saveConfigFile(); | ||
}; // namespace MoreDimensionConfig |
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