Skip to content
This repository has been archived by the owner on Oct 9, 2024. It is now read-only.
vfyjxf edited this page Feb 12, 2023 · 10 revisions

Event

Multiblocked provides a number of events through which you can customize logic with them.

We assume you already know how KubeJS events subevent. An intuitive example is shown in the provided ebf_recipe.js:

// register event for a specific machine.
let subID = ebfDefinition.getID() // "mbd.ebf"
onEvent(`mbd.setup_recipe.${subID}`, event => {
    let recipe = event.getRecipe(); // get recipe found (matching IO requirement).
    let recipeLogic = event.getRecipeLogic(); // get RecipeLogic
    // get custom data
    let temp = recipe.getData().getInt("temperature")
    if (temp != null) {
        if (temp > 1000) {
            // console.info(`ebf recipe cancel, ${temp} < 1000`)
            event.cancel(); // cancel to block this recipe setup.
        }
    }
})

Multiblocked's events generally consist of a prefix event name and a machine ID. mbd.setup_recipe is the event name here, and ${subID} is the id of that machine.

if you subscribe event without subID, the logic will fired for all multiblocked machines:

onEvent(`mbd.setup_recipe`, event => {

})

List of Events

All events can be found here: events

We just a brief description of what the event does. For parameters, see the Java code.

Java KubeJS Descrption Cancelable Side
DropEvent mbd.drop add drops while breaking disable drops of machine itself and its container's contents SERVER
DynamicPatternEvent mbd.dynamic_pattern dynamically set the structure pattern of the machine according to the environment. (could create a new Pattern via MbdFactoryBlockPattern) never formed SERVER
NeighborChangedEvent mbd.neighbor_changed fired while neighbor blocks changed - SERVER
OutputRedstoneEvent mbd.output_redstone redstone to emmit - SERVER
PartAddedEvent mbd.part_added part block added as a part of a formed structure - SERVER
PartRemovedEvent mbd.part_removed fired while part block is removed from a structure - SERVER
ReadInitialDataEvent mbd.read_initial_data receive initial data from server - CLIENT
WriteInitialDataEvent mbd.write_initial_data send initial data to remote - SERVER
ReceiveCustomDataEvent mbd.receive_custom_data receive data from server (send data call component.writeCustomData()) - CLIENT
RecipeFinishEvent.Pre mbd.recipe_finish_pre fired while recipe finish(Before handle output) don't handle reipce output logic SERVER
RecipeFinishEvent.Post mbd.recipe_finish_post fired while recipe finish do not check if the conditions and inputs for the next time are met when the recipe is completed.(Change the structure of the multi-block here) SERVER
SetupRecipeEvent mbd.setup_recipe fired while a recipe found before execute block execution SERVER
RightClickEvent mbd.right_click fired while player right click the machine block gui opening and formed checking by click COMMON
StatusChangedEvent mbd.status_changed fired while status changed block status changed SERVER
StructureFormedEvent mbd.structure_formed fired while structure formed - SERVER
StructureInvalidEvent mbd.structure_invalid fired while structure invalid - SERVER
UpdateFormedEvent mbd.update_formed fired each tick while structure formed - SERVER
UpdateRendererEvent mbd.update_renderer update current renderer, you can other renderer here - CLIENT
UpdateTickEvent mbd.update_tick fired each tick - SERVER
CreateUIEvent mbd.create_ui set the gui of the machine disable gui COMMON
InitTraitUIEvent mbd.trait_ui set the custom gui page of the machien - COMMON
RecipeUIEvent mbd.recipe_ui set the custom gui page of the recipe widget - CLIENT
CustomShapeEvent mbd.custom_shape set the shape of the machine - CLIENT

NOTE: mbd.recipe_ui.${recipe_map}