Corn Delight[Forge]

Corn Delight[Forge]

10M Downloads

[Bug] Invalid category value in corn_delight recipes causing kubejs error

SundustYc opened this issue ยท 1 comments

commented

Description

When using corn_delight-1.1.4-1.21.1 mod, I discovered that its recipes are incompatible with kubejs, resulting in some errors such as:

Failed to read category?:crafting_book_category from recipe corn_delight:caramel_popcorn[minecraft:crafting_shapeless]: java.util.NoSuchElementException: No value present

Environment

  • Minecraft version: 1.21.1
  • NeoForge: 21.1.169
  • rhino-2101.2.7-build.74.jar
  • kubejs-neoforge-2101.7.1-build.181.jar
  • FarmersDelight-1.21.1-1.2.7.jar
  • mysterious_mountain_lib-1.1.8-1.21.1.jar
  • corn_delight-1.1.4-1.21.1.jar

Steps to Reproduce

  1. Install those mods, and use ServerEvents.recipes in server_scripts to listen for recipe events
  2. Launch the game.
  3. Observed error logs (server.log) after entering the world

Analysis

The corn_delight mod defines recipe JSONs with category values that don't comply with Minecraft standards (https://minecraft.wiki/w/Recipe):

(For crafting_shaped and crafting_shapeless) category: Optional. Controls to which recipe book category the recipe belongs to. Available values are: equipment, building, misc, and redstone. Defaults to misc.

An example in corn_delight:

{
  "type": "minecraft:crafting_shapeless",
  "category": "food",
  "ingredients": [
    {
      "tag": "c:foods/popcorn"
    },
    {
      "item": "minecraft:sugar"
    }
  ],
  "result": {
    "count": 1,
    "id": "corn_delight:caramel_popcorn"
  }
}

I guess that's why kjs reports these errors, corn_delight uses food as a category value for some recipes (crafting_shaped and crafting_shapeless), which is not a valid option, causing kubejs to throw an exception when trying to read these recipes. After I replaced all the places that were incorrectly used "category": "food" with "misc", everything was fine.

commented

Should fixed in 1.1.8-1.21.1