Skip to content

Commit 8657ac8

Browse files
authored
1.21.5 heart canisters update (#1122)
* update heart canisters * improve heart canisters counting * update heart canister tests * meaningless change to make tests run
1 parent d675ade commit 8657ac8

10 files changed

Lines changed: 44 additions & 30 deletions

File tree

gm4_heart_canisters/data/gm4_heart_canisters/function/apply_health_boost.mcfunction

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,9 @@
22
# run from check_heart_canisters
33
attribute @s minecraft:max_health modifier remove minecraft:38a576e7-341b-46ed-a9e3-7b7291beae72
44

5-
attribute @s[scores={gm4_heart_can=1}] minecraft:max_health modifier add minecraft:38a576e7-341b-46ed-a9e3-7b7291beae72 4 add_value
6-
attribute @s[scores={gm4_heart_can=2}] minecraft:max_health modifier add minecraft:38a576e7-341b-46ed-a9e3-7b7291beae72 8 add_value
7-
attribute @s[scores={gm4_heart_can=3}] minecraft:max_health modifier add minecraft:38a576e7-341b-46ed-a9e3-7b7291beae72 12 add_value
8-
attribute @s[scores={gm4_heart_can=4}] minecraft:max_health modifier add minecraft:38a576e7-341b-46ed-a9e3-7b7291beae72 16 add_value
9-
attribute @s[scores={gm4_heart_can=5}] minecraft:max_health modifier add minecraft:38a576e7-341b-46ed-a9e3-7b7291beae72 20 add_value
10-
attribute @s[scores={gm4_heart_can=6}] minecraft:max_health modifier add minecraft:38a576e7-341b-46ed-a9e3-7b7291beae72 24 add_value
11-
attribute @s[scores={gm4_heart_can=7}] minecraft:max_health modifier add minecraft:38a576e7-341b-46ed-a9e3-7b7291beae72 28 add_value
12-
attribute @s[scores={gm4_heart_can=8}] minecraft:max_health modifier add minecraft:38a576e7-341b-46ed-a9e3-7b7291beae72 32 add_value
13-
attribute @s[scores={gm4_heart_can=9}] minecraft:max_health modifier add minecraft:38a576e7-341b-46ed-a9e3-7b7291beae72 36 add_value
14-
attribute @s[scores={gm4_heart_can=10}] minecraft:max_health modifier add minecraft:38a576e7-341b-46ed-a9e3-7b7291beae72 40 add_value
5+
execute store result storage gm4_heart_cannisters:temp amount int 4 run scoreboard players get @s gm4_heart_can
6+
function gm4_heart_canisters:eval_health_boost with storage gm4_heart_cannisters:temp
7+
data remove storage gm4_heart_cannisters:temp amount
158

169
tag @s[predicate=gm4_heart_canisters:has_health_boost] add gm4_hc_has_effect
1710
effect give @s[tag=!gm4_hc_has_effect] health_boost 1
Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
# gets called for every player with at least 1 heart canister tier 1 item
1+
# gets called for every player with at least 1 heart canister item
22

3-
scoreboard players set @s[nbt={Inventory:[{count:1,components:{"minecraft:custom_data":{gm4_heart_canister_tier:1b}}}]}] gm4_heart_can 1
4-
scoreboard players set @s[nbt={Inventory:[{count:2,components:{"minecraft:custom_data":{gm4_heart_canister_tier:1b}}}]}] gm4_heart_can 2
5-
scoreboard players set @s[nbt={Inventory:[{count:3,components:{"minecraft:custom_data":{gm4_heart_canister_tier:1b}}}]}] gm4_heart_can 3
6-
scoreboard players set @s[nbt={Inventory:[{count:4,components:{"minecraft:custom_data":{gm4_heart_canister_tier:1b}}}]}] gm4_heart_can 4
7-
scoreboard players set @s[nbt={Inventory:[{count:5,components:{"minecraft:custom_data":{gm4_heart_canister_tier:1b}}}]}] gm4_heart_can 5
3+
# tier 1
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
88

9-
scoreboard players set @s[scores={gm4_heart_can=5..},nbt={Inventory:[{count:1,components:{"minecraft:custom_data":{gm4_heart_canister_tier:2b}}}]}] gm4_heart_can 6
10-
scoreboard players set @s[scores={gm4_heart_can=5..},nbt={Inventory:[{count:2,components:{"minecraft:custom_data":{gm4_heart_canister_tier:2b}}}]}] gm4_heart_can 7
11-
scoreboard players set @s[scores={gm4_heart_can=5..},nbt={Inventory:[{count:3,components:{"minecraft:custom_data":{gm4_heart_canister_tier:2b}}}]}] gm4_heart_can 8
12-
scoreboard players set @s[scores={gm4_heart_can=5..},nbt={Inventory:[{count:4,components:{"minecraft:custom_data":{gm4_heart_canister_tier:2b}}}]}] gm4_heart_can 9
13-
scoreboard players set @s[scores={gm4_heart_can=5..},nbt={Inventory:[{count:5,components:{"minecraft:custom_data":{gm4_heart_canister_tier:2b}}}]}] gm4_heart_can 10
9+
# tier 2
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
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# apply the health boost
2+
3+
$attribute @s minecraft:max_health modifier add minecraft:38a576e7-341b-46ed-a9e3-7b7291beae72 $(amount) add_value

gm4_heart_canisters/data/gm4_heart_canisters/function/init.mcfunction

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ execute unless score heart_canisters gm4_modules matches 1 run data modify stora
44
execute unless score heart_canisters gm4_earliest_version < heart_canisters gm4_modules run scoreboard players operation heart_canisters gm4_earliest_version = heart_canisters gm4_modules
55
scoreboard players set heart_canisters gm4_modules 1
66

7+
scoreboard players set $heart_cannister_cap gm4_heart_can 5
8+
79
schedule function gm4_heart_canisters:main 1t
810

911
#$moduleUpdateList
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# check how many heart canisters the player has
22
scoreboard players operation $heart_can_last gm4_heart_can = @s gm4_heart_can
33
scoreboard players set @s gm4_heart_can 0
4-
execute if predicate gm4_heart_canisters:carries_tier_1 run function gm4_heart_canisters:check_heart_canisters
4+
execute if predicate gm4_heart_canisters:carries_heart_canister run function gm4_heart_canisters:check_heart_canisters
55

66
execute unless score @s gm4_heart_can = $heart_can_last gm4_heart_can run function gm4_heart_canisters:apply_health_boost

gm4_heart_canisters/data/gm4_heart_canisters/loot_table/items/tier_1_heart_canister.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,20 @@
1111
"function": "minecraft:set_components",
1212
"components": {
1313
"minecraft:custom_model_data": "item/heart_canister_tier_1",
14-
"minecraft:profile": "$heart_canister_tier_1"
14+
"minecraft:profile": "$heart_canister_tier_1"
1515
}
1616
},
1717
{
1818
"function": "minecraft:set_custom_data",
1919
"tag": "{gm4_heart_canister:1b,gm4_heart_canister_tier:1b}"
2020
},
21+
{
22+
"function": "set_components",
23+
"components": {
24+
"max_stack_size": 5,
25+
"!equippable": {}
26+
}
27+
},
2128
{
2229
"function": "minecraft:set_name",
2330
"name": {

gm4_heart_canisters/data/gm4_heart_canisters/loot_table/items/tier_2_heart_canister.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@
1818
"function": "minecraft:set_custom_data",
1919
"tag": "{gm4_heart_canister:1b,gm4_heart_canister_tier:2b}"
2020
},
21+
{
22+
"function": "set_components",
23+
"components": {
24+
"max_stack_size": 5,
25+
"!equippable": {}
26+
}
27+
},
2128
{
2229
"function": "minecraft:set_name",
2330
"name": {

gm4_heart_canisters/data/gm4_heart_canisters/predicate/carries_tier_1.json renamed to gm4_heart_canisters/data/gm4_heart_canisters/predicate/carries_heart_canister.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"container.*": {
1010
"items": "minecraft:player_head",
1111
"predicates": {
12-
"minecraft:custom_data": "{gm4_heart_canister_tier:1b}"
12+
"minecraft:custom_data": "{gm4_heart_canister:1b}"
1313
}
1414
}
1515
}
@@ -23,7 +23,7 @@
2323
"armor.*": {
2424
"items": "minecraft:player_head",
2525
"predicates": {
26-
"minecraft:custom_data": "{gm4_heart_canister_tier:1b}"
26+
"minecraft:custom_data": "{gm4_heart_canister:1b}"
2727
}
2828
}
2929
}
@@ -37,7 +37,7 @@
3737
"player.cursor": {
3838
"items": "minecraft:player_head",
3939
"predicates": {
40-
"minecraft:custom_data": "{gm4_heart_canister_tier:1b}"
40+
"minecraft:custom_data": "{gm4_heart_canister:1b}"
4141
}
4242
}
4343
}
@@ -51,7 +51,7 @@
5151
"player.crafting.*": {
5252
"items": "minecraft:player_head",
5353
"predicates": {
54-
"minecraft:custom_data": "{gm4_heart_canister_tier:1b}"
54+
"minecraft:custom_data": "{gm4_heart_canister:1b}"
5555
}
5656
}
5757
}
@@ -65,7 +65,7 @@
6565
"weapon.*": {
6666
"items": "minecraft:player_head",
6767
"predicates": {
68-
"minecraft:custom_data": "{gm4_heart_canister_tier:1b}"
68+
"minecraft:custom_data": "{gm4_heart_canister:1b}"
6969
}
7070
}
7171
}

gm4_heart_canisters/data/gm4_heart_canisters/recipe/heart_canister_tier_1.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
"id": "minecraft:player_head",
1717
"components": {
1818
"minecraft:custom_model_data": "item/heart_canister_tier_1",
19+
"minecraft:max_stack_size": 5,
20+
"!minecraft:equippable": {},
1921
"minecraft:profile": "$heart_canister_tier_1",
2022
"minecraft:custom_data": "{gm4_heart_canister:1b,gm4_heart_canister_tier:1b}",
2123
"minecraft:custom_name": {"translate":"item.gm4.heart_canister","fallback":"Heart Canister","italic":false},

gm4_heart_canisters/data/gm4_heart_canisters/test/apply_tier_1.mcfunction

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ scoreboard objectives add gm4_test dummy
77
execute store result score $max_health gm4_test run attribute @s minecraft:max_health get
88
assert score $max_health gm4_test matches 24
99

10-
loot give @s loot gm4_heart_canisters:items/tier_2_heart_canister
1110
loot give @s loot gm4_heart_canisters:items/tier_1_heart_canister
1211

1312
await delay 1s
@@ -21,4 +20,4 @@ loot give @s loot gm4_heart_canisters:items/tier_1_heart_canister
2120

2221
await delay 1s
2322
execute store result score $max_health gm4_test run attribute @s minecraft:max_health get
24-
assert score $max_health gm4_test matches 20
23+
assert score $max_health gm4_test matches 40

0 commit comments

Comments
 (0)