💥 ScoreToMaxHealthを破壊 & ModifierAPIの最大体力のupdate_bonus以外を削除#2248
💥 ScoreToMaxHealthを破壊 & ModifierAPIの最大体力のupdate_bonus以外を削除#2248
Conversation
There was a problem hiding this comment.
Pull request overview
Fix #2246 by removing the legacy ScoreToMaxHealth/max-health ModifierAPI flow and switching max-health reads/updates to the vanilla attribute command path.
Changes:
- Replaced
api:modifier/max_health/getusages withattribute @s generic.max_health getacross player/mob damage, regen, and health-percentage calculations. - Removed
api:modifier/max_health/{add,get,remove}and related core functions; reworkedmax_health/update_bonusto apply an attribute modifier directly (via a new macro helper). - Disabled
ScoreToMaxHealth-driven max-health modification in theScoreToHealthdatapack tick flow.
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| TheSkyBlessing/data/player_manager/functions/void_damage/damage.mcfunction | Compute void damage from current generic.max_health attribute instead of API storage. |
| TheSkyBlessing/data/player_manager/functions/set_team_and_per_health.mcfunction | Use attribute-based max health for team assignment / PerHealth computation. |
| TheSkyBlessing/data/player_manager/functions/health/regen/do.mcfunction | Regen scaling now reads max health directly from attributes. |
| TheSkyBlessing/data/player_manager/functions/fall_damage/deal_damage/get_vars.mcfunction | Fall-damage variables now pull max health from attributes. |
| TheSkyBlessing/data/mob_manager/functions/processing_tag/common_tag/anti_void_action/damage.mcfunction | Mob anti-void damage scaling now uses attributes. |
| TheSkyBlessing/data/lib/functions/score_to_health_wrapper/proc.mcfunction | Wrapper now reads max health from attributes. |
| TheSkyBlessing/data/debug/functions/modify_health/remove.mcfunction | Debug remove now directly removes an attribute modifier by UUID. |
| TheSkyBlessing/data/debug/functions/modify_health/add.m.mcfunction | Debug add now directly adds an attribute modifier via macro arg. |
| TheSkyBlessing/data/core/functions/handler/respawn.mcfunction | Respawn “heal to 50% max” now uses attribute-based max health. |
| TheSkyBlessing/data/core/functions/handler/first_join.mcfunction | Initializes player max health via attribute base set; removes MaxHealth from stored defaults. |
| TheSkyBlessing/data/asset_manager/functions/artifact/create/set_lore/modifier/.mcfunction | Removes custom lore handling for Type:"max_health". |
| TheSkyBlessing/data/api/functions/modifier/max_health/update_bonus.mcfunction | Reworks bonus max-health update to use attribute modifiers directly. |
| TheSkyBlessing/data/api/functions/modifier/max_health/remove.mcfunction | Deleted legacy API remove entrypoint. |
| TheSkyBlessing/data/api/functions/modifier/max_health/get.mcfunction | Deleted legacy API get entrypoint. |
| TheSkyBlessing/data/api/functions/modifier/max_health/add.mcfunction | Deleted legacy API add entrypoint. |
| TheSkyBlessing/data/api/functions/modifier/core/max_health/remove.mcfunction | Deleted legacy core remove implementation (storage-based). |
| TheSkyBlessing/data/api/functions/modifier/core/max_health/add.mcfunction | Deleted legacy core add implementation (storage-based). |
| TheSkyBlessing/data/api/functions/modifier/core/max_health/add.m.mcfunction | New macro helper to apply the BonusHealth attribute modifier. |
| TheSkyBlessing/data/api/functions/entity/player/get_health_per.mcfunction | Health percentage now uses attribute-based max health. |
| ScoreToHealth/data/score_to_health/functions/player_tick.mcfunction | Comments out ScoreToMaxHealth synchronization/modify step. |
| ScoreToHealth/data/score_to_health/functions/check.mcfunction | Uses attribute-based max health instead of removed API call. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # 削除前に更新前の補正量を取得しておく | ||
| execute store result score $RemovedAmount Temporary run attribute @s generic.max_health modifier value get 00000001-0000-0001-0000-000200000000 | ||
|
|
||
| # 古いのをremove | ||
| data modify storage api: Argument.UUID set value [I;1,1,2,0] | ||
| function api:modifier/max_health/remove | ||
| attribute @s generic.max_health modifier remove 00000001-0000-0001-0000-000200000000 |
There was a problem hiding this comment.
attribute ... modifier value get / modifier remove will fail (and can produce command feedback) when the BonusHealth modifier is not present. Since this function is called from core:handler/join, players who have never had this modifier (e.g., on first join / BonusHealth=0) will hit this path. Consider guarding these lines with an execute if data entity @s Attributes[{Name:"generic.max_health",Modifiers:[{UUID:[I;1,1,2,0]}]}] check (or equivalent) and default $RemovedAmount to 0 when absent, so join doesn’t emit errors.
| execute if data storage asset:artifact Modifier{Type:"max_health"} run scoreboard players set $CustomModifier Temporary 1 | ||
| execute if data storage asset:artifact Modifier{Type:"max_health"} run data modify storage asset:artifact Line[1] set value '"最大体力"' | ||
| execute if data storage asset:artifact Modifier{Type:"max_mp"} run scoreboard players set $CustomModifier Temporary 1 | ||
| execute if data storage asset:artifact Modifier{Type:"max_mp"} run data modify storage asset:artifact Line[1] set value '"最大MP"' |
There was a problem hiding this comment.
Modifier{Type:"max_health"} no longer has a custom label, so it falls through to generic.m, which renders {"translate":"attribute.name.$(Type)"}. For Type:"max_health" this likely becomes an invalid translation key (attribute.name.max_health) and will show untranslated lore. There is still at least one producer of Type:"max_health" (e.g., TheSkyBlessing/data/asset/functions/artifact/example/give/2.give.mcfunction). Either keep a custom mapping here, or change producers to use the vanilla id (generic.max_health) so the generic path works.
| execute if data storage asset:artifact Modifier{Type:"max_mp"} run data modify storage asset:artifact Line[1] set value '"最大MP"' | |
| execute if data storage asset:artifact Modifier{Type:"max_mp"} run data modify storage asset:artifact Line[1] set value '"最大MP"' | |
| execute if data storage asset:artifact Modifier{Type:"max_health"} run scoreboard players set $CustomModifier Temporary 1 | |
| execute if data storage asset:artifact Modifier{Type:"max_health"} run data modify storage asset:artifact Line[1] set value '"最大体力"' |
Fix #2246