From aa39ea764024baf0935677bbb221b610bba1b479 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=9D=E5=A4=8F=E5=90=8C=E5=AD=A6?= <2411829240@qq.com> Date: Wed, 3 Apr 2024 21:55:00 +0800 Subject: [PATCH] Use static block initialization for better compatibility --- .../gtnhintergalactic/block/IGBlocks.java | 11 +++++++---- .../gtnewhorizons/gtnhintergalactic/item/IGItems.java | 11 +++++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/gtnewhorizons/gtnhintergalactic/block/IGBlocks.java b/src/main/java/com/gtnewhorizons/gtnhintergalactic/block/IGBlocks.java index a814d80..e69f968 100644 --- a/src/main/java/com/gtnewhorizons/gtnhintergalactic/block/IGBlocks.java +++ b/src/main/java/com/gtnewhorizons/gtnhintergalactic/block/IGBlocks.java @@ -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"); SpaceElevatorCasing = new BlockCasingSpaceElevator(); SpaceElevatorMotor = new BlockCasingSpaceElevatorMotor(); } + + /** + * For explicit loading of this class. + */ + public static void init() {} } diff --git a/src/main/java/com/gtnewhorizons/gtnhintergalactic/item/IGItems.java b/src/main/java/com/gtnewhorizons/gtnhintergalactic/item/IGItems.java index 664e3c5..618d386 100644 --- a/src/main/java/com/gtnewhorizons/gtnhintergalactic/item/IGItems.java +++ b/src/main/java/com/gtnewhorizons/gtnhintergalactic/item/IGItems.java @@ -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 *