Jump to content

[1.17.1] Description: Exception initializing level java.lang.NoClassDefFoundError: Could not initialize class


DireTook

Recommended Posts

I been further trying to figure this out and believe I've narrowed it down to my FMLCommonSetupEvent event. 

Quote

    private void setup(final FMLCommonSetupEvent event) {
        event.enqueueWork(() -> {
            StructureInit.setupStructures();
            StructureInit.registerConfiguredStructures();
        });
    }

It seems to call setup but not actually call either method inside the  event.enqueueWork() at any point. So my configured structure is never actually registered before my BiomeLoadingEvent event?

Do anyone know what would be causing this? 

Link to comment
Share on other sites

1 hour ago, DireTook said:

It seems to call setup but not actually call either method inside the  event.enqueueWork() at any point. So my configured structure is never actually registered before my BiomeLoadingEvent event?

answer: do not use event.enqueueWork

Link to comment
Share on other sites

So I've essentially been trying to replicate this tutorial code as its the best info I could find on custom structures: https://github.com/TelepathicGrunt/StructureTutorialMod and it makes use of event.enqueueWork. I've tried replacing it but can't find anything else that would work.

You can see my methods in this gist: https://gist.github.com/DireTook/dd13728e54cc58a2615d8ebf9f7ed167

registerConfiguredStructures() should just register my structure as a configured structure whilst setupStructures() should add the separation settings.

What made me think it doesn't actually call the methods, is that I was simply putting a System.out.println("REACHED HERE"); and seeing if it printed. It did print if placed above event.enqueueWork but not when placed in the Structure methods.

Link to comment
Share on other sites

Definitely my bad for not realising I didn't register my STRUCTURES DeferredRegister.

I've moved the Configured Structure code to its own class so it should only be accessed after registry. Not sure if that's the best solution? But it does work now.

Thanks very much for the help!

Link to comment
Share on other sites

But since I'm using CONFIGURED_EXAMPLE_STRUCTURE in the biomeModification method and calling my new Configured Structure class using the setup method with event.enqueueWork, is a static initializer not the most efficient way?

Quote

public void setup(final FMLCommonSetupEvent event) {
    event.enqueueWork(() -> {
        StructureInit.setupStructures();
        ConfiguredStructureInit.registerConfiguredStructures();
    }).whenComplete((v, err) -> {
        err.printStackTrace();
    });

 }

public void biomeModification(final BiomeLoadingEvent event) 
{
    event.getGeneration().getStructures().add(() -> ConfiguredStructureInit.CONFIGURED_EXAMPLE_STRUCTURE);
}

 

Edited by DireTook
Link to comment
Share on other sites

I guess I mean neater. This way I don't have to potentially use return CONFIGURED_EXAMPLE_STRUCTURE and possibly merging methods together in one class or... tbh I'm not entirely sure how I'd successfully go about not doing it as a static initializer whilst still functioning but I'm after attempting to for bit, it seems like it'd be a lot messier

Link to comment
Share on other sites

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.