KubeJS (Old)

KubeJS (Old)

3M Downloads

Recipes are not removed on first load using KubeJS for Fabric 1.19.2

clockler opened this issue ยท 4 comments

commented

Minecraft Version

1.19.2

KubeJS Version

1902.6.0-build.142

Rhino Version

1902.2.2-build.268

Architectury Version

6.5.85

Forge/Fabric Version

Quilt 0.19.2, confirmable with Fabric 0.14.21

Describe your issue

Using KubeJS for Fabric, server scripts attempting to remove recipes are failing to do so on first load, but succeed fine on reloading or on leaving world and loading again - the script fails only on first world load after starting the game.

This is confirmable using these loader/API combinations:

  • Quilt 0.19.2 + Quilted Fabric API 4.0.0-beta.30+0.76.0-1.19.2 (Fabric API 0.76.0+1.19.2)
  • Quilt 0.19.2 + Fabric API 0.76.0+1.19.2
  • Fabric 0.14.21 + Fabric API 0.76.0+1.19.2

The behaviour is the same, and the logs are basically identical with all permutations (Quilt+QFAPI, Quilt+Fabric API, Fabric+Fabric API). This is on a test instance with no mods other than the noted versions of Fabric/QFAPI, Architectury, Rhino, and KubeJS.

The script removes all recipes using or resulting in items which are in the #c:hidden_from_recipe_viewers tag. The tag is loaded from the KubeJS data directory, and contains only minecraft:cobblestone_slab (that's kubejs/data/c/tags/items/hidden_from_recipe_viewers.json containing {"replace":true,"values":["minecraft:cobblestone_slab"]}).

ServerEvents.recipes(e => {
    console.info("REMOVING RECIPES FOR HIDDEN ITEMS");
    e.remove({ "output": "#c:hidden_from_recipe_viewers" });
    e.remove({ "input": "#c:hidden_from_recipe_viewers" });
});

Doing this item-by-item rather than using a tag results in a JavaException: java.util.NoSuchElementException: No value present [dev.latvian.mods.rhino.NativeError] thrown for each individual item on first load, and then works as expected after the first load, exactly as the tag behaves.

Log excerpt from first load, cobblestone slabs still craftable:

[13:10:55] [Render thread/INFO]: Scanning recipes...
[13:10:57] [Render thread/INFO]: Found 1089 recipes and 0 failed recipes in 69.63 ms
[13:10:57] [Render thread/INFO]: server_scripts:script.js:6: REMOVING RECIPES FOR HIDDEN ITEMS
[13:10:57] [Render thread/INFO]: Posted recipe events in 12.20 ms
[13:10:57] [Render thread/INFO]: Modified & removed recipes in 21.93 ms
[13:10:57] [Render thread/INFO]: Added recipes in 745.2 ?s
[13:10:57] [Render thread/INFO]: Added 0 recipes, removed 0 recipes, modified 0 recipes, with 0 failed recipes and 0 fall-backed recipes

On reloading, cobblestone slabs no longer craftable:

[13:11:27] [Server thread/INFO]: Scanning recipes...
[13:11:27] [Server thread/INFO]: Found 1089 recipes and 0 failed recipes in 20.40 ms
[13:11:27] [Server thread/INFO]: server_scripts:script.js:6: REMOVING RECIPES FOR HIDDEN ITEMS
[13:11:27] [Server thread/INFO]: Loaded dev.properties
[13:11:27] [Server thread/INFO]: Posted recipe events in 4.537 ms
[13:11:27] [Server thread/INFO]: Modified & removed recipes in 8.250 ms
[13:11:27] [Server thread/INFO]: Added recipes in 10.80 ?s
[13:11:27] [Server thread/INFO]: Added 0 recipes, removed 2 recipes, modified 0 recipes, with 0 failed recipes and 0 fall-backed recipes

And after exiting to the menu and reloading the world, cobblestone slabs remain uncraftable:

[13:11:35] [Render thread/INFO]: Scanning recipes...
[13:11:35] [Render thread/INFO]: Found 1089 recipes and 0 failed recipes in 13.09 ms
[13:11:35] [Render thread/INFO]: server_scripts:script.js:6: REMOVING RECIPES FOR HIDDEN ITEMS
[13:11:35] [Render thread/INFO]: Posted recipe events in 1.785 ms
[13:11:35] [Render thread/INFO]: Modified & removed recipes in 6.833 ms
[13:11:35] [Render thread/INFO]: Added recipes in 8.100 ?s
[13:11:35] [Render thread/INFO]: Added 0 recipes, removed 2 recipes, modified 0 recipes, with 0 failed recipes and 0 fall-backed recipes

Exiting to the menu without reloading first has the same result. On one run out of several, I got this message:

[13:09:04] [Render thread/INFO]: Added 0 recipes, removed 2 recipes, modified 0 recipes, with 0 failed recipes and 0 fall-backed recipes
...
[13:09:07] [Render thread/INFO]: Preparing spawn area: 89%
[13:09:07] [Render thread/INFO]: Time elapsed: 2547 ms
[13:09:08] [Server thread/INFO]: Changing view distance to 12, from 10
[13:09:08] [Server thread/INFO]: Changing simulation distance to 12, from 0
[13:09:08] [Server thread/ERROR]: Tried to load unrecognized recipe: minecraft:cobblestone_slab_from_cobblestone_stonecutting removed now.
[13:09:08] [Server thread/ERROR]: Tried to load unrecognized recipe: minecraft:cobblestone_slab removed now.
[13:09:08] [Server thread/ERROR]: Tried to load unrecognized recipe: minecraft:cobblestone_slab_from_cobblestone_stonecutting removed now.
[13:09:08] [Server thread/ERROR]: Tried to load unrecognized recipe: minecraft:cobblestone_slab removed now.
[13:09:08] [Server thread/INFO]: clockler[local:E:b2b4e689] logged in with entity id 385 at (309.1874417528874, 68.0, -178.05437345482923)
[13:09:08] [Server thread/INFO]: clockler joined the game

This was when loading the world after first loading once and then exiting to the menu without using /reload. I wasn't able to replicate this on other attempts (this is one log of ~30 total including those on the modpack instance I first noticed this). Both logs are included in the link.

Crash report/logs

https://gist.github.com/clockler/50cc4b1b3f0b1d38145454b9a02d4f65

commented

I'm encountering a similar issue in the forge version, trying to invoke event.remove({output: '#forge:gears', type: 'minecraft:crafting_shaped'}); appears to remove no recipes, until /reload is invoked.

commented

Does this still happen in the latest version? (Major version 6.1+)

commented

Updated to 6.1, no longer experiencing the issue personally. Can't speak for the OP.

commented

This issue seems fixed on 6.1 with Fabric as well. I'll close the issue, thanks!