Introduction 6.1 6.2 - Project-Vyre/another-create-wiki GitHub Wiki
Introduction to KubeJS 6.1-6.2 on Minecraft 1.19.2
Welcome to the another-create-wiki wiki!
This section contains essential information on how to get started with KubeJS on Minecraft 1.19.2.
First step is to install the following:
- Visual Studio Code
- I highly recommend using the GitHub theme. You can install it by clicking the button that looks like a 2x2 rubik's cube and the corner piece has been taken out on the left hand side of the VSCode window then searching up GitHub theme.
- KubeJS
- Rhino
- Architectury API
- ProbeJS
- KubeJS Create
After KubeJS is installed, run the game once and make a world to generate the kubejs folder which is located in your Minecraft instance folder.
For context, your Minecraft Instance folder will contain the majority of the following folders:
- config
- defaultconfig
- kubejs
- mods
- saves
- screenshots
- schematics
If you see most of these folders without opening any of them, you are in the right place.
It contains the following folders and a README.txt file.
assets- Here is where you put your custom item, armor, block and fluid textures.
- Yes, you can use
.jsonfiles for custom block models. - Yes, you can use
.mcmetafiles to change how your block is displayed in-game and make another color variant for deepslate for example.
- Yes, you can use
- Here is where you put your custom item, armor, block and fluid textures.
client_scripts- This is where your scripts related to tooltips, JEI modification and other client side things will go.
config- This is where you can put
defaultoptions.txtso you don't have to use DefaultOptions. - Setting the Window Title. That's the client name that shows up in the window on the top left corner if you don't know what that means.
- Setting the client icon. Must be an
.pngfile exported in 32-bit, otherwise it will cause a JVM crash.
- This is where you can put
data- Put the
datafolder contents of your datapacks in here. It will not work if you have it like:kubejs\data\bigcustomdatapack\
- Put the
exported- You don't really need to worry about it. It's just where data dumps like texture atlases are well... dumped.
server_scripts- This is where the recipe magic happens! Remember to
Ctrl + Sto save your recipe once it is finished then type /reload. - You can also modify item tags, loot tables, and more in here.
- This is where the recipe magic happens! Remember to
startup_scripts- Scripts for your custom items, blocks, armor and fluids go in here.
- This is where you can modify item and armor durability.
Also some important guidelines:
- DO NOT use an existing modID in your recipeID unless if you are overriding it.
- KubeJS uses slightly different syntax (way of typing "commands" in layman's terms) depending on which version of Minecraft you are using, specifically 1.19.2+ and 1.18.2. I will be skipping 1.16.5 syntax, go bother someone else.
- For all intents and purposes, the main focus of this tutorial is for adding and removing your own recipes.
Tutorial
- Open up Visual Studio Code and click
Open Folderand navigate to either your instance folder or just thekubejsfolder if you are just going to edit KubeJS stuff after doing modpack configs in theconfigfolder. - Click it, then click the
Select Folderbutton on the bottom right corner. If a prompt says "Do you want to trust the authors of these files?" click yes. - In the
server_scriptsfolder, there should already be ascript.jsfile. Open that via the VSCode Explorer panel where you can see all the kubejs folders. Personally I would organize scripts by mod if you want to easily transfer your scripts without having to delete and remove certain lines of code.
Some More Important Things
Some things I know you will ask about when you are in the KubeJS support channel. If you are a visual learner, this wiki page should be most helpful.
What are events?
- Here is something that you should know: The word
eventis simply something that happens. When it comes to being inside the mainServerEvent/onEventclass, the wordeventcan be changed toeto keep it short. Just ensure that it matches so that youreventscan be fired and be registered in-game. In layman's terms: for example, when the recipes event is triggered in the mod loader, everything insideServerEvents.recipes()will be read and loaded into the game.
What are strings?
- Strings are either inside double "quotes" or single 'quotes'. In JavaScript, using single 'quotes' is standard unless if you have a string that contains
'that's'or something similar. In that case.
What are objects, properties, listeners, etc?
- This is better explained in the code block below.
Now, are you in the
.jsfile insideserver_scripts? Good. See the gigantic code block below? I'll explain everything through there.
// requires: kubejs_create
/*
This header above tells KubeJS that this script needs KubeJS Create to be installed to work.
If you have pasted this code into Visual Studio Code, then the word event should be in ORANGE
if you are using the Github Default Dark Theme.
Also I would suggest renaming this file to recipes.js for the sake of identification.
Right-click the file on the left Explorer panel and rename it there for the easiest method.
*/
// Single line comments are indicated with two forward slashes.
/*
Multi line comments are indicated with...
*/
/**
* Documentation is automatically generated by using two * after the first forward slash.
* Press Enter to automatically make a new line unless if a function is written below
*
* Functions will be explained later on.
*/
// Directly below is the Server Event listener for the recipes event.
// event => is what triggers everything that has the word "connected"
ServerEvents.recipes(event => {
/*
Type your recipe scripts inside here. Don't forget to right click the background and
click Format Document to let Visual Studio Code format your code properly.
Let's start with the basics with a few **shaped** recipe that you will recognize in-game.
*/
event.shaped('minecraft:iron_sword', [
'I',
'I',
'S'
], {
I: 'minecraft:iron_ingot',
S: 'minecraft:stick'
}).id('minecraft:iron_sword')
event.shaped('minecraft:bucket', [
'I I',
' I '
], {
I: 'minecraft:iron_ingot'
}).id('minecraft:bucket')
event.shaped('8x create:shaft', [
'A',
'A'
], {
A: 'create:andesite_alloy'
}).id('create:crafting/kinetics/shafts')
event.shaped('minecraft:clock', [
' G ',
'GRG',
' G '
], {
G: 'minecraft:gold_ingot',
R: 'minecraft:redstone'
}).id('minecraft:clock')
/*
Now I know you might be thinking...
What does this all mean?
Results are always usually first, with ingredients following.
Spaces in the single quotation mark grid [] equal empty space.
The capital letters inside the array [] individually DEFINE where the ingredient is located on the crafting grid.
The capital letters inside the object {} are what define the item used in that position.
.id() is what gives your recipe a recipeID and the ability to override existing recipes from
other mods. Also, as a general guideline you should put this at the very end of your recipe in
case you have a recipe that keeps ingredients.
You do not have to use the same letters as the ingredients, it can be anything from
A-Z, 0-9, #, etc though Visual Studio Code will show a syntax error.
*/
event.shaped('create:shaft', [
'#',
'#'
], {
'#': 'create:andesite_alloy'
}).id('kubejs:a_duplicate_recipe_for_the_shaft')
// above is an example of using non-letter characters as keys.
// Let's move onto shapeless recipes.
event.shapeless('create:cogwheel', [
'create:shaft',
'#minecraft:planks'
]).id('create:crafting/kinetics/cogwheel')
event.shapeless('create:large_cogwheel', [
'create:shaft',
'2x #minecraft:planks'
]).id('create:crafting/kinetics/large_cogwheel')
// unlike shaped recipes, there is nothing to define the location of.
// simply list your ingredients inside the [array] that comes after the output item string.
/*
Let's get started with removing recipes... and your first if statement.
*/
let remove_recipes = false
// if this is set to false, the if statement below will be false and thus will not run unless set to true.
if (remove_recipes) {
event.remove([
{ output: 'minecraft:stick' }, // I remove all recipes that output sticks!
{
mod: 'create',
input: 'create:andesite_alloy',
output: 'create:cogwheel'
} // I remove all recipes from the Create mod that use Andesite Alloy and output Cogwheels!
])
}
})
Advanced Things
Tired of repeating the same things multiple times? Tired of having to edit your code every time a mod is not present yet? This section has that covered.
What are functions?