Posted July 25, 20178 yr 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 July 25, 20178 yr by DragonFerocity
July 25, 20178 yr 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.
July 25, 20178 yr 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 https://www.akliz.net/manage/aff.php?aff=179 coupon: kreezxil KreezCraft.com - Twitch.TV/Kreezxil - YouTube.com/Kreezxil
July 25, 20178 yr 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.
July 25, 20178 yr 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? https://www.akliz.net/manage/aff.php?aff=179 coupon: kreezxil KreezCraft.com - Twitch.TV/Kreezxil - YouTube.com/Kreezxil
July 25, 20178 yr 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.
July 25, 20178 yr 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?
July 25, 20178 yr 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. https://www.akliz.net/manage/aff.php?aff=179 coupon: kreezxil KreezCraft.com - Twitch.TV/Kreezxil - YouTube.com/Kreezxil
August 28, 20178 yr 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 August 28, 20178 yr 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.