Skip to content

feat: Guard sky-limit block updates against out-of-range chunk section indices#3098

Merged
milutinke merged 2 commits intomasterfrom
copilot/bugfix-out-of-bounds-exception
May 6, 2026
Merged

feat: Guard sky-limit block updates against out-of-range chunk section indices#3098
milutinke merged 2 commits intomasterfrom
copilot/bugfix-out-of-bounds-exception

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 6, 2026

On 1.8, joining near the sky limit could crash MCC with an out-of-bounds exception while terrain updates were being applied. The failure came from treating the first invalid section above the world ceiling as if it were still inside the loaded chunk column.

  • Root cause

    • World.SetBlock() accepted location.ChunkY == column.ColumnSize.
    • In 256-high worlds, Y=256 maps to chunk section 16, but valid sections are 0..15.
    • A block update at that boundary could therefore index past the chunk column.
  • Change

    • Tightened the chunk-section bounds check in World.SetBlock().
    • The method now ignores block writes whose computed chunk Y is outside the valid column range, including negative section indices.
  • Effect

    • Prevents terrain-update crashes at the upper world boundary.
    • Keeps normal in-range terrain handling unchanged.
ChunkColumn? column = this[location.ChunkX, location.ChunkZ];
if (column is not null && location.ChunkY >= 0 && location.ChunkY < column.ColumnSize)
{
    Chunk? chunk = column.GetChunk(location);
    if (chunk is null)
        column[location.ChunkY] = chunk = new Chunk();
    chunk[location.ChunkBlockX, location.ChunkBlockY, location.ChunkBlockZ] = block;
}

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • snoop.minecraft.net
    • Triggering command: /usr/bin/java /usr/bin/java -Xmx2G -Xms2G -jar server.jar nogui (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI linked an issue May 6, 2026 that may be closed by this pull request
4 tasks
Copilot AI changed the title [WIP] Fix out of bounds exception at sky limit Guard sky-limit block updates against out-of-range chunk section indices May 6, 2026
Copilot AI requested a review from milutinke May 6, 2026 20:36
@milutinke milutinke changed the title Guard sky-limit block updates against out-of-range chunk section indices feat: Guard sky-limit block updates against out-of-range chunk section indices May 6, 2026
@milutinke milutinke marked this pull request as ready for review May 6, 2026 22:10
@milutinke milutinke merged commit 6673b39 into master May 6, 2026
2 checks passed
@milutinke milutinke deleted the copilot/bugfix-out-of-bounds-exception branch May 6, 2026 22:10
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.

[BUG] Out of bounds exception at sky limit

2 participants