diff --git a/gm4_sweethearts/assets/translations.csv b/gm4_sweethearts/assets/translations.csv index 297027b3bf..f52993d2e7 100644 --- a/gm4_sweethearts/assets/translations.csv +++ b/gm4_sweethearts/assets/translations.csv @@ -2,4 +2,4 @@ key,en_us advancement.gm4.sweethearts.title,Selfless advancement.gm4.sweethearts.description,Give your last heart to another text.gm4.guidebook.module_desc.sweethearts,Transfer your health to another player using flowers. -text.gm4.guidebook.sweethearts.description,Sneaking while holding a small flower will transfer health to a nearby ally in need.\n\nAll small flowers except wither roses work. +text.gm4.guidebook.sweethearts.description,Sneaking while holding a small flower will transfer health to a nearby ally in need.\n\nAll small flowers work. diff --git a/gm4_sweethearts/data/gm4_sweethearts/function/check_transfer.mcfunction b/gm4_sweethearts/data/gm4_sweethearts/function/check_transfer.mcfunction deleted file mode 100644 index 0f10cf5b32..0000000000 --- a/gm4_sweethearts/data/gm4_sweethearts/function/check_transfer.mcfunction +++ /dev/null @@ -1,4 +0,0 @@ -# @s = none -# run from main - -execute as @a[tag=gm4_sh_transfered] run function gm4_sweethearts:revert_health diff --git a/gm4_sweethearts/data/gm4_sweethearts/function/delayed_revert.mcfunction b/gm4_sweethearts/data/gm4_sweethearts/function/delayed_revert.mcfunction new file mode 100644 index 0000000000..814ddcce30 --- /dev/null +++ b/gm4_sweethearts/data/gm4_sweethearts/function/delayed_revert.mcfunction @@ -0,0 +1,5 @@ +# @s = none +# at undefined +# scheduled from transfer_recipient + +execute as @a[tag=gm4_sh_revert_health] run function gm4_sweethearts:revert_health diff --git a/gm4_sweethearts/data/gm4_sweethearts/function/get_health.mcfunction b/gm4_sweethearts/data/gm4_sweethearts/function/get_health.mcfunction index 2ee8ec717b..e365ad155b 100644 --- a/gm4_sweethearts/data/gm4_sweethearts/function/get_health.mcfunction +++ b/gm4_sweethearts/data/gm4_sweethearts/function/get_health.mcfunction @@ -1,4 +1,5 @@ -# @s = players near sneaking player holding flower +# @s = players near sneaking player holding flower (including player holding flower) +# at player holding flower # run from transferring # get max health of player diff --git a/gm4_sweethearts/data/gm4_sweethearts/function/kill_donor.mcfunction b/gm4_sweethearts/data/gm4_sweethearts/function/kill_donor.mcfunction index dc21a8f588..8d21ff1196 100644 --- a/gm4_sweethearts/data/gm4_sweethearts/function/kill_donor.mcfunction +++ b/gm4_sweethearts/data/gm4_sweethearts/function/kill_donor.mcfunction @@ -1,10 +1,6 @@ # @s = sneaking player donating health +# at @s # run from transfer_donor -execute store result score $deathmessage gm4_sh_data run gamerule show_death_messages -gamerule show_death_messages false advancement grant @s only gm4:sweethearts execute if score $deathmessage gm4_sh_data matches 1 run tellraw @a [{"text":"","color":"white"},{"selector":"@s"},{"text":" was shot through the heart and "},{"selector":"@p[tag=gm4_sh_recipient]"},{"text":" was to blame"}] -kill @s -execute if score $deathmessage gm4_sh_data matches 1 run gamerule show_death_messages true -scoreboard players reset $deathmessage gm4_sh_data diff --git a/gm4_sweethearts/data/gm4_sweethearts/function/main.mcfunction b/gm4_sweethearts/data/gm4_sweethearts/function/main.mcfunction index 6874527913..6717341c87 100644 --- a/gm4_sweethearts/data/gm4_sweethearts/function/main.mcfunction +++ b/gm4_sweethearts/data/gm4_sweethearts/function/main.mcfunction @@ -1,4 +1,7 @@ -execute as @a[gamemode=!creative,gamemode=!spectator,predicate=gm4_sweethearts:valid_transfer] at @s run function gm4_sweethearts:transferring +# @s = none +# at undefined +# scheduled from init and self + +execute as @a[gamemode=!creative,gamemode=!spectator,predicate=gm4_sweethearts:valid_donor] at @s run function gm4_sweethearts:transferring -schedule function gm4_sweethearts:check_transfer 1t schedule function gm4_sweethearts:main 16t diff --git a/gm4_sweethearts/data/gm4_sweethearts/function/revert_health.mcfunction b/gm4_sweethearts/data/gm4_sweethearts/function/revert_health.mcfunction index 2df62ff40f..4402ad32fa 100644 --- a/gm4_sweethearts/data/gm4_sweethearts/function/revert_health.mcfunction +++ b/gm4_sweethearts/data/gm4_sweethearts/function/revert_health.mcfunction @@ -1,20 +1,19 @@ -# @s = player that received or donated health -# run from check_transfer +# @s = player that received health, tagged with gm4_sh_revert_health +# at undefined +# run from delayed_revert # revert max health -attribute @s minecraft:max_health modifier remove minecraft:2a0687d4-f85c-4b07-9310-beaa76ef6f7d -attribute @s minecraft:max_health modifier remove minecraft:3749747b-8bab-4f91-a63c-518268ca4856 -attribute @s minecraft:max_health modifier remove minecraft:fc665a2d-71e8-4fe4-8d6d-91283f14e536 -attribute @s minecraft:max_health modifier remove minecraft:9dd58507-2a53-4ab6-8688-b0fa0be102dd -attribute @s minecraft:max_health modifier remove minecraft:226acf45-e0df-4164-92ed-cbf02a65eee2 -attribute @s minecraft:max_health modifier remove minecraft:04f2b196-ca85-4ac8-b8e0-a7d569b415c8 -attribute @s minecraft:max_health modifier remove minecraft:8c5c4e5e-1823-45c0-9e96-5992e75ae463 -attribute @s minecraft:max_health modifier remove minecraft:4cb0a7c9-22f2-4a73-86c6-745d2f59331f -attribute @s minecraft:max_health modifier remove minecraft:e565e188-bfb5-47c4-83bd-7e0babf62ccb -attribute @s minecraft:max_health modifier remove minecraft:52ff177d-8222-4810-924f-f8bd44b43cfd +attribute @s minecraft:max_health modifier remove gm4_sweethearts:health_remove_512 +attribute @s minecraft:max_health modifier remove gm4_sweethearts:health_remove_256 +attribute @s minecraft:max_health modifier remove gm4_sweethearts:health_remove_128 +attribute @s minecraft:max_health modifier remove gm4_sweethearts:health_remove_64 +attribute @s minecraft:max_health modifier remove gm4_sweethearts:health_remove_32 +attribute @s minecraft:max_health modifier remove gm4_sweethearts:health_remove_16 +attribute @s minecraft:max_health modifier remove gm4_sweethearts:health_remove_8 +attribute @s minecraft:max_health modifier remove gm4_sweethearts:health_remove_4 +attribute @s minecraft:max_health modifier remove gm4_sweethearts:health_remove_2 +attribute @s minecraft:max_health modifier remove gm4_sweethearts:health_remove_1 -attribute @s minecraft:max_health modifier remove minecraft:381e44f6-ebee-4f7c-9aff-8471a843c4b2 -attribute @s minecraft:max_health modifier remove minecraft:17d25a01-e9ba-4c08-8a79-ee8f72fb033d +attribute @s minecraft:max_health modifier remove gm4_sweethearts:health_add_1 - -tag @s remove gm4_sh_transfered +tag @s remove gm4_sh_revert_health diff --git a/gm4_sweethearts/data/gm4_sweethearts/function/transfer_donor.mcfunction b/gm4_sweethearts/data/gm4_sweethearts/function/transfer_donor.mcfunction index 095a3ce7cb..5f4ce94288 100644 --- a/gm4_sweethearts/data/gm4_sweethearts/function/transfer_donor.mcfunction +++ b/gm4_sweethearts/data/gm4_sweethearts/function/transfer_donor.mcfunction @@ -1,46 +1,20 @@ # @s = sneaking player donating health +# at @s # run from transfer_recipient -# calculate amount of max_health to remove to get to current health -execute store result score $remove_health gm4_sh_data run attribute @s minecraft:max_health get -scoreboard players operation $remove_health gm4_sh_data -= @s gm4_sh_health -scoreboard players operation $donor_init_health gm4_sh_data = $remove_health gm4_sh_data - -# lower player's max health to their current health -execute if score $remove_health gm4_sh_data matches 512.. run attribute @s minecraft:max_health modifier add minecraft:2a0687d4-f85c-4b07-9310-beaa76ef6f7d -512 add_value -execute if score $remove_health gm4_sh_data matches 512.. run scoreboard players remove $remove_health gm4_sh_data 512 -execute if score $remove_health gm4_sh_data matches 256.. run attribute @s minecraft:max_health modifier add minecraft:3749747b-8bab-4f91-a63c-518268ca4856 -256 add_value -execute if score $remove_health gm4_sh_data matches 256.. run scoreboard players remove $remove_health gm4_sh_data 256 -execute if score $remove_health gm4_sh_data matches 128.. run attribute @s minecraft:max_health modifier add minecraft:fc665a2d-71e8-4fe4-8d6d-91283f14e536 -128 add_value -execute if score $remove_health gm4_sh_data matches 128.. run scoreboard players remove $remove_health gm4_sh_data 128 -execute if score $remove_health gm4_sh_data matches 64.. run attribute @s minecraft:max_health modifier add minecraft:9dd58507-2a53-4ab6-8688-b0fa0be102dd -64 add_value -execute if score $remove_health gm4_sh_data matches 64.. run scoreboard players remove $remove_health gm4_sh_data 64 -execute if score $remove_health gm4_sh_data matches 32.. run attribute @s minecraft:max_health modifier add minecraft:226acf45-e0df-4164-92ed-cbf02a65eee2 -32 add_value -execute if score $remove_health gm4_sh_data matches 32.. run scoreboard players remove $remove_health gm4_sh_data 32 -execute if score $remove_health gm4_sh_data matches 16.. run attribute @s minecraft:max_health modifier add minecraft:04f2b196-ca85-4ac8-b8e0-a7d569b415c8 -16 add_value -execute if score $remove_health gm4_sh_data matches 16.. run scoreboard players remove $remove_health gm4_sh_data 16 -execute if score $remove_health gm4_sh_data matches 8.. run attribute @s minecraft:max_health modifier add minecraft:8c5c4e5e-1823-45c0-9e96-5992e75ae463 -8 add_value -execute if score $remove_health gm4_sh_data matches 8.. run scoreboard players remove $remove_health gm4_sh_data 8 -execute if score $remove_health gm4_sh_data matches 4.. run attribute @s minecraft:max_health modifier add minecraft:4cb0a7c9-22f2-4a73-86c6-745d2f59331f -4 add_value -execute if score $remove_health gm4_sh_data matches 4.. run scoreboard players remove $remove_health gm4_sh_data 4 -execute if score $remove_health gm4_sh_data matches 2.. run attribute @s minecraft:max_health modifier add minecraft:e565e188-bfb5-47c4-83bd-7e0babf62ccb -2 add_value -execute if score $remove_health gm4_sh_data matches 2.. run scoreboard players remove $remove_health gm4_sh_data 2 -execute if score $remove_health gm4_sh_data matches 1.. run attribute @s minecraft:max_health modifier add minecraft:52ff177d-8222-4810-924f-f8bd44b43cfd -1 add_value -execute if score $remove_health gm4_sh_data matches 1.. run scoreboard players remove $remove_health gm4_sh_data 1 +# turn off death messages for potential death +execute store result score $deathmessage gm4_sh_data run gamerule show_death_messages +gamerule show_death_messages false # damage player -attribute @s minecraft:max_health modifier add minecraft:381e44f6-ebee-4f7c-9aff-8471a843c4b2 -1 add_value -effect give @s minecraft:instant_health 1 0 true - -# kill if health should be 0 -execute store result score $donor_curr_health gm4_sh_data run attribute @s minecraft:max_health get -scoreboard players operation $donor_lost_health gm4_sh_data = $donor_init_health gm4_sh_data -scoreboard players operation $donor_lost_health gm4_sh_data += $donor_curr_health gm4_sh_data +damage @s 1 magic by @s -execute if score $donor_lost_health gm4_sh_data = @s gm4_sh_data run function gm4_sweethearts:kill_donor +# handle death (@e only selects entities which are alive) +execute at @s unless entity @e[type=player,tag=gm4_sh_donor,distance=0,limit=1] run function gm4_sweethearts:kill_donor -# revert max health -tag @s add gm4_sh_transfered +# re-enable death messages +execute if score $deathmessage gm4_sh_data matches 1 run gamerule show_death_messages true +scoreboard players reset $deathmessage gm4_sh_data # visuals particle damage_indicator ~ ~2 ~ 0 0 0 .255 5 diff --git a/gm4_sweethearts/data/gm4_sweethearts/function/transfer_recipient.mcfunction b/gm4_sweethearts/data/gm4_sweethearts/function/transfer_recipient.mcfunction index 922daff208..b8445a940e 100644 --- a/gm4_sweethearts/data/gm4_sweethearts/function/transfer_recipient.mcfunction +++ b/gm4_sweethearts/data/gm4_sweethearts/function/transfer_recipient.mcfunction @@ -1,7 +1,8 @@ # @s = player near a sneaking player holding flower -# run from sneaking +# at @s +# run from transferring -# tag player +# tag player, for selection in death message of donor tag @s add gm4_sh_recipient # run donor transfer @@ -12,33 +13,34 @@ execute store result score $remove_health gm4_sh_data run attribute @s minecraft scoreboard players operation $remove_health gm4_sh_data -= @s gm4_sh_health # lower player's max health to their current health -execute if score $remove_health gm4_sh_data matches 512.. run attribute @s minecraft:max_health modifier add minecraft:2a0687d4-f85c-4b07-9310-beaa76ef6f7d -512 add_value +execute if score $remove_health gm4_sh_data matches 512.. run attribute @s minecraft:max_health modifier add gm4_sweethearts:health_remove_512 -512 add_value execute if score $remove_health gm4_sh_data matches 512.. run scoreboard players remove $remove_health gm4_sh_data 512 -execute if score $remove_health gm4_sh_data matches 256.. run attribute @s minecraft:max_health modifier add minecraft:3749747b-8bab-4f91-a63c-518268ca4856 -256 add_value +execute if score $remove_health gm4_sh_data matches 256.. run attribute @s minecraft:max_health modifier add gm4_sweethearts:health_remove_256 -256 add_value execute if score $remove_health gm4_sh_data matches 256.. run scoreboard players remove $remove_health gm4_sh_data 256 -execute if score $remove_health gm4_sh_data matches 128.. run attribute @s minecraft:max_health modifier add minecraft:fc665a2d-71e8-4fe4-8d6d-91283f14e536 -128 add_value +execute if score $remove_health gm4_sh_data matches 128.. run attribute @s minecraft:max_health modifier add gm4_sweethearts:health_remove_128 -128 add_value execute if score $remove_health gm4_sh_data matches 128.. run scoreboard players remove $remove_health gm4_sh_data 128 -execute if score $remove_health gm4_sh_data matches 64.. run attribute @s minecraft:max_health modifier add minecraft:9dd58507-2a53-4ab6-8688-b0fa0be102dd -64 add_value +execute if score $remove_health gm4_sh_data matches 64.. run attribute @s minecraft:max_health modifier add gm4_sweethearts:health_remove_64 -64 add_value execute if score $remove_health gm4_sh_data matches 64.. run scoreboard players remove $remove_health gm4_sh_data 64 -execute if score $remove_health gm4_sh_data matches 32.. run attribute @s minecraft:max_health modifier add minecraft:226acf45-e0df-4164-92ed-cbf02a65eee2 -32 add_value +execute if score $remove_health gm4_sh_data matches 32.. run attribute @s minecraft:max_health modifier add gm4_sweethearts:health_remove_32 -32 add_value execute if score $remove_health gm4_sh_data matches 32.. run scoreboard players remove $remove_health gm4_sh_data 32 -execute if score $remove_health gm4_sh_data matches 16.. run attribute @s minecraft:max_health modifier add minecraft:04f2b196-ca85-4ac8-b8e0-a7d569b415c8 -16 add_value +execute if score $remove_health gm4_sh_data matches 16.. run attribute @s minecraft:max_health modifier add gm4_sweethearts:health_remove_16 -16 add_value execute if score $remove_health gm4_sh_data matches 16.. run scoreboard players remove $remove_health gm4_sh_data 16 -execute if score $remove_health gm4_sh_data matches 8.. run attribute @s minecraft:max_health modifier add minecraft:8c5c4e5e-1823-45c0-9e96-5992e75ae463 -8 add_value +execute if score $remove_health gm4_sh_data matches 8.. run attribute @s minecraft:max_health modifier add gm4_sweethearts:health_remove_8 -8 add_value execute if score $remove_health gm4_sh_data matches 8.. run scoreboard players remove $remove_health gm4_sh_data 8 -execute if score $remove_health gm4_sh_data matches 4.. run attribute @s minecraft:max_health modifier add minecraft:4cb0a7c9-22f2-4a73-86c6-745d2f59331f -4 add_value +execute if score $remove_health gm4_sh_data matches 4.. run attribute @s minecraft:max_health modifier add gm4_sweethearts:health_remove_4 -4 add_value execute if score $remove_health gm4_sh_data matches 4.. run scoreboard players remove $remove_health gm4_sh_data 4 -execute if score $remove_health gm4_sh_data matches 2.. run attribute @s minecraft:max_health modifier add minecraft:e565e188-bfb5-47c4-83bd-7e0babf62ccb -2 add_value +execute if score $remove_health gm4_sh_data matches 2.. run attribute @s minecraft:max_health modifier add gm4_sweethearts:health_remove_2 -2 add_value execute if score $remove_health gm4_sh_data matches 2.. run scoreboard players remove $remove_health gm4_sh_data 2 -execute if score $remove_health gm4_sh_data matches 1.. run attribute @s minecraft:max_health modifier add minecraft:52ff177d-8222-4810-924f-f8bd44b43cfd -1 add_value +execute if score $remove_health gm4_sh_data matches 1.. run attribute @s minecraft:max_health modifier add gm4_sweethearts:health_remove_1 -1 add_value execute if score $remove_health gm4_sh_data matches 1.. run scoreboard players remove $remove_health gm4_sh_data 1 # heal player -attribute @s minecraft:max_health modifier add minecraft:17d25a01-e9ba-4c08-8a79-ee8f72fb033d 1 add_value +attribute @s minecraft:max_health modifier add gm4_sweethearts:health_add_1 1 add_value effect give @s minecraft:instant_health 1 0 true # revert max health -tag @s add gm4_sh_transfered +tag @s add gm4_sh_revert_health +schedule function gm4_sweethearts:delayed_revert 1t # visuals particle heart ~ ~2 ~ 0.2 0.2 0.2 1 2 diff --git a/gm4_sweethearts/data/gm4_sweethearts/function/transferring.mcfunction b/gm4_sweethearts/data/gm4_sweethearts/function/transferring.mcfunction index 1f9bd50d1a..e88a6da1b2 100644 --- a/gm4_sweethearts/data/gm4_sweethearts/function/transferring.mcfunction +++ b/gm4_sweethearts/data/gm4_sweethearts/function/transferring.mcfunction @@ -1,4 +1,5 @@ # @s = sneaking player holding flower +# at @s # run from main tag @s add gm4_sh_donor @@ -7,6 +8,6 @@ tag @s add gm4_sh_donor execute as @a[gamemode=!creative,gamemode=!spectator,distance=..3] run function gm4_sweethearts:get_health # transfer health to nearest player -execute as @p[gamemode=!creative,gamemode=!spectator,tag=!gm4_sh_donor,distance=..3,predicate=gm4_sweethearts:not_sneaking] unless score @s gm4_sh_health >= @s gm4_sh_data at @s run function gm4_sweethearts:transfer_recipient +execute as @p[gamemode=!creative,gamemode=!spectator,tag=!gm4_sh_donor,distance=..3,predicate=!gm4_sweethearts:valid_donor] if score @s gm4_sh_health < @s gm4_sh_data at @s run function gm4_sweethearts:transfer_recipient tag @s remove gm4_sh_donor diff --git a/gm4_sweethearts/data/gm4_sweethearts/guidebook/sweethearts.json b/gm4_sweethearts/data/gm4_sweethearts/guidebook/sweethearts.json index 69ee2d7788..7f9e3e53b6 100644 --- a/gm4_sweethearts/data/gm4_sweethearts/guidebook/sweethearts.json +++ b/gm4_sweethearts/data/gm4_sweethearts/guidebook/sweethearts.json @@ -33,7 +33,7 @@ }, { "translate": "text.gm4.guidebook.sweethearts.description", - "fallback": "Sneaking while holding a small flower will transfer health to a nearby ally in need.\n\nAll small flowers except wither roses work." + "fallback": "Sneaking while holding a small flower will transfer health to a nearby ally in need.\n\nAll small flowers work." } ] ] diff --git a/gm4_sweethearts/data/gm4_sweethearts/predicate/not_sneaking.json b/gm4_sweethearts/data/gm4_sweethearts/predicate/not_sneaking.json deleted file mode 100644 index 9d5c91d935..0000000000 --- a/gm4_sweethearts/data/gm4_sweethearts/predicate/not_sneaking.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "condition": "minecraft:entity_properties", - "entity": "this", - "predicate": { - "flags": { - "is_sneaking": false - } - } -} diff --git a/gm4_sweethearts/data/gm4_sweethearts/predicate/valid_transfer.json b/gm4_sweethearts/data/gm4_sweethearts/predicate/valid_donor.json similarity index 83% rename from gm4_sweethearts/data/gm4_sweethearts/predicate/valid_transfer.json rename to gm4_sweethearts/data/gm4_sweethearts/predicate/valid_donor.json index 66ac07a2b0..ba466b632b 100644 --- a/gm4_sweethearts/data/gm4_sweethearts/predicate/valid_transfer.json +++ b/gm4_sweethearts/data/gm4_sweethearts/predicate/valid_donor.json @@ -5,8 +5,8 @@ "flags": { "is_sneaking": true }, - "equipment": { - "mainhand": { + "slots": { + "weapon.*": { "items": "#minecraft:small_flowers" } }