How to create a custom Trigger?

What is a Trigger?

In technical terms, a Trigger is an Event Listener.

Think of it as a guard standing by and watching the game and saying, "Hey, X just happened, now do Y!"

There are two types of Triggers in MCreator: Global Triggers: System events that happen in the world (e.g., the sun rises, a player dies).

Element-Specific Triggers: Events related to one of your objects (e.g., "When this block is broken," "When this sword hits an enemy"). How to Create a Trigger (Step-by-Step)

1. Create the Procedure Element

First, click the + button (Add new mod element) and select Procedure. Give your function a name (e.g., MySuperPower)

2. Choose the Event (The Trigger)

Once the block editor opens, you'll see a dark green block called "Event trigger" at the top.

Click the drop-down menu inside this block. Here you'll find a huge list of events (e.g., Player joins the world, Entity dies, Right clicked on block).

If you select a trigger here, the procedure will become Global (active for everyone, always).

3. Link the action

Under the green trigger block, you must insert the colored blocks that define the action (e.g., "Send message," "Create explosion," "Give potion effect").

4. Alternative: Direct triggers from elements

If you want the trigger to affect only a specific object: Open the element you created (e.g., your new Block). Go to the Triggers tab.

There you'll find a list of specific events (e.g., "When block added," "When entity walks on block").

Click the + button next to the selected event: MCreator will create a procedure already linked to that specific moment.

Practical Usage Examples Example 1:

The "Lightning" Sword Objective: When you hit a mob with your custom sword, lightning strikes it. Where: Go to your Sword settings -> Triggers tab. Chosen event: When living entity is hit with tool. Procedure: Drag the Spawn lightning at x y z block. Result: Each strike of that sword will summon lightning at the exact coordinates of the target.

Example 2:

The "Trap" Block Objective: If a player walks over a specific block, they receive the "Slowness" effect. Where: Block settings -> Triggers tab. Chosen event: When entity walks on the block.

Procedure: Use the Add potion effect block -> select SLOWNESS -> duration 100 ticks -> level 2. Result: The block becomes an invisible pressure plate that slows anyone who steps on it.

Example 3:

Welcome Message (Global Trigger) Objective: Send a message to chat every time someone joins the server. Where: Create a new free procedure.

Event (Global Trigger): Select Player joins the world from the drop-down menu.

Procedure: Drag the Send message to chat block and type "Welcome to this crazy world!".

Result: You don't need to hold anything or touch blocks; the trigger "listens" to the server and activates when the player joins.

Example 4:

Armor that lets you fly Objective: If you wear the full set of your armor, you gain the ability to fly (Creative Flight). Where: Armor Settings (Body/Legs/etc) -> Triggers tab.

Selected event: Body tick update (this trigger occurs every time you wear it). Procedure: Insert an IF block that checks if the player is wearing all the pieces, then use the Allow player to fly block.

Pro tip

Be careful with repeating triggers (like On player tick or On update tick).

If you put heavy actions (like creating 100 explosions) into a trigger that repeats 20 times per second, your Minecraft will explode (in real life, not in the game!).