#afterEvents and successful use guide

1 messages · Page 1 of 1 (latest)

civic iris
#

**This is not a big guide about how "successful use" works in afterEvents **

world.afterEvents has a system that causes events to only fire if used successfully. For example using bone meal on a grass block should be successful. However, using your own item on grass will not count as successful. And if you want to use your item, then you need to use beforeEvents. Example:

world.beforeEvents.playerInteractWithBlock.subscribe(data => {
  const block = data.block
  const item = data.itemStack
  if (item?.typeId == "wiki:super_bone_meal" && block.typeId == "minecraft:grass_block") {
    system.run(() => {
      data.player.sendMessage("You touched the grass!")
    })
  }
})

This method also has a minus - this is the system of privileges in beforeEvents. You can find out about it here
-# This post can also be used as a quick answer to similar questions

gilded sandal
civic iris
stuck tinsel
#

Thank you for this, this is really helpful and I appreciate it ❤️ Thanks for helping me the other day again