Other

Default Options

You can ship default options from options.txt with KubeJS. This includes keybindings, video settings, enabled resource packs, controls like autojump and toggle sprint and wierd things like advanced tooltips.

Why use this instead of just shipping options.txt? If you ship options.txt then the users options will get overridden every time they update your modpack, where-as KubeJS only sets the options once, on the first time the modpack boots.

 

To use it simply make a file called defaultoptions.txt in the kubejs/config folder. Then copy any lines you want to set by default over from the normal options.txt file. You can also just copy the entire file if you want to include everything.

A full list of what options the options.txt file can contain is available on the Minecraft Wiki: https://minecraft.fandom.com/wiki/Options.txt

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 kubejs/config/client.properties.

To change icon, you create a kubejs/config/packicon.png image in standard Minecraft texture size preferably (64x64, 128x128, 256x256, that kind of size).

The image has to be saved as 32-bit PNG, not Auto-detect/24-bit, otherwise you will get a JVM crash!

Here's how to do that in PaintNET:

Example result:

Currently incompatible with Fancy Menu!

Loading Assets and Data

You can also use KubeJS to load assets from resource packs and data from datapacks! While this isn't the only method, its one of the easiest. Other options are <TODO: make and link server datapack load page and client generate assets event page>

The data folder is loaded identically to the data folder in a datapack. If you already have a datapack just copy the folder(s) from inside the datapacks data folder to KubeJS' data folder.

The assets folder is loaded identically to the assets folder in a resourcepack. If you already have a resourcepack just copy the folder(s) from inside the resourcepacks assets folder to KubeJS' assets folder.

Changing Mod Display Names

Yes, it's cursed, but possible!

In a startup script, add this line:

Platform.mods.kubejs.name = 'My Modpack Name'

This is useful when you add a bunch of items with KubeJS but want them to show your modpack name instead of "KubeJS"

And yes, you can change name of other mods as well:

Platform.mods.botania.name = 'Plant Tech Mod'

KubeJS 6.1 Update

For script and pack developers

For addon mod developers

Update Primer (sorted by topics, still incomplete):

Recipe Schemas

From the announcement:

This is the big one. Recipe schemas completely change the way custom recipe handlers are registered in KubeJS, and should hopefully also mean a lot less boilerplate code down the line for you. Each recipe is now defined by a schema containing a set of recipe components, with those components acting as "codecs" for the underlying values. For you, this means the following:
- Instead of primarily using RecipeJS subclasses, you will now have to define a RecipeSchema
  - Each schema uses a set of RecipeKeys, which are named RecipeComponents with some additional properties like optional default values and settings for automatic constructor and method generation
  - A RecipeComponent is a reusable definition of a recipe element (such as an in/output item, a fluid, or even just a number value) that has a role (input, output, other), a description (for use in addon mods like ProbeJS) and contains logic for (de)serialisation and bulk recipe operations (i.e. recipe filtering and replacement). There are lots of standard components provided in the dev.latvian.mods.kubejs.recipe.component package, including blocks, items and fluids, generic group and logic components (array, map, and, or), and all kinds of primitives (including specialised ones such as number ranges and characters)
  - While the recipe schema will generate constructors by default, you can override this behaviour by defining one yourself using constructor(factory, keys). Note that this will stop the default constructor from being generated, so if you want to keep that, you will have to define it yourself again.
  (A good example of complex custom recipe constructors is `ShapedRecipeSchema`)
- While schemas replace RecipeJS on the java side, on the JS side, the user is still passed a RecipeJS object after creation, with additional autogenerated "builder" methods for each component to allow for the user to set e.g. optional values after recipe creation  (e.g. event.smelting(...).xp(20).cookingTime(100)). and you can add even more properties or do additional after-load validation by overriding the recipe factory entirely!

Download

You can download KubeJS 6.1 at https://kubejs.com/downloads!