call_each.mcfunction 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # 处理单个奖励物品
  2. # as player
  3. # 获取当前物品
  4. data modify storage item:bonus item set from storage item:bonus item_buff[0]
  5. data remove storage item:bonus item_buff[0]
  6. # 播放音效
  7. function lib:sounds/hit
  8. # 显示拾取提示(获得积分的提示由 add_score 显示,获得随机物品则该物品不显示)
  9. execute unless data storage item:bonus item.tag.bonus_add_score unless data storage item:bonus item.tag.bonus_stole_score unless data storage item:bonus item.tag.bonus_gold unless data storage item:bonus item.tag.bonus_random_bonus[0] run tellraw @a ["",{"text": ">> ","color":"aqua","bold": true},{"selector": "@s","color":"aqua"}," 获得了 ",{"nbt": "item.tag.item_name","storage":"item:bonus","interpret": true}]
  10. # 如果有 clean_inventory 标签则清空物品栏
  11. execute if data storage item:bonus item.tag{"clean_inventory":1b} run tellraw @a ["",{"text": ">> ","color":"red","bold": true},{"selector": "@s","color":"red"}," 的物品栏被清空了……"]
  12. execute if data storage item:bonus item.tag{"clean_inventory":1b} run clear @s #item:non_game
  13. # 如果有 return 标签则退回物品
  14. execute if data storage item:bonus item.tag{"bonus_return":1b} run function item:bonus_item/return_item
  15. # 如果有 add_score 标签则增加积分
  16. execute if data storage item:bonus item.tag.bonus_add_score run function item:bonus_item/add_score
  17. # 如果有 give_items 标签则给予物品
  18. execute if data storage item:bonus item.tag.bonus_give_items[0] run function item:bonus_item/give_items
  19. # 如果有 random_bonus 标签则返还随机物品
  20. execute if data storage item:bonus item.tag.bonus_random_bonus[0] run function item:bonus_item/random_bonus
  21. # 如果有 random_bonus 标签则偷分
  22. execute if data storage item:bonus item.tag.bonus_stole_score run function item:bonus_item/stole_score
  23. # 如果有 random_bonus 标签则给予金粒
  24. execute if data storage item:bonus item.tag.bonus_gold run function item:bonus_item/gold
  25. # 执行特定函数
  26. execute if score $state mem matches 5 if score $mini_type mem matches 1 run function mini:parkour/pickup
  27. execute if score $state mem matches 7 run function item:bonus_item/pickup_1
  28. # 处理下一个
  29. execute if data storage item:bonus item_buff[0] run function item:bonus_item/call_each