Jump to content

Recommended Posts

Posted

So, I have two SubscribeEvent methods. One registers all my items (1 so far) and the other registers the models on the client. From many other tutorials, I've seen many styles of this, but they are all different. I'm using this one from cubicoder's tutorial.

Spoiler

public class SoochModelRegEvents { // this is only registered on client and in preinit (placing the register call anywhere else will cause the handler to miss the modelreg events)
    @SubscribeEvent
    public static void registerModels(ModelRegistryEvent event) {
        registerModel(SoochItems.SOOCH);
    }

    private static void registerModel(Item item) {
        ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(item.getRegistryName(), "inventory"));
    }
}

 

Spoiler

public class SoochRegisterEvents {
    @SubscribeEvent
    public static void registerItems(Register<Item> event) {
        final Item[] items = {
                new ItemSooch()
        };

        event.getRegistry().registerAll(items);
    }
}

 

Here's the problem though. Item registering comes after the model registries. Which means that SoochItems.SOOCH is null when the model register events are called.
How do I handle this? Should I just initialize all of my items in an array? This gets rid of the entire point of ObjectHolder, so I wasn't tempted to do it. As I said, every tutorial I can find conflicts in some way. What do I do?

Epic Website

Posted (edited)

Alright, may have jumped to conclusions there. But why is SOOCH null? According to the Forge Documentation:
"After the Register<Block> event has fired, all ObjectHolder annotations are refreshed, and after Register<Item> has fired they are refreshed again."
Which means that SOOCH should've been injected, but it's null.
 

Spoiler

@ObjectHolder(Soochcraft.MODID)
public class SoochItems {
    public static final ItemSooch SOOCH = null;
}

 

Is it not injecting because of the uppercased SOOCH variable? I was told before that it automatically lowercases and *then* checks for injection.

Edited by FrostBytes
unnecessary quote sorry!

Epic Website

Posted

Was this changed recently? I used to use @ObjectHolder filled fields for my model registration and it worked.

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

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.