Skip to content

Instantly share code, notes, and snippets.

@LatvianModder LatvianModder/example.js

Last active Jun 16, 2020
Embed
What would you like to do?
KubeJS 1.14+ Recipes
// kubejs/data/modpack/kubejs/example.js
// This is just an example script to show off multiple types of recipes and removal methods
// Supports /reload
// Enable recipe logging, off by default
server.logAddedRecipes = true
server.logRemovedRecipes = true
// Listen to server recipe event
events.listen('recipes', function (event) {
// Remove broken recipes from vanilla and other mods
// This is on by default, so you don't need this line
//event.removeBrokenRecipes = true
event.remove({}) // Deletes all recipes
event.remove({id: 'minecraft:glowstone'}) // Removes data/minecraft/recipes/glowstone.json
event.remove({input: '#forge:dusts/redstone'}) // Removes all recipes where input is Redstone Dust tag
event.remove({output: '#minecraft:wool'}) // Removes all recipes where output is Wool tag
event.remove({mod: 'quartzchests'}) // Remove all recipes from Quartz Chests mod
event.remove({type: 'minecraft:campfire_cooking'}) // Remove all campfire cooking recipes
// Add shaped recipe for 3 Stone from 8 Sponge in chest shape
// (Shortcut for event.recipes.minecraft.crafting_shaped)
event.shaped(item.of('minecraft:stone', 3), [
'SSS',
'S S',
'SSS'
], {
S: 'minecraft:sponge'
})
// Add shapeless recipe for 4 Cobblestone from 1 Stone and 1 Glowstone
// (Shortcut for event.recipes.minecraft.crafting_shapeless)
event.shapeless(item.of('minecraft:cobblestone', 4), ['minecraft:stone', '#forge:dusts/glowstone'])
// Add Stonecutter recipe for Golden Apple to 4 Apples
event.recipes.minecraft.stonecutting(item.of('minecraft:apple', 4), 'minecraft:golden_apple')
// Add Stonecutter recipe for Golden Apple to 2 Carrots
event.recipes.minecraft.stonecutting(item.of('minecraft:carrot', 2), 'minecraft:golden_apple')
// Add Furnace recipe for Golden Apple to 3 Carrots
// (Shortcut for event.recipes.minecraft.smelting)
event.smelting(item.of('minecraft:carrot', 2), 'minecraft:golden_apple')
// Add similar recipes for Blast Furnace, Smoker and Campfire
event.recipes.minecraft.blasting(item.of('minecraft:apple', 3), 'minecraft:golden_apple')
event.recipes.minecraft.smoking(item.of('minecraft:apple', 5), 'minecraft:golden_apple')
event.recipes.minecraft.campfire_cooking('minecraft:apple', 'minecraft:golden_apple')
// You can also add .xp(1.0) at end of any smelting recipe to change given XP
// Create a variable for function and use that to make things shorter
var s = event.recipes.minecraft.smelting
s('minecraft:blue_dye', '#forge:gems/lapis')
s('minecraft:black_dye', 'minecraft:ink_sac')
s('minecraft:white_dye', 'minecraft:bone_meal')
// Add Create's crushing recipe, Apple to Apple + 50% Carrot
event.recipes.create.crushing(['minecraft:apple', item.of('minecraft:carrot').chance(0.5)], 'minecraft:apple', 100)
// If you use {} as only argument, it will be using vanilla Json syntax
// You can add recipe to any recipe handler that uses vanilla recipe system or isn't supported by KubeJS
event.recipes.create.crushing({
ingredients: [
{ item: 'minecraft:carrot' }
],
results: [
{ item: 'minecraft:apple', count: 1, chance: 0.5 },
{ item: 'minecraft:carrot', count: 1 }
],
processingTime: 100
})
// In all shapeless crafting recipes, replace any planks with Gold Nugget in input items
event.replaceInput({type: 'minecraft:crafting_shapeless'}, '#minecraft:planks', 'minecraft:gold_nugget')
// In all recipes, replace Stick with Oak Sapling in output items
event.replaceOutput({}, 'minecraft:stick', 'minecraft:oak_sapling')
})
// Listen to item tag event
events.listen('item.tags', function (event) {
// Add #forge:cobblestone tag to Diamond Ore
event.get('forge:cobblestone').add('minecraft:diamond_ore')
// Remove Cobblestone from #forge:cobblestone tag
event.get('forge:cobblestone').remove('minecraft:cobblestone')
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.