Skip to content

Fix Ender Dragon damage, End portal transition, and End Poem crash#1428

Open
itsRevela wants to merge 1 commit intosmartcmd:mainfrom
itsRevela:fix-end-dimension-dedicated
Open

Fix Ender Dragon damage, End portal transition, and End Poem crash#1428
itsRevela wants to merge 1 commit intosmartcmd:mainfrom
itsRevela:fix-end-dimension-dedicated

Conversation

@itsRevela
Copy link
Copy Markdown
Contributor

Description

  • Fixes three End dimension issues on dedicated servers: Ender Dragon immune to melee damage, End exit portal crashing the game, and End Poem crashing the client

Changes

Previous Behavior

  • Hitting the Ender Dragon with a sword on a dedicated server did nothing. The dragon appeared immune to all melee damage.
  • Entering the End exit portal after defeating the dragon crashed the game.
  • The End Poem crashed the client on dedicated servers with an out-of-bounds access.

Root Cause

  • Dragon melee: The server's entity ID allocator (smallId pool) assigned non-sequential IDs to the dragon's body parts (head, body, etc.), but the client assumed sequential offsets from the parent entity ID. Melee attacks targeted IDs the server didn't recognize, so hits were silently dropped.
  • End portal: The player entity was never added to the Overworld level during the dimension transition. The addEntity call in PlayerList::changeDimension was gated behind a lastDimension != 1 check that excluded End-to-Overworld transitions, leaving the player as a ghost entity that caused a crash on the next interaction.
  • End Poem: The WIN_GAME event handler indexed into localplayers[] using the server-assigned player index without bounds checking. On dedicated servers this index can exceed XUSER_MAX_COUNT, causing a null dereference.

Fix Implementation

  • Dragon melee: ServerLevel::entityAdded() now reassigns sub-entity IDs to be sequential from the parent entity ID when an entity with parts is added to the level
  • End portal: Removed the lastDimension != 1 gate so the player entity is always added to the destination level during End transitions
  • End Poem: Added bounds check on the player index before accessing localplayers[], with a fallback to the primary local player

AI Use Disclosure

  • No AI was used to write the code in this PR.

Related Issues

  • None

Dragon melee damage: reassign sub-entity IDs to be sequential from
the parent entity ID in ServerLevel::entityAdded(), so the client's
offset-based ID calculation matches the server. Previously the server's
smallId pool allocated non-sequential IDs, causing melee attacks to
target entity IDs the server didn't recognize.

End portal transition: ensure the player entity is always added to the
new level when transitioning from The End, not just for non-End
dimensions. The addEntity call was previously gated behind a
lastDimension != 1 check that also excluded it from End exits.

End Poem crash: bounds-check the WIN_GAME event's player index before
accessing localplayers[], with a fallback to prevent null dereference
when the server sends an out-of-range index.
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