Skip to main content

Recipes Event (ServerEvents.recipes)

This page is still under development. It is not complete, and subject to change at any time.

The recipe event can be used to add, remove, or replace recipes.

Any script that modifies recipes should be placed in the kubejs/server_scripts folder, and can be reloaded at any time with /reload.

Any modifications to the recipes should be done within the context of a recipes event. This means that we need to register an "event listener" for the ServerEvents.recipes event, and give it some code to execute whenever the game is ready to modify recipes. Here's how we tell KubeJS to execute some code whenever it's recipe time:

/* ServerEvents.recipes() is a function that accepts another function,
 * called the "callback", as a parameter. The callback gets run when the 
 * server is working on recipes, and then we can make our own changes.
 * When the callback runs, it is also known as the event "firing". 
*/

ServerEvents.recipes(event => { //listen for the "recipes" server event.
  // You can replace `event` with any name you like, as 
  // long as you change it inside the callback too!
  
  // This part, inside the curly braces, is the callback.
  // You can modify as many recipes as you like in here,
  // without needing to use ServerEvents.recipes() again.
  
  
  console.log("Hello! The recipe event has fired!")
})

In the next sections you can see what to put inside your callback.

Contents

Adding Recipes

The following is all code that should be placed inside your recipe callback.

Shaped

Shaped recipes are added with the event.shaped() method. Shaped recipes must have their ingredients in a specific order and shape in order to match the player input. The arguments to event.shaped() are:

  1. The output Item, which can have a count of 1-64
  2. An Array (max length 3) of crafting table rows, represented as Strings (max length 3). Spaces represent slots with no item, and letters represent items. The letters don't have to mean anything; you explain what they mean in the next argument.
  3. An object mapping the letters to Items, like {letter: item}. Input items must have a count of 1.
//event.shaped is a shortcut for event.recipes.minecraft.crafting_shaped
event.shaped(
  Item.of('minecraft:stone', 3), // arg 1: output
  [ 
    'A B', 
    ' C ', // arg 2: the shape (array of strings)
    'B A'  
  ],
  {
    A: 'minecraft:andesite', 
    B: 'minecraft:diorite',  //arg 3: the mapping object
    C: 'minecraft:granite'   
  }
)
Shapeless


Shapeless recipes are added with the event.shapeless() method. Players can put ingredients of shapeless recipes anywhere on the grid and it will still craft. The arguments to event.shapeless() are:

  1. The output item
  2. An Array of input items. Input items must have a count of 1.
//event.shapeless is a shortcut for event.recipes.minecraft.crafting_shapeless
event.shapeless(
  Item.of('minecraft:dandelion', 3), // arg 1: output
  [ 
    'minecraft:bone_meal',
    'minecraft:yellow_dye', //arg 2: the array of inputs
    'minecraft:ender_pearl'
  ]
)
Smithing

Smithing recipes have 2 inputs and one output, and are added with the event.smithing() method. Smithing recipes are crafted in the smithing table.

//event.smithing is a shortcut for event.recipes.minecraft.smithing
event.smithing(
  'minecraft:netherite',  // arg 1: output
  'minecraft:iron_ingot', // arg 2: the item to be upgraded
  'minecraft:black_dye'   // arg 3: the upgrade item
)
Smelting & Cooking

Cooking recipes are all very similar, accepting one input (a single item) and giving one output (which can be up to 64 of the same item). The fuel cannot be changed in this recipe event, and should be done with tags instead.

  • Smelting recipes are added with event.smelting(), and require the regular Furnace block.
  • Blasting recipes are added with event.blasting(), and require the Blast Furnace block.
  • Smoking recipes are added with event.smoking(), and require the Smoker block.
  • Campfire cooking recipes are added with event.campfireCooking(), and require the Campfire block.
// Cook 1 stone into 3 gravel in a Furnace:
event.smelting('3x minecraft:gravel', 'minecraft:stone')
// Blast 1 iron ingot into 10 nuggets in a Blast Furnace: 
event.blasting('10x minecraft:iron_nugget', 'minecraft:iron_ingot')
// Smoke glass into tinted glass in the Smoker:
event.smoking('minecraft:tinted_glass', 'minecraft:glass')
// Burn sticks into torches on the Campfire:
event.campfireCooking('minecraft:torch', 'minecraft:stick')
Stonecutting

Like the cooking recipes, stonecutting recipes are very simple, with one input (a single item) and one output (which can be up to 64 of the same item). They are added with the event.stonecutting() method.

//allow cutting 3 sticks from any plank on the stonecutter
event.stonecutting('3x minecraft:stick', '#minecraft:planks')

Removing Recipes

Removing recipes can be done with the evemt.remove() method. event.remove() accepts 1 argument: a filterThere are many conditions with which you can remove a recipe:

  • by output item
  • by input item(s)
  • by mod
  • by the recipe's unique ID
  • any combination of the above
  event.remove({}) // Removes all recipes (obviously not recommended)
  event.remove({output: 'minecraft:stone_pickaxe'}) // Removes all recipes where output is stone pickaxe
  event.remove({output: '#minecraft:wool'}) // Removes all recipes where output is Wool tag
  event.remove({input: '#forge:dusts/redstone'}) // Removes all recipes where input is Redstone Dust tag
  event.remove({mod: 'quartzchests'}) // Remove all recipes from Quartz Chests mod
  event.remove({type: 'minecraft:campfire_cooking'}) // Remove all campfire cooking recipes
  event.remove({id: 'minecraft:glowstone'}) // Removes recipe by ID. in this case, data/minecraft/recipes/glowstone.json
  event.remove({output: 'minecraft:cooked_chicken', type: 'minecraft:campfire_cooking'}) // Combining filters!

To find a recipe's unique ID, turn on advanced tooltips using the F3+H keys (you will see an announcement in chat), then hover over the output (if using JEI) or the plus symbol (if using REI).

Modifying & Replacing Recipes

You can bulk-modify recipes using event.replaceInput() and event.replaceOutput().