player_death.mcfunction 1.1 KB

1234567891011121314151617181920212223
  1. # 执行重生方法
  2. function mini:diamond/game/respawn1
  3. # 复活特效
  4. execute as @a at @s run function lib:sounds/error
  5. effect give @s blindness 3 5 true
  6. effect give @s weakness 30 1
  7. # 处理玩家掉落物品
  8. execute at @s as @e[type=item,distance=..100] store result score @s temp run data get entity @s Age
  9. execute at @s store result score #total_drop temp run tag @e[type=item,scores={temp=..3}] add death_drop
  10. tellraw @a [{"selector":"@s"},{"text":"一共掉了"},{"score": {"name":"#total_drop","objective": "temp"}},{"text":"件物品"}]
  11. scoreboard players reset @e[type=item] temp
  12. # 单独处理钻石还没写
  13. # 掉落数量向上取整
  14. scoreboard players add #total_drop temp 1
  15. scoreboard players operation #total_drop temp /= #const_2 mem
  16. tellraw @a [{"selector":"@s"},{"text":"将掉落"},{"score": {"name":"#total_drop","objective": "temp"}},{"text":"件物品"}]
  17. execute if score #total_drop temp matches 1.. run function mini:diamond/game/item_drop
  18. # 其余物品丢回背包
  19. tag @s add dead_player
  20. execute as @e[type=item,tag=death_drop] run data modify entity @s Thrower set from entity @a[tag=dead_player,limit=1] UUID
  21. tag @s remove dead_player