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

Recipe Condition

vfyjxf edited this page Feb 18, 2023 · 1 revision

What is Recipe Condition?

  • A Recipe condition is similar to a special recipe input where the machine will only execute a recipe if a special condition is met, for example, a recipe need to multiblock 's y postion over 256 to run.

How to use?

You can usually add recipe conditions directly inside the blueprint table or you can use kubejs to do so.

All Recipe Conditions

Name KubeJS Mtehod Or Descrption
BlockCondition block(BlockState blockState, int count, @Optional boolean reverse) false A certain number of certain blocks must be present in the composition of multiple blocks.
BiomeCondition biome(ResourceLocation biome, @Optional boolean reverse) ture Multiple blocks must be in a biome before a recipe will run.
DimensionCondition dimension(ResourceLocation dimension, @Optional boolean reverse) ture Multiple blocks must be in some dimension in order to run a recipe.
PositionYCondition yLevel(int min, int max, @Optional boolean reverse) false Multiple blocks must be at a certain height to run the recipe.
RainingCondition raining(float level, @Optional boolean reverse) false Recipes must be run when it is raining.
ThunderCondition thunder(float level, @Optional boolean reverse) false Recipes must be run when it is thundering.
PredicateCondition predicate(BiPredicate<Recipe, RecipeLogic> predicate, @Optional Component tooltip, @Optional boolean reverse) false A special recipe condition that allows you to use kubejs to customise the entries to be checked.

Examples

onEvent('recipes', event => {
    event.recipes.multiblocked.multiblock("coal")
        .block(Block.getBlock('minecraft:gold_block').defaultBlockState(), 10)
        .thunder(1)
        .dimension("minecraft:nether")
        .biome("minecraft:plains")
        .yLevel(1, 10)
        .raining(1)
        .predicate((recipe, recipeLogic) => {
            let controllerTe = recipeLogic.controller.self()
            let level = controllerTe.getLevel()
            let under =level.getBlockState(controllerTe.getBlockPos().below()).getBlock()
            return Block.getBlock('minecraft:iron_block').equals(under)
        }, Component.string('Require a iron block under the controller'))
})