player_death.mcfunction 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 0.1 run scoreboard players get @s posX
  11. execute store result entity @e[type=armor_stand,tag=dead_marker,limit=1] Pos[1] double 0.1 run scoreboard players get @s posY
  12. execute store result entity @e[type=armor_stand,tag=dead_marker,limit=1] Pos[2] double 0.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 ~ ~0.2 ~ {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. execute store result score #raw_iron_count temp run clear @s raw_iron
  21. scoreboard players add #raw_iron_count temp 2
  22. execute if score #raw_iron_count temp matches 3.. at @e[type=armor_stand,tag=dead_marker,limit=1] run summon item ~-0.1 ~0.2 ~0.1 {Tags:["temp_raw_iron"],Item:{id:"minecraft:raw_iron",Count:1b},Glowing:1b}
  23. execute as @e[type=item,tag=temp_raw_iron,limit=1] store result entity @s Item.Count byte 0.33334 run scoreboard players get #raw_iron_count temp
  24. tag @e[type=item,tag=temp_raw_iron,limit=1] remove temp_raw_iron
  25. # 生成圆石物品
  26. execute store result score #cobblestone_count temp run clear @s cobblestone
  27. scoreboard players add #cobblestone_count temp 2
  28. execute if score #cobblestone_count temp matches 3.. at @e[type=armor_stand,tag=dead_marker,limit=1] run summon item ~0.1 ~0.2 ~0.1 {Tags:["temp_cobblestone"],Item:{id:"minecraft:cobblestone",Count:1b}}
  29. execute as @e[type=item,tag=temp_cobblestone,limit=1] store result entity @s Item.Count byte 0.33334 run scoreboard players get #cobblestone_count temp
  30. tag @e[type=item,tag=temp_cobblestone,limit=1] remove temp_cobblestone
  31. # 随机槽位掉落
  32. function mini:iron/game/random_slot
  33. function mini:iron/game/pop_slot
  34. # 返还剩余物品给玩家
  35. scoreboard players remove #iron_count temp 2
  36. scoreboard players operation #iron_count temp *= #2 mem
  37. scoreboard players operation #iron_count temp /= #3 mem
  38. execute if score #iron_count temp matches 1.. run function mini:iron/game/give_iron
  39. scoreboard players remove #raw_iron_count temp 2
  40. scoreboard players operation #raw_iron_count temp *= #2 mem
  41. scoreboard players operation #raw_iron_count temp /= #3 mem
  42. execute if score #raw_iron_count temp matches 1.. run function mini:iron/game/give_raw_iron
  43. scoreboard players remove #cobblestone_count temp 2
  44. scoreboard players operation #cobblestone_count temp *= #2 mem
  45. scoreboard players operation #cobblestone_count temp /= #3 mem
  46. execute if score #cobblestone_count temp matches 1.. run function mini:iron/game/give_cobblestone
  47. # 删除marker
  48. kill @e[type=armor_stand,tag=dead_marker]