Skip to content

Fix registerPotionBrewing not working because it was a server script by making it a startup script - #33

Open
Minimaxi28 wants to merge 1 commit into
AlmostReliable:1.21.1from
Minimaxi28:1.21.1
Open

Fix registerPotionBrewing not working because it was a server script by making it a startup script#33
Minimaxi28 wants to merge 1 commit into
AlmostReliable:1.21.1from
Minimaxi28:1.21.1

Conversation

@Minimaxi28

Copy link
Copy Markdown

Issue Reference

Proposed Changes

  • change registerPotionBrewing from server to startup
  • fix registerPotionBrewing not working because it was changed to server in b40db9e

Additional Context

Tested with

MoreJS.registerPotionBrewing(event => {
  event.removePotionBrewing({
    ingredient: 'minecraft:rabbit_foot'
  })
  
  event.addPotionBrewing("minecraft:acacia_log", "minecraft:harming")
})

in startup_scripts, it correctly removes the potion recipes using 'minecraft:rabbit_foot' as an ingredient and correctly adds the "minecraft:acacia_log" to "minecraft:harming" recipes.

@LLytho

LLytho commented Aug 16, 2026

Copy link
Copy Markdown
Member

My example scripts just run without a problem. Can you describe what exactly doesn't work? Saying something doesn't work without any information is not really helpful.

@Minimaxi28

Minimaxi28 commented Aug 16, 2026

Copy link
Copy Markdown
Author

Ok my bad, it seems that even though it's a server script, it only actually applies when restarting the game ?
That's very unintuitive, why not make it a startup script ?
I had started writing here before finding that so here is what I wrote:

If I copy paste everything shown here https://github.com/AlmostReliable/morejs/wiki/Potion-Brewing in minecraft\kubejs\server_scripts\main.js, I get this in server.log

[10:15:33] [INIT] KubeJS 2101.7.2-build.368; MC 2101 NeoForge
[10:15:33] [INIT] Loaded plugins:
[10:15:33] [INIT] - dev.latvian.mods.kubejs.plugin.builtin.BuiltinKubeJSPlugin
[10:15:33] [INIT] - dev.latvian.mods.kubejs.plugin.builtin.BuiltinKubeJSClientPlugin
[10:15:33] [INIT] - com.almostreliable.morejs.Plugin
[10:15:33] [INIT] - moe.wolfgirl.probejs.plugin.ProbeJSKJSPlugin
[10:15:33] [ERROR] ! main.js#3: dev.latvian.mods.rhino.EcmaError: ReferenceError: "MoreJSEvents" is not defined.
[10:15:33] [INFO] Loaded 0/1 KubeJS server scripts in 0.003 s with 1 errors and 0 warnings
[10:15:33] [INIT] KubeJS 2101.7.2-build.368; MC 2101 NeoForge
[10:15:33] [INIT] Loaded plugins:
[10:15:33] [INIT] - dev.latvian.mods.kubejs.plugin.builtin.BuiltinKubeJSPlugin
[10:15:33] [INIT] - dev.latvian.mods.kubejs.plugin.builtin.BuiltinKubeJSClientPlugin
[10:15:33] [INIT] - com.almostreliable.morejs.Plugin
[10:15:33] [INIT] - moe.wolfgirl.probejs.plugin.ProbeJSKJSPlugin
[10:15:33] [ERROR] ! main.js#3: dev.latvian.mods.rhino.EcmaError: ReferenceError: "MoreJSEvents" is not defined.
[10:15:33] [INFO] Loaded 0/1 KubeJS server scripts in 0.003 s with 1 errors and 0 warnings
[10:15:34] [INFO] Server resource reload complete!

If I modify MoreJSEvents to MoreJS like ProbeJS is telling me (seems like the wiki is wrong), I don't have the ReferenceError anymore but nothing happens, I don't get the recipes that sould've been added / removed

example: event.addPotionBrewing("minecraft:emerald", "minecraft:fire_resistance", "minecraft:strength");
but nothing shows up in JEI on the uses of Emeralds and I can't input Emerald into a Brewing Stand so it's not a display issue
image

If I restart my game instead of doing /reload I now get this in server.log

[10:23:24] [INIT] KubeJS 2101.7.2-build.368; MC 2101 NeoForge
[10:23:24] [INIT] Loaded plugins:
[10:23:24] [INIT] - dev.latvian.mods.kubejs.plugin.builtin.BuiltinKubeJSPlugin
[10:23:24] [INIT] - dev.latvian.mods.kubejs.plugin.builtin.BuiltinKubeJSClientPlugin
[10:23:24] [INIT] - com.almostreliable.morejs.Plugin
[10:23:24] [INIT] - moe.wolfgirl.probejs.plugin.ProbeJSKJSPlugin
[10:23:24] [INFO] Loaded script server_scripts:main.js in 0.001 s
[10:23:24] [INFO] Loaded 1/1 KubeJS server scripts in 0.013 s with 0 errors and 0 warnings
[10:23:26] [ERROR] ! main.js#9: Error in 'MoreJS.registerPotionBrewing': dev.latvian.mods.rhino.EvaluatorException: Java class "dev.latvian.mods.kubejs.plugin.builtin.wrapper.IngredientWrapper" has no public instance field or method named "customNBT".
[10:23:26] [ERROR] ! …rhino.EvaluatorException: Java class "…kubejs.plugin.builtin.wrapper.IngredientWrapper" has no public instance field or method named "customNBT". (server_scripts:main.js#9)
[10:23:26] [ERROR] !   at …rhino.DefaultErrorReporter.runtimeError(DefaultErrorReporter.java:67)
[10:23:26] [ERROR] !   at …rhino.Context.reportRuntimeError(Context.java:93)
.........

which is not related to my issue but the wiki is also wrong on that

now, if I remove

    event.addCustomBrewing(
        "minecraft:gold_ingot",
        Ingredient.customNBT("minecraft:potion", (nbt) => {
            return nbt.contains("Potion") && nbt.Potion == "minecraft:water";
        }),
        Item.of("minecraft:potion", { Potion: "kubejs:felix_felicis" }) // This is a custom made potion. It's not vanilla
    );

and restart the game, the recipes do show up like expected

So actually it's the wiki that needs to be updated because it's a server script that only works on startup (very unintuitive, it would be better just a startup script), MoreJSEvents doesn't exist, it's MoreJS, Ingredient.customNBT doesn't exist (I don't know what that one became), also removeByPotion and removeByCustom don't exist too.

My bad for not having tested more

GitHub
A Minecraft mod to extend KubeJS with additional events. - AlmostReliable/morejs

@LLytho

LLytho commented Aug 16, 2026

Copy link
Copy Markdown
Member

it only actually applies when restarting the game ?

Its not. Its invoked on world- oading which is part of the server. Minecraft has two loading states when bootstrapping the server. First world related stuff are loaded like worldgen, enchantments, potions etc. After that data related resources are loaded like tags, recipes etc. And minecraft does not reload world stuf on /reload, for this you have to rejoin the world.

I will yeet all information about Ingredient.customNBT in the wiki. Thats some old KubeJS stuff which should not exist anyway.

@Minimaxi28

Copy link
Copy Markdown
Author

Ah yes indeed, so it's even more confusing because it's written nowhere that it's what you should do

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants