#How to run code when a recipe occurs

6 messages · Page 1 of 1 (latest)

vivid falcon
#

For example, using crate KubeJS I want to execute code when someone does this following recipe

    event.recipes.create.filling('quartz_block', [Fluid.water(), 'quartz_block'])  
})```


What I want to happen is that when this recipe happens, the spout will create another quartz block on top of the original recipe target.

The main thing I need help with is that I don't know how I can make KubeJS run code when a recipe occurs
karmic galleonBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

cinder heart
#

I don't believe that's possible

#

wdym by it creates another quartz block on top?

marble turtleBOT
#

The XY problem is when you really want to do X, and you think that Y can achieve X. However, you can't get Y to work, and so ask for help exclusively about Y.

This can lead to a lot of confusion from the people trying to help you, as Y can seem like a very random thing to want to do, and a lot of the time isn't the best way to achieve X anyway.

Its fine to ask about Y, just always include some context about X so you can be put on the right track if Y won't do X well, or there is an easier way to do X.

vivid falcon
#

Here is an example of this code being done in 1.18 in the pack Create: Arcane Engineering. I'm hoping to achieve something similar in 1.19

    let spoutInteraction = (blockId, fluidId, fluidAmount, result, requiredAmount) => {
    event.addSpoutHandler(blockId + "_spout_interaction", blockId, (block, fluid, simulate) => {
        if (!requiredAmount)
        requiredAmount = fluidAmount
        if (fluid.id == fluidId && fluid.amount >= requiredAmount) {
            if (!simulate)
                if (result)
                block.setBlockState(Block.getBlock(result).defaultBlockState(), 2);
                else
                block.blockState.randomTick(block.level.minecraftLevel, block.pos, block.level.minecraftLevel.random)
            return fluidAmount;
        }   
        return 0;
        });
    }
     let corundum = ["red", "orange", "yellow", "green", "blue", "indigo", "violet", "white", "black"]
        corundum.forEach(Color => {
            spoutInteraction("quark:" + Color + "_corundum", "minecraft:water", 100)
        });   
})```