Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gm4_sweethearts/assets/translations.csv
Original file line number Diff line number Diff line change
Expand Up @@ -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.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
7 changes: 5 additions & 2 deletions gm4_sweethearts/data/gm4_sweethearts/function/main.mcfunction
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# @s = sneaking player holding flower
# at @s
# run from main

tag @s add gm4_sh_donor
Expand All @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}
]
]
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"flags": {
"is_sneaking": true
},
"equipment": {
"mainhand": {
"slots": {
"weapon.*": {
"items": "#minecraft:small_flowers"
}
}
Expand Down
Loading