添加战利品表、生成规则与合成配方
接下来,我们将通过添加基础机制来增强自定义幽灵实体:
战利品表
首先让幽灵死亡时掉落灵质,创建以下文件:
BP/loot_tables/entities/ghost.json
json
{
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "item",
"name": "wiki:ectoplasm",
"weight": 1,
"functions": [
{
"function": "set_count",
"count": {
"min": 1,
"max": 3
}
}
]
}
]
}
]
}- 战利品表由
"pools"组成,每个池定义不同的战利品。一个池包含三部分:"rolls"(随机次数)、"entries"(条目)和可选的"conditions"(条件,本指南不作讨论)。详细了解条件请参阅战利品表。 "rolls"定义从"entries"中随机选择物品的次数。"entries"定义可供选择的物品列表,每次roll会从中选取新物品。"type"指定选择类型,可设为"item"(物品)或"loot_table"(其他战利品表)。"name"设置带命名空间的物品ID,决定具体掉落物。"weight"(可选)决定物品被选中的概率权重(默认1)。当存在多个条目时,可通过调整权重改变概率。"functions"提供强大的物品定制功能,可添加附魔、设置物品名称或数量。这里使用"set_count"函数,通过"count"属性设置掉落数量的最小值和最大值。
更多战利品表信息请参阅进阶指南:战利品表!
生成规则
接下来让幽灵在沙漠夜间生成:
BP/spawn_rules/ghost.json
json
{
"format_version": "1.8.0",
"minecraft:spawn_rules": {
"description": {
"identifier": "wiki:ghost",
"population_control": "monster"
},
"conditions": [
{
"minecraft:spawns_on_surface": {},
"minecraft:brightness_filter": {
"min": 0,
"max": 7,
"adjust_for_weather": true
},
"minecraft:difficulty_filter": {
"min": "easy",
"max": "hard"
},
"minecraft:weight": {
"default": 80
},
"minecraft:herd": {
"min_size": 1,
"max_size": 3
},
"minecraft:biome_filter": {
"test": "has_biome_tag",
"operator": "==",
"value": "desert"
}
}
]
}
}"format_version"功能已知。"minecraft:spawn_rules"内定义生成规则。"description"设置基础属性:"identifier"指定应用实体,"population_control"限制生成数量池。"conditions"定义生成条件(详见原版生成规则):"spawns_on_surface":仅在地表生成"brightness_filter":光照等级范围("adjust_for_weather"为true时忽略天气影响)"difficulty_filter":所需游戏难度"weight":生成频率权重(值越高生成越频繁)"herd":单次生成数量范围"biome_filter":限定沙漠生物群系生成
更多生成规则请参阅:原版生成规则
合成配方
最后作为配方入门,我们将灵质设置为可合成粘液块:
BP/recipes/ectoplasm_slime_blocks.json
json
{
"format_version": "1.12.0",
"minecraft:recipe_shaped": {
"description": {
"identifier": "wiki:ectoplasm_slime_block"
},
"tags": ["crafting_table"],
"pattern": ["###", "###", "###"],
"key": {
"#": {
"item": "wiki:ectoplasm"
}
},
"result": {
"item": "minecraft:slime"
}
}
}"format_version"功能已知"recipe_shaped"表示配方需要固定排列(其他类型详见配方指南)"description"中设置配方ID"tags"指定可用工作台列表(1.16.100+支持自定义工作台)"pattern"定义合成格布局,#符号对应"key"中定义的物品(此处全用"wiki:ectoplasm"填充3x3网格)"result"指定输出物品
更多配方知识请访问:配方系统!
学习成果
你已掌握:
- 创建战利品表并设置生物掉落物
- 配置生物生成规则
- 制作新合成配方
当前进度
已完成步骤:
恭喜!你已完成本指南并创建了第一个附加包。🎉









