How Block Effects Work in Modern Bedrock
In older versions of the Bedrock add-on format, blocks could run slash commands or apply effects directly inside the block JSON using event responses like add_mob_effect under the Holiday Creator Features toggle. Those JSON event responses were removed when Holiday Creator Features was retired.
Today, applying a status effect from a block requires two parts: a behavior pack block file that declares a custom component identifier, and a TypeScript or JavaScript file registered through the @minecraft/server module. When a game event happens on the block, Bedrock fires the matching handler in your script, which then calls the addEffect method on the target entity.
Setting Up the Block JSON
Your block definition needs the minecraft:custom_components list inside its components object. Every string in this list must match a component name you register during the worldInitialize or system.beforeEvents.startup phase in your script.
If you want the effect to trigger when an entity walks onto the block, the block must have a collision box that entities can actually touch. A full cube has this by default, while a carpet-like block needs a thin minecraft:collision_box so the step-on event still registers.
{
"format_version": "1.21.10",
"minecraft:block": {
"description": {
"identifier": "wiki:healing_pad",
"menu_category": {
"category": "construction"
}
},
"components": {
"minecraft:collision_box": {
"origin": [-8, 0, -8],
"size": [16, 2, 16]
},
"minecraft:selection_box": {
"origin": [-8, 0, -8],
"size": [16, 2, 16]
},
"minecraft:geometry": "minecraft:geometry.full_block",
"minecraft:destructible_by_mining": {
"seconds_to_destroy": 1.5
},
"minecraft:custom_components": [
"wiki:apply_regeneration"
]
}
}
}Applying Effects on Step and Interact
Inside your script entry file, register the custom component inside system.beforeEvents.startup (or worldInitialize in slightly older script versions). The BlockCustomComponent interface gives you several hooks: onStepOn fires the moment an entity's feet land on top of the block, and onPlayerInteract fires when a player right-clicks or taps the block.
Both event objects give you direct access to the entity or player involved. Call entity.addEffect(effectType, durationInTicks, options) to grant the status effect. Remember that 20 ticks equal one second of real time, and the amplifier is zero-indexed (an amplifier of 0 gives Level I, while 1 gives Level II).
import { system } from "@minecraft/server";
system.beforeEvents.startup.subscribe((initEvent) => {
initEvent.blockComponentRegistry.registerCustomComponent(
"wiki:apply_regeneration",
{
onStepOn(event) {
const entity = event.entity;
if (!entity) return;
entity.addEffect("regeneration", 100, {
amplifier: 1,
showParticles: true
});
},
onPlayerInteract(event) {
const player = event.player;
if (!player) return;
player.addEffect("absorption", 600, {
amplifier: 0,
showParticles: false
});
}
}
);
});Continuous Area Effects with Block Ticking
onStepOn only triggers once when an entity first walks onto the block. If a player stands completely still on the block, onStepOn will not fire again until they leave and step back on. To keep an effect active for as long as someone stands on or near the block, pair your custom component with minecraft:tick in the block JSON.
Add minecraft:tick to your block's components and set an interval_range in ticks, such as [20, 20] to run once per second. Then implement the onTick handler in your custom component. Inside onTick, use event.dimension.getEntities to search a small radius around event.block.location and apply the effect to every matching entity found.
import { system } from "@minecraft/server";
system.beforeEvents.startup.subscribe((initEvent) => {
initEvent.blockComponentRegistry.registerCustomComponent(
"wiki:poison_aura",
{
onTick(event) {
const { block, dimension } = event;
const center = block.center();
const targets = dimension.getEntities({
location: center,
maxDistance: 4
});
for (const target of targets) {
target.addEffect("poison", 60, {
amplifier: 0,
showParticles: true
});
}
}
}
);
});Effect Method Parameters
When calling addEffect on an Entity or Player object in @minecraft/server, the arguments control how long the effect lasts and how visible it is to the player.
Note that certain instantaneous effects like instant_health or instant_damage still require a duration of at least 1 tick to process properly, even though their impact happens on the first tick.
| Parameter | What it does | Notes |
|---|---|---|
| effectType | The ID string or EffectType object of the status effect | Accepts vanilla names like "speed", "slowness", "regeneration", or "wither". |
| duration | How long the effect lasts, measured in game ticks | Must be an integer between 1 and 20000000. 20 ticks equals 1 second. |
| options.amplifier | Strength level of the effect starting at 0 | 0 is Level I, 1 is Level II, up to a maximum of 255. |
| options.showParticles | Controls whether swirl particles appear around the entity | Boolean. Defaults to true if omitted. |
Which versions this applies to
Applies to Minecraft Bedrock 1.21.0 and newer using stable format_version and @minecraft/server 1.11.0+. No experimental toggles are required for custom block components or addEffect in current releases.
When it does not work
| What you see | Why | The fix |
|---|---|---|
| Content Log Error: [Blocks] Failed to find custom component 'wiki:apply_regeneration' | The block JSON references a custom component name that was never registered in your script, or the script registered it after the world had already initialized. | Ensure your manifest.json has a valid script entry point, the identifier matches character-for-character, and registerCustomComponent is called inside the startup before-event. |
| Stepping on the block does nothing and no errors appear in the Content Log | The block has minecraft:collision_box set to false, or its collision height is 0. Entities cannot trigger onStepOn if they pass straight through the block without colliding with its top surface. | Give the block a solid minecraft:collision_box at least 1 pixel high, or switch to a ticking block that checks for entities inside its block space. |
| Script error: Failed to call function 'addEffect', native object is not valid or EffectType is invalid | You passed a misspelled effect identifier (such as "regen" instead of "regeneration" or "haste" instead of "mining_fatigue" / valid IDs) or a duration of 0. | Use the exact vanilla effect string IDs and ensure the duration integer is at least 1. |
Reference, straight from the game files
Read out of the game itself, so the ids match the version you are building for.
