player_death.mcfunction 1013 B

12345678910111213141516171819202122
  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 0 true
  6. # 处理玩家掉落物品
  7. execute at @s as @e[type=item,distance=..100] store result score @s temp run data get entity @s Age
  8. execute at @s store result score #total_drop temp run tag @e[type=item,scores={temp=..5}] add death_drop
  9. execute as @e[type=item,tag=death_drop] run data modify entity @s Invulnerable set value 1b
  10. scoreboard players reset @e[type=item] temp
  11. # 单独处理钻石还没写
  12. function mini:diamond/game/drop_diamond
  13. # 掉落数量向上取整
  14. scoreboard players add #total_drop temp 1
  15. scoreboard players operation #total_drop temp /= #const_2 mem
  16. execute if score #total_drop temp matches 1.. run function mini:diamond/game/item_drop
  17. # 其余物品丢回背包
  18. tag @s add dead_player
  19. execute as @e[type=item,tag=death_drop] run data modify entity @s Thrower set from entity @a[tag=dead_player,limit=1] UUID
  20. tag @s remove dead_player