-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #166 from aksiome/health-tests
✅ Health module tests
- Loading branch information
Showing
25 changed files
with
197 additions
and
86 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
datapacks/Bookshelf/data/bs.health/advancements/restore_health.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"criteria": { | ||
"requirement": { | ||
"trigger": "minecraft:effects_changed", | ||
"conditions": { | ||
"player": [ | ||
{ | ||
"condition": "minecraft:inverted", | ||
"term": { | ||
"condition": "minecraft:entity_properties", | ||
"entity": "this", | ||
"predicate": { | ||
"effects": { | ||
"minecraft:instant_health": { | ||
"amplifier": 28 | ||
} | ||
} | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"rewards": { | ||
"function": "bs.health:apply/remove_modifier" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 5 additions & 3 deletions
8
datapacks/Bookshelf/data/bs.health/functions/apply/decrease_health.mcfunction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
$attribute @s minecraft:generic.max_health base set $(x) | ||
advancement grant @s only bs.health:restore_health | ||
attribute @s minecraft:generic.max_health modifier remove 68f0b501-5dca-4abb-8b69-057945a9583d | ||
$attribute @s minecraft:generic.max_health modifier add 68f0b501-5dca-4abb-8b69-057945a9583d "bs.health" $(x) add | ||
effect give @s minecraft:health_boost 1 0 true | ||
effect clear @s minecraft:health_boost | ||
|
||
scoreboard players reset @s bs.health.x | ||
effect clear @s minecraft:instant_health | ||
attribute @s minecraft:generic.max_health modifier remove 68f0b501-5dca-4abb-8b69-057945a9583d |
10 changes: 3 additions & 7 deletions
10
datapacks/Bookshelf/data/bs.health/functions/apply/increase_health.mcfunction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,4 @@ | ||
$attribute @s minecraft:generic.max_health base set $(x) | ||
attribute @s minecraft:generic.max_health modifier remove 68f0b501-5dca-4abb-8b69-057945a9583d | ||
$attribute @s minecraft:generic.max_health modifier add 68f0b501-5dca-4abb-8b69-057945a9583d "bs.health" $(x) add | ||
effect give @s minecraft:instant_health 1 28 true | ||
|
||
tag @s add bs.health.break | ||
scoreboard players operation @s bs.health.y = #health.max bs.data | ||
scoreboard players operation @s bs.health.y -= #health.points bs.data | ||
execute if score @s bs.health.y matches 0 run scoreboard players reset @s bs.health.y | ||
scoreboard players reset @s bs.health.x | ||
advancement revoke @s only bs.health:restore_health |
1 change: 1 addition & 0 deletions
1
datapacks/Bookshelf/data/bs.health/functions/apply/remove_modifier.mcfunction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
attribute @s minecraft:generic.max_health modifier remove 68f0b501-5dca-4abb-8b69-057945a9583d |
3 changes: 0 additions & 3 deletions
3
datapacks/Bookshelf/data/bs.health/functions/apply/set_max_health.mcfunction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
$attribute @s minecraft:generic.max_health base set $(y) | ||
effect give @s minecraft:health_boost 1 0 true | ||
effect clear @s minecraft:health_boost | ||
|
||
tag @s remove bs.health.break | ||
scoreboard players reset @s bs.health.y |
12 changes: 0 additions & 12 deletions
12
datapacks/Bookshelf/data/bs.health/functions/apply/update_health.mcfunction
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
datapacks/Bookshelf/data/bs.health/functions/time_to_live/register_unit.mcfunction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 0 additions & 19 deletions
19
datapacks/Bookshelf/data/bs.health/predicates/is_stale.json
This file was deleted.
Oops, something went wrong.
15 changes: 15 additions & 0 deletions
15
datapacks/Bookshelf/data/bs.health/tests/add/concurrent.mcfunction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Max HP and HP are added or removed correctly in a single tick | ||
# @batch bs.health | ||
# @dummy | ||
|
||
function #bs.health:add_health {points:5.0} | ||
function #bs.health:add_max_health {points:10.0} | ||
function #bs.health:add_health {points:5.0} | ||
function #bs.health:add_health {points:-10.0} | ||
execute store result score #result bs.data run data get entity @s Health | ||
assert score #result bs.data matches 15 | ||
|
||
function #bs.health:add_health {points:20.0} | ||
await delay 1t | ||
execute store result score #result bs.data run data get entity @s Health | ||
assert score #result bs.data matches 30 |
12 changes: 12 additions & 0 deletions
12
datapacks/Bookshelf/data/bs.health/tests/add/health.mcfunction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# HP are added or removed correctly | ||
# @batch bs.health | ||
# @dummy | ||
|
||
function #bs.health:add_health {points:-10} | ||
execute store result score #result bs.data run data get entity @s Health | ||
assert score #result bs.data matches 10 | ||
|
||
function #bs.health:add_health {points:5} | ||
await delay 1t | ||
execute store result score #result bs.data run data get entity @s Health | ||
assert score #result bs.data matches 15 |
11 changes: 11 additions & 0 deletions
11
datapacks/Bookshelf/data/bs.health/tests/add/max_health.mcfunction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Max HP are added or removed correctly | ||
# @batch bs.health | ||
# @dummy | ||
|
||
function #bs.health:add_max_health {points:10} | ||
execute store result score #result bs.data run attribute @s minecraft:generic.max_health get | ||
assert score #result bs.data matches 30 | ||
|
||
function #bs.health:add_max_health {points:-5} | ||
execute store result score #result bs.data run attribute @s minecraft:generic.max_health get | ||
assert score #result bs.data matches 25 |
10 changes: 10 additions & 0 deletions
10
datapacks/Bookshelf/data/bs.health/tests/get/health.mcfunction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Get HP returns correct value | ||
# @batch bs.health | ||
# @dummy | ||
|
||
execute store result score #result bs.data run function #bs.health:get_health {scale:1} | ||
assert score #result bs.data matches 20 | ||
|
||
attribute @s minecraft:generic.max_health modifier add 68f0b501-5dca-4abb-8b69-057945a9583d "bs.health" -5 add | ||
execute store result score #result bs.data run function #bs.health:get_health {scale:1} | ||
assert score #result bs.data matches 15 |
10 changes: 10 additions & 0 deletions
10
datapacks/Bookshelf/data/bs.health/tests/get/max_health.mcfunction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Get Max HP returns correct value | ||
# @batch bs.health | ||
# @dummy | ||
|
||
execute store result score #result bs.data run function #bs.health:get_max_health {scale:1} | ||
assert score #result bs.data matches 20 | ||
|
||
attribute @s minecraft:generic.max_health modifier add 68f0b501-5dca-4abb-8b69-057945a9583d "bs.health" -10 add | ||
execute store result score #result bs.data run function #bs.health:get_max_health {scale:1} | ||
assert score #result bs.data matches 20 |
14 changes: 14 additions & 0 deletions
14
datapacks/Bookshelf/data/bs.health/tests/set/concurrent.mcfunction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Max HP and HP are set correctly in a single tick | ||
# @batch bs.health | ||
# @dummy | ||
|
||
function #bs.health:set_health {points:10.0} | ||
function #bs.health:set_max_health {points:30.0} | ||
execute store result score #result bs.data run data get entity @s Health | ||
assert score #result bs.data matches 10 | ||
|
||
function #bs.health:set_max_health {points:20.0} | ||
function #bs.health:set_health {points:30.0} | ||
await delay 1t | ||
execute store result score #result bs.data run data get entity @s Health | ||
assert score #result bs.data matches 20 |
12 changes: 12 additions & 0 deletions
12
datapacks/Bookshelf/data/bs.health/tests/set/health.mcfunction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# HP are set correctly | ||
# @batch bs.health | ||
# @dummy | ||
|
||
function #bs.health:set_health {points:10} | ||
execute store result score #result bs.data run data get entity @s Health | ||
assert score #result bs.data matches 10 | ||
|
||
function #bs.health:set_health {points:15} | ||
await delay 1t | ||
execute store result score #result bs.data run data get entity @s Health | ||
assert score #result bs.data matches 15 |
Oops, something went wrong.