Jump to content

Recommended Posts

Posted (edited)

Hi,
I am just updating my mod from 1.20.1 to 1.20.2 and I saw a big change for the custom RecipeSerializers, they now require Codec<?> serialization instead of a simple fromJson() function.
Unfortunately, I am struggling with setting up the Codec for a few of the serialization features:

- Using the Forge "mod_loaded" condition (the file should not be loaded when a mod is missing)

- Loading an Ingredient field 

Current Codec Code:

Spoiler
    public static final Codec<EnvironmentData> CODEC = RecordCodecBuilder.create((builder) -> builder
            .group(
                Ingredient.CODEC_NONEMPTY.fieldOf("input").forGetter(EnvironmentData::getInputItem),
                BlockState.CODEC.fieldOf("render").forGetter(EnvironmentData::getRenderState),
                Codec.FLOAT.fieldOf("growModifier").forGetter(EnvironmentData::getGrowModifier),
                Codec.list(Codec.STRING).fieldOf("categories").forGetter(EnvironmentData::getCategories)
            ).apply(builder, EnvironmentData::new));

For the first problem, previously the "mod_loaded" condition was automatically taken into account, but I suppose that now it changed and has to be taken care of in the codec?
For the second problem, I am trying to read the Ingredient with the CODEC_NONEMPTY from the Ingredient class, but I get the following error:

[17:35:14] [Render thread/ERROR] [minecraft/RecipeManager]: Parsing error loading recipe cagedmobs:environments/red_mushroom_block
com.google.gson.JsonParseException: Not a JSON object: "minecraft:red_mushroom_block"
	at net.minecraft.Util.getOrThrow(Util.java:820) ~[forge-1.20.2-48.0.33_mapped_parchment_2023.10.22-1.20.2-recomp.jar:?] {re:classloading}
	at net.minecraft.world.item.crafting.RecipeManager.fromJson(RecipeManager.java:171) ~[forge-1.20.2-48.0.33_mapped_parchment_2023.10.22-1.20.2-recomp.jar:?] {re:classloading}
	at net.minecraft.world.item.crafting.RecipeManager.apply(RecipeManager.java:76) ~[forge-1.20.2-48.0.33_mapped_parchment_2023.10.22-1.20.2-recomp.jar:?] {re:classloading}
	at net.minecraft.world.item.crafting.RecipeManager.apply(RecipeManager.java:37) ~[forge-1.20.2-48.0.33_mapped_parchment_2023.10.22-1.20.2-recomp.jar:?] {re:classloading}
	at net.minecraft.server.packs.resources.SimplePreparableReloadListener.lambda$reload$1(SimplePreparableReloadListener.java:12) ~[forge-1.20.2-48.0.33_mapped_parchment_2023.10.22-1.20.2-recomp.jar:?] {re:classloading}
	at java.util.concurrent.CompletableFuture$UniAccept.tryFire(CompletableFuture.java:718) ~[?:?] {}
	at java.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:482) ~[?:?] {}
	at net.minecraft.server.packs.resources.SimpleReloadInstance.lambda$new$3(SimpleReloadInstance.java:65) ~[forge-1.20.2-48.0.33_mapped_parchment_2023.10.22-1.20.2-recomp.jar:?] {re:classloading}
	at net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:166) ~[forge-1.20.2-48.0.33_mapped_parchment_2023.10.22-1.20.2-recomp.jar:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEventLoop.java:22) ~[forge-1.20.2-48.0.33_mapped_parchment_2023.10.22-1.20.2-recomp.jar:?] {re:classloading}
	at net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:132) ~[forge-1.20.2-48.0.33_mapped_parchment_2023.10.22-1.20.2-recomp.jar:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.util.thread.BlockableEventLoop.managedBlock(BlockableEventLoop.java:145) ~[forge-1.20.2-48.0.33_mapped_parchment_2023.10.22-1.20.2-recomp.jar:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.client.gui.screens.worldselection.CreateWorldScreen.openFresh(CreateWorldScreen.java:132) ~[forge-1.20.2-48.0.33_mapped_parchment_2023.10.22-1.20.2-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.gui.screens.worldselection.WorldSelectionList.loadLevels(WorldSelectionList.java:189) ~[forge-1.20.2-48.0.33_mapped_parchment_2023.10.22-1.20.2-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.gui.screens.worldselection.WorldSelectionList.<init>(WorldSelectionList.java:100) ~[forge-1.20.2-48.0.33_mapped_parchment_2023.10.22-1.20.2-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.gui.screens.worldselection.SelectWorldScreen.init(SelectWorldScreen.java:37) ~[forge-1.20.2-48.0.33_mapped_parchment_2023.10.22-1.20.2-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.gui.screens.Screen.init(Screen.java:338) ~[forge-1.20.2-48.0.33_mapped_parchment_2023.10.22-1.20.2-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.Minecraft.setScreen(Minecraft.java:1090) ~[forge-1.20.2-48.0.33_mapped_parchment_2023.10.22-1.20.2-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.gui.screens.TitleScreen.lambda$createNormalMenuOptions$7(TitleScreen.java:171) ~[forge-1.20.2-48.0.33_mapped_parchment_2023.10.22-1.20.2-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.gui.components.Button.onPress(Button.java:38) ~[forge-1.20.2-48.0.33_mapped_parchment_2023.10.22-1.20.2-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.gui.components.AbstractButton.onClick(AbstractButton.java:41) ~[forge-1.20.2-48.0.33_mapped_parchment_2023.10.22-1.20.2-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.gui.components.AbstractWidget.mouseClicked(AbstractWidget.java:179) ~[forge-1.20.2-48.0.33_mapped_parchment_2023.10.22-1.20.2-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.gui.components.events.ContainerEventHandler.mouseClicked(ContainerEventHandler.java:53) ~[forge-1.20.2-48.0.33_mapped_parchment_2023.10.22-1.20.2-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.gui.screens.TitleScreen.mouseClicked(TitleScreen.java:329) ~[forge-1.20.2-48.0.33_mapped_parchment_2023.10.22-1.20.2-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.MouseHandler.lambda$onPress$0(MouseHandler.java:98) ~[forge-1.20.2-48.0.33_mapped_parchment_2023.10.22-1.20.2-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.gui.screens.Screen.wrapScreenError(Screen.java:461) ~[forge-1.20.2-48.0.33_mapped_parchment_2023.10.22-1.20.2-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.MouseHandler.onPress(MouseHandler.java:95) ~[forge-1.20.2-48.0.33_mapped_parchment_2023.10.22-1.20.2-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.MouseHandler.lambda$setup$4(MouseHandler.java:207) ~[forge-1.20.2-48.0.33_mapped_parchment_2023.10.22-1.20.2-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.util.thread.BlockableEventLoop.execute(BlockableEventLoop.java:106) ~[forge-1.20.2-48.0.33_mapped_parchment_2023.10.22-1.20.2-recomp.jar:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.client.MouseHandler.lambda$setup$5(MouseHandler.java:206) ~[forge-1.20.2-48.0.33_mapped_parchment_2023.10.22-1.20.2-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at org.lwjgl.glfw.GLFWMouseButtonCallbackI.callback(GLFWMouseButtonCallbackI.java:43) ~[lwjgl-glfw-3.3.2.jar:build 13] {}
	at org.lwjgl.system.JNI.invokeV(Native Method) ~[lwjgl-3.3.2.jar:build 13] {}
	at org.lwjgl.glfw.GLFW.glfwWaitEventsTimeout(GLFW.java:3509) ~[lwjgl-glfw-3.3.2.jar:build 13] {}
	at com.mojang.blaze3d.systems.RenderSystem.limitDisplayFPS(RenderSystem.java:207) ~[forge-1.20.2-48.0.33_mapped_parchment_2023.10.22-1.20.2-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.Minecraft.runTick(Minecraft.java:1261) ~[forge-1.20.2-48.0.33_mapped_parchment_2023.10.22-1.20.2-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.Minecraft.run(Minecraft.java:783) ~[forge-1.20.2-48.0.33_mapped_parchment_2023.10.22-1.20.2-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.main.Main.main(Main.java:221) ~[forge-1.20.2-48.0.33_mapped_parchment_2023.10.22-1.20.2-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?] {}
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?] {}
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?] {}
	at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?] {}
	at net.minecraftforge.fml.loading.targets.CommonLaunchHandler.runTarget(CommonLaunchHandler.java:98) ~[fmlloader-1.20.2-48.0.33.jar:?] {}
	at net.minecraftforge.fml.loading.targets.CommonLaunchHandler.lambda$makeService$0(CommonLaunchHandler.java:82) ~[fmlloader-1.20.2-48.0.33.jar:?] {}
	at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:17) ~[modlauncher-10.1.1.jar:?] {}
	at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:40) ~[modlauncher-10.1.1.jar:?] {}
	at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:58) ~[modlauncher-10.1.1.jar:?] {}
	at cpw.mods.modlauncher.Launcher.run(Launcher.java:96) ~[modlauncher-10.1.1.jar:?] {}
	at cpw.mods.modlauncher.Launcher.main(Launcher.java:66) ~[modlauncher-10.1.1.jar:?] {}
	at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:13) ~[modlauncher-10.1.1.jar:?] {}
	at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:10) ~[modlauncher-10.1.1.jar:?] {}
	at net.minecraftforge.bootstrap.BootstrapLauncher.main(BootstrapLauncher.java:126) ~[bootstrap-1.2.0.jar:?] {}

 

The "cagedmobs:environments/red_mushroom_block" JSON recipe:

Spoiler
{
	"type": "cagedmobs:environment_data",
	"conditions": [
		{
			"type": "forge:mod_loaded",
			"modid": "cagedmobs"
		}
	],
	"input": {
		"item": "minecraft:red_mushroom_block"
	},
	"render": "minecraft:red_mushroom_block",
	"growModifier": 1.0,
	"categories": ["mycelium"]
}

As seen here, the Ingredient input item is in the form of a nested JSON:

"input": {
		"item": "minecraft:red_mushroom_block"
}

 

 

Edited by Corgam
Posted (edited)

The problem is not the 'input' field its' the 'render' field.
You expect there a BlockState but 'minecraft:red_mushroom_block' is a Block.

If you need no BlockState you can use ForgeRegistries.BLOCKS.getCodec() instead of BlockState.CODEC.
If you need explicit a BlockState take a look at the Codec which fields are required.

Edited by Luis_ST
  • Like 1
Posted
16 hours ago, Corgam said:

Thank you, and what about the "mod_loaded" condition with Codecs?

The recipe conditions are added by Forge, there should be a codec from Forge somewhere that you can use.

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Hi,  I'm using Forge 47.3.0 for Minecraft 1.20.1 I apologise if this is obvious I am very new to modding for Minecraft. I sucessfully made a mod that launched without errors or crashes (without it doing anything) but in order to add the features I need, I need to add "Custom Portal API [Forge]" as a dependency. However no matter the way I've tried to acheive this, it crashes. I am pretty sure it's not the way I'm putting it in the repositories, the dependencies or the way I'm refrencing it, as I've a hundred diffrent combinations and multiple Maven methods. And on all those diffrent variations I still get this crash: pastebin.com/UhumzZCZ Any tips would be invaluable as I've been loosing my mind over this!
    • Hi, i'm really having problems trying to set the texture to my custom item. I thought i'm doing everything correctly, but all i see is the missing texture block for my item. I am trying this for over a week now and getting really frustrated. The only time i could make the texture work, was when i used an older Forge version (52.0.1) for Minecraft (1.21.4). Was there a fundamental change for textures and models somewhere between versions that i'm missing? I started with Forge 54.1.0 and had this problem, so in my frustration i tried many things: Upgrading to Forge 54.1.1, created multiple new projects, workspaces, redownloaded everything and setting things up multiple times, as it was suggested in an older thread. Therea are no errors in the console logs, but maybe i'm blind, so i pasted the console logs to pastebin anyway: https://pastebin.com/zAM8RiUN The only time i see an error is when i change the models JSON file to an incorrect JSON which makes sense and that suggests to me it is actually reading the JSON file.   I set the github repository to public, i would be so thankful if anyone could take a look and tell me what i did wrong: https://github.com/xLorkin/teleport_pug_forge   As a note: i'm pretty new to modding, this is my first mod ever. But i'm used to programming. I had some up and downs, but through reading the documentation, using google and experimenting, i could solve all other problems. I only started modding for Minecraft because my son is such a big fan and wanted this mod.
    • Please read the FAQ (link in orange bar at top of page), and post logs as described there.
    • Hello fellow Minecrafters! I recently returned to Minecraft and realized I needed a wiki that displays basic information easily and had great user navigation. That’s why I decided to build: MinecraftSearch — a site by a Minecraft fan, for Minecraft fans. Key Features So Far Straight-to-the-Point Info: No extra fluff; just the essentials on items, mobs, recipes, loot and more. Clean & Intuitive Layout: Easy navigation so you spend less time scrolling and more time playing. Optimized Search: Search for anything—items, mobs, blocks—and get results instantly. What I’m Thinking of Adding More data/information: Catch chances for fishing rod, traveling villager trades, biomes info and a lot more. The website is still under development and need a lot more data added. Community Contributions: Potential for user-uploaded tips for items/mobs/blocks in the future. Feature Requests Welcome: Your ideas could shape how the wiki evolves! You can see my roadmap at the About page https://minecraftsearch.com/about I’d love for you to check out MinecraftSearch and see if it helps you find the info you need faster. Feedback is crucial—I want to develop this further based on what the community needs most, so please let me know what you think. Thanks, and happy crafting!
    • Instructions on how to install newer Java can be found in the FAQ
  • Topics

×
×
  • Create New...

Important Information

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