Skip to content

🐛 ScoreToHealth 干渉中も正しい最大体力を返すよう修正#2266

Merged
haiiro2gou merged 7 commits into
masterfrom
fix/max_health_get
May 26, 2026
Merged

🐛 ScoreToHealth 干渉中も正しい最大体力を返すよう修正#2266
haiiro2gou merged 7 commits into
masterfrom
fix/max_health_get

Conversation

@EllaCoat
Copy link
Copy Markdown
Member

@EllaCoat EllaCoat commented May 25, 2026

Fixes #2263

api:entity/player/get_health_per (および同じく attribute @s generic.max_health get 直読みしている箇所) で、 プレイヤーが HP 変化した直後の 1〜2 tick だけ HealthPer が 1.0 を超える不具合の修正。

原因

PR #2248api:modifier/max_health/get を破棄し、 attribute @s generic.max_health get を直接読むようにした影響。

ScoreToHealth ライブラリは instant_health 1 252 で体力を目標値に揃えるため、 1 tick だけ max_health 属性に大量の負の modifier (UUID prefix bab7cdc2-fb6a-47f6-0001-*) を一時付与する。 そのタイミングで attribute から最大体力を読むと target 値 (= 低い値) が返ってしまい、 OhMyDat キャッシュ越しに読んでる Health (damage 反映前) と並べると Health / MaxHealth > 1.0 が成立する。

修正方針

ScoreToHealth が次 tick の advancement (entity tick フェーズ) で行う score_to_health:restore を、 同じ tick の function tick の最先頭 で先回りで実行する。 これにより core:tick/ 全域での attribute 直読みは干渉値ではなく真値を返すようになる。

Copilot AI review requested due to automatic review settings May 25, 2026 02:44
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

ScoreToHealth による一時的な generic.max_health modifier 干渉中でも、プレイヤーの「本来の最大体力」を参照できるようにして api:entity/player/get_health_per の HealthPer が一時的に 1.0 を超える不具合(#2263)を抑止するPRです。

Changes:

  • core:tick/player/pre のタイミングで最大体力を OhMyDat に条件付きでキャッシュする処理を追加
  • 最大体力取得API api:modifier/max_health/get を OhMyDat キャッシュ参照として復元
  • api:entity/player/get_health_per を上記 API 経由の最大体力参照に戻す

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
TheSkyBlessing/data/player_manager/functions/cache_max_health.mcfunction ScoreToHealth干渉を避けた最大体力のキャッシュ更新を追加
TheSkyBlessing/data/core/functions/tick/player/pre.mcfunction pre tick に最大体力キャッシュ更新呼び出しを追加
TheSkyBlessing/data/api/functions/modifier/max_health/get.mcfunction 最大体力取得APIをOhMyDatキャッシュ読み出しとして追加
TheSkyBlessing/data/api/functions/entity/player/get_health_per.mcfunction 最大体力取得を attribute 直読から API 経由に切替

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread TheSkyBlessing/data/player_manager/functions/cache_max_health.mcfunction Outdated
Comment thread TheSkyBlessing/data/api/functions/modifier/max_health/get.mcfunction Outdated
@EllaCoat
Copy link
Copy Markdown
Member Author

Linter がぶっ壊れているのはローカルの方でした、アホ

@EllaCoat EllaCoat force-pushed the fix/max_health_get branch from 96f47d1 to d3da810 Compare May 25, 2026 03:05
@EllaCoat EllaCoat marked this pull request as draft May 25, 2026 03:33
@EllaCoat
Copy link
Copy Markdown
Member Author

本当は
tag @s remove ScoreToHealth.Return をつけたかったんだけど
なんかの意図でわざわざ、モディファイアの再付与を回避しているのであれば、怖いので……見送り
これでもろもろが直るはず

@EllaCoat EllaCoat marked this pull request as ready for review May 26, 2026 15:22
Copy link
Copy Markdown
Member

@haiiro2gou haiiro2gou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WANT: score_to_health:player_tick の restore 呼び出し部分をコメントアウトしていいんじゃない?

@haiiro2gou haiiro2gou merged commit ad2c19b into master May 26, 2026
2 checks passed
@haiiro2gou haiiro2gou deleted the fix/max_health_get branch May 26, 2026 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

最大体力を正常に取得できない

3 participants