Skip to content

Guard Folia creature cause expansion by region ownership - #2312

Open
baichuan335 wants to merge 1 commit into
EngineHub:version/7.0.xfrom
baichuan335:fix/folia-cause-region-ownership
Open

baichuan335 wants to merge 1 commit into
EngineHub:version/7.0.xfrom
baichuan335:fix/folia-cause-region-ownership

Conversation

@baichuan335

Copy link
Copy Markdown

Summary

Fixes #2311.

On Folia, Cause.Builder can expand a projectile shooter that belongs to another Region. For creature shooters, that expansion reads mutable AI state through Creature#getTarget() (and for creepers Creeper#getTarget() / getIgniter()), which violates Folia ownership rules during vehicle damage handling.

This change keeps the projectile, shooter, and other cause objects in the cause chain, but skips only the mutable creature AI-state expansion when the creature is not owned by the current Region. Non-Folia behavior is unchanged, and locally owned Folia creatures retain the existing expansion behavior.

Verification

  • ./gradlew.bat build -s --max-workers=1
    • Passed on the WorldGuard branch.
    • Includes unit tests, Checkstyle, header verification, and packaging.
  • Official Folia runtime reproduction:
    • Folia 1.21.11-14, commit 529aabc
    • WorldEdit 7.4.3+7515-78babeb
    • WorldGuard 7.0.17 with this fix applied
    • Java 25.0.4.1
    • Four Region tick threads
    • Deterministic projectile/vehicle damage test
    • Result: projectile-owned-by-current=true
    • Result: shooter-owned-by-current=false
    • Result: VehicleDamageEvent returned; cancelled=true with global vehicle-destroy: deny
    • No Thread failed main thread check, CraftMob.getTarget() cross-Region exception, or other exception/error output

The same runtime behavior was also compared against the newer Folia 26.2 environment separately; that version changes projectile shooter ownership behavior, so it was not used as evidence for the original issue.

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.

Folia: Cause.Builder reads Creature#getTarget() from a non-owning region during vehicle damage

1 participant