player_death.mcfunction 1.0 KB

123456789101112131415161718192021222324
  1. say DEBUG: 触发mini:diamond/player_death
  2. # 执行重生方法
  3. function mini:diamond/game/respawn1
  4. # 复活特效
  5. execute as @a at @s run function lib:sounds/error
  6. effect give @s blindness 3 5 true
  7. effect give @s weakness 30 1
  8. # 处理玩家掉落物品
  9. execute at @s as @e[type=item,distance=..100] store result score @s temp run data get entity @s Age
  10. execute at @s store result score #total_drop temp run tag @e[type=item,scores={temp=..3}] add death_drop
  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. 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
  21. execute as @e[type=item,tag=death_drop] run function item:disable_throw
  22. tag @e[type=item] remove death_drop