Block Interactions

Right-clicking on blocks, breaking them, etc.


All block events listed on this page can be put in server_scripts/ or client_scripts/.

#Broken Event

The block broken event is cancellable.
Here's an example of replacing stone with cobblestone once it's broken.
BlockEvents.broken('minecraft:stone', event => {
  event.block.set('minecraft:cobblestone')
  event.cancel()
})

#Detector Events

WIP

#Farmland Trampled Event

The farmland trampled event is cancellable.
The farmland trampled event only exists on version 1.19.2 and above!
Here's an example of cancelling the event if the player has boots on with the feather falling 4 enchant
BlockEvents.farmlandTrampled(event => {
  if(event.player.feetArmorItem.hasEnchantment('minecraft:feather_falling', 4)) e.cancel()
})

#Left Clicked Event

The left click event is cancellable.
Here's an example of giving the player stone when left clicking sand, and removing the sand.
BlockEvents.leftClicked('minecraft:sand', event => {
  event.player.give('minecraft:cobblestone')
  event.block.set('minecraft:air')
})

#Placed Event

The block placed event is cancellable.
Here's an example of replacing a crafting table with an oak log when placed.
BlockEvents.placed('minecraft:crafting_table', event => {
  event.player.tell('NO CRAFTING FOR YOU')
  event.block.set('minecraft:oak_log')
})

#Right Clicked Event

The right click event is cancellable.
Here's an example of cancelling the event when right clicking chests.
BlockEvents.rightClicked('minecraft:chest', event => event.cancel())