player_death.mcfunction 1.6 KB

123456789101112131415161718192021222324252627282930
  1. # 执行重生方法
  2. function mini:iron/game/respawn
  3. # 复活特效
  4. execute as @a at @s run function lib:sounds/error
  5. effect give @s blindness 3 0 true
  6. # 处理玩家掉落物品
  7. # 获取玩家死亡位置
  8. kill @e[type=armor_stand,tag=dead_marker]
  9. summon armor_stand 1000 0 5000 {Marker:1b,Invisible:1b,Invulnerable:1b,Small:1b,NoGravity:1b,Tags:["dead_marker"]}
  10. execute store result entity @e[type=armor_stand,tag=dead_marker,limit=1] Pos[0] double 1 run scoreboard players get @s posX
  11. execute store result entity @e[type=armor_stand,tag=dead_marker,limit=1] Pos[1] double 1 run scoreboard players get @s posY
  12. execute store result entity @e[type=armor_stand,tag=dead_marker,limit=1] Pos[2] double 1 run scoreboard players get @s posZ
  13. # 生成铁锭物品
  14. execute store result score #iron_count temp run clear @s iron_ingot
  15. scoreboard players add #iron_count temp 2
  16. execute if score #iron_count temp matches 3.. at @e[type=armor_stand,tag=dead_marker,limit=1] run summon item ~ ~ ~ {Tags:["temp_iron"],Item:{id:"minecraft:iron_ingot",Count:1b},Glowing:1b}
  17. execute as @e[type=item,tag=temp_iron,limit=1] store result entity @s Item.Count byte 0.33334 run scoreboard players get #iron_count temp
  18. tag @e[type=item,tag=temp_iron,limit=1] remove temp_iron
  19. # 随机槽位掉落
  20. function mini:iron/game/random_slot
  21. function mini:iron/game/pop_slot
  22. # 返还剩余铁锭给玩家
  23. scoreboard players remove #iron_count temp 2
  24. scoreboard players operation #iron_count temp *= #2 mem
  25. scoreboard players operation #iron_count temp /= #3 mem
  26. execute if score #iron_count temp matches 1.. run function mini:iron/game/give_iron
  27. # 删除marker
  28. kill @e[type=armor_stand,tag=dead_marker]