Jump to content

[1.14.4] Registering a custom Stairs Block leads to a crash


F43nd1r

Recommended Posts

I tried to register a custom Stairs Block in my mod, but it always leads to a crash:


java.lang.ExceptionInInitializerError
	at net.minecraftforge.registries.NamespacedDefaultedWrapper$Factory.onCreate(NamespacedDefaultedWrapper.java:154)
	at net.minecraftforge.registries.RegistryBuilder.lambda$getCreate$2(RegistryBuilder.java:228)
	at net.minecraftforge.registries.ForgeRegistry.<init>(ForgeRegistry.java:127)
	at net.minecraftforge.registries.RegistryManager.createRegistry(RegistryManager.java:134)
	at net.minecraftforge.registries.RegistryBuilder.create(RegistryBuilder.java:184)
	at net.minecraftforge.registries.GameData.init(GameData.java:169)
	at net.minecraftforge.registries.GameData.<clinit>(GameData.java:153)
	at net.minecraft.block.Block.<clinit>(Block.java:81)
	at com.faendir.minecraft.hadron.generated.ModObjects0.<clinit>(ModObjects0.java:76)
	at com.faendir.minecraft.hadron.generated.Registry1.registerBlock(Registry1.java:35)
	at net.minecraftforge.eventbus.ASMEventHandler_10_Registry1_registerBlock_Register.invoke(.dynamic)
	at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:80)
	at net.minecraftforge.eventbus.EventBus.post(EventBus.java:258)
	at net.minecraftforge.fml.javafmlmod.FMLModContainer.fireEvent(FMLModContainer.java:106)
	at java.base/java.util.function.Consumer.lambda$andThen$0(Consumer.java:65)
	at java.base/java.util.function.Consumer.lambda$andThen$0(Consumer.java:65)
	at net.minecraftforge.fml.ModContainer.transitionState(ModContainer.java:112)
	at net.minecraftforge.fml.ModList.lambda$dispatchSynchronousEvent$4(ModList.java:110)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1378)
	at net.minecraftforge.fml.ModList.dispatchSynchronousEvent(ModList.java:110)
	at net.minecraftforge.fml.ModList.lambda$static$0(ModList.java:81)
	at net.minecraftforge.fml.LifecycleEventProvider.dispatch(LifecycleEventProvider.java:71)
	at net.minecraftforge.fml.ModLoader.dispatchAndHandleError(ModLoader.java:173)
	at net.minecraftforge.fml.ModLoader.lambda$gatherAndInitializeMods$21(ModLoader.java:165)
	at net.minecraftforge.registries.GameData.fireRegistryEvents(GameData.java:918)
	at net.minecraftforge.fml.ModLoader.gatherAndInitializeMods(ModLoader.java:165)
	at net.minecraftforge.fml.client.ClientModLoader.lambda$begin$2(ClientModLoader.java:68)
	at net.minecraftforge.fml.client.ClientModLoader.lambda$createRunnableWithCatch$5(ClientModLoader.java:84)
	at net.minecraftforge.fml.client.ClientModLoader.begin(ClientModLoader.java:68)
	at net.minecraft.client.Minecraft.init(Minecraft.java:456)
	at net.minecraft.client.Minecraft.run(Minecraft.java:365)
	at net.minecraft.client.main.Main.main(Main.java:128)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:564)
	at net.minecraftforge.userdev.FMLUserdevClientLaunchProvider.lambda$launchService$0(FMLUserdevClientLaunchProvider.java:55)
	at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37)
	at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:50)
	at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:68)
	at cpw.mods.modlauncher.Launcher.run(Launcher.java:80)
	at cpw.mods.modlauncher.Launcher.main(Launcher.java:65)
	at net.minecraftforge.userdev.LaunchTesting.main(LaunchTesting.java:101)
Caused by: java.lang.NullPointerException: Attempted to get vanilla wrapper for unknown registry: class net.minecraft.util.SoundEvent
	at org.apache.commons.lang3.Validate.notNull(Validate.java:225)
	at net.minecraftforge.registries.GameData.getWrapper(GameData.java:233)
	at net.minecraft.util.registry.Registry.forge(Registry.java:250)
	at net.minecraft.util.registry.Registry.<clinit>(Registry.java:77)
	... 43 more

I'll try to add all relevant classes here, please ask if I need to provide more information to receive help.

@Mod.EventBusSubscriber(
        modid = "hadron",
        bus = Mod.EventBusSubscriber.Bus.MOD
)
public class Registry1 {
  ...

    @SubscribeEvent
    public static void registerBlock(RegistryEvent.Register<Block> event) {
        event.getRegistry().register(ModObjects0.OAK_WOOD_WALL);
        event.getRegistry().register(ModObjects0.DIORITE_BRICK_STAIRS);
        event.getRegistry().register(ModObjects0.ANDESITE_BRICK_STAIRS);
        event.getRegistry().register(ModObjects0.GRANITE_BRICK_SLABS);
        event.getRegistry().register(ModObjects0.ANDESITE_BRICK_SLABS);
        event.getRegistry().register(ModObjects0.DIORITE_BRICK_SLABS);
        event.getRegistry().register(ModObjects0.OAK_WOOD_SLABS);
        event.getRegistry().register(ModObjects0.OAK_WOOD_STAIRS);
        event.getRegistry().register(ModObjects0.GRANITE_BRICK_STAIRS);
    }
}
public class ModObjects0 {
...

    public static final Block DIORITE_BRICK_SLABS = new SlabBlock(Block.Properties.from(StoneBricks.DIORITE_BRICKS)).setRegistryName("diorite_brick_slabs");

    public static final Block OAK_WOOD_SLABS = new SlabBlock(Block.Properties.from(MoreBark.OAK_BARK)).setRegistryName("oak_wood_slabs");

    public static final Block GRANITE_BRICK_SLABS = new SlabBlock(Block.Properties.from(StoneBricks.GRANITE_BRICKS)).setRegistryName("granite_brick_slabs");

    public static final Block ANDESITE_BRICK_SLABS = new SlabBlock(Block.Properties.from(StoneBricks.ANDESITE_BRICKS)).setRegistryName("andesite_brick_slabs");

    public static final Block DIORITE_BRICK_STAIRS = new HadronStairsBlock(StoneBricks.DIORITE_BRICKS.getDefaultState(), Block.Properties.from(StoneBricks.DIORITE_BRICKS)).setRegistryName("diorite_brick_stairs");

    public static final Block OAK_WOOD_STAIRS = new HadronStairsBlock(MoreBark.OAK_BARK.getDefaultState(), Block.Properties.from(MoreBark.OAK_BARK)).setRegistryName("oak_wood_stairs");

    public static final Block GRANITE_BRICK_STAIRS = new HadronStairsBlock(StoneBricks.GRANITE_BRICKS.getDefaultState(), Block.Properties.from(StoneBricks.GRANITE_BRICKS)).setRegistryName("granite_brick_stairs");

    public static final Block ANDESITE_BRICK_STAIRS = new HadronStairsBlock(StoneBricks.ANDESITE_BRICKS.getDefaultState(), Block.Properties.from(StoneBricks.ANDESITE_BRICKS)).setRegistryName("andesite_brick_stairs");

    public static final Block OAK_WOOD_WALL = new WallBlock(Block.Properties.from(MoreBark.OAK_BARK)).setRegistryName("oak_wood_wall");
}
public class HadronStairsBlock extends StairsBlock {
    public HadronStairsBlock(BlockState state, Properties properties) {
        super(state, properties);
    }
}

 

It seems to me that my class is loaded at the wrong point in time (too late?), but I'm not sure if that's the issue or how to fix it.

Am I doing something wrong?

Link to comment
Share on other sites

Do not use static initializers. Initialize your items and blocks during the appropriate registry events.

 

Please post a GitHub repo of your mod.

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

Link to comment
Share on other sites

  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.