call.mcfunction 1.1 KB

123456789101112131415161718192021222324
  1. # 当玩家拾取到奖励物品时触发
  2. # as player
  3. # 将玩家拾取到的原物品替换到原点的唱片机里
  4. data modify block 0 0 0 RecordItem set from entity @s Inventory[{"tag":{"bonus_new":1b}}]
  5. clear @s #item:bonus{"bonus_new":1b}
  6. # 播放音效
  7. function lib:sounds/hit
  8. # 显示拾取提示(获得得分的提示由 add_score 显示)
  9. execute unless data block 0 0 0 RecordItem.tag.bonus_add_score run tellraw @a ["",{"text": ">> ","color":"aqua","bold": true},{"selector": "@s","color":"aqua"}," 获得了 ",{"nbt": "RecordItem.tag.item_name","block": "0 0 0","interpret": true}]
  10. # 如果有 return 标签则退回物品(最先执行)
  11. execute if data block 0 0 0 RecordItem.tag{"bonus_return":1b} run function item:bonus_item/return_item
  12. # 如果有 add_score 标签则增加积分
  13. execute if data block 0 0 0 RecordItem.tag.bonus_add_score run function item:bonus_item/add_score
  14. # 如果有 give_items 标签则给予物品
  15. execute if data block 0 0 0 RecordItem.tag.bonus_give_items[0] run function item:bonus_item/give_items
  16. # 执行特定函数
  17. execute if score $state mem matches 7 run function item:bonus_item/pickup_1