TCT-Datapack/data/tctcoins/functions/cointodia.mcfunction

19 lines
1.2 KiB
Mcfunction

# Add exchg2 tag for players within distance with 10 coins minimum
execute as @a[distance=..5] run execute store result score @s tokenCount run clear @s minecraft:sunflower{ctcb:"certified"} 0
execute as @a[distance=..5] run execute if score @s tokenCount matches 10.. run tag @s add exchg2
# Save scores on monetary and player itself
execute as @a[tag=exchg2] run scoreboard players remove @e[type=minecraft:armor_stand,tag=monetary] diaStore 1
execute as @a[tag=exchg2] run scoreboard players remove @e[type=minecraft:armor_stand,tag=monetary] tokenCirculation 10
execute as @a[tag=exchg2] run scoreboard players add @s diaOuttake 1
# Clear coins and give diamond
execute as @a[tag=exchg2] run clear @s minecraft:sunflower{ctcb:"certified"} 10
give @a[tag=exchg2] minecraft:diamond 1
# Notify using tellraw of the results
tellraw @a[tag=exchg2] ["",{"text":"CTCB Exchange >> ","bold":true,"color":"dark_green"},{"text":"Exchanged 10 CraftyCoins for 1 diamond.","color":"white"}]
tellraw @a[distance=..5,tag=!exchg2] ["",{"text":"CTCB Exchange >> ","bold":true,"color":"dark_green"},{"text":"Could not exchange. ","bold":true,"color":"dark_red"},{"text":"Not enough CraftyCoins in your inventory.","color":"white"}]
# Remove exchange tag
tag @a[tag=exchg2] remove exchg2