Jump to content

Recommended Posts

Posted

Hey there,

I just started a new mod and when I lauched it for the first time none of my items were loading. I did some troubleshooting and eventually I found out that the constructor of my main mod file (the one with the Mod annotation) is not being called at all!

I have checked the mods.toml file but its all correct. The annotations are correct too. In minecraft the mod shows up as loaded. But as I said, none of the items are registered since the constructor was never called.

 

@Mod("witchcraftmod")
@EventBusSubscriber(modid = "witchcraftmod", bus = Bus.MOD)
public class WitchcraftMod {
    public static final String MOD_ID = "witchcraftmod"; 
    public static WitchcraftMod instance;
    
    public WitchcraftMod() {

        System.exit(0); //<---- I put this here to test if the constructor is called, but since minecraft starts normally Im assuming its not

        
    	final IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
        modEventBus.addListener(this::setup);
        modEventBus.addListener(this::doClientStuff);
        
        ModItems.ITEMS.register(modEventBus);
        ModBlocks.BLOCKS.register(modEventBus);
        Features.FEATURES.register(modEventBus);
        
        MinecraftForge.EVENT_BUS.register(this);

        instance = this;
    }

Does anyone know what I shoulkd do to troubleshoot this further or maybe even how to solve this issue?

Posted

Please show your logs, and use the debugger instead of just adding exit methods in places.

This probably isn't part of the issue, but it also looks like you don't need that EventBusSubscriber annotation since you're using IEventBus#addListener.

I'm eager to learn and am prone to mistakes. Don't hesitate to tell me how I can improve.

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.