player_lose_heart.mcfunction 895 B

1234567891011121314151617
  1. # 玩家失去一条命时调用此函数
  2. # 检测不死图腾
  3. execute if score @s mini_heart matches 1 if entity @s[nbt={SelectedItem:{id:"minecraft:totem_of_undying"}}] run tag @s add have_totem
  4. execute if score @s mini_heart matches 1 if entity @s[nbt={Inventory:[{Slot:-106b,id:"minecraft:totem_of_undying"}]}] run tag @s add have_totem
  5. execute if entity @s[tag=have_totem] run effect clear @s resistance
  6. execute if entity @s[tag=have_totem] run effect give @s instant_damage 1 10 true
  7. # schedule function mini:main/lose_heart_effect 1t
  8. # 现在触发图腾会默认清除效果了
  9. # 减少命
  10. execute if score @s[tag=!have_totem] mini_heart matches 1.. run scoreboard players remove @s mini_heart 1
  11. execute at @s run function lib:sounds/hurt
  12. # 计算血量
  13. function mini:main/player_max_health
  14. # 判定失败
  15. execute if score @s mini_heart matches 0 run function mini:main/player_failed