Intro
FAQ
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, add custom handlers for quest mods 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 and README.txt. Read that!
Here's a video tutorial for 1.19.2:
I don't know JavaScript
There's examples and pre-made scripts here. And you can always ask in discord support channel for help with scripts, but be specific.
Can I reload scripts?
Yes, use /reload
to reload server_scripts/
, F3 + T
to reload client_scripts/
and /kubejs reload startup_scripts
to reload startup_scripts/
. If you don't care about reloading recipes but are testing some world interaction event, you can run /kubejs reload server_scripts
. Note: Not everything is reloadable. Some things require you to restart game, some only world, some work on fly. Reloading startup scripts is not recommended, but if you only have event listeners, it shouldn't be a problem.
What mod recipes does it support / is mod X supported?
If the mod uses datapack recipes, then it's supported by default. Some more complicated mods require addon mods, but in theory, still would work with datapack recipes. See Recipes and Addons sections for more info.
What features does this mod have?
See list of all Features.
How does this mod work?
It uses a fork of Rhino, a JavaScript engine by Mozilla to convert JS code to Java classes at runtime. KubeJS wraps minecraft classes and adds utilities to simplify that a lot and remove need for mappings. Architectury lets nearly the same source code be compiled for both Forge and Fabric making porting extremely easy.
Ok, but what if it.. doesn't work?
You can report issues here.
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 #support channel!
Website: https://kubejs.com/
Source and issue tracker: https://github.com/KubeJS-Mods/KubeJS
Download: https://www.curseforge.com/minecraft/mc-mods/kubejs
Anything below 1.18 is no longer supported!
Features
Here's a list of all documented (and sometimes undocumented) features that I can remember:
- [Full list of events]
- Editing Recipes
- Editing Tags
- Adding New Items
- Adding New Blocks
- Default Options
- Changing Window Title and Icon
- Changing Mod Display Names
- Loading Assets and Data
- Modify Items
- Modify Blocks
- Adding Fluids
- Worldgen
- Chat event
- Block placement event
- Item right-click event
- And a bunch more that I forgot...
Global
Primitive prototype additions
String#namespace
: String - namespace part of namespaced string, aka of "minecraft:oak_planks" it's "minecraft". Defaults to "minecraft" if there's no:
.String#path
: String - path part of namespaced string, aka of "minecraft:oak_planks" it's "oak_planks"
Constants
SECOND
: Number = 1000MINUTE
: Number = 60000 (60 * SECOND)HOUR
: Number = 3600000 (60 * MINUTE)
Objects
global
: Map<String, Object>console
: Console
Classes
Platform
ResourceLocation
Utils
Java
Text
UUID
JsonIO
Block
Item
Ingredient
IngredientHelper
NBT
NBTIO
Direction
Facing
AABB
Fluid
Color
BlockStatePredicate
Wrapped Classes
Name | Class |
---|---|
JavaMath |
java.lang.Math |
Blocks |
net.minecraft.world.level.block.Blocks |
Items |
net.minecraft.world.item.Items |
Stats |
net.minecraft.stats.Stats |
DecorationGenerationStep |
net.minecraft.world.level.levelgen.GenerationStep.Decoration |
CarvingGenerationStep |
net.minecraft.world.level.levelgen.GenerationStep.Carving |
BlockPos |
net.minecraft.core.BlockPos |
DamageSource |
net.minecraft.world.damagesource.DamageSource |
BlockProperties |
net.minecraft.world.level.block.state.properties.BlockStateProperties |
Vec3 , Vec3d |
net.minecraft.world.phys.Vec3 |
Vec3i |
net.minecraft.core.Vec3i |