KubeJS Legacy
This wiki is for KubeJS 1.18.2 and below. That said, this one still has a lot of useful info!
Intro
FAQ What does this mod do? This mod lets you create scripts in JavaScript language to manage yo...
Migrating to KubeJS 6
This page is still being worked on, so if some info is missing, please check back later! What's ...
Getting Started
A step by step guide for learning the basics of KubeJS
Introduction and Installation
Installation Install the mod and its two dependencies Architectury and Rhino.Make you use the mo...
Your First Script
Writing Your First Script If you have launched the game at least once before you will find kubej...
Basics Custom Mechanics
By now you have created a custom recipe, or maybe multiple, or even manipulated tags, or created ...
Using ProbeJS
ProbeJS is an add-on that is built exclusively to help you program. What it does: It generates ...
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...
Custom Items
This is a startup_scripts/ event // Listen to item registry event onEvent('item.registry', even...
EventJS
This event is the most basic event class, parent of all other events. Parent class Object Can ...
Custom Blocks
This is a startup script. onEvent('block.registry', event => { event.create('test_block') ...
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...
Loot Table Modification
onEvent('block.loot_tables', event => { event.addSimpleBlock('minecraft:dirt', 'minecraft:red_...
RecipeEventJS
Examples The most basic script to add a single recipe: onEvent('recipes', event => { event.s...
Item Modification
item.modification event is a startup script event that allows you to change properties of existin...
WorldgenAddEventJS (1.16)
This event isn't complete yet and can only do basic things. Adding dimension-specific features al...
Block Modification
block.modification event is a startup script event that allows you to change properties of existi...
JEI Integration
All JEI events are client sided and so go in the client_scripts folder Sub-types onEvent('jei.s...
WorldgenRemoveEventJS (1.16)
For more information on biomes field, see worldgen.add event page. onEvent('worldgen.remove', ev...
REI Integration
Note: REI integration only works on Fabric in 1.16. In 1.18+, it works on both Forge and Fabric! ...
ItemTooltipEventJS
A client event that allows adding tooltips to any item! onEvent('item.tooltip', tooltip => { ...
Worldgen Events
These following examples will only work on 1.18+! If you need examples for 1.16, you can look her...
Chat Event
This script is peak of human evolution. Whenever someone says "Creeper" in chat, it replies with ...
Custom Fluids
Supported by Forge on all versions, and Fabric on 1.18.2+ // Startup script onEvent('fluid.regi...
Command Registry
This page is unfinished and only provides basic information Example: The following code has not...
Datapack Load Events
You can load json datapack files programmatically! onEvent('server.datapack.first', event => { ...
Examples
Example scripts for various things you can do with KubeJS
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...
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...
Running Commands
Preface Sometimes, you might want to run a command (such as /tell @a Hi!), in your code. Most a...
Spawning Entities
Basics Overview Spawning entities consists of 3 steps: Making the variable storing the futur...
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
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...
Loading Assets and Data
You can also use KubeJS to load assets from resource packs and data from datapacks! While this is...
Default Options
You can ship default options from options.txt with KubeJS. This includes keybindings, video setti...
Addons
Scripts using various KubeJS addons for recipes.
KubeJS UI
You can also always look at existing modpack using KubeJS UI to see how they do it onEvent('ui.m...
KubeJS Thermal
You can use KubeJS Thermal to add recipes to a lot of the machines from the Thermal Series. T...
KubeJS Create
Create integration for KubeJS. This mod allows you to add and properly edit recipes of Create mod...
3rd Party addons
3rd party add-ons: (Not including mods with optional dependencies of KubeJS) Name: Descri...
KJSPKG
KJSPKG is a package manager for KubeJS that can allow you to download different example scripts a...