KubeJS
Looking for the Forge version?
Click here.
What does this mod do?
This mod lets you create scripts in JavaScript language to manage your server, add new blocks and items, change recipes and tags, add custom handlers for quest mods, change worldgen and more!
How to use it?
Run the game with mod installed once. It should generate kubejs
folder in your minecraft directory with example scripts. startup scripts only get run once when the game loads. Those are for registering items, setting up configs etc. Server/data scripts are loaded when you join a world, those are better for things like clearlag, displaying custom login messages and world/player related things in general.
Can I reload scripts?
Yes, use /reload
. Note: Not everything is reloadable. Some things require you to restart game, some only world, some work on fly.
I don't know JavaScript / I need help with this mod
There are examples and pre-made scripts on KubeJS Wiki.
How does this mod work?
It uses Rhino.
Ok, but what if it.. doesn't work?
You can report issues on GitHub.
I have more questions/suggestions!
If wiki didn't have the answer for what you were looking for, you can join the Discord server and ask for help on #kubejs-and-code
channel!
Why are so many people involved in this port?
yeet
HI, is it possible to create an starter-Kit Script for Fabric? I can't find an example. GameStages is not available on Fabric. And I can not find any other Starter Kit Mod for Fabric.
can anyone help me i am trying to get a mod for not tree puching like the forge one and i tought that kubejs would work but don't know where to start
What's with the restriction on custom recipes in the latest versions? I thought the whole point of being able to use javascript was to avoid having to fill out JSON, which the custom recipe functions now require as the one and only argument.
In reply to Cubby989:
Alpha versions are not done, they lack mod integrations. Only mod intergrations can provide you with a simple api to add recipes, because KubeJS needs to know how to generate the json from your arguments.
In reply to shedaniel:
Y'all should add a way to define the JSON generation in javascript, so that support could be added by any random Joe with a burning desire for compatibility.
In reply to Cubby989:
You can just make a method yourself, it is javascript anyways
In reply to shedaniel:
Unfortunately, even if I did, kubejs currently loses a few of the object keys after being given the JSON object for that recipe type.
Is the alpha version of KubeJS-fabric feature-complete/stable enough compared to KubeJS 1.6.0?
In reply to juergenscht:
The alpha versions have full feature parity to the forge kubejs, however does not include mod integration, thus breaking in modpacks and being alpha
This is genuinely awesome. It would be fantastic to see the documentation get some love. As someone who knows js but knows nothing about MC coding, it's not really that helpful yet.
Tried to run this with Oracle Java 15. Turns out Nashorn engine was removed from Java 15.
In reply to 0xfeeddeadbeef:
Correct, this does not support Java 15. We will be migrating to alternative JS engine, namely GraalJS. However the transition is not easy and will not fully be compatible with all current scripts, so we are holding back to 1.17 where we have more time to experiment and break scripts.
In reply to shedaniel:
Might be a good idea to mention this in the description. It does currently say Java 8 and above.
In reply to thegiggitybyte:
True, I will get that changed, however Java 15 support is coming with the migration to Rhino (yes I said we will be changing to graaljs but rhino is easier), so expect that in the future!
Another option: temporarily switch to https://github.com/openjdk/nashorn
yay
In reply to yoghurt4c:
you concern me everyday
In reply to shedaniel:

According to the example of listening "creeper" and replying "aww man", is it possible to post a help list to players by listening texts like "!!help" and replying certain order lists? (I'm unfamiliar to JS so just a guess)