Skip to content
This repository has been archived by the owner on Oct 9, 2024. It is now read-only.

Recipe Converter

vfyjxf edited this page Feb 18, 2023 · 4 revisions

Recipe Converter

This tool helps you to convert recipes from other sources into mbd recipes, for example you can import recipes from a furnace into a recipe map.

Examples

var Ingredient = java('net.minecraft.world.item.crafting.Ingredient')

//convert crafting recipe and smelting recipe to mbd recipe.
//event.register(String recipeType, String recipeMap, (recipe, map) =>{
// use map to add recipe.
//})
onEvent('mbd.recipe_converter_register', event => {
    console.info("Starting conversion of recipes")
    event.register('minecraft:smelting', 'converter_map', (recipe, map) => {
        map.start().duration(1)
            .inputItems(ArrayUtils.create(recipe.getIngredients(), Ingredient))//i'm not sure kubejs whether will help me to wrap a list to array.
            .outputItems(recipe.getResultItem())
            .buildAndRegister();
    })
    event.register('minecraft:crafting', 'crafting_map', (recipe, map) => {
        map.start().duration(1)
            .inputItems(ArrayUtils.create(recipe.getIngredients(), Ingredient))
            .outputItems(recipe.getResultItem())
            .buildAndRegister();
    })
    console.info("Finished conversion of recipes")
})