refresh_gold.mcfunction 1.2 KB

1234567891011121314151617181920
  1. # 刷新单个玩家背包中的金粒
  2. clear @s gold_ingot
  3. clear @s gold_nugget
  4. # 获取金锭数,存于 temp
  5. scoreboard players operation @s temp = @s gold
  6. scoreboard players operation @s temp /= #count_9 mem
  7. # 给予金锭
  8. execute if score @s temp matches 1.. run summon item ~ ~ ~ {Item:{id:"gold_ingot",Count:1b},Tags:["score_item_ingot"],PickupDelay:0}
  9. execute if score @s temp matches 1.. store result entity @e[type=item,tag=score_item_ingot,limit=1] Item.Count byte 1 run scoreboard players get @s temp
  10. execute if score @s temp matches 1.. run data modify entity @e[type=item,tag=score_item_ingot,limit=1] Owner set from entity @s UUID
  11. # 获取金粒数,存于 temp
  12. scoreboard players operation @s temp = @s gold
  13. scoreboard players operation @s temp %= #count_9 mem
  14. # 给予金粒
  15. execute if score @s temp matches 1.. run summon item ~ ~ ~ {Item:{id:"gold_nugget",Count:1b},Tags:["score_item_nugget"],PickupDelay:0}
  16. execute if score @s temp matches 1.. store result entity @e[type=item,tag=score_item_nugget,limit=1] Item.Count byte 1 run scoreboard players get @s temp
  17. execute if score @s temp matches 1.. run data modify entity @e[type=item,tag=score_item_nugget,limit=1] Owner set from entity @s UUID
  18. # TODO : 给予指定数量的物品