refresh_gold.mcfunction 1007 B

123456789101112131415161718192021222324
  1. # 刷新单个玩家背包中的金粒
  2. execute unless entity @s[scores={gold=0..}] run scoreboard players set @s gold 0
  3. execute unless entity @s[scores={gold=0..}] run scoreboard players set @s gold_total 0
  4. clear @s gold_block
  5. clear @s gold_ingot
  6. clear @s gold_nugget
  7. # 获取金块数,存于 temp
  8. scoreboard players operation @s temp = @s gold
  9. scoreboard players operation @s temp /= #const_81 mem
  10. # 给予金块
  11. execute if score @s temp matches 1.. at @s run function item:shop/summon_gold_block
  12. # 获取金锭数,存于 temp
  13. scoreboard players operation @s temp = @s gold
  14. scoreboard players operation @s temp %= #const_81 mem
  15. scoreboard players operation @s temp /= #const_9 mem
  16. # 给予金锭
  17. execute if score @s temp matches 1.. at @s run function item:shop/summon_gold
  18. # 获取金粒数,存于 temp
  19. scoreboard players operation @s temp = @s gold
  20. scoreboard players operation @s temp %= #const_9 mem
  21. # 给予金粒
  22. execute if score @s temp matches 1.. at @s run function item:shop/summon_nugget