KubeJS
This wiki is still very much work in progress! Feel free to suggest changes in the #off-topic Discord channel.
Intro
FAQ What does this mod do? This mod lets you create scripts in JavaScript language to manage yo...
Events
Events that get fired during game to control recipes, world, etc.
List of all events
This is a list of all events. It's possible that not all events are listed here, but this list wi...
EventJS
This event is the most basic event class, parent of all other events. Parent class Object Can ...
CommandEventJS
This event needs cleanup! Using it is not recommended. Information This event is fired when a c...
TagEventJS
This event is fired when a tag collection is loaded, to modify it with script. You can add and re...
RecipeEventJS
Examples The most basic script to add a single recipe: onEvent('recipes', event => { even...
WorldgenAddEventJS
This event isn't complete yet and can only do basic things. Adding dimension-specific features al...
WorldgenRemoveEventJS
For more information on biomes field, see worldgen.add event page. onEvent('worldgen.remove', ev...
ItemTooltipEventJS
onEvent('item.tooltip', tooltip => { // Add tooltip to all of these items tooltip.add(['...
Classes
Available fields and methods and examples on how to use them
Object
Parent class of all Java objects. Parent None (and itself at the same time, don't question it)...
String
Class of string objects, such as "abc" (and in JS 'abc' works as well) Parent Object Variable...
Primitive Types
Information Primitive types are objects that don't have a real class and don't inherit methods f...
Global
Constants, classes and functions
Examples
Example scripts for various things you can do with KubeJS
KubeJS UI
You can also always look at existing modpack using KubeJS UI to see how they do it onEvent('ui.m...
Custom Items
This is a startup_scripts/ event // Listen to item registry event onEvent('item.registry', even...
Custom Blocks
This is a startup script. onEvent('block.registry', event => { event.create('test_block') ...
Loot Table Modification
onEvent('block.loot_tables', event => { event.addSimpleBlock('minecraft:dirt', 'minecraft:r...
Item Modification
item.modification event is a startup script event that allows you to change properties of existin...
Block Modification
block.modification event is a startup script event that allows you to change properties of existi...
JEI Integration
Sub-types onEvent('jei.subtypes', event => { event.useNBT('example:item') event.userNBT...
REI Integration
Note: REI integration only works on Fabric in 1.16. In 1.18+, it works on both Forge and Fabric! ...
FTB Quests Integration
onEvent('ftbquests.custom_task.75381f79', event => { log.info('Custom task!') event.chec...
Reflection / Java access
Very limited reflection is possible, but is not recommended. Use it in cases when KubeJS doesnt s...
Painter API
About Painter API allows you to draw things on the screen, both from server and directly from cl...
Units
This page describes all functions and operations available for units Usage Most basic unit is p...
Chat Event
This script is peak of human evolution. Whenever someone says "Creeper" in chat, it replies with ...
Network Packets
This script shows how to use network packets: // Listen to a player event, in this case item rig...
Starting Items
This server script adds items on first time player joins, checking stages. GameStages mod is not ...
FTB Utilities Rank Promotions
With this script you can have FTB Utilities roles that change over time. Is for 1.12 only. Requi...
Clearlag 1.12
This script removes all items from world every 30 minutes. Only works in 1.12. // Create item wh...
Scheduled Server Events
At server load, you can schedule anything to happen at later time. Within callback handler you ca...
Custom Fluids
Supported by Forge on all versions, and Fabric on 1.18.2+ // Startup script onEvent('fluid.regi...
Components, KubeJS and you!
In 1.18.2 and beyond KubeJS uses Components in a lot of places. It returns them for entity names,...
Other
Examples and how-tos of other things KubeJS can do!
Changing Window Title and Icon
Yes, you can do that with KubeJS too. To change title, all you have to do is change title in kub...
Default Options
You can ship default options from options.txt with KubeJS. This includes keybindings, video setti...
Loading Assets and Data
You can also use KubeJS to load assets from resource packs and data from datapacks! While this is...
Addons
Scripts using various KubeJS addons for recipes.