Skip to content
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

Add an error block, and render it in case of NPE in ISBRH #658

Merged
merged 4 commits into from
Oct 13, 2024

Conversation

Cleptomania
Copy link
Member

@Cleptomania Cleptomania commented Oct 13, 2024

This does two things:

  1. Adds a new BlockError, which has a static instance stored in AngelicaMod. For most purposes, this functions like a normal block in the game, however it is not actually registered. A mixin to TextureMap is causing the texture for it to get pulled in when all the other block textures get loaded. This means we get the client side texture loading and such, and we can use this block with normal functions from RenderBlocks, but don't actually have to register it. Registering the block on the client but not the server can cause problems with Block IDs.

  2. It wraps all ISBRH calls in a try/catch for NullPointerException. If this exception happens, it renders this new error block instead.

This should eliminate crashes due to the race condition involved with multi-threading ISBRHs and blocks getting broken, causing the TileEntity to be null by the time the worker thread gets to rendering that block. As we are doing a deepcopy of the block data to the thread, but only a shallow copy which still pulls references to the main data for the TE data, since a deepcopy of all TE data to the worker threads is not feasible.

Below is an example of the block, this is with a fake fork of StorageDrawers which is forcibly throwing a NullPointerException in renderWorldBlock.

image

Copy link
Collaborator

@mitchej123 mitchej123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@mitchej123 mitchej123 merged commit 6c99872 into master Oct 13, 2024
1 check passed
@mitchej123 mitchej123 deleted the null-te-race branch October 13, 2024 21:59
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.

2 participants