世界生成
Minecraft 将世界生成划分为了若干个阶段,其中模组开发者们经常关注的阶段有下列几个:
- 生物群系生成:游戏会在这一阶段中决定世界的每一个位置上都是什么生物群系。
- 地形生成:游戏会在这一阶段中决定世界的整体地势地貌。
- 地表生成:游戏会在这一阶段中根据生物群系等信息,为光秃秃的地表覆盖上一层「衣服」,例如沙漠的沙子、平原的草方块等
- 大型结构生成:游戏会在这一阶段中随机放置少量大型建筑(村庄、要塞、神殿、等)
- 地物生成:游戏会在这一阶段中随机放置小型的地表、地下装饰,如树木、竹子、大型蘑菇、晶洞、各类矿石等。
我们接下来将通过几个实例来说明「什么时候该用什么」。
生成矿物,树木,或是···
由于大部分地物都可以使用数据包定制,所以配置地物本身不再赘述,此处仅推荐一个工具用于制作地物。
可能已经有读者尝试过并感到一头雾水:怎么把他们加到已有的生物群系里而不是必须要重新写一个生物群系?
得益于使用的是 forge,我们可以使用 net.minecraftforge.common.world.BiomeModifier
对已有的生物群系进行更改,参照已有的实现类,我们将使用 AddFeaturesBiomeModifier
。
他们将以这样的格式组织:
xiaozhong
├─ forge
│ └─ biome_modifier
│ └─ add_tree.json
└─ worldgen
├─ configured_feature
│ └─ c_gold_tree.json
└─ placed_feature
└─ gold_tree.json
- add_tree
- c_gold_tree
- gold_tree
xiaozhong/forge/biome_modifier/add_tree.json
{
"type": "forge:add_features",
"biomes": "#minecraft:is_forest",
"features": "xiaozhong:gold_tree",
"step": "vegetal_decoration"
}
xiaozhong/worldgen/configured_feature/c_gold_tree.json
{
"type": "minecraft:tree",
"config": {
"minimum_size": {
"type": "minecraft:two_layers_feature_size"
},
"dirt_provider": {
"type": "minecraft:simple_state_provider",
"state": {
"Name": "minecraft:stone"
}
},
"trunk_provider": {
"type": "minecraft:simple_state_provider",
"state": {
"Name": "minecraft:blackstone"
}
},
"foliage_provider": {
"type": "minecraft:simple_state_provider",
"state": {
"Name": "minecraft:glowstone"
}
},
"trunk_placer": {
"type": "minecraft:straight_trunk_placer",
"base_height": 5,
"height_rand_a": 2,
"height_rand_b": 0
},
"foliage_placer": {
"type": "minecraft:blob_foliage_placer",
"radius": 2,
"offset": 0,
"height": 3
},
"decorators": []
}
}
xiaozhong/worldgen/placed_feature/gold_tree.json
{
"feature": "xiaozhong:c_gold_tree",
"placement": [
{
"type": "minecraft:count",
"count": {
"type": "minecraft:weighted_list",
"distribution": [
{
"weight": 9,
"data": 10
},
{
"weight": 1,
"data": 11
}
]
}
},
{
"type": "minecraft:in_square"
},
{
"type": "minecraft:surface_water_depth_filter",
"max_water_depth": 0
},
{
"type": "minecraft:heightmap",
"heightmap": "OCEAN_FLOOR"
},
{
"type": "minecraft:biome"
},
{
"type": "minecraft:block_predicate_filter",
"predicate": {
"type": "minecraft:would_survive",
"state": {
"Name": "minecraft:birch_sapling",
"Properties": {
"stage": "0"
}
}
}
}
]
}
最终我们会在游戏内看到这样的内容: