Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.12] Override vanilla recipe


DragonFerocity
 Share

Recommended Posts

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

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

 Share



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • In 1.16 i used onBlockAdded() to create the other blocks.  So far in 1.17 i cannot find the equivalent.  Something i read makes me think i have to create and register a event
    • in you item class add code: @Override public ItemStack getContainerItem(ItemStack itemStack) { return itemStack.copy(); } @Override public boolean hasContainerItem(ItemStack stack) { return true; }  
    • I only made a custom sword, but it is too small, I want to make it a little bigger    
    • Hello, Whenever I try to start forge 1.16.5, I get an error saying MVI couldn't load because there's not enough data available. Can anyone help with this? This is the crash text:   ---- Minecraft Crash Report ---- // You should try our sister game, Minceraft! Time: 12/2/21 5:27 PM Description: Mod loading error has occurred java.lang.Exception: Mod Loading has failed     at net.minecraftforge.fml.CrashReportExtender.dumpModLoadingCrashReport(CrashReportExtender.java:85) [?:?] {re:classloading}     at net.minecraftforge.fml.client.ClientModLoader.completeModLoading(ClientModLoader.java:188) [?:?] {re:classloading,pl:runtimedistcleaner:A}     at net.minecraft.client.Minecraft.lambda$null$1(Minecraft.java:508) [?:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A}     at net.minecraft.client.Minecraft$$Lambda$4660/1471145035.run(Unknown Source) [?:?] {}     at net.minecraft.util.Util.func_215077_a(Util.java:430) [?:?] {re:classloading,xf:OptiFine:default,re:mixin}     at net.minecraft.client.Minecraft.lambda$new$2(Minecraft.java:504) [?:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A}     at net.minecraft.client.Minecraft$$Lambda$4409/1341785997.accept(Unknown Source) [?:?] {}     at net.minecraft.client.gui.ResourceLoadProgressGui.func_230430_a_(ResourceLoadProgressGui.java:172) [?:?] {re:classloading,xf:OptiFine:default}     at net.minecraft.client.renderer.GameRenderer.func_195458_a(GameRenderer.java:802) [?:?] {re:mixin,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,xf:OptiFine:default,pl:mixin:APP:mvw.mixins.json:GameRendererMixin,pl:mixin:A}     at net.minecraft.client.Minecraft.func_195542_b(Minecraft.java:976) [?:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A}     at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:607) [?:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A}     at net.minecraft.client.main.Main.main(Main.java:184) [?:?] {re:classloading,pl:runtimedistcleaner:A}     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_51] {}     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_51] {}     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_51] {}     at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_51] {}     at net.minecraftforge.fml.loading.FMLClientLaunchProvider.lambda$launchService$0(FMLClientLaunchProvider.java:51) [forge-1.16.5-36.2.0.jar:36.2] {}     at net.minecraftforge.fml.loading.FMLClientLaunchProvider$$Lambda$461/27818833.call(Unknown Source) [forge-1.16.5-36.2.0.jar:36.2] {}     at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-8.0.9.jar:?] {}     at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [modlauncher-8.0.9.jar:?] {}     at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [modlauncher-8.0.9.jar:?] {}     at cpw.mods.modlauncher.Launcher.run(Launcher.java:82) [modlauncher-8.0.9.jar:?] {}     at cpw.mods.modlauncher.Launcher.main(Launcher.java:66) [modlauncher-8.0.9.jar:?] {} A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Thread: Render thread Stacktrace:     at com.electronwill.nightconfig.core.io.ParsingException.notEnoughData(ParsingException.java:22) ~[core-3.6.3.jar:?] {} -- MOD mvw -- Details:     Mod File: mvw-1.7.2.jar     Failure message: MoreVanillaWeapons (mvw) has failed to load correctly         com.electronwill.nightconfig.core.io.ParsingException: Not enough data available     Mod Version: 1.16.X-1.7.2     Mod Issue URL: NOT PROVIDED     Exception message: com.electronwill.nightconfig.core.io.ParsingException: Not enough data available Stacktrace:     at com.electronwill.nightconfig.core.io.ParsingException.notEnoughData(ParsingException.java:22) ~[core-3.6.3.jar:?] {}     at com.electronwill.nightconfig.core.io.ReaderInput.directReadChar(ReaderInput.java:36) ~[core-3.6.3.jar:?] {}     at com.electronwill.nightconfig.core.io.AbstractInput.readChar(AbstractInput.java:49) ~[core-3.6.3.jar:?] {}     at com.electronwill.nightconfig.core.io.AbstractInput.readCharsUntil(AbstractInput.java:123) ~[core-3.6.3.jar:?] {}     at com.electronwill.nightconfig.toml.TableParser.parseKey(TableParser.java:166) ~[toml-3.6.3.jar:?] {}     at com.electronwill.nightconfig.toml.TableParser.parseDottedKey(TableParser.java:145) ~[toml-3.6.3.jar:?] {}     at com.electronwill.nightconfig.toml.TableParser.parseNormal(TableParser.java:55) ~[toml-3.6.3.jar:?] {}     at com.electronwill.nightconfig.toml.TomlParser.parse(TomlParser.java:44) ~[toml-3.6.3.jar:?] {}     at com.electronwill.nightconfig.toml.TomlParser.parse(TomlParser.java:37) ~[toml-3.6.3.jar:?] {}     at com.electronwill.nightconfig.core.io.ConfigParser.parse(ConfigParser.java:113) ~[core-3.6.3.jar:?] {}     at com.electronwill.nightconfig.core.io.ConfigParser.parse(ConfigParser.java:219) ~[core-3.6.3.jar:?] {}     at com.electronwill.nightconfig.core.io.ConfigParser.parse(ConfigParser.java:202) ~[core-3.6.3.jar:?] {}     at com.electronwill.nightconfig.core.file.WriteSyncFileConfig.load(WriteSyncFileConfig.java:73) ~[core-3.6.3.jar:?] {}     at com.electronwill.nightconfig.core.file.AutosaveCommentedFileConfig.load(AutosaveCommentedFileConfig.java:85) ~[core-3.6.3.jar:?] {}     at com.mrbelieve.mvw.ModConfig.<init>(ModConfig.java:21) ~[?:1.7.2] {re:classloading}     at com.mrbelieve.Mvw.<init>(Mvw.java:48) ~[?:1.7.2] {re:classloading}     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_51] {}     at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:1.8.0_51] {}     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.8.0_51] {}     at java.lang.reflect.Constructor.newInstance(Constructor.java:422) ~[?:1.8.0_51] {}     at java.lang.Class.newInstance(Class.java:442) ~[?:1.8.0_51] {}     at net.minecraftforge.fml.javafmlmod.FMLModContainer.constructMod(FMLModContainer.java:81) ~[?:36.2] {re:classloading}     at net.minecraftforge.fml.javafmlmod.FMLModContainer$$Lambda$3105/1982468278.run(Unknown Source) ~[?:?] {}     at net.minecraftforge.fml.ModContainer.lambda$buildTransitionHandler$4(ModContainer.java:120) ~[?:?] {re:classloading}     at net.minecraftforge.fml.ModContainer$$Lambda$3189/76306072.run(Unknown Source) ~[?:?] {}     at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1618) ~[?:1.8.0_51] {}     at java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1610) ~[?:1.8.0_51] {}     at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289) ~[?:1.8.0_51] {}     at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056) ~[?:1.8.0_51] {}     at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1689) ~[?:1.8.0_51] {re:computing_frames}     at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157) ~[?:1.8.0_51] {} -- System Details -- Details:     Minecraft Version: 1.16.5     Minecraft Version ID: 1.16.5     Operating System: Windows 10 (amd64) version 10.0     Java Version: 1.8.0_51, Oracle Corporation     Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation     Memory: 1351327720 bytes (1288 MB) / 2147483648 bytes (2048 MB) up to 2147483648 bytes (2048 MB)     CPUs: 8     JVM Flags: 10 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump -Xss1M -XX:+IgnoreUnrecognizedVMOptions -Xmx2G -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:MaxGCPauseMillis=50 -XX:G1HeapRegionSize=32M     ModLauncher: 8.0.9+86+master.3cf110c     ModLauncher launch target: fmlclient     ModLauncher naming: srg     ModLauncher services:          /mixin-0.8.2.jar mixin PLUGINSERVICE          /eventbus-4.0.0.jar eventbus PLUGINSERVICE          /forge-1.16.5-36.2.0.jar object_holder_definalize PLUGINSERVICE          /forge-1.16.5-36.2.0.jar runtime_enum_extender PLUGINSERVICE          /accesstransformers-3.0.1.jar accesstransformer PLUGINSERVICE          /forge-1.16.5-36.2.0.jar capability_inject_definalize PLUGINSERVICE          /forge-1.16.5-36.2.0.jar runtimedistcleaner PLUGINSERVICE          /mixin-0.8.2.jar mixin TRANSFORMATIONSERVICE          /OptiFine_1.16.5_HD_U_G7.jar OptiFine TRANSFORMATIONSERVICE          /forge-1.16.5-36.2.0.jar fml TRANSFORMATIONSERVICE      FML: 36.2     Forge: net.minecraftforge:36.2.0     FML Language Providers:          javafml@36.2         minecraft@1     Mod List:          forge-1.16.5-36.2.0-client.jar                    |Minecraft                     |minecraft                     |1.16.5              |CREATE_REG|Manifest: NOSIGNATURE         BetterDungeons-1.16.4-1.2.1.jar                   |YUNG's Better Dungeons        |betterdungeons                |1.16.4-1.2.1        |CREATE_REG|Manifest: NOSIGNATURE         BiomesOPlenty-1.16.5-13.1.0.481-universal.jar     |Biomes O' Plenty              |biomesoplenty                 |1.16.5-13.1.0.481   |CREATE_REG|Manifest: NOSIGNATURE         1.16.5-enchantedgoldenapplecrafting-1.0.jar       |Enchanted Golden Apple Craftin|enchantedgoldenapplecrafting  |1.0                 |CREATE_REG|Manifest: NOSIGNATURE         Weeping-Angels-1.16.x-2.1.6.jar                   |Weeping Angels                |weeping_angels                |2.1.6               |CREATE_REG|Manifest: NOSIGNATURE         dungeons_plus-1.16.5-1.1.5.jar                    |Dungeons Plus                 |dungeons_plus                 |1.1.5               |CREATE_REG|Manifest: NOSIGNATURE         Creative Core.jar                                 |CreativeCore                  |creativecore                  |2.0.0               |CREATE_REG|Manifest: NOSIGNATURE         Tree Harvester.jar                                |Tree Harvester                |treeharvester                 |2.4                 |CREATE_REG|Manifest: NOSIGNATURE         Just Enough Items.jar                             |Just Enough Items             |jei                           |7.7.0.106           |CREATE_REG|Manifest: NOSIGNATURE         villagespawnpoint_1.16.5-1.8.jar                  |Village Spawn Point           |villagespawnpoint             |1.8                 |CREATE_REG|Manifest: NOSIGNATURE         Toro Health Bar.jar                               |ToroHealth                    |torohealth                    |NONE                |CREATE_REG|Manifest: NOSIGNATURE         SpartanShields-1.16.5-2.1.2.jar                   |Spartan Shields               |spartanshields                |2.1.2               |CREATE_REG|Manifest: NOSIGNATURE         Waystones.jar                                     |Waystones                     |waystones                     |7.4.0               |CREATE_REG|Manifest: NOSIGNATURE         collective-1.16.5-3.0.jar                         |Collective                    |collective                    |3.0                 |CREATE_REG|Manifest: NOSIGNATURE         journeymap-1.16.5-5.7.3.jar                       |Journeymap                    |journeymap                    |5.7.3               |CREATE_REG|Manifest: NOSIGNATURE         citadel-1.8.1-1.16.5.jar                          |Citadel                       |citadel                       |1.8.1               |CREATE_REG|Manifest: NOSIGNATURE         alexsmobs-1.12.1.jar                              |Alex's Mobs                   |alexsmobs                     |1.12.1              |CREATE_REG|Manifest: NOSIGNATURE         TravelersBackpack-1.16.5-5.4.2.jar                |Traveler's Backpack           |travelersbackpack             |5.4.2               |CREATE_REG|Manifest: NOSIGNATURE         YungsApi-1.16.4-Forge-13.jar                      |YUNG's API                    |yungsapi                      |1.16.4-Forge-13     |CREATE_REG|Manifest: NOSIGNATURE         InventoryHud_[1.16.2-1.16.5].forge-3.4.1.jar      |Inventory HUD+(Forge edition) |inventoryhud                  |3.4.1               |CREATE_REG|Manifest: NOSIGNATURE         DungeonCrawl-1.16.5-2.3.2.jar                     |Dungeon Crawl                 |dungeoncrawl                  |2.3.2               |CREATE_REG|Manifest: NOSIGNATURE         iceandfire-2.1.9-1.16.5.jar                       |Ice and Fire                  |iceandfire                    |2.1.9-1.16.5        |CREATE_REG|Manifest: NOSIGNATURE         mvw-1.7.2.jar                                     |MoreVanillaWeapons            |mvw                           |1.16.X-1.7.2        |ERROR     |Manifest: NOSIGNATURE         Item Physic.jar                                   |ItemPhysic                    |itemphysic                    |1.6.0               |CREATE_REG|Manifest: NOSIGNATURE         forge-1.16.5-36.2.0-universal.jar                 |Forge                         |forge                         |36.2.0              |CREATE_REG|Manifest: 22:af:21:d8:19:82:7f:93:94:fe:2b:ac:b7:e4:41:57:68:39:87:b1:a7:5c:c6:44:f9:25:74:21:14:f5:0d:90         Disenchanting-forge-1.16.5-1.7.2.jar              |Disenchanting                 |disenchanting                 |1.6.0               |CREATE_REG|Manifest: NOSIGNATURE         BetterMineshafts-Forge-1.16.4-2.0.4.jar           |YUNG's Better Mineshafts      |bettermineshafts              |1.16.4-2.0.4        |CREATE_REG|Manifest: NOSIGNATURE         DynamicSurroundings-1.16.4-4.0.4.2 (1).jar        |§3Dynamic Surroundings        |dsurround                     |1.16.4-4.0.4.2      |CREATE_REG|Manifest: b4:98:14:b9:76:55:25:4f:e5:5f:4d:71:90:87:43:5b:f9:d5:3a:02:60:42:5e:da:1f:15:9c:ff:be:a9:7c:77         structure_gel-1.16.5-1.7.8.jar                    |Structure Gel API             |structure_gel                 |1.7.8               |CREATE_REG|Manifest: NOSIGNATURE         corpse-1.16.5-1.0.5.jar                           |Corpse                        |corpse                        |1.16.5-1.0.5        |CREATE_REG|Manifest: NOSIGNATURE     Crash Report UUID: cdcb879d-5dae-4e29-88ad-a4ace45db323     OptiFine Version: OptiFine_1.16.5_HD_U_G7     OptiFine Build: 20210305-003221     Render Distance Chunks: 12     Mipmaps: 4     Anisotropic Filtering: 1     Antialiasing: 0     Multitexture: false     Shaders: null     OpenGlVersion: 4.6.0 - Build 30.0.100.9955     OpenGlRenderer: Intel(R) Iris(R) Xe Graphics     OpenGlVendor: Intel     CpuCount: 8
    • Yeah its a question sorry for phrasing it weird, currently everytime I restart the server the mobs .mobLevel is being reset because it isn't saving. Im trying to decipher why this is happening and how to make it so that the .mobLevel for all the mobs in the server persists after a server restart
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.