player_death.mcfunction 1.6 KB

1234567891011121314151617181920212223242526272829
  1. # 执行重生方法
  2. function mini:trade/game/respawn1
  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 #emerald_count temp run clear @s emerald
  15. scoreboard players add #emerald_count temp 1
  16. execute at @e[type=armor_stand,tag=dead_marker,limit=1] run summon item ~ ~ ~ {Tags:["temp_emerald"],Item:{id:"minecraft:emerald",Count:1b},Glowing:1b}
  17. execute as @e[type=item,tag=temp_emerald,limit=1] store result entity @s Item.Count byte 0.5 run scoreboard players get #emerald_count temp
  18. tag @e[type=item,tag=temp_emerald,limit=1] remove temp_emerald
  19. # 随机槽位掉落
  20. function mini:trade/game/random_slot
  21. function mini:trade/game/pop_slot
  22. # 返还绿宝石
  23. scoreboard players remove #emerald_count temp 1
  24. scoreboard players operation #emerald_count temp /= #const_2 mem
  25. execute if score #emerald_count temp matches 1.. run function mini:trade/game/give_emerald
  26. # 删除marker
  27. kill @e[type=armor_stand,tag=dead_marker]