summaryrefslogtreecommitdiff
path: root/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'index.js')
-rw-r--r--index.js134
1 files changed, 126 insertions, 8 deletions
diff --git a/index.js b/index.js
index 5c4c8ca..3c6a450 100644
--- a/index.js
+++ b/index.js
@@ -19,22 +19,65 @@ function getMetaData(dataPath) {
);
}
+function getData(namespace, dataPath) {
+ let encoding = '';
+ if (dataPath.endsWith('json')) {
+ encoding = 'utf8';
+ }
+
+ return fs.readFileSync(
+ path.resolve(__dirname, `data/${namespace}/${dataPath}`),
+ encoding
+ );
+}
+
+function getJsonData(namespace, dataPath) {
+ return JSON.parse(
+ getData(namespace, `${dataPath}.json`)
+ );
+}
+
function writeData(namespace, dataPath, data) {
+ return fs.writeFileSync(
+ path.resolve(__dirname, `data/${namespace}/${dataPath}`),
+ data
+ );
+}
+
+function overwriteData(dataPath, data) {
+ return writeData('minecraft', dataPath, data);
+}
+
+function writeJson(namespace, dataPath, data) {
// sort keys
const allKeys = new Set();
JSON.stringify(data, (key, value) => (allKeys.add(key), value));
const sortedKeys = Array.from(allKeys).sort();
// write file
- return fs.writeFileSync(
- path.resolve(__dirname, `data/${namespace}/${dataPath}.json`),
+ return writeData(
+ namespace,
+ `${dataPath}.json`,
JSON.stringify(data, sortedKeys, 2)
);
}
-function overwriteData(dataPath, data) {
- return writeData('minecraft', dataPath, data);
+function overwriteJson(dataPath, data) {
+ return writeJson('minecraft', dataPath, data);
+}
+
+
+function replaceData(source, destination) {
+ const destinationDirectory = path.resolve(__dirname, `data/minecraft/${path.dirname(destination)}`);
+ if (!fs.existsSync(destinationDirectory)) {
+ fs.mkdirSync(destinationDirectory, { recursive: true });
+ }
+
+ return fs.copyFileSync(
+ path.resolve(__dirname, `data/vanilla_skyblock/${source}`),
+ path.resolve(__dirname, `data/minecraft/${destination}`)
+ );
}
@@ -48,7 +91,7 @@ function getWorldgenNoiseSettingsMeta(name) {
}
function overwriteWorldgenNoiseSettings(name, data) {
- return overwriteData(`worldgen/noise_settings/${name}`, data);
+ return overwriteJson(`worldgen/noise_settings/${name}`, data);
}
@@ -114,7 +157,7 @@ function getWorldgenStructureMeta(name) {
}
function overwriteWorldgenStructure(name, data) {
- return overwriteData(`worldgen/structure/${name}`, data);
+ return overwriteJson(`worldgen/structure/${name}`, data);
}
@@ -250,7 +293,7 @@ for (const noise of noisesToSilence) {
firstOctave: 0,
amplitudes: [],
});
- overwriteData(`worldgen/noise/${noise}`, noiseData);
+ overwriteJson(`worldgen/noise/${noise}`, noiseData);
}
@@ -275,7 +318,7 @@ for (const feature of featuresToRemove) {
height: 0,
},
});
- overwriteData(`worldgen/configured_feature/${feature}`, featureData);
+ overwriteJson(`worldgen/configured_feature/${feature}`, featureData);
}
@@ -286,3 +329,78 @@ for (const feature of featuresToRemove) {
// TODO if applicable check worldgen/structure.json for pool_start and get location of nbt files.
// write to nbt files accordingly
+
+// ancient city
+const ancientCityStartPool = ancientCity.start_pool.replace('minecraft:', '');
+const ancientCityTemplatePool = getMetaData(`worldgen/template_pool/${ancientCityStartPool}`);
+for (const templatePoolElement of ancientCityTemplatePool.elements) {
+ const location = templatePoolElement.element.location.replace('minecraft:', '');
+ replaceData('structure/ancient_city.nbt', `structure/${location}.nbt`);
+}
+
+// bastion
+const bastionStartPool = getWorldgenStructureMeta('bastion_remnant').start_pool.replace('minecraft:', '');
+const bastionTemplatePool = getMetaData(`worldgen/template_pool/${bastionStartPool}`);
+for (const templatePoolElement of bastionTemplatePool.elements) {
+ const location = templatePoolElement.element.location.replace('minecraft:', '');
+ if (location.includes('/units/')) {
+ replaceData('structure/bastion/bastion_other.nbt', `structure/${location}.nbt`);
+ }
+ else if (location.includes('/hoglin_stable/')) {
+ replaceData('structure/bastion/bastion_hoglin_stable.nbt', `structure/${location}.nbt`);
+ }
+ else if (location.includes('/treasure/')) {
+ replaceData('structure/bastion/bastion_treasure.nbt', `structure/${location}.nbt`);
+ }
+ else if (location.includes('/bridge/')) {
+ replaceData('structure/bastion/bastion_bridge.nbt', `structure/${location}.nbt`);
+ }
+}
+
+// pillager outpost
+const pillagerOutpostStartPool = getWorldgenStructureMeta('pillager_outpost').start_pool.replace('minecraft:', '');
+const pillagerOutpostTemplatePool = getMetaData(`worldgen/template_pool/${pillagerOutpostStartPool}`);
+for (const templatePoolElement of pillagerOutpostTemplatePool.elements) {
+ const location = templatePoolElement.element.location.replace('minecraft:', '');
+ replaceData('structure/empty_16.nbt', `structure/${location}.nbt`);
+}
+
+// trail ruins
+const trailRuinsStartPool = getWorldgenStructureMeta('trail_ruins').start_pool.replace('minecraft:', '');
+const trailRuinsTemplatePool = getMetaData(`worldgen/template_pool/${trailRuinsStartPool}`);
+const trailRuinsRareChancePercent = 25;
+const trailRuinsRareMaxIndex = Math.ceil(trailRuinsTemplatePool.elements.length / (100 / trailRuinsRareChancePercent));
+for (const idx in trailRuinsTemplatePool.elements) {
+ const templatePoolElement = trailRuinsTemplatePool.elements[idx];
+ const location = templatePoolElement.element.location.replace('minecraft:', '');
+ if (idx >= trailRuinsRareMaxIndex) {
+ replaceData('structure/archaeology/trail_ruins_common.nbt', `structure/${location}.nbt`);
+ } else {
+ replaceData('structure/archaeology/trail_ruins_rare.nbt', `structure/${location}.nbt`);
+ }
+}
+
+// trial chambers
+const trialChambersStartPool = getWorldgenStructureMeta('trial_chambers').start_pool.replace('minecraft:', '');
+const trialChambersTemplatePool = getMetaData(`worldgen/template_pool/${trialChambersStartPool}`);
+for (const templatePoolElement of trialChambersTemplatePool.elements) {
+ const location = templatePoolElement.element.location.replace('minecraft:', '');
+ replaceData('structure/trial_chamber.nbt', `structure/${location}.nbt`);
+}
+
+// villages
+const villages = [
+ 'village_desert',
+ 'village_plains',
+ 'village_savanna',
+ 'village_snowy',
+ 'village_taiga',
+];
+for (const village of villages) {
+ const villageStartPool = getWorldgenStructureMeta(village).start_pool.replace('minecraft:', '');
+ const villageTemplatePool = getMetaData(`worldgen/template_pool/${villageStartPool}`);
+ for (const templatePoolElement of villageTemplatePool.elements) {
+ const location = templatePoolElement.element.location.replace('minecraft:', '');
+ replaceData('structure/empty_16.nbt', `structure/${location}.nbt`);
+ }
+}