FalconFalcon
Docs menuScript events

Packs and scripting

Script events

Subscribe with world.afterEvents.<name>.subscribe(callback), and remove with unsubscribe.

afterEvents

GroupEvents
PlayersplayerSpawn, playerJoin, playerLeave, playerHotbarSelectedSlotChange, playerInventoryItemChange
BlocksplayerBreakBlock, playerPlaceBlock, playerInteractWithBlock
EntitiesentitySpawn, entityRemove, entityLoad, entityHurt, entityDie, entityHitBlock, entityHitEntity, entityItemDrop
ProjectilesprojectileHitBlock, projectileHitEntity
OtherchatSend, itemUse, worldLoad

beforeEvents

Set event.cancel = true to stop the action.

EventUse
playerBreakBlockBefore a block breaks
chatSendBefore a chat message
playerInteractWithBlock, playerInteractWithEntityBefore an interaction
itemUse, itemUseOnBefore an item is used
entityHurtBefore damage
effectAddBefore an effect
worldInitializeGives itemComponentRegistry and blockComponentRegistry
import { world } from "@minecraft/server";

world.beforeEvents.chatSend.subscribe((event) => {
  if (event.message.includes("badword")) event.cancel = true;
});