Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hey guys,

 

So how do I override a vanilla recipe in 1.12? I tried overriding the recipe json file in a resource pack but it didn't work. Sorry if this is a basic question, but there doesn't seem to be anything out there for 1.12 yet that I can find.

Edited by DragonFerocity

Now that IRecipes are in a Forge registry, you can override an existing IRecipe simply by registering a new one with the same registry name.

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.

9 hours ago, Choonster said:

Now that IRecipes are in a Forge registry, you can override an existing IRecipe simply by registering a new one with the same registry name.

This didn't work for me until I removed the recipe first. Unless by registering  you mean in code and not via JSON.

 

My solution:

    @SubscribeEvent
    public static void registerRecipes(RegistryEvent.Register<IRecipe> event)
    {
    	ResourceLocation theButton = new ResourceLocation("minecraft:wooden_button");
        IForgeRegistryModifiable modRegistry = (IForgeRegistryModifiable) event.getRegistry();
        modRegistry.remove(theButton);
    }

from https://github.com/kreezxil/More-Beautiful-Buttons/blob/master/src/main/java/com/kreezcraft/morebeautifulbuttons/init/Registrar.java#L43-L49

Just now, kreezxil said:

This didn't work for me until I removed the recipe first. Unless by registering  you mean in code and not via JSON.

 

JSON recipes always have your mod ID as the domain of their registry name, so they can't directly override a vanilla recipe.

 

Removing a vanilla recipe and then loading your own to replace is it possible, as you discovered.

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.

6 minutes ago, Choonster said:

 

JSON recipes always have your mod ID as the domain of their registry name, so they can't directly override a vanilla recipe.

 

Removing a vanilla recipe and then loading your own to replace is it possible, as you discovered.

Is there an easier way to do what I did?

Just now, kreezxil said:

Is there an easier way to do what I did?

 

Not really, the recipe removal needs to be done in code and the replacement should generally be added via JSON; so replacing recipes via the registry override system (registering a new value with the same name) usually isn't practical.

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.

  • Author
5 hours ago, kreezxil said:

This didn't work for me until I removed the recipe first. Unless by registering  you mean in code and not via JSON.

 

My solution:


    @SubscribeEvent
    public static void registerRecipes(RegistryEvent.Register<IRecipe> event)
    {
    	ResourceLocation theButton = new ResourceLocation("minecraft:wooden_button");
        IForgeRegistryModifiable modRegistry = (IForgeRegistryModifiable) event.getRegistry();
        modRegistry.remove(theButton);
    }

from https://github.com/kreezxil/More-Beautiful-Buttons/blob/master/src/main/java/com/kreezcraft/morebeautifulbuttons/init/Registrar.java#L43-L49

Where exactly did you put that snippet of code? Preinit or init or elsewhere?

Look at my github link that I provided. Note that above the class for the file containing this snipped it says @EventBusSubscriber. That's what tells Forge to come to the file and load up the subscriber events, ie these routines don't go in the init, preinit, or postinit. So feel free to copy my registrar.java and use it as you please. You'll probably end up with a class that looks like:

package com.mod.awesomeyour;

import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.event.RegistryEvent.Register;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.registries.IForgeRegistryModifiable;

@EventBusSubscriber
public class Registrar {

    @SubscribeEvent
    public static void registerRecipes(RegistryEvent.Register<IRecipe> event)
    {
    	ResourceLocation theButton = new ResourceLocation("minecraft:wooden_button");
        IForgeRegistryModifiable modRegistry = (IForgeRegistryModifiable) event.getRegistry();
        modRegistry.remove(theButton);
    }
}

that's all you need to remove the wooden button, extrapolate as necessary.

  • 1 month later...

This doesn't work for me on Forge 2462, the event never fires.

Nevermind, I was using a non-static event handler and copied in a static method.

Edited by Draco18s

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.