Created
November 5, 2024 22:08
-
-
Save gardenappl/584026d90ac091c98a07c3bc5c331eb8 to your computer and use it in GitHub Desktop.
Python script for generating config files for Minecraft 1.18 Custom Spawn mod
This file contains hidden or 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
import json | |
import sys | |
MONSTER = "MONSTER" | |
CREATURE = "CREATURE" | |
AMBIENT = "AMBIENT" | |
AXOLOTLS = "AXOLOTLS" | |
UNDERGROUND_WATER_CREATURE = "UNDERGROUND_WATER_CREATURE" | |
WATER_CREATURE = "WATER_CREATURE" | |
MISC = "MISC" | |
# biome groups | |
# modify these to add different biomes from different mods | |
# can use `/kubejs dump` for this, or extract the data from mod JARs and find biome tag JSON files in the resources/ folder | |
savanna = { | |
"minecraft:savanna_plateau", | |
"minecraft:windswept_savanna", | |
"minecraft:savanna", | |
"wythers:chaparral", | |
"wythers:dry_tropical_grassland", | |
"wythers:flooded_savanna", | |
"wythers:savanna_basaltic_incursions", | |
"wythers:wooded_savanna", | |
"wythers:dry_savanna", | |
"wythers:savanna_badlands", | |
"wythers:dry_tropical_forest", | |
"wythers:eucalyptus_salubris_woodland", | |
"wythers:eucalyptus_woodland", | |
"wythers:giant_sequoia_forest", | |
"wythers:humid_tropical_grassland", | |
"wythers:jacaranda_savanna", | |
"wythers:scrubland", | |
"wythers:scrub_forest", | |
"wythers:tsingy_forest", | |
"wythers:tropical_forest", | |
"wythers:tropical_grassland" | |
} | |
river = { | |
"minecraft:river", | |
"minecraft:frozen_river", | |
"tectonic:cold_river", | |
"tectonic:warm_river", | |
"tectonic:lukewarm_river", | |
"tectonic:coral_river", | |
"tectonic:dripstone_river", | |
"tectonic:icy_river", | |
"tectonic:lantern_river", | |
"tectonic:lush_river", | |
"wythers:savanna_river", | |
"wythers:jungle_river", | |
"wythers:flooded_savanna", | |
"wythers:badlands_river", | |
"wythers:billabong", | |
"wythers:black_river", | |
"wythers:desert_river", | |
"wythers:deep_desert_river", | |
"wythers:gravelly_river", | |
"wythers:icy_river", | |
"wythers:lantern_river" | |
} | |
mesa = { | |
"minecraft:wooded_badlands", | |
"minecraft:eroded_badlands", | |
"minecraft:badlands", | |
"wythers:ayers_rock", | |
"wythers:outback", | |
"wythers:outback_desert", | |
"wythers:badlands_canyon", | |
"wythers:badlands_desert", | |
"wythers:kwongan_heath", | |
} | |
jungle = { | |
"minecraft:bamboo_jungle", | |
"minecraft:jungle", | |
"minecraft:sparse_jungle", | |
"wythers:tropical_rainforest", | |
"wythers:eucalyptus_jungle", | |
"wythers:eucalyptus_jungle_canyon", | |
"wythers:sparse_bamboo_jungle", | |
"wythers:jungle_island", | |
"wythers:bamboo_swamp", | |
"wythers:bamboo_jungle_swamp", | |
"wythers:bamboo_jungle_canyon", | |
"wythers:bamboo_jungle_highlands", | |
"wythers:dry_tropical_grassland", | |
"wythers:highland_tropical_rainforest", | |
"wythers:mushroom_island", | |
"wythers:flooded_jungle", | |
"wythers:flooded_rainforest", | |
"wythers:pantanal", | |
"wythers:sandy_jungle", | |
"wythers:sparse_eucalyptus_jungle", | |
"wythers:sparse_eucalyptus_woodland", | |
"wythers:windswept_jungle", | |
} | |
extreme_hills = { | |
"minecraft:windswept_gravelly_hills", | |
"minecraft:windswept_hills", | |
} | |
mushroom = { | |
"minecraft:mushroom_fields", | |
"wythers:fungous_dripstone_caves", | |
"wythers:lush_fungous_dripstone_caves", | |
"wythers:lush_shroom_caves", | |
"wythers:mushroom_caves", | |
"wythers:mushroom_island", | |
} | |
underground = { | |
"minecraft:dripstone_caves", | |
"minecraft:lush_caves", | |
"wythers:calcite_caverns", | |
"wythers:fungous_dripstone_caves", | |
"wythers:lichenous_caves", | |
"wythers:lichenous_dripstone_caves", | |
"wythers:lush_dripstone_caves", | |
"wythers:lush_fungous_dripstone_caves", | |
"wythers:lush_shroom_caves", | |
"wythers:mossy_caves", | |
"wythers:mossy_dripstone_caves", | |
"wythers:mushroom_caves", | |
"wythers:volcanic_chamber", | |
"tectonic:coral_river", | |
"tectonic:dripstone_river", | |
"tectonic:icy_river", | |
"tectonic:lantern_river", | |
"tectonic:lush_river", | |
"wythers:deep_underground", | |
"wythers:underground", | |
} | |
mountain = { | |
"minecraft:meadow", | |
"minecraft:frozen_peaks", | |
"minecraft:jagged_peaks", | |
"minecraft:stony_peaks", | |
"minecraft:snowy_slopes", | |
"tectonic:alpine_meadow", | |
"wythers:cool_stony_peaks", | |
"wythers:cool_plains", | |
"wythers:crimson_tundra", | |
"wythers:highlands", | |
"wythers:highland_plains", | |
"wythers:huangshan_highlands", | |
"wythers:maple_mountains", | |
"wythers:tropical_volcano", | |
"wythers:volcano", | |
} | |
swamp = { | |
"minecraft:swamp", | |
"wythers:berry_bog", | |
"wythers:fen", | |
"wythers:flooded_temperate_rainforest", | |
"wythers:old_growth_taiga_swamp", | |
"wythers:phantasmal_swamp", | |
"wythers:ancient_oak_swamp", | |
"wythers:birch_swamp", | |
"wythers:autumnal_swamp", | |
"wythers:marsh", | |
"wythers:bayou", | |
"wythers:waterlily_swamp", | |
"wythers:ancient_mossy_swamp", | |
"wythers:dripleaf_swamp", | |
"wythers:bamboo_swamp", | |
"wythers:bamboo_jungle_swamp", | |
"wythers:flooded_jungle", | |
"wythers:flooded_rainforest", | |
"wythers:tangled_forest", | |
"wythers:flooded_savanna", | |
"wythers:mud_pools", | |
} | |
beach = { | |
"minecraft:beach", | |
"minecraft:snowy_beach", | |
"tectonic:cold_beach", | |
"tectonic:lukewarm_beach", | |
"wythers:tropical_beach", | |
"wythers:coastal_mangroves", | |
"wythers:sand_dunes", | |
"wythers:gravelly_beach", | |
"wythers:black_beach", | |
"wythers:desert_beach", | |
"wythers:icy_shore", | |
"minecraft:stony_shore", | |
} | |
plains = { | |
"minecraft:sunflower_plains", | |
"minecraft:plains", | |
"tectonic:grasslands", | |
"tectonic:cold_plains", | |
"wythers:tropical_grassland", | |
"wythers:humid_tropical_grassland", | |
"wythers:subtropical_grassland", | |
"wythers:cold_plains", | |
"wythers:cool_plains", | |
"wythers:autumnal_plains", | |
"wythers:harvest_fields", | |
"wythers:highland_plains", | |
"wythers:lapacho_plains", | |
"wythers:tundra", | |
} | |
taiga = { | |
"minecraft:taiga", | |
"minecraft:snowy_taiga", | |
"minecraft:old_growth_pine_taiga", | |
"minecraft:old_growth_spruce_taiga", | |
"tectonic:old_growth_snowy_taiga", | |
"wythers:birch_taiga", | |
"wythers:boreal_forest_red", | |
"wythers:boreal_forest_yellow", | |
"wythers:cold_island", | |
"wythers:deep_snowy_taiga", | |
"wythers:fen", | |
"wythers:forested_highlands", | |
"wythers:jade_highlands", | |
"wythers:larch_taiga", | |
"wythers:maple_mountains", | |
"wythers:flooded_temperate_rainforest", | |
"wythers:old_growth_taiga_crags", | |
"wythers:old_growth_taiga_swamp", | |
"wythers:pine_barrens", | |
"wythers:taiga_crags", | |
"wythers:temperate_rainforest", | |
"wythers:temperate_rainforest_crags", | |
"wythers:thermal_taiga", | |
"wythers:thermal_taiga_crags", | |
} | |
icy = { | |
"minecraft:frozen_river", | |
"minecraft:frozen_peaks", | |
"minecraft:deep_frozen_ocean", | |
"minecraft:ice_spikes", | |
"minecraft:frozen_ocean", | |
"wythers:glacial_cliffs", | |
"wythers:ice_cap", | |
"wythers:snowy_bog", | |
} | |
desert = { | |
"minecraft:desert", | |
"tectonic:desert_dunes", | |
"wythers:cactus_desert", | |
"wythers:desert_beach", | |
"wythers:desert_island", | |
"wythers:desert_pinnacles", | |
"wythers:deep_desert", | |
"wythers:guelta", | |
"wythers:wooded_desert", | |
} | |
forest = { | |
"minecraft:forest", | |
"minecraft:flower_forest", | |
"minecraft:birch_forest", | |
"minecraft:old_growth_birch_forest", | |
"minecraft:dark_forest", | |
"minecraft:grove", | |
"tectonic:autumn_birch_forest", | |
"tectonic:autumn_forest", | |
"tectonic:evergreen_forest", | |
"tectonic:old_growth_evergreen_forest", | |
"wythers:ancient_copper_beech_forest", | |
"wythers:ancient_emerald_beech_forest", | |
"wythers:ancient_golden_beech_forest", | |
"wythers:ancient_moss_forest", | |
"wythers:autumnal_birch_forest", | |
"wythers:autumnal_forest", | |
"wythers:autumnal_flower_forest", | |
"wythers:cool_forest", | |
"wythers:cool_forest_edge", | |
"wythers:deep_dark_forest", | |
"wythers:eucalyptus_deanei_forest", | |
"wythers:flowering_pantanal", | |
"wythers:forbidden_forest", | |
"wythers:phantasmal_forest", | |
"wythers:sakura_forest", | |
"wythers:spring_flower_forest", | |
"wythers:subtropical_forest", | |
"wythers:subtropical_forest_edge", | |
"wythers:warm_birch_forest", | |
"wythers:wistman_woods", | |
} | |
# Sets of added mob spawns. Modify these to add different mobs. | |
# Multiple sets can be used to add the same mobs to different sets of biomes with different spawn chances | |
# (e.g. make bears momre common in taigas than in regular forests) | |
# mob ID, spawn group, biome groups, (weight, min count, max count) | |
mob_add_sets = [ | |
# FIrst set | |
[ | |
("naturalist:rhino", CREATURE, savanna, (15, 1, 3)), | |
("naturalist:lion", CREATURE, savanna, (15, 3, 5)), | |
("naturalist:elephant", CREATURE, savanna, (10, 2, 3)), | |
("naturalist:zebra", CREATURE, savanna, (10, 2, 3)), | |
("naturalist:giraffe", CREATURE, savanna, (10, 2, 4)), | |
("naturalist:hippo", CREATURE, [savanna, jungle], (15, 3, 4)), | |
("naturalist:vulture", CREATURE, [savanna, desert], (15, 2, 4)), | |
("naturalist:boar", CREATURE, [savanna], (15, 4, 4)), | |
("naturalist:snail", CREATURE, [forest, plains, swamp, savanna, river, extreme_hills, mushroom, underground, mountain], (5, 1, 3)), | |
("naturalist:rattlesnake", CREATURE, [mesa, savanna, desert], (4, 1, 1)), | |
("naturalist:cardinal", CREATURE, [forest, swamp, savanna, desert], (8, 1, 4)), | |
("naturalist:bear", CREATURE, [forest, taiga], (8, 1, 2)), | |
("naturalist:deer", CREATURE, forest, (8, 1, 3)), | |
("naturalist:butterfly", CREATURE, [forest, plains], (6, 1, 3)), | |
("naturalist:firefly", CREATURE, [forest, plains, swamp, mushroom], (8, 2, 3)), | |
("naturalist:snake", CREATURE, [forest, plains, swamp], (4, 1, 1)), | |
("naturalist:coral_snake", CREATURE, [jungle, beach, river], (4, 1, 1)), | |
("naturalist:bluejay", CREATURE, [taiga, extreme_hills, icy], (8, 1, 4)), | |
("naturalist:canary", CREATURE, [extreme_hills, mountain], (8, 1, 4)), | |
("naturalist:robin", CREATURE, [forest, plains, mountain], (8, 1, 4)), | |
], | |
# Second set | |
[ | |
("minecraft:rabbit", CREATURE, forest, (6, 2, 3)), | |
("minecraft:fox", CREATURE, forest, (6, 2, 4)) | |
], | |
# You can add more sets here | |
] | |
# Remove mob spawns from biome groups. | |
mob_remove_set = { | |
"minecraft:sheep": [savanna], | |
"minecraft:cow": [savanna], | |
"minecraft:pig": savanna, | |
"minecraft:chicken": [savanna] | |
} | |
# Code for JSON generation | |
if len(sys.argv) > 1 and sys.argv[1] == "add": | |
mob_spawn_additions_json = [] | |
for mob_add_set in mob_add_sets: | |
for mob_add in mob_add_set: | |
add_biomes = set() | |
mob_id = mob_add[0] | |
spawn_group = mob_add[1] | |
add_biome_groups = mob_add[2] | |
weight = mob_add[3][0] | |
min_group = mob_add[3][1] | |
max_group = mob_add[3][2] | |
if not isinstance(add_biome_groups, list): | |
add_biome_groups = [add_biome_groups] | |
for add_biome_group in add_biome_groups: | |
add_biomes |= add_biome_group | |
for biome in add_biomes: | |
mob_spawn_additions_json.append({ | |
"biomeId": biome, | |
"mobId": mob_id, | |
"spawnGroup": spawn_group, | |
"weight": weight, | |
"minCount": min_group, | |
"maxCount": max_group | |
}) | |
print(json.dumps(mob_spawn_additions_json, indent=4)) | |
elif len(sys.argv) > 1 and sys.argv[1] == "remove": | |
mob_spawn_removals_json = [] | |
for mob_id, biome_groups in mob_remove_set.items(): | |
remove_biomes = set() | |
if not isinstance(biome_groups, list): | |
biome_groups = [biome_groups] | |
for remove_biome_group in biome_groups: | |
remove_biomes |= remove_biome_group | |
for biome in remove_biomes: | |
mob_spawn_removals_json.append({ | |
"biomeId": biome, | |
"mobId": mob_id | |
}) | |
print(json.dumps(mob_spawn_removals_json, indent=4)) | |
else: | |
print("Usage: python custom_spawn_script.py add") | |
print(" or python custom_spawn_script.py remove") | |
sys.exit(64) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment