Skip to content

fix: guard onPlayerUpdate against non-Player entities#349

Open
Bobbyperson wants to merge 1 commit into
RazorDevs:1.21.1-1.1from
Bobbyperson:guard-onplayerupdate
Open

fix: guard onPlayerUpdate against non-Player entities#349
Bobbyperson wants to merge 1 commit into
RazorDevs:1.21.1-1.1from
Bobbyperson:guard-onplayerupdate

Conversation

@Bobbyperson
Copy link
Copy Markdown

DAGeneralEvents.onPlayerUpdate is subscribed to EntityTickEvent.Post, which fires for every ticking entity, but it casts the entity to Player after only an attachment check. Any non-player entity carrying DAAttachments.PLAYER reaches the cast and throws ClassCastException, crashing the server.

On a 1.21.1 / NeoForge 21.1.231 dedicated server this showed up as a crash loop. The real exception was masked by ServerHangWatchdog reports (a single server tick took 60000004.00 seconds), the actual cause was only in latest.log:

ClassCastException: Villager cannot be cast to Player
  at DAGeneralEvents.onPlayerUpdate(DAGeneralEvents.java:261)
  via fireEntityTickPost -> Ticking entity -> server shutdown

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.

1 participant