For CraftTweaker, the syntax has not changed much between 1.19.2 and 1.18.2. Well, at least only for writing recipes. The other functions of CraftTweaker can be found on the official documentation site which is currently missing a search bar, soooo yeah.

CraftTweaker Documentation

Here are some perquisites to make using ZenScript cough tolerable cough because there is no built-in syntax highlighting or intellisense1 soooo yeah.

  • Visual Studio Code
  • Some syntax highlighting help…
    • Mrthomas20121.zenscript (that’s the vscode extension ID)

However, CT does have better support for MC versions below 1.16.

JSON syntax is supported for mods that don’t support CraftTweaker natively, but the solution is not as elegant as with KubeJS, so I won’t be going over it as in-depth. This is what a haunting recipe looks like in pure JSON.

1
2
3
4
5
6
7
8
9
10
11
12
13
<recipetype:create:haunting>.addJsonRecipe("deepslate", {
  "type": "create:haunting",
  "ingredients": [
    {
      "item": "minecraft:andesite"
    }
  ],
  "results": [
    {
      "item": "minecraft:deepslate"
    }
  ]
});

For comparison’s sake, here’s the same exact recipe in KubeJS.

1
2
3
4
5
6
7
8
9
10
11
ServerEvents.recipes(event => {
    event.custom({
        type: 'create:haunting',
        ingredients: [
            { item: 'minecraft:andesite' }
        ],
        results: [
            { item: 'minecraft:deepslate' }
        ]
    })
})

Anyway, here are some things you should definitely know.

  • Casting an array requires imports.
    • What does this mean? It means you have to always type a certain line at the very top while accounting each different recipe type.
  • You have to end each script with );
    • Each script is also “indepdentent” unlike in JS where everything has to be nested under ServerEvents.recipes(e => {})

Recipe Removal

1
recipes.removeByName("minecraft:bucket") // is how you remove recipes by recipe ID.

Shaped Recipes

Instead of using a letter key, it is literal. Where you type the is where that item will be defined in the crafting grid. Each row will also be defined by a `[]` group inside the `[]` group. So it will be like `[gridcontainer[gridarrangement]]`

1
2
3
4
craftingTable.addShaped("recipenamegoeshere_nocustom_mod_id", <item:minecraft:bucket>, [
    [<item:minecraft:iron_ingot>, <item:minecraft:air>, <item:minecraft:iron_ingot>],
    [<item:minecraft:air>, <item:minecraft:iron_ingot>, <item:minecraft:air>]
]);

Shapeless Recipes

1
2
// I am sorry but the code block can't display the entire code block.
craftingTable.addShapeless("recipename", <item:minecraft:netherite_scrap>, [<item:minecraft:netherite_scrap>, <item:minecraft:netherite_scrap>, <item:minecraft:netherite_scrap>, <item:minecraft:netherite_scrap>, <item:minecraft:gold_ingot>, <item:minecraft:gold_ingot>, <item:minecraft:gold_ingot>, <item:minecraft:gold_ingot>]);

  1. Basically smart speak for autocompletion / autocorrect but for coding. 


Table of contents