mirror of
https://github.com/neocturne/MinedMap.git
synced 2025-04-14 00:45:09 +02:00
resource: codegen biome list
This commit is contained in:
parent
7b98954c80
commit
8f408e78a0
3 changed files with 197 additions and 134 deletions
|
@ -1,137 +1,117 @@
|
||||||
//! Biome data
|
//! Biome data
|
||||||
|
//!
|
||||||
|
//! This file is generated using resource/biomes.py, do not edit
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use BiomeGrassColorModifier::*;
|
||||||
|
|
||||||
/// Standard biome specifications
|
/// List if known biomes and their properties
|
||||||
pub const BIOMES: &[(&str, Biome)] = {
|
pub const BIOMES: &[(&str, Biome)] = &[
|
||||||
use BiomeGrassColorModifier::*;
|
(
|
||||||
|
"badlands",
|
||||||
// Data extracted from Minecraft code decompiled using https://github.com/Hexeption/MCP-Reborn
|
Biome::new(200, 0)
|
||||||
|
.foliage([158, 129, 77])
|
||||||
// We can't use floats in const functions, to temperature and downfall values
|
.grass([144, 129, 77]),
|
||||||
// are specified multipled by 100. The underscore is used in place of the decimal point
|
),
|
||||||
// of the original values.
|
("bamboo_jungle", Biome::new(95, 90)),
|
||||||
|
("basalt_deltas", Biome::new(200, 0)),
|
||||||
#[allow(clippy::zero_prefixed_literal)]
|
("beach", Biome::new(80, 40)),
|
||||||
&[
|
("birch_forest", Biome::new(60, 60)),
|
||||||
// Overworld
|
(
|
||||||
(
|
"cherry_grove",
|
||||||
"badlands",
|
Biome::new(50, 80)
|
||||||
Biome::new(2_00, 0_00)
|
.foliage([182, 219, 97])
|
||||||
.foliage([158, 129, 77])
|
.grass([182, 219, 97])
|
||||||
.grass([144, 129, 77]),
|
.water([93, 183, 239]),
|
||||||
),
|
),
|
||||||
("bamboo_jungle", Biome::new(0_95, 0_90)),
|
("cold_ocean", Biome::new(50, 50).water([61, 87, 214])),
|
||||||
("beach", Biome::new(0_80, 0_40)),
|
("crimson_forest", Biome::new(200, 0)),
|
||||||
("birch_forest", Biome::new(0_60, 0_60)),
|
("dark_forest", Biome::new(70, 80).modify(DarkForest)),
|
||||||
(
|
("deep_cold_ocean", Biome::new(50, 50).water([61, 87, 214])),
|
||||||
"cherry_grove",
|
("deep_dark", Biome::new(80, 40)),
|
||||||
Biome::new(0_50, 0_80)
|
("deep_frozen_ocean", Biome::new(50, 50).water([57, 56, 201])),
|
||||||
.water([93, 183, 239])
|
(
|
||||||
.grass([182, 219, 97])
|
"deep_lukewarm_ocean",
|
||||||
.foliage([182, 219, 97]),
|
Biome::new(50, 50).water([69, 173, 242]),
|
||||||
),
|
),
|
||||||
("cold_ocean", Biome::new(0_50, 0_50).water([61, 87, 214])),
|
("deep_ocean", Biome::new(50, 50)),
|
||||||
("dark_forest", Biome::new(0_70, 0_80).modify(DarkForest)),
|
("desert", Biome::new(200, 0)),
|
||||||
(
|
("dripstone_caves", Biome::new(80, 40)),
|
||||||
"deep_cold_ocean",
|
("end_barrens", Biome::new(50, 50)),
|
||||||
Biome::new(0_50, 0_50).water([61, 87, 214]),
|
("end_highlands", Biome::new(50, 50)),
|
||||||
),
|
("end_midlands", Biome::new(50, 50)),
|
||||||
("deep_dark", Biome::new(0_80, 0_40)),
|
(
|
||||||
(
|
"eroded_badlands",
|
||||||
"deep_frozen_ocean",
|
Biome::new(200, 0)
|
||||||
Biome::new(0_50, 0_50).water([57, 56, 201]),
|
.foliage([158, 129, 77])
|
||||||
),
|
.grass([144, 129, 77]),
|
||||||
(
|
),
|
||||||
"deep_lukewarm_ocean",
|
("flower_forest", Biome::new(70, 80)),
|
||||||
Biome::new(0_50, 0_50).water([69, 173, 242]),
|
("forest", Biome::new(70, 80)),
|
||||||
),
|
("frozen_ocean", Biome::new(0, 50).water([57, 56, 201])),
|
||||||
("deep_ocean", Biome::new(0_50, 0_50)),
|
("frozen_peaks", Biome::new(-70, 90)),
|
||||||
("desert", Biome::new(2_00, 0_00)),
|
("frozen_river", Biome::new(0, 50).water([57, 56, 201])),
|
||||||
("dripstone_caves", Biome::new(0_80, 0_40)),
|
("grove", Biome::new(-20, 80)),
|
||||||
(
|
("ice_spikes", Biome::new(0, 50)),
|
||||||
"eroded_badlands",
|
("jagged_peaks", Biome::new(-70, 90)),
|
||||||
Biome::new(2_00, 0_00)
|
("jungle", Biome::new(95, 90)),
|
||||||
.foliage([158, 129, 77])
|
("lukewarm_ocean", Biome::new(50, 50).water([69, 173, 242])),
|
||||||
.grass([144, 129, 77]),
|
("lush_caves", Biome::new(50, 50)),
|
||||||
),
|
(
|
||||||
("flower_forest", Biome::new(0_70, 0_80)),
|
"mangrove_swamp",
|
||||||
("forest", Biome::new(0_70, 0_80)),
|
Biome::new(80, 90)
|
||||||
("frozen_ocean", Biome::new(0_00, 0_50).water([57, 56, 201])),
|
.foliage([141, 177, 39])
|
||||||
("frozen_peaks", Biome::new(-0_70, 0_90)),
|
.modify(Swamp)
|
||||||
("frozen_river", Biome::new(0_00, 0_50).water([57, 56, 201])),
|
.water([58, 122, 106]),
|
||||||
("grove", Biome::new(-0_20, 0_80)),
|
),
|
||||||
("ice_spikes", Biome::new(0_00, 0_50)),
|
("meadow", Biome::new(50, 80).water([14, 78, 207])),
|
||||||
("jagged_peaks", Biome::new(-0_70, 0_90)),
|
("mushroom_fields", Biome::new(90, 100)),
|
||||||
("jungle", Biome::new(0_95, 0_90)),
|
("nether_wastes", Biome::new(200, 0)),
|
||||||
(
|
("ocean", Biome::new(50, 50)),
|
||||||
"lukewarm_ocean",
|
("old_growth_birch_forest", Biome::new(60, 60)),
|
||||||
Biome::new(0_50, 0_50).water([69, 173, 242]),
|
("old_growth_pine_taiga", Biome::new(30, 80)),
|
||||||
),
|
("old_growth_spruce_taiga", Biome::new(25, 80)),
|
||||||
("lush_caves", Biome::new(0_50, 0_50)),
|
(
|
||||||
(
|
"pale_garden",
|
||||||
"mangrove_swamp",
|
Biome::new(70, 80)
|
||||||
Biome::new(0_80, 0_90)
|
.foliage([135, 141, 118])
|
||||||
.water([58, 122, 106])
|
.grass([119, 130, 114])
|
||||||
.foliage([141, 177, 39])
|
.water([118, 136, 157]),
|
||||||
.modify(Swamp),
|
),
|
||||||
),
|
("plains", Biome::new(80, 40)),
|
||||||
("meadow", Biome::new(0_50, 0_80).water([14, 78, 207])),
|
("river", Biome::new(50, 50)),
|
||||||
("mushroom_fields", Biome::new(0_90, 1_00)),
|
("savanna", Biome::new(200, 0)),
|
||||||
("ocean", Biome::new(0_50, 0_50)),
|
("savanna_plateau", Biome::new(200, 0)),
|
||||||
("old_growth_birch_forest", Biome::new(0_60, 0_60)),
|
("small_end_islands", Biome::new(50, 50)),
|
||||||
("old_growth_pine_taiga", Biome::new(0_30, 0_80)),
|
("snowy_beach", Biome::new(5, 30).water([61, 87, 214])),
|
||||||
("old_growth_spruce_taiga", Biome::new(0_25, 0_80)),
|
("snowy_plains", Biome::new(0, 50)),
|
||||||
(
|
("snowy_slopes", Biome::new(-30, 90)),
|
||||||
"pale_garden",
|
("snowy_taiga", Biome::new(-50, 40).water([61, 87, 214])),
|
||||||
Biome::new(0_70, 0_80)
|
("soul_sand_valley", Biome::new(200, 0)),
|
||||||
.water([118, 136, 157])
|
("sparse_jungle", Biome::new(95, 80)),
|
||||||
.foliage([135, 141, 118])
|
("stony_peaks", Biome::new(100, 30)),
|
||||||
.grass([119, 130, 114]),
|
("stony_shore", Biome::new(20, 30)),
|
||||||
),
|
("sunflower_plains", Biome::new(80, 40)),
|
||||||
("plains", Biome::new(0_80, 0_40)),
|
(
|
||||||
("river", Biome::new(0_50, 0_50)),
|
"swamp",
|
||||||
("savanna", Biome::new(2_00, 0_00)),
|
Biome::new(80, 90)
|
||||||
("savanna_plateau", Biome::new(2_00, 0_00)),
|
.foliage([106, 112, 57])
|
||||||
("snowy_beach", Biome::new(0_05, 0_30).water([61, 87, 214])),
|
.modify(Swamp)
|
||||||
("snowy_plains", Biome::new(0_00, 0_50)),
|
.water([97, 123, 100]),
|
||||||
("snowy_slopes", Biome::new(-0_30, 0_90)),
|
),
|
||||||
("snowy_taiga", Biome::new(-0_50, 0_40).water([61, 87, 214])),
|
("taiga", Biome::new(25, 80)),
|
||||||
("sparse_jungle", Biome::new(0_95, 0_80)),
|
("the_end", Biome::new(50, 50)),
|
||||||
("stony_peaks", Biome::new(1_00, 0_30)),
|
("the_void", Biome::new(50, 50)),
|
||||||
("stony_shore", Biome::new(0_20, 0_30)),
|
("warm_ocean", Biome::new(50, 50).water([67, 213, 238])),
|
||||||
("sunflower_plains", Biome::new(0_80, 0_40)),
|
("warped_forest", Biome::new(200, 0)),
|
||||||
(
|
("windswept_forest", Biome::new(20, 30)),
|
||||||
"swamp",
|
("windswept_gravelly_hills", Biome::new(20, 30)),
|
||||||
Biome::new(0_80, 0_90)
|
("windswept_hills", Biome::new(20, 30)),
|
||||||
.water([97, 123, 100])
|
("windswept_savanna", Biome::new(200, 0)),
|
||||||
.foliage([106, 112, 57])
|
(
|
||||||
.modify(Swamp),
|
"wooded_badlands",
|
||||||
),
|
Biome::new(200, 0)
|
||||||
("taiga", Biome::new(0_25, 0_80)),
|
.foliage([158, 129, 77])
|
||||||
("the_void", Biome::new(0_50, 0_50)),
|
.grass([144, 129, 77]),
|
||||||
("warm_ocean", Biome::new(0_50, 0_50).water([67, 213, 238])),
|
),
|
||||||
("windswept_forest", Biome::new(0_20, 0_30)),
|
];
|
||||||
("windswept_gravelly_hills", Biome::new(0_20, 0_30)),
|
|
||||||
("windswept_hills", Biome::new(0_20, 0_30)),
|
|
||||||
("windswept_savanna", Biome::new(2_00, 0_00)),
|
|
||||||
(
|
|
||||||
"wooded_badlands",
|
|
||||||
Biome::new(2_00, 0_00)
|
|
||||||
.foliage([158, 129, 77])
|
|
||||||
.grass([144, 129, 77]),
|
|
||||||
),
|
|
||||||
// Nether
|
|
||||||
("basalt_deltas", Biome::new(2_00, 0_00)),
|
|
||||||
("crimson_forest", Biome::new(2_00, 0_00)),
|
|
||||||
("nether_wastes", Biome::new(2_00, 0_00)),
|
|
||||||
("soul_sand_valley", Biome::new(2_00, 0_00)),
|
|
||||||
("warped_forest", Biome::new(2_00, 0_00)),
|
|
||||||
// End
|
|
||||||
("end_barrens", Biome::new(0_50, 0_50)),
|
|
||||||
("end_highlands", Biome::new(0_50, 0_50)),
|
|
||||||
("end_midlands", Biome::new(0_50, 0_50)),
|
|
||||||
("small_end_islands", Biome::new(0_50, 0_50)),
|
|
||||||
("the_end", Biome::new(0_50, 0_50)),
|
|
||||||
]
|
|
||||||
};
|
|
||||||
|
|
|
@ -11,13 +11,15 @@ work.
|
||||||
- `extract.py`: Takes the block type information from `blocks.json` and texture data
|
- `extract.py`: Takes the block type information from `blocks.json` and texture data
|
||||||
from an unpacked Minecraft JAR, storing the result in `colors.json`
|
from an unpacked Minecraft JAR, storing the result in `colors.json`
|
||||||
- `generate.py`: Generates `block_types.rs` from `colors.json`
|
- `generate.py`: Generates `block_types.rs` from `colors.json`
|
||||||
|
- `biomes.py`: Generates `biomes.rs` from biome JSON files of an unpacked
|
||||||
|
Minecraft JAR
|
||||||
- `sign_textures.py`: Generates all needed sign graphics from Minecraft assets
|
- `sign_textures.py`: Generates all needed sign graphics from Minecraft assets
|
||||||
|
|
||||||
In addition to these scripts, the JSON processor *jq* is a useful tool to work
|
In addition to these scripts, the JSON processor *jq* is a useful tool to work
|
||||||
with MinedMap's resource metadata.
|
with MinedMap's resource metadata.
|
||||||
|
|
||||||
|
|
||||||
## How to add support for block IDs of a new Minecraft version
|
## How to add support for block IDs and biomes of a new Minecraft version
|
||||||
|
|
||||||
1. Download the Minecraft version you want to support as well as the previous
|
1. Download the Minecraft version you want to support as well as the previous
|
||||||
version currently supported by MinedMap. You can use the Minecraft launcher
|
version currently supported by MinedMap. You can use the Minecraft launcher
|
||||||
|
@ -69,6 +71,17 @@ with MinedMap's resource metadata.
|
||||||
cargo fmt --all
|
cargo fmt --all
|
||||||
```
|
```
|
||||||
|
|
||||||
|
8. Update the source code for new biome data:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
./biomes.py data/new ../crates/resource/src/biomes.rs
|
||||||
|
cargo fmt --all
|
||||||
|
```
|
||||||
|
|
||||||
|
After regenerating, check if only new biomes were added. If entries
|
||||||
|
got removed, biomes may have been renamed or merged, requiring updates
|
||||||
|
to the alias list in `crates/resource/src/legacy_biomes.rs`.
|
||||||
|
|
||||||
After the update, the new version should be tested with old savegames (both
|
After the update, the new version should be tested with old savegames (both
|
||||||
before and after migration by the new version) as well as newly generated
|
before and after migration by the new version) as well as newly generated
|
||||||
worlds. Use creative mode to add the new block types to your test world.
|
worlds. Use creative mode to add the new block types to your test world.
|
||||||
|
|
70
resource/biomes.py
Executable file
70
resource/biomes.py
Executable file
|
@ -0,0 +1,70 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
if len(sys.argv) != 3:
|
||||||
|
sys.exit('Usage: biomes.py <data directory> <biomes.rs>')
|
||||||
|
|
||||||
|
biomes = {}
|
||||||
|
|
||||||
|
for file in os.scandir(os.path.join(sys.argv[1], 'data/minecraft/worldgen/biome')):
|
||||||
|
(name, ext) = os.path.splitext(file.name)
|
||||||
|
if ext != '.json':
|
||||||
|
continue
|
||||||
|
with open(file) as f:
|
||||||
|
data = json.load(f)
|
||||||
|
biomes[name] = {
|
||||||
|
'downfall': data['downfall'],
|
||||||
|
'temperature': data['temperature'],
|
||||||
|
'foliage_color': data['effects'].get('foliage_color'),
|
||||||
|
'grass_color': data['effects'].get('grass_color'),
|
||||||
|
'grass_color_modifier': data['effects'].get('grass_color_modifier'),
|
||||||
|
'water_color': data['effects'].get('water_color'),
|
||||||
|
}
|
||||||
|
|
||||||
|
def color(v):
|
||||||
|
return f'[{v>>16}, {(v>>8)&0xff}, {v&0xff}]'
|
||||||
|
|
||||||
|
# Converts the snake_case grass color modifier to CamelCase
|
||||||
|
def modify(v):
|
||||||
|
return ''.join([s.capitalize() for s in v.split('_')])
|
||||||
|
|
||||||
|
def gen_biome(name, info, f):
|
||||||
|
temp = round(100*info['temperature'])
|
||||||
|
downfall = round(100*info['downfall'])
|
||||||
|
foliage_color = info['foliage_color']
|
||||||
|
grass_color = info['grass_color']
|
||||||
|
grass_color_modifier = info['grass_color_modifier']
|
||||||
|
water_color = info['water_color']
|
||||||
|
|
||||||
|
print(f'\t("{name}", Biome::new({temp}, {downfall})', file=f)
|
||||||
|
|
||||||
|
if foliage_color is not None:
|
||||||
|
print(f'\t\t.foliage({color(foliage_color)})', file=f)
|
||||||
|
if grass_color is not None:
|
||||||
|
print(f'\t\t.grass({color(grass_color)})', file=f)
|
||||||
|
if grass_color_modifier is not None:
|
||||||
|
print(f'\t\t.modify({modify(grass_color_modifier)})', file=f)
|
||||||
|
if water_color is not None and water_color != 0x3f76e4:
|
||||||
|
print(f'\t\t.water({color(water_color)})', file=f)
|
||||||
|
|
||||||
|
print('\t),', file=f)
|
||||||
|
|
||||||
|
with open(sys.argv[2], 'w') as f:
|
||||||
|
print('//! Biome data', file=f);
|
||||||
|
print('//!', file=f);
|
||||||
|
print('//! This file is generated using resource/biomes.py, do not edit', file=f);
|
||||||
|
print('', file=f)
|
||||||
|
print('use super::*;', file=f)
|
||||||
|
print('use BiomeGrassColorModifier::*;', file=f)
|
||||||
|
print('', file=f)
|
||||||
|
print('/// List if known biomes and their properties', file=f);
|
||||||
|
print('pub const BIOMES: &[(&str, Biome)] = &[', file=f)
|
||||||
|
|
||||||
|
for name in sorted(biomes):
|
||||||
|
gen_biome(name, biomes[name], f)
|
||||||
|
|
||||||
|
print('];', file=f)
|
Loading…
Add table
Reference in a new issue