-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix raycasting errors on unloaded chunks #88
Conversation
Fix raycasting exceptions in async world when a chunk is unloaded, would previously result in `undefined.getBlock()`. Return undefined on getters where no cc is present. https://github.com/PrismarineJS/prismarine-world/blob/master/src/world.js#L64
This doesn't make sense to me. Mineflayer uses sync, flying squid uses async Raycast is defined based on the async API Is raycast used in mineflayer? If yes it should had the sync API, or there should be a separate sync version |
Yes so when reading chunks off of disk through prismarine-provider-anvil without a chunk generator the raycasting can fail on movement if you move the cursor somewhere where there isn’t a generated chunk. This can happen for example when reading a vanilla world through prismarine-viewer (reproducible through the electron prismarine viewer example) |
this is a breaking API change, currently the async api cannot return null |
To make it not breaking what about returning air or 0? The alternative here is crashing on undefined property which is probably slower to handle. I believe the issue is with the raycast function below which is used in pviewer, it checks for undefined blocks but it doesn't catch the error in the getBlock() call |
something that would make this easier is doing #64 if we merge this, we would need to change all calls to getBlock to handle null even with the async API, it doesn't seem like the best path |
returning air/0 might be ok I guess |
just to clarify: today getBlock() async is supposed to never error out and never return null |
seems too old |
yeah I don't remember the full context behind this, so if I visit anvil-provider again I'll revisit this |
Fix raycasting exceptions in async world when a chunk is unloaded, would previously result in
undefined.getBlock()
. Return undefined on getters where no cc is present.https://github.com/PrismarineJS/prismarine-world/blob/master/src/world.js#L64