Bedrock Wiki
  • Discord
  • Contribute
  • bedrock.dev
  • MS Learn
Beginner's Guide
  • Guide
    • 1. Introduction
      guide
    • 2. Add-Ons Explained
    • 3. Software & Preparation
    • 4. Project Setup
    • 5. Create a Custom Item
    • 6. Create a Custom Entity
    • 7. Blockbench: Modeling, Texturing & Animating
    • 8. Adding a Loot Table, Spawn Rule & Crafting Recipe
  • Extra
    • a. Understanding JSON
    • b. Download Example Packs
    • c. Troubleshooting
      help
    • d. Advanced Manifest
    • e. Format Versions
    • f. Project Setup Android
Animation Controllers
  • Intro to Animation Controllers
    guide
  • Entity Commands
  • AFK Detector
  • Death Commands
  • Molang into Scoreboard
  • Respawn Commands
Blocks
  • General
    • Intro to Blocks
      guide
    • Block Components
    • Block Tags
    • Block States
    • Block Traits
    • Block Permutations
    • Block Events
      Scripts
    • Block Event Migration
      help
    • Blocks as Items
    • Troubleshooting Blocks
      help
  • Visuals
    • Block Culling
    • Block Models
      guide
    • Block Texture Animation
    • Block Texture Variation
    • Block Tinting
  • Tutorials
    • Applying Effects
      Scripts
    • Avoiding State Limit
    • Block Orientation
    • Fake Blocks
      Scripts
    • Intercardinal Orientation
      Scripts
    • Ore Loot Tables
      Scripts
    • Tool-Based Destruction
  • Vanilla Re-Creations
    • Custom Crops
      Scripts
    • Custom Glass
    • Custom Glazed Terracotta
    • Custom Heads
      Scripts
    • Custom Trapdoors
      Scripts
  • Documentation
    • Block Format History
    • Block Shapes
    • Block Sounds
    • Redstone Components
    • Vanilla Block Models
    • Vanilla Block Tags
    • Vanilla Voxel Shapes
Commands
  • General
    • Intro to Command Blocks
    • Understanding Selectors
    • Functions
      guide
    • Block States
    • Coordinate System
    • Giving NBT Items
    • Scoreboard Operations
  • Commands
    • Damage
    • Execute
    • Playanimation
    • Playsound
  • On Event Systems
    • On First World Load
      function
    • On Player First Join
    • On Player Join
    • On Player Leave
    • On Player Death
    • On Player Respawn
  • Scoreboard Systems
    • Entity Counter
    • Scoreboard Timers
    • Comparing And Retrieving Scores
  • Detection Systems
    • Look Detection
    • Item Drop Detection
    • Movement Detections
    • Rain Detection
  • Techniques
    • Execute Logic Gates
      concept
    • Execute at Block Variant
    • Execution Forking
      concept
    • Binary in Commands
      concept
    • MBE - Max's Block Entity
    • FMBE - A New Way to Create Display Entities
    • Dynamic Displays
    • Orbital Camera
  • Useful Creations
    • Sphere Command
    • Compass Display
    • Custom Crafting
    • Multiplayer Position Rearrangement
      function
Concepts
  • contents.json
  • Molang
  • Namespaces
  • Overwriting Assets
  • Shaders
  • Sounds
  • Subpacks
  • Texture Atlases
  • textures_list.json
Documentation
  • Advanced Molang
  • File Types
  • Fog IDs
  • Material Configuration Description
  • Molang Queries
  • Pack Folder Structure
  • Shared Constructs
  • Sound Definitions
  • Vanilla Materials
Entities
  • General
    • Intro to Entities BP
      guide
    • Intro to Entities RP
      guide
    • Troubleshooting Entities
      help
    • Entity Events
    • Entity Properties
    • NPC Dialogue
    • Render Controllers
    • Spawn Rules
  • Tutorials
    • Area Effect Clouds
    • Coordinate Space Conversion
    • Creating Boats
    • Detecting Other Entities
    • Disabling Team Damage
    • Dummy Entities
    • Entity Attacks
    • Entity Movement
    • Entity Timers
    • Holding Items
    • Invulnerable Entities
    • Look at Entity
    • Riding Flying Entities
    • Sleeping Entities
    • Solid Entities
    • Spawning Tamed Entities
      Scripts
    • Village Mechanic
  • Documentation
    • Dummy Components
    • Non-Mob Runtime Identifiers
    • Projectiles
    • Runtime Identifiers
    • Vanilla Usage Components
    • Vanilla Usage Spawn Rules
Items
  • General
    • Intro to Items
      guide
    • Item Components
    • Item Tags
    • Item Events
      Scripts
    • Item Event Migration
      help
    • Item Catalog
    • Troubleshooting Items
      help
  • Tutorials
    • Custom Armor
    • Custom Food
      Scripts
    • Custom Pottery Sherds
    • Custom Weapons
    • Equipment-Based Commands
    • Spawning Items
    • Throwable Items
  • Documentation
    • Enchantments
    • Attachables
    • Item Format History
    • Numerical Item IDs
    • Vanilla Item Groups
    • Vanilla Item Tags
    • Vanilla Usage Components
JSON UI
  • General
    • Intro to JSON UI
      guide
    • Best Practices
      guide
  • Tutorials
    • Adding HUD Elements
    • Aseprite Animations
    • Buttons and Toggles
    • Modifying Server Forms
    • Preserve Title Texts
    • String to Number
  • Documentation
    • JSON UI Documentation
Loot, Recipes & Trading
  • General
    • Trading Behavior
  • Documentation
    • Loot Tables
    • Trade Tables
    • Recipes
    • Item Functions
  • Tutorials
    • Randomized Structure Loot
Meta
  • Add-On Performance
  • Style Guide
  • Useful Links
  • Using Schemas
  • Version Control
  • Q&A
    • Blocks and Items Q&A 2024/08/30
    • Deferred Technical Preview Q&A 2024/02/23
    • GameTest Q&A 2021/08/06
    • Scripting and Editor Q&A 2023/09/22
    • World Generation Q&A 2024/11/15
NBT
  • General
    • .mcstructure
  • Tutorials
    • Enabling Experiments by Editing NBT
    • Extending Structure Limits
  • NBT in Depth
    • About NBT (Named Binary Tag)
    • NBT Libraries
    • Reading NBT Example
Particles
  • General
    • Intro to Particles
      guide
  • Tutorials
    • Disabling Particles
  • Documentation
    • Vanilla Particles
Scripting
  • General
    • Intro to Scripting
    • What is Script API?
    • API Modules
  • Tutorials
    • Block Placement Prevention
    • Custom Commands
    • GameTests
    • Script Core Features
    • Script Privileges
    • Script Requests API
    • Server Forms
  • Documentation
    • Engine Environment
    • Script Resources
    • Script Watchdog
    • Troubleshooting JavaScript
    • TypeScript
Servers
  • Software
    • Bedrock Server Software
  • Protocols
    • Bedrock Protocol
    • NetherNet Protocol
    • RakNet Protocol
Text & Localization
  • General
    • Intro to Text & Localization
    • Raw Text
    • Splashes
  • Emojis & Symbols
    • Fonts
    • Intro to Emojis
    • Custom Emojis
    • Input Keys
Visuals
  • General
    • Introduction to Entity Visuals
      guide
    • Bedrock Modeling
    • Custom Death Animations
    • Effects in Animations
    • Material Creations
    • Materials
    • Math-Based Animations
    • Skin Packs
  • Tutorials
    • Entity Texture Animation
    • Glowing Entity Texture
    • Hurt Animations
    • Leash Position
    • Player Geometry
    • Remove Entity Shadows
    • Retexturing Spawn Eggs
  • Ideas
    • Structure Presentation
World Generation
  • General
    • Intro to World Generation
      guide
    • Biomes
      guide
    • Feature Types
    • Jigsaw Structures
  • Tutorials
    • Block Conditions for Features
    • Generating Custom Ores
    • Generating Custom Structures
    • Generating Patches
    • Heightmap Noise
  • Documentation
    • Biome Tags

Block Events

scripting
Block Events
  • Registering Custom Components
  • Applying Custom Components
  • List of Events
    • Before Player Place
    • Break
    • Entity
    • Entity Fall On
    • Place
    • Player Break
    • Player Interact
    • Random Tick
    • Redstone Update
    • Step Off
    • Step On
    • Tick

FORMAT VERSION 1.26.10

Using the latest format version when creating custom blocks provides access to fresh features and improvements. The wiki aims to share up-to-date information about custom blocks, and currently targets format version 1.26.10.

Registering Custom Components ​

Block events trigger when certain conditions are met and can be "listened" to in custom components which are registered in scripts before the world is loaded.

Within each custom component, event handler functions (such as beforeOnPlayerPlace()) are listed to configure what you want to happen when each event is triggered.

This example prevents the player from placing the block if they aren't in creative mode:

BP/scripts/creativeModeOnly.js
js
import { system, GameMode } from "@minecraft/server"; // Must be version 2.0.0 or higher

/** @type {import("@minecraft/server").BlockCustomComponent} */
const BlockCreativeModeOnlyComponent = {
    beforeOnPlayerPlace(event) {
        const gameMode = event.player?.getGameMode();

        if (gameMode !== GameMode.Creative) {
            event.cancel = true;
        }
    },
};

system.beforeEvents.startup.subscribe(({ blockComponentRegistry }) => {
    blockComponentRegistry.registerCustomComponent(
        "wiki:creative_mode_only",
        BlockCreativeModeOnlyComponent
    );
});
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

Applying Custom Components ​

To bind a custom component to a block, simply list it in the components of your block JSON.

Like any normal component, custom components can be added and removed based on the block's permutation.

Requires format version 1.21.90 or later.

minecraft:block
json
"components": {
    "wiki:creative_mode_only": {}
}
1
2
3

List of Events ​

Before Player Place ​

Called before a player places the block, preventing the client-side placement of the block.

Custom Component
js
beforeOnPlayerPlace(event) {
    event.block // Block impacted by this event. This is the block that will be replaced.
    event.cancel // If set to true, cancels the block place event.
    event.dimension // Dimension that contains the block.
    event.face // The block face that was placed onto.
    event.permutationToPlace // The block permutation that will be placed. Can be changed to place a different permutation instead.
    event.player // The player that is placing this block. May be undefined.
}
1
2
3
4
5
6
7
8

Break ​

Called whenever the block is removed from the world, including when replaced via commands.

Custom Component
js
onBreak(event) {
    event.block // Block impacted by this event. This is the block after it has been broken.
    event.dimension // Dimension that contains the block.
    event.blockDestructionSource // The block that broke the block (such as an extended piston). May be undefined.
    event.brokenBlockPermutation // Permutation of the block before it was broken.
    event.entitySource // The entity that broke the block. May be undefined.
}
1
2
3
4
5
6
7

Entity ​

Called when an entity executes an event on the block.

Events can be triggered by the execute_event_on_home_block entity event response or by vanilla entity components (see vanilla entity events). Events will not necessarily be received by this hook in the same tick that the entity requests for the event to be executed.

Custom Component
js
onEntity(event) {
    event.block // Block impacted by this event.
    event.blockPermutation // The permutation of the block when it was originally affected by the entity.
    event.dimension // Dimension that contains the block.
    event.entitySource // The entity that executed the event on the block.
    event.name // The name of the event executed by the entity. May be custom or one of the vanilla events listed below.
}
1
2
3
4
5
6
7

Vanilla Entity Events ​

Event NameRequired Entity ComponentDescription
"on_escape"minecraft:behavior.avoid_blockExecuted after the entity escapes from the block.
"on_home"minecraft:behavior.go_homeExecuted after the entity reaches the block.
"on_place"minecraft:behavior.place_blockExecuted after the entity places the block.
"on_reach"minecraft:behavior.move_to_blockExecuted after the entity reaches the block.
"on_take"minecraft:behavior.take_blockExecuted after the entity takes the block.

Custom Dog Example ​

minecraft:entity
json
"components": {
    // The dog's home will be set to its kennel
    "minecraft:home": {
        "restriction_radius": 32,
        "restriction_type": "random_movement",
        "home_block_types": ["wiki:kennel", "wiki:large_kennel"]
    }
},
"events": {
    // Event that can be triggered to make this dog's kennel bigger
    "wiki:upgrade_kennel": {
        "execute_event_on_home_block": {
            "event": "wiki:on_upgrade"
        }
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Custom Component
js
onEntity({ name, block }) {
    if (name === "wiki:on_upgrade") {
        // Upgrade regular kennel to large kennel
        block.setType("wiki:large_kennel");
    }
}
1
2
3
4
5
6

Entity Fall On ​

DEPENDENCIES

The entity fall on event requires the minecraft:entity_fall_on component to be active on your block to trigger.

The entity fall on event requires the minecraft:collision_box component to be taller than 3.2 pixels on the Y-axis in order to trigger.

Called when an entity falls on the block.

minecraft:block > components
json
"minecraft:entity_fall_on": {
    "min_fall_distance": 5 // The minimum distance an entity must fall to trigger this event (optional).
}
1
2
3
Custom Component
js
onEntityFallOn(event) {
    event.block // Block impacted by this event.
    event.dimension // Dimension that contains the block.
    event.entity // The entity that stepped on the block. May be undefined.
    event.fallDistance // The distance that the entity fell before landing.
}
1
2
3
4
5
6

Place ​

Called when the block is placed.

Custom Component
js
onPlace(event) {
    event.block // Block impacted by this event.
    event.dimension // Dimension that contains the block.
    event.previousBlock // Permutation of the replaced block.
}
1
2
3
4
5

Player Break ​

Called when the player breaks the block.

Custom Component
js
onPlayerBreak(event) {
    event.block // Block impacted by this event. This is the block after it has been broken.
    event.brokenBlockPermutation // Permutation of the block before it was broken.
    event.dimension // Dimension that contains the block.
    event.player // The player that broke the block. May be undefined.
}
1
2
3
4
5
6

Player Interact ​

EMPTY BUCKETS

The onPlayerInteract hook is not called when the player interacts with the block using an empty bucket.

Called when the player interacts with / uses the block.

Custom Component
js
onPlayerInteract(event) {
    event.block // Block impacted by this event.
    event.dimension // Dimension that contains the block.
    event.face // The block face that was interacted with.
    event.faceLocation // Location relative to the bottom north-west corner of the block that the player interacted with.
    event.player // The player that interacted with the block. May be undefined.
}
1
2
3
4
5
6
7

Random Tick ​

Triggered on every random tick, allowing for behavior like random crop growth.

Custom Component
js
onRandomTick(event) {
    event.block // Block impacted by this event.
    event.dimension // Dimension that contains the block.
}
1
2
3
4

Redstone Update ​

DEPENDENCY

The redstone update event requires the minecraft:redstone_consumer component to be active on your block to trigger.

Triggers every time the block receives a redstone update.

This happens in the following situations:

  • The block is placed
  • The chunk containing the block is loaded
  • The redstone power level of the block changes
minecraft:block > components
json
"minecraft:redstone_consumer": {
    "min_power": 5 // The minimum power level needed to trigger this event.
}
1
2
3
Custom Component
js
onRedstoneUpdate(event) {
    event.block // Block impacted by this event.
    event.dimension // Dimension that contains the block.
    event.powerLevel // The redstone power level received by the block.
}
1
2
3
4
5

Step Off ​

DEPENDENCY

The step off event requires the minecraft:collision_box component to be taller than 3.2 pixels on the Y-axis in order to trigger.

Called when an entity steps off the block.

Custom Component
js
onStepOff(event) {
    event.block // Block impacted by this event.
    event.dimension // Dimension that contains the block.
    event.entity // The entity that stepped on the block. May be undefined.
}
1
2
3
4
5

Step On ​

DEPENDENCY

The step on event requires the minecraft:collision_box component to be taller than 3.2 pixels on the Y-axis in order to trigger.

Called when an entity steps onto the block.

Custom Component
js
onStepOn(event) {
    event.block // Block impacted by this event.
    event.dimension // Dimension that contains the block.
    event.entity // The entity that stepped on the block. May be undefined.
}
1
2
3
4
5

Tick ​

DEPENDENCY

The tick event requires the minecraft:tick component to be active on your block to trigger.

Triggers between X and Y amount of ticks inside interval_range of the block's minecraft:tick component.

minecraft:block > components
json
"minecraft:tick": {
    "interval_range": [10, 20],
    "looping": true
}
1
2
3
4
Custom Component
js
onTick(event) {
    event.block // Block impacted by this event.
    event.dimension // Dimension that contains the block.
}
1
2
3
4

Contributors

Edit Block Events on GitHub

Text and image content on this page is licensed under the Creative Commons Attribution 4.0 International License

Code samples on this page are licensed under the MIT License

Bedrock Wiki by Bedrock OSS

"Minecraft" is a trademark of Mojang AB.

Bedrock OSS, Bedrock Wiki and bedrock.dev are not affiliated in any way with Microsoft or Mojang AB.

  • Privacy Policy
  • Join our Discord
  • Learn how to Contribute
  • Visit our Repository