diff options
author | Daniel Weipert <git@mail.dweipert.de> | 2024-06-24 12:55:49 +0200 |
---|---|---|
committer | Daniel Weipert <git@mail.dweipert.de> | 2024-06-24 12:55:49 +0200 |
commit | f4ead94a90f775a99132ead16aa1ccf1bfde4e80 (patch) | |
tree | 82918b14b8b9d1492646b28b394859aaba2a22ec | |
parent | 0028d1276f042953a4034016815593006d823f6d (diff) |
generate nbt files programmatically
37 files changed, 126 insertions, 8 deletions
diff --git a/data/minecraft/structure/trail_ruins/tower/tower_1.nbt b/data/minecraft/structure/trail_ruins/tower/tower_1.nbt Binary files differindex 7537513..1ebd680 100644 --- a/data/minecraft/structure/trail_ruins/tower/tower_1.nbt +++ b/data/minecraft/structure/trail_ruins/tower/tower_1.nbt diff --git a/data/minecraft/structure/trail_ruins/tower/tower_2.nbt b/data/minecraft/structure/trail_ruins/tower/tower_2.nbt Binary files differindex 7537513..1ebd680 100644 --- a/data/minecraft/structure/trail_ruins/tower/tower_2.nbt +++ b/data/minecraft/structure/trail_ruins/tower/tower_2.nbt diff --git a/data/minecraft/structure/trail_ruins/tower/tower_5.nbt b/data/minecraft/structure/trail_ruins/tower/tower_5.nbt Binary files differindex 1ebd680..7537513 100644 --- a/data/minecraft/structure/trail_ruins/tower/tower_5.nbt +++ b/data/minecraft/structure/trail_ruins/tower/tower_5.nbt diff --git a/data/minecraft/structure/village/desert/town_centers/desert_meeting_point_1.nbt b/data/minecraft/structure/village/desert/town_centers/desert_meeting_point_1.nbt Binary files differnew file mode 100644 index 0000000..3eddcb6 --- /dev/null +++ b/data/minecraft/structure/village/desert/town_centers/desert_meeting_point_1.nbt diff --git a/data/minecraft/structure/village/desert/town_centers/desert_meeting_point_2.nbt b/data/minecraft/structure/village/desert/town_centers/desert_meeting_point_2.nbt Binary files differnew file mode 100644 index 0000000..3eddcb6 --- /dev/null +++ b/data/minecraft/structure/village/desert/town_centers/desert_meeting_point_2.nbt diff --git a/data/minecraft/structure/village/desert/town_centers/desert_meeting_point_3.nbt b/data/minecraft/structure/village/desert/town_centers/desert_meeting_point_3.nbt Binary files differnew file mode 100644 index 0000000..3eddcb6 --- /dev/null +++ b/data/minecraft/structure/village/desert/town_centers/desert_meeting_point_3.nbt diff --git a/data/minecraft/structure/village/desert/zombie/town_centers/desert_meeting_point_1.nbt b/data/minecraft/structure/village/desert/zombie/town_centers/desert_meeting_point_1.nbt Binary files differnew file mode 100644 index 0000000..3eddcb6 --- /dev/null +++ b/data/minecraft/structure/village/desert/zombie/town_centers/desert_meeting_point_1.nbt diff --git a/data/minecraft/structure/village/desert/zombie/town_centers/desert_meeting_point_2.nbt b/data/minecraft/structure/village/desert/zombie/town_centers/desert_meeting_point_2.nbt Binary files differnew file mode 100644 index 0000000..3eddcb6 --- /dev/null +++ b/data/minecraft/structure/village/desert/zombie/town_centers/desert_meeting_point_2.nbt diff --git a/data/minecraft/structure/village/desert/zombie/town_centers/desert_meeting_point_3.nbt b/data/minecraft/structure/village/desert/zombie/town_centers/desert_meeting_point_3.nbt Binary files differnew file mode 100644 index 0000000..3eddcb6 --- /dev/null +++ b/data/minecraft/structure/village/desert/zombie/town_centers/desert_meeting_point_3.nbt diff --git a/data/minecraft/structure/village/plains/town_centers/plains_fountain_01.nbt b/data/minecraft/structure/village/plains/town_centers/plains_fountain_01.nbt Binary files differnew file mode 100644 index 0000000..3eddcb6 --- /dev/null +++ b/data/minecraft/structure/village/plains/town_centers/plains_fountain_01.nbt diff --git a/data/minecraft/structure/village/plains/town_centers/plains_meeting_point_1.nbt b/data/minecraft/structure/village/plains/town_centers/plains_meeting_point_1.nbt Binary files differnew file mode 100644 index 0000000..3eddcb6 --- /dev/null +++ b/data/minecraft/structure/village/plains/town_centers/plains_meeting_point_1.nbt diff --git a/data/minecraft/structure/village/plains/town_centers/plains_meeting_point_2.nbt b/data/minecraft/structure/village/plains/town_centers/plains_meeting_point_2.nbt Binary files differnew file mode 100644 index 0000000..3eddcb6 --- /dev/null +++ b/data/minecraft/structure/village/plains/town_centers/plains_meeting_point_2.nbt diff --git a/data/minecraft/structure/village/plains/town_centers/plains_meeting_point_3.nbt b/data/minecraft/structure/village/plains/town_centers/plains_meeting_point_3.nbt Binary files differnew file mode 100644 index 0000000..3eddcb6 --- /dev/null +++ b/data/minecraft/structure/village/plains/town_centers/plains_meeting_point_3.nbt diff --git a/data/minecraft/structure/village/plains/zombie/town_centers/plains_fountain_01.nbt b/data/minecraft/structure/village/plains/zombie/town_centers/plains_fountain_01.nbt Binary files differnew file mode 100644 index 0000000..3eddcb6 --- /dev/null +++ b/data/minecraft/structure/village/plains/zombie/town_centers/plains_fountain_01.nbt diff --git a/data/minecraft/structure/village/plains/zombie/town_centers/plains_meeting_point_1.nbt b/data/minecraft/structure/village/plains/zombie/town_centers/plains_meeting_point_1.nbt Binary files differnew file mode 100644 index 0000000..3eddcb6 --- /dev/null +++ b/data/minecraft/structure/village/plains/zombie/town_centers/plains_meeting_point_1.nbt diff --git a/data/minecraft/structure/village/plains/zombie/town_centers/plains_meeting_point_2.nbt b/data/minecraft/structure/village/plains/zombie/town_centers/plains_meeting_point_2.nbt Binary files differnew file mode 100644 index 0000000..3eddcb6 --- /dev/null +++ b/data/minecraft/structure/village/plains/zombie/town_centers/plains_meeting_point_2.nbt diff --git a/data/minecraft/structure/village/plains/zombie/town_centers/plains_meeting_point_3.nbt b/data/minecraft/structure/village/plains/zombie/town_centers/plains_meeting_point_3.nbt Binary files differnew file mode 100644 index 0000000..3eddcb6 --- /dev/null +++ b/data/minecraft/structure/village/plains/zombie/town_centers/plains_meeting_point_3.nbt diff --git a/data/minecraft/structure/village/savanna/town_centers/savanna_meeting_point_1.nbt b/data/minecraft/structure/village/savanna/town_centers/savanna_meeting_point_1.nbt Binary files differindex e69de29..3eddcb6 100644 --- a/data/minecraft/structure/village/savanna/town_centers/savanna_meeting_point_1.nbt +++ b/data/minecraft/structure/village/savanna/town_centers/savanna_meeting_point_1.nbt diff --git a/data/minecraft/structure/village/savanna/town_centers/savanna_meeting_point_2.nbt b/data/minecraft/structure/village/savanna/town_centers/savanna_meeting_point_2.nbt Binary files differindex e69de29..3eddcb6 100644 --- a/data/minecraft/structure/village/savanna/town_centers/savanna_meeting_point_2.nbt +++ b/data/minecraft/structure/village/savanna/town_centers/savanna_meeting_point_2.nbt diff --git a/data/minecraft/structure/village/savanna/town_centers/savanna_meeting_point_3.nbt b/data/minecraft/structure/village/savanna/town_centers/savanna_meeting_point_3.nbt Binary files differindex e69de29..3eddcb6 100644 --- a/data/minecraft/structure/village/savanna/town_centers/savanna_meeting_point_3.nbt +++ b/data/minecraft/structure/village/savanna/town_centers/savanna_meeting_point_3.nbt diff --git a/data/minecraft/structure/village/savanna/town_centers/savanna_meeting_point_4.nbt b/data/minecraft/structure/village/savanna/town_centers/savanna_meeting_point_4.nbt Binary files differindex e69de29..3eddcb6 100644 --- a/data/minecraft/structure/village/savanna/town_centers/savanna_meeting_point_4.nbt +++ b/data/minecraft/structure/village/savanna/town_centers/savanna_meeting_point_4.nbt diff --git a/data/minecraft/structure/village/savanna/zombie/town_centers/savanna_meeting_point_1.nbt b/data/minecraft/structure/village/savanna/zombie/town_centers/savanna_meeting_point_1.nbt Binary files differnew file mode 100644 index 0000000..3eddcb6 --- /dev/null +++ b/data/minecraft/structure/village/savanna/zombie/town_centers/savanna_meeting_point_1.nbt diff --git a/data/minecraft/structure/village/savanna/zombie/town_centers/savanna_meeting_point_2.nbt b/data/minecraft/structure/village/savanna/zombie/town_centers/savanna_meeting_point_2.nbt Binary files differnew file mode 100644 index 0000000..3eddcb6 --- /dev/null +++ b/data/minecraft/structure/village/savanna/zombie/town_centers/savanna_meeting_point_2.nbt diff --git a/data/minecraft/structure/village/savanna/zombie/town_centers/savanna_meeting_point_3.nbt b/data/minecraft/structure/village/savanna/zombie/town_centers/savanna_meeting_point_3.nbt Binary files differnew file mode 100644 index 0000000..3eddcb6 --- /dev/null +++ b/data/minecraft/structure/village/savanna/zombie/town_centers/savanna_meeting_point_3.nbt diff --git a/data/minecraft/structure/village/savanna/zombie/town_centers/savanna_meeting_point_4.nbt b/data/minecraft/structure/village/savanna/zombie/town_centers/savanna_meeting_point_4.nbt Binary files differnew file mode 100644 index 0000000..3eddcb6 --- /dev/null +++ b/data/minecraft/structure/village/savanna/zombie/town_centers/savanna_meeting_point_4.nbt diff --git a/data/minecraft/structure/village/snowy/town_centers/snowy_meeting_point_1.nbt b/data/minecraft/structure/village/snowy/town_centers/snowy_meeting_point_1.nbt Binary files differnew file mode 100644 index 0000000..3eddcb6 --- /dev/null +++ b/data/minecraft/structure/village/snowy/town_centers/snowy_meeting_point_1.nbt diff --git a/data/minecraft/structure/village/snowy/town_centers/snowy_meeting_point_2.nbt b/data/minecraft/structure/village/snowy/town_centers/snowy_meeting_point_2.nbt Binary files differnew file mode 100644 index 0000000..3eddcb6 --- /dev/null +++ b/data/minecraft/structure/village/snowy/town_centers/snowy_meeting_point_2.nbt diff --git a/data/minecraft/structure/village/snowy/town_centers/snowy_meeting_point_3.nbt b/data/minecraft/structure/village/snowy/town_centers/snowy_meeting_point_3.nbt Binary files differnew file mode 100644 index 0000000..3eddcb6 --- /dev/null +++ b/data/minecraft/structure/village/snowy/town_centers/snowy_meeting_point_3.nbt diff --git a/data/minecraft/structure/village/snowy/zombie/town_centers/snowy_meeting_point_1.nbt b/data/minecraft/structure/village/snowy/zombie/town_centers/snowy_meeting_point_1.nbt Binary files differnew file mode 100644 index 0000000..3eddcb6 --- /dev/null +++ b/data/minecraft/structure/village/snowy/zombie/town_centers/snowy_meeting_point_1.nbt diff --git a/data/minecraft/structure/village/snowy/zombie/town_centers/snowy_meeting_point_2.nbt b/data/minecraft/structure/village/snowy/zombie/town_centers/snowy_meeting_point_2.nbt Binary files differnew file mode 100644 index 0000000..3eddcb6 --- /dev/null +++ b/data/minecraft/structure/village/snowy/zombie/town_centers/snowy_meeting_point_2.nbt diff --git a/data/minecraft/structure/village/snowy/zombie/town_centers/snowy_meeting_point_3.nbt b/data/minecraft/structure/village/snowy/zombie/town_centers/snowy_meeting_point_3.nbt Binary files differnew file mode 100644 index 0000000..3eddcb6 --- /dev/null +++ b/data/minecraft/structure/village/snowy/zombie/town_centers/snowy_meeting_point_3.nbt diff --git a/data/minecraft/structure/village/taiga/town_centers/taiga_meeting_point_1.nbt b/data/minecraft/structure/village/taiga/town_centers/taiga_meeting_point_1.nbt Binary files differindex e69de29..3eddcb6 100644 --- a/data/minecraft/structure/village/taiga/town_centers/taiga_meeting_point_1.nbt +++ b/data/minecraft/structure/village/taiga/town_centers/taiga_meeting_point_1.nbt diff --git a/data/minecraft/structure/village/taiga/town_centers/taiga_meeting_point_2.nbt b/data/minecraft/structure/village/taiga/town_centers/taiga_meeting_point_2.nbt Binary files differindex e69de29..3eddcb6 100644 --- a/data/minecraft/structure/village/taiga/town_centers/taiga_meeting_point_2.nbt +++ b/data/minecraft/structure/village/taiga/town_centers/taiga_meeting_point_2.nbt diff --git a/data/minecraft/structure/village/taiga/zombie/town_centers/taiga_meeting_point_1.nbt b/data/minecraft/structure/village/taiga/zombie/town_centers/taiga_meeting_point_1.nbt Binary files differnew file mode 100644 index 0000000..3eddcb6 --- /dev/null +++ b/data/minecraft/structure/village/taiga/zombie/town_centers/taiga_meeting_point_1.nbt diff --git a/data/minecraft/structure/village/taiga/zombie/town_centers/taiga_meeting_point_2.nbt b/data/minecraft/structure/village/taiga/zombie/town_centers/taiga_meeting_point_2.nbt Binary files differnew file mode 100644 index 0000000..3eddcb6 --- /dev/null +++ b/data/minecraft/structure/village/taiga/zombie/town_centers/taiga_meeting_point_2.nbt diff --git a/data/vanilla_skyblock/structure/empty.nbt b/data/vanilla_skyblock/structure/empty.nbt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/data/vanilla_skyblock/structure/empty.nbt @@ -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`); + } +} |