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

Use static block initialization for better compatibility #58

Closed
wants to merge 1 commit into from
Closed

Conversation

wohaopa
Copy link

@wohaopa wohaopa commented Apr 3, 2024

Sometimes explicit initializers are not called in time, which may improve the compatibility of this mod.

@Dream-Master Dream-Master requested a review from a team April 3, 2024 20:15
*/
public static void init() {
static {
// Initialize the blocks of this mod
SpaceElevatorCable = new BlockSpaceElevatorCable();
GameRegistry.registerBlock(SpaceElevatorCable, ItemBlockSpaceElevatorCable.class, "spaceelevatorcable");
Copy link
Member

Choose a reason for hiding this comment

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

This is a bad idea imo, registration should be called from this mod's preinit and this will cause the first class load try to register the blocks, which might happen in another mod

Copy link
Member

Choose a reason for hiding this comment

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

If something needs the blocks from this mod, it should use a after: or required-after: dependency in its @Mod annotation to ensure the blocks are registered in time

@Dream-Master Dream-Master added ongoing freeze - don't merge Not just a bug fix and thus affected by a current freeze for a upcoming version and removed ongoing freeze - don't merge Not just a bug fix and thus affected by a current freeze for a upcoming version labels Apr 28, 2024
@wohaopa wohaopa closed this May 6, 2024
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.

4 participants