Overrides!
This commit is contained in:
@@ -36,6 +36,19 @@ bool ContentLoader::fixPackIndices(fs::path folder,
|
||||
if (name[0] == '_')
|
||||
continue;
|
||||
detected.push_back(name);
|
||||
} else if (fs::is_directory(file)) {
|
||||
std::string space = file.stem().string();
|
||||
if (space[0] == '_')
|
||||
continue;
|
||||
for (auto entry : fs::directory_iterator(file)) {
|
||||
fs::path file = entry.path();
|
||||
if (fs::is_regular_file(file) && file.extension() == ".json") {
|
||||
std::string name = file.stem().string();
|
||||
if (name[0] == '_')
|
||||
continue;
|
||||
detected.push_back(space + ':' + name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -268,7 +281,7 @@ void ContentLoader::loadBlock(Block& def, std::string full, std::string name) {
|
||||
auto folder = pack->folder;
|
||||
|
||||
fs::path configFile = folder/fs::path("blocks/"+name+".json");
|
||||
loadBlock(def, full, configFile);
|
||||
if (fs::exists(configFile)) loadBlock(def, full, configFile);
|
||||
|
||||
fs::path scriptfile = folder/fs::path("scripts/"+def.scriptName+".lua");
|
||||
if (fs::is_regular_file(scriptfile)) {
|
||||
@@ -280,7 +293,7 @@ void ContentLoader::loadItem(ItemDef& def, std::string full, std::string name) {
|
||||
auto folder = pack->folder;
|
||||
|
||||
fs::path configFile = folder/fs::path("items/"+name+".json");
|
||||
loadItem(def, full, configFile);
|
||||
if (fs::exists(configFile)) loadItem(def, full, configFile);
|
||||
|
||||
fs::path scriptfile = folder/fs::path("scripts/"+def.scriptName+".lua");
|
||||
if (fs::is_regular_file(scriptfile)) {
|
||||
@@ -313,8 +326,11 @@ void ContentLoader::load(ContentBuilder& builder) {
|
||||
if (blocksarr) {
|
||||
for (uint i = 0; i < blocksarr->size(); i++) {
|
||||
std::string name = blocksarr->str(i);
|
||||
std::string full = pack->id+":"+name;
|
||||
auto colon = name.find(':');
|
||||
std::string full = colon == std::string::npos ? pack->id + ":" + name : name;
|
||||
if (colon != std::string::npos) name[colon] = '/';
|
||||
auto& def = builder.createBlock(full);
|
||||
if (colon != std::string::npos) def.scriptName = name.substr(0, colon) + '/' + def.scriptName;
|
||||
loadBlock(def, full, name);
|
||||
stats.totalBlocks++;
|
||||
if (!def.hidden) {
|
||||
@@ -336,8 +352,12 @@ void ContentLoader::load(ContentBuilder& builder) {
|
||||
if (itemsarr) {
|
||||
for (uint i = 0; i < itemsarr->size(); i++) {
|
||||
std::string name = itemsarr->str(i);
|
||||
std::string full = pack->id+":"+name;
|
||||
loadItem(builder.createItem(full), full, name);
|
||||
auto colon = name.find(':');
|
||||
std::string full = colon == std::string::npos ? pack->id + ":" + name : name;
|
||||
if (colon != std::string::npos) name[colon] = '/';
|
||||
auto& def = builder.createItem(full);
|
||||
if (colon != std::string::npos) def.scriptName = name.substr(0, colon) + '/' + def.scriptName;
|
||||
loadItem(def, full, name);
|
||||
stats.totalItems++;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user