Jump to content

Recommended Posts

Posted (edited)

Hi dear modders,

 

I'm quite new to modding (but not to Java ;)) and I need some explanations about the Forge 1.12 registry event system.

 

Registering an Item or a Block seems quite easy to do, but I'm trying to add a basic WorldGenerator to create some ore vein.

The tutorial I'm following is now old, so I guess the registration part isn't up to date. l supposed we should now use some event, but I'm surprised, WorldGenerator isn't suitable for RegistryEvent.Register<T extends IForgeRegistryEntry==<==T>>. So what is the new way to register it?

 

Also, I discovered Recipe is an instance of IForgeRegistryEntry. So I suppose I should use the event for registration. For now I'm doing it this way:

Spoiler

    @EventHandler
    public void init(FMLInitializationEvent event) {
      	// Some stuff
        CraftingHelper.register(new ResourceLocation(References.MODID, "item_registry_name.json"),
                                (IRecipeFactory) (context, json) -> CraftingHelper.getRecipe(json, context));
        proxy.init(event);
    }

 

Is it the intended way to do this? What is your way to register recipes from JSON files?

 

Any detail would be appreciated.

Edited by Unit
Posted

RegistryEvent.Register is only for types that are in a Forge registry (i.e. types that implement IForgeRegistryEntry). There's no IWorldGenerator registry (IWorldGenerator doesn't extend IForgeRegistryEntry), so IWorldGenerators should still be registered in preInit/init.

 

Recipe files in your mod's assets/<modid>/recipes directory are automatically loaded and registered by Forge. IRecipeFactory, IIngredientFactory and IConditionFactory classes should be specified in assets/<modid>/recipes/_factories.json rather than being registered in code.

 

If you do register recipes in code (which you should avoid doing where possible), do it in RegistryEvent.Register<IRecipe>.

  • Like 1

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted (edited)

Thanks for your quick answer.

I think this topic is closed. I still have some issues with my WorldGenerator (for some reason it works like a charm with Minecraft vanilla blocks, but not with mines), but I guess it's a subject for another topic.

 

EDIT:

I was wrong, it actually works, I don't know why I couldn't find any veins. No luck I guest.

 

Edited by Unit

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.