HerobrineXia 6 лет назад
Родитель
Сommit
6d7172e502

+ 2 - 7
data/ltw/functions/shop/refresh_gold.mcfunction

@@ -7,14 +7,9 @@ clear @s gold_nugget
 scoreboard players operation @s temp = @s gold
 scoreboard players operation @s temp /= #count_9 mem
 # 给予金锭
-execute if score @s temp matches 1.. at @s run summon item ~ ~ ~ {Item:{id:"gold_ingot",Count:1b},Tags:["score_item_ingot"],PickupDelay:0}
-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
-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
+execute if score @s temp matches 1.. at @s run function ltw:shop/summon_gold
 # 获取金粒数,存于 temp
 scoreboard players operation @s temp = @s gold
 scoreboard players operation @s temp %= #count_9 mem
 # 给予金粒
-execute if score @s temp matches 1.. at @s run summon item ~ ~ ~ {Item:{id:"gold_nugget",Count:1b},Tags:["score_item_nugget"],PickupDelay:0}
-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
-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
-# TODO : 给予指定数量的物品
+execute if score @s temp matches 1.. at @s run function ltw:shop/summon_nugget

+ 10 - 0
data/ltw/functions/shop/summon_gold.mcfunction

@@ -0,0 +1,10 @@
+# 给予金锭
+summon item ~ ~ ~ {Item:{id:"gold_ingot",Count:1b},Tags:["score_item"],PickupDelay:0}
+execute if score @s temp matches 1..64 store result entity @e[type=item,tag=score_item,limit=1] Item.Count byte 1 run scoreboard players get @s temp
+execute if score @s temp matches 65.. run data modify entity @e[type=item,tag=score_item,limit=1] Item.Count set value 64b 
+data modify entity @e[type=item,tag=score_item,limit=1] Owner set from entity @s UUID
+tag @e[type=item,tag=score_item] remove score_item
+scoreboard players remove @s temp 64
+execute if score @s temp matches 1.. run function ltw:shop/summon_gold
+
+

+ 10 - 0
data/ltw/functions/shop/summon_nugget.mcfunction

@@ -0,0 +1,10 @@
+# 给予金粒 
+summon item ~ ~ ~ {Item:{id:"gold_nugget",Count:1b},Tags:["score_item"],PickupDelay:0}
+execute if score @s temp matches 1..64 store result entity @e[type=item,tag=score_item,limit=1] Item.Count byte 1 run scoreboard players get @s temp
+execute if score @s temp matches 65.. run data modify entity @e[type=item,tag=score_item,limit=1] Item.Count set value 64b 
+data modify entity @e[type=item,tag=score_item,limit=1] Owner set from entity @s UUID
+tag @e[type=item,tag=score_item] remove score_item
+scoreboard players remove @s temp 64
+execute if score @s temp matches 1.. run function ltw:shop/summon_nugget
+
+