00ll00 пре 6 година
родитељ
комит
c8e4cc1560

+ 4 - 4
data/item/functions/shop/buy_apple1.mcfunction

@@ -1,16 +1,16 @@
-# 金苹果 (5 gb)
+# 金苹果 (4 gi)
 # 触发器ID 1
 execute unless entity @s[scores={shop_apple=0..}] run scoreboard players set @s shop_apple 0
 tag @s remove canbuy
-tag @s[scores={shop_apple=..0,gold=405..}] add canbuy
+tag @s[scores={shop_apple=..0,gold=36..}] add canbuy
 
 tellraw @s[scores={shop_apple=1..}] ["",{"text":">> ","color":"aqua","bold":true},{"text":"你已经购买了这个物品了!","color":"aqua"}]
-tellraw @s[scores={shop_apple=..0,gold=..404}] ["",{"text":">> ","color":"red","bold":true},{"text":"你没有足够的金块来购买这个物品!","color":"red"}]
+tellraw @s[scores={shop_apple=..0,gold=..35}] ["",{"text":">> ","color":"red","bold":true},{"text":"你没有足够的金块来购买这个物品!","color":"red"}]
 
 tellraw @s[tag=canbuy] ["",{"text":">> ","color":"green","bold":true},"你购买了 ",{"text":"生命果","color":"green"}]
 execute as @s[tag=canbuy] run tellraw @a[tag=!canbuy] ["",{"text":">> ","color":"green","bold":true},{"selector": "@s","color":"green"}," 购买了 ",{"text":"生命果","color":"green"}]
 scoreboard players add @s[tag=canbuy] shop_apple 1
-scoreboard players remove @s[tag=canbuy] gold 405
+scoreboard players remove @s[tag=canbuy] gold 36
 
 execute as @s[tag=!canbuy] at @s run function lib:sounds/error
 execute as @s[tag=canbuy] at @s run function lib:sounds/levelup

+ 18 - 0
data/item/functions/shop/buy_apple2.mcfunction

@@ -0,0 +1,18 @@
+# 附魔金苹果 (1 gb)
+# 触发器ID 2
+execute unless entity @s[scores={shop_apple=0..}] run scoreboard players set @s shop_apple 0
+tag @s remove canbuy
+tag @s[scores={shop_apple=1,gold=81..}] add canbuy
+
+tellraw @s[scores={shop_apple=1..}] ["",{"text":">> ","color":"aqua","bold":true},{"text":"你已经购买了这个物品了!","color":"aqua"}]
+tellraw @s[scores={shop_apple=..0,gold=..80}] ["",{"text":">> ","color":"red","bold":true},{"text":"你没有足够的金块来购买这个物品!","color":"red"}]
+
+tellraw @s[tag=canbuy] ["",{"text":">> ","color":"green","bold":true},"你购买了 ",{"text":"附魔生命果","color":"green"}]
+execute as @s[tag=canbuy] run tellraw @a[tag=!canbuy] ["",{"text":">> ","color":"green","bold":true},{"selector": "@s","color":"green"}," 购买了 ",{"text":"附魔生命果","color":"green"}]
+scoreboard players add @s[tag=canbuy] shop_apple 1
+scoreboard players remove @s[tag=canbuy] gold 81
+
+execute as @s[tag=!canbuy] at @s run function lib:sounds/error
+execute as @s[tag=canbuy] at @s run function lib:sounds/levelup
+
+execute as @s[tag=canbuy] run function item:shop/refresh_gold

+ 7 - 0
data/item/functions/shop/check.mcfunction

@@ -0,0 +1,7 @@
+#as player
+execute if score @s buy_trigger matches 1 run function item:shop/buy_apple1
+execute if score @s buy_trigger matches 2 run function item:shop/buy_apple2
+execute if score @s buy_trigger matches 3 run function item:shop/buy_armor1
+execute if score @s buy_trigger matches 4 run function item:shop/buy_armor2
+
+scoreboard players set @s buy_trigger 0

+ 3 - 0
data/item/functions/tick2.mcfunction

@@ -7,3 +7,6 @@ execute as @a if data entity @s Inventory[{"tag":{"bonus_new":1b}}] run function
 
 # 检测玩家第九格锁定
 execute if score $state mem matches 1.. as @a run function item:disable_slot/check_slot
+
+# 检查购买物品
+execute as @a run function item:shop/check

+ 3 - 0
data/ltw/functions/state/0/player_enter.mcfunction

@@ -10,6 +10,9 @@ attribute @s generic.max_health base set 20
 xp set @s 0 points
 xp set @s 0 levels
 
+# 开启触发器
+scoreboard players enable @s buy_trigger
+
 # 状态效果
 effect clear @s
 effect give @s saturation 1000000 0 true