fix: add full Minecraft 1.18+ support for negative Y coordinates#471
Open
keithworrell wants to merge 1 commit into
Open
fix: add full Minecraft 1.18+ support for negative Y coordinates#471keithworrell wants to merge 1 commit into
keithworrell wants to merge 1 commit into
Conversation
Fixes several critical bugs preventing proper rendering of Minecraft 1.18+ worlds with negative Y coordinates (Y=-64 to Y=320). ## Issues Fixed ### 1. Chunk sections not rendering on initial load **Files**: viewer/lib/worldrenderer.js (addColumn, removeColumn) **Problem**: Y loop hardcoded to 0-256, ignoring negative Y sections **Solution**: Changed range to -64 to 320 (full 1.18+ world height) ### 2. Section index calculation errors **File**: viewer/lib/worker.js **Problem**: Math.floor(y / 16) produces negative array indices for Y < 0 **Solution**: Use Math.floor((y - chunk.minY) / 16) to account for minY offset ### 3. Unknown entity crashes **File**: viewer/lib/entity/Entity.js **Problem**: Throws error when encountering unknown entity types **Solution**: Log warning and create placeholder mesh instead ### 4. Null block handling **File**: viewer/lib/models.js **Problem**: Crashes when chunk not fully loaded **Solution**: Skip null blocks gracefully ## Testing Tested on Minecraft 1.21.1 (protocol 767) with: - Flat creative world at Y=-60 - Underground structures at Y < 0 - Chunk loading/unloading - Browser refresh persistence ## Before/After **Before**: Chunks at negative Y don't render until blocks are modified **After**: All chunks render immediately on initial load Fixes rendering for underground bases, caves, and flat worlds introduced in Minecraft 1.18 (Nov 2021).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes several critical bugs preventing proper rendering of Minecraft 1.18+ worlds with negative Y coordinates (Y=-64 to Y=320).
Issues Fixed
1. Chunk sections not rendering on initial load Files: viewer/lib/worldrenderer.js (addColumn, removeColumn) Problem: Y loop hardcoded to 0-256, ignoring negative Y sections Solution: Changed range to -64 to 320 (full 1.18+ world height)
2. Section index calculation errors
File: viewer/lib/worker.js
Problem: Math.floor(y / 16) produces negative array indices for Y < 0 Solution: Use Math.floor((y - chunk.minY) / 16) to account for minY offset
3. Unknown entity crashes
File: viewer/lib/entity/Entity.js
Problem: Throws error when encountering unknown entity types Solution: Log warning and create placeholder mesh instead
4. Null block handling
File: viewer/lib/models.js
Problem: Crashes when chunk not fully loaded
Solution: Skip null blocks gracefully
Testing
Tested on Minecraft 1.21.1 (protocol 767) with:
Before/After
Before: Chunks at negative Y don't render until blocks are modified After: All chunks render immediately on initial load
Fixes rendering for underground bases, caves, and flat worlds introduced in Minecraft 1.18 (Nov 2021).