Skip to content

Add MixinHideEntitySystems to prevent world crash on cross-world teleport#16

Open
Dimotai wants to merge 10 commits intoIroriPowered:masterfrom
Dimotai:fix/hide-entity-systems-clean
Open

Add MixinHideEntitySystems to prevent world crash on cross-world teleport#16
Dimotai wants to merge 10 commits intoIroriPowered:masterfrom
Dimotai:fix/hide-entity-systems-clean

Conversation

@Dimotai
Copy link

@Dimotai Dimotai commented Feb 28, 2026

Summary

Adds MixinHideEntitySystems to catch IllegalStateException: Invalid entity reference! in HideEntitySystems$AdventurePlayerSystem.tick(). This crash occurs when a player teleports between worlds and their entity reference is invalidated mid-tick, crashing the entire world thread and disconnecting all players.

Related issues

  • None (new crash path not previously covered)

Type of change

  • Bug fix (non-breaking)

Implementation details

Adds MixinHideEntitySystems.java targeting HideEntitySystems$AdventurePlayerSystem. Uses the same wrap-and-rethrow pattern as MixinStateSupport — injects at HEAD of tick(), wraps the original call in a try/catch for IllegalStateException, and logs a warning instead of crashing. Uses a ThreadLocal<Boolean> re-entry guard to prevent infinite recursion.

Stack trace from production server (15-20 concurrent players):

java.lang.IllegalStateException: Invalid entity reference!
    at com.hypixel.hytale.component.Ref.validate(Ref.java)
    at com.hypixel.hytale.component.Store.__internal_getArchetype(Store.java)
    at com.hypixel.hytale.component.CommandBuffer.getArchetype(CommandBuffer.java)
    at com.hypixel.hytale.server.core.modules.entity.system.HideEntitySystems$AdventurePlayerSystem.tick(HideEntitySystems.java)

Files changed:

  • early/src/main/java/.../mixin/MixinHideEntitySystems.java (new)
  • early/src/main/resources/refixes.mixins.json (added registration)

Checklist

  • Code compiles successfully
  • Pull request does not contain unrelated changes
  • Changes follow this project's code style (Use spotlessApply when necessary)
  • Changes are tested or will be tested after submission

Additional info

Tested on a production Hytale server (Histatu). The mixin loads cleanly and the server boots without errors. The fix only activates on the exact code path that would have crashed the world thread — normal tick execution is unaffected.

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.

2 participants