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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@ public class IGBlocks {
public static BlockCasingSpaceElevator SpaceElevatorCasing;
public static BlockCasingSpaceElevatorMotor SpaceElevatorMotor;

/**
* Initialize the blocks of this mod
*/
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

SpaceElevatorCasing = new BlockCasingSpaceElevator();
SpaceElevatorMotor = new BlockCasingSpaceElevatorMotor();
}

/**
* For explicit loading of this class.
*/
public static void init() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,19 @@ public class IGItems {
public static ItemStack SpaceElevatorModuleManager;
public static ItemStack SpaceElevatorModuleResearch;

/**
* Initialize the items of this mod
*/
public static void init() {
static {
// Initialize the items of this mod
SpaceElevatorItems = new ItemSpaceElevatorParts();
MiningDrones = new ItemMiningDrones();
registerItem(SpaceElevatorItems);
registerItem(MiningDrones);
}

/**
* For explicit loading of this class.
*/
public static void init() {}

/**
* Register an item in the game registry, using its unlocalized name
*
Expand Down