Skip to content

Commit cfd9e0f

Browse files
committed
improve heart canisters counting
1 parent e6df0bd commit cfd9e0f

2 files changed

Lines changed: 9 additions & 22 deletions

File tree

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,14 @@
11
# gets called for every player with at least 1 heart canister item
22

33
# tier 1
4-
scoreboard players set $count_total gm4_heart_can 0
5-
data modify storage gm4_heart_cannisters:temp heart_cannister_data set value []
6-
data modify storage gm4_heart_cannisters:temp heart_cannister_data append from entity @s Inventory[{components:{"minecraft:custom_data":{gm4_heart_canister_tier:1b}}}]
7-
execute store result score $count_add gm4_heart_can run data get entity @s equipment.offhand{components:{"minecraft:custom_data":{gm4_heart_canister_tier:1b}}}.count
8-
scoreboard players operation $count_total gm4_heart_can += $count_add gm4_heart_can
9-
function gm4_heart_canisters:count_heart_canisters
10-
scoreboard players operation $count_total gm4_heart_can < $heart_cannister_cap gm4_heart_can
11-
scoreboard players operation @s gm4_heart_can += $count_total gm4_heart_can
4+
execute store result score @s gm4_heart_can if items entity @s container.* player_head[custom_data~{gm4_heart_canister_tier:1b}]
5+
execute store result score $count_add gm4_heart_can if items entity @s weapon.offhand player_head[custom_data~{gm4_heart_canister_tier:1b}]
6+
scoreboard players operation @s gm4_heart_can += $count_add gm4_heart_can
7+
scoreboard players operation @s gm4_heart_can < $heart_cannister_cap gm4_heart_can
128

139
# tier 2
14-
scoreboard players set $count_total gm4_heart_can 0
15-
data modify storage gm4_heart_cannisters:temp heart_cannister_data set value []
16-
data modify storage gm4_heart_cannisters:temp heart_cannister_data append from entity @s Inventory[{components:{"minecraft:custom_data":{gm4_heart_canister_tier:2b}}}]
17-
execute store result score $count_add gm4_heart_can run data get entity @s equipment.offhand{components:{"minecraft:custom_data":{gm4_heart_canister_tier:2b}}}.count
18-
scoreboard players operation $count_total gm4_heart_can += $count_add gm4_heart_can
19-
function gm4_heart_canisters:count_heart_canisters
20-
scoreboard players operation $count_total gm4_heart_can < $heart_cannister_cap gm4_heart_can
21-
scoreboard players operation @s gm4_heart_can += $count_total gm4_heart_can
10+
execute store result score $count_tier2 gm4_heart_can if items entity @s container.* player_head[custom_data~{gm4_heart_canister_tier:2b}]
11+
execute store result score $count_add gm4_heart_can if items entity @s weapon.offhand player_head[custom_data~{gm4_heart_canister_tier:2b}]
12+
scoreboard players operation $count_tier2 gm4_heart_can += $count_add gm4_heart_can
13+
scoreboard players operation $count_tier2 gm4_heart_can < $heart_cannister_cap gm4_heart_can
14+
scoreboard players operation @s gm4_heart_can += $count_tier2 gm4_heart_can

gm4_heart_canisters/data/gm4_heart_canisters/function/count_heart_canisters.mcfunction

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)