Minecraft 1.21:如何让Husk掉落带指定Loot表的可刷可疑沙?
问题:让Husk掉落的可疑沙带有正确的LootTable标签
问题背景
我正在制作Skyblock数据包,希望玩家能从怪物农场获取嗅探器相关物品,无需依赖海洋废墟结构。目前用命令方块能生成可放置且战利品表正常的可疑沙,但Husk掉落的可疑沙放置后无法刷出物品。
当前配置
Husk的战利品表(当前版本)
{ "type": "minecraft:entity", "pools": [{ "rolls": 1, "entries": [{ "type": "minecraft:item", "name": "minecraft:suspicious_sand", "functions": [{ "function": "minecraft:set_loot_table", "type": "minecraft:brushable_block", "name": "minecraft:archaeology/ocean_ruin_warm" }] }] }], "random_sequence": "minecraft:entities/husk" }
Husk掉落方块放置后的异常NBT
{ components: { "minecraft:container_loot": { loot_table: "minecraft:archaeology/ocean_ruin_warm" } }, x: 24, y: -23, z: 88, id: "minecraft:brushable_block" }
可生成正常方块的/give命令
/give @p minecraft:suspicious_sand[ minecraft:block_entity_data={ id: "minecraft:brushable_block", LootTable: "minecraft:archaeology/ocean_ruin_warm" } ]
正确放置后的目标NBT
{ LootTable: "minecraft:archaeology/ocean_ruin_warm", x: 24, y: -23, z: 89, id: "minecraft:brushable_block" }
解决方案
set_loot_table函数会自动使用新版组件式NBT(components字段),而可刷方块需要的是旧版直接挂载的LootTable标签。要解决这个问题,需改用set_nbt函数直接给物品添加BlockEntityTag标签,模拟/give命令的逻辑:
修改后的Husk战利品表:
{ "type": "minecraft:entity", "pools": [{ "rolls": 1, "entries": [{ "type": "minecraft:item", "name": "minecraft:suspicious_sand", "functions": [{ "function": "minecraft:set_nbt", "tag": "{BlockEntityTag:{id:\"minecraft:brushable_block\",LootTable:\"minecraft:archaeology/ocean_ruin_warm\"}}" }] }] }], "random_sequence": "minecraft:entities/husk" }
原理说明
set_nbt函数可直接给物品添加指定NBT标签,这里给可疑沙添加的BlockEntityTag对应/give命令里的block_entity_data,包含可刷方块必需的LootTable和id字段。- 该方法绕过了
set_loot_table的组件式转换,生成的物品NBT与/give命令完全一致,放置后会自动生成带有正确LootTable标签的方块实体,刷取时能正常触发战利品表。
内容的提问来源于stack exchange,提问作者Ash Ivory
相关产品推荐
相关产品推荐

