# 生物生成
# 概述
开发者可以使用原版addon的spawn_rules
功能控制自定义维度中的生物生成。
# spawn_rules使用方法
1.在addon的bevavior目录下新增spawn_rules文件夹
2.创建一个json文件并命名,如example.json,例子:
{
"format_version": "1.8.0",
"minecraft:spawn_rules": {
"description": {
"identifier": "minecraft:netease_example",
"population_control": "ambient"
},
"conditions": [
{
"minecraft:spawns_underground": {},
"minecraft:brightness_filter": {
"min": 0,
"max": 4,
"adjust_for_weather": true
},
"minecraft:height_filter": {
"min": 0,
"max": 63
},
"minecraft:weight": {
"default": 10
},
"minecraft:herd": {
"min_size": 2,
"max_size": 2
},
"minecraft:density_limit": {
"surface": 5
},
"minecraft:biome_filter": {
"test": "has_biome_tag", "operator":"==", "value": "animal"
}
}
]
}
}
description参数解释
参数 | 类型 | 解释 |
---|---|---|
description | str | 该spawn rule的identifier,格式为namespace:name |
population_control | str | 生成生物的种类,每一种类都有生成个数的限制,可选的值为: animal monster water_animal villager ambient cat pillager |
conditions参数解释
Name | Description |
---|---|
minecraft:spawns_on_surface | 允许mob在地上生成 |
minecraft:spawns_underwater | 允许mob在水里生成 |
minecraft:brightness_filter | 允许mob生成的光照条件 |
minecraft:weight | mob生成的权重,默认为0 |
minecraft:difficulty_filter | mob生成的困难模式 |
minecraft:herd | herd的大小 |
minecraft:biome_filter | 允许mob生成的biome |
# 自定义群系的spawn_rules
利用condition中的minecraft:biome_filter过滤自定义群系的tag,例如群系开发模板自带的dm3等tag,或者其他自定义tag。
# demo解释
示例CustomBiomesMod中,对dm4于dm5两个自定义维度的生物生成做了一些调整。
dm4
使北极熊仅中该维度中生成,不会在其他维度的冰原群系生成。
在polar_bear的spawn_rules中设置为仅在含dm4标签的群系生成:
(见customBiomesBehaviorPack/spawn_rules/polar_bear.json)
"minecraft:biome_filter": [ ..., {"test": "has_biome_tag", "operator":"==", "value": "dm4"} ]
dm5
在冰原上不会生成兔子,会生成3倍大小的北极熊。
重写rabbit的spawn_rules,使其不在带dm5标签的群系生成:
(见customBiomesBehaviorPack/spawn_rules/rabbit.json)
"minecraft:biome_filter": { "any_of": [ { "all_of": [ { "test": "has_biome_tag", "operator":"==", "value": "taiga"}, { "test": "has_biome_tag", "operator":"!=", "value": "mega"} ] }, { "all_of": [ {"test": "is_snow_covered", "operator":"==", "value": true}, {"test": "has_biome_tag", "operator":"!=", "value": "dm5"} //添加这一句 ] }, {"test": "has_biome_tag", "operator":"==", "value":"desert"} ] }
新建一个名为neteasebiomes:dm5_polar_bear的自定义生物,除了设置为3倍大小外与原版北极熊一致
(见customBiomesBehaviorPack/entities/polar_bear.json,及customBiomesResourcePack/entity/dm5_polar_bear.entity.json)
"minecraft:scale": { "value": 3.0 },
然后为其配置spawn_rules,使其仅在dm5中生成
(见customBiomesBehaviorPack/spawn_rules/dm5_polar_bear.json)
"minecraft:biome_filter": [ ... , {"test": "has_biome_tag", "operator":"==", "value": "dm5"} ]