Wiki 9Minecraft Wiki 9Minecraft

Trigger Actions When Players Break Blocks

Java EditionPluginGuides 4FAQ 10Related mods 48
DownloadSkript Plugin

Get the files on 9Minecraft

Contents (3)
  1. Using Block Break Events
  2. Setting Up a Block Break Handler
  3. Practical Examples

Using Block Break Events

Skript allows you to detect when players break blocks and respond with custom actions. This is useful for creating mining rewards, preventing certain blocks from breaking, or logging activity.

Setting Up a Block Break Handler

Create a .sk file with an event listener:

`

on block break:

if event-block is diamond ore:

give diamond to player

send "You mined a diamond!" to player

`

This code runs every time any player breaks a block. The if statement checks what type of block was broken.

Practical Examples

You can cancel the break, drop custom items, or apply effects:

`

on block break:

if player has permission "admin.nobreak":

cancel event

send "You cannot break blocks!" to player

`

Use cancel event to prevent the block from actually breaking. Reload your scripts with /skript reload all and test by breaking blocks in-game. The actions will trigger instantly.

More guides for this mod