# Events

Events are typed signals from the game. Subscribe with `JsMacros.on`, wait with `JsMacros.waitForEvent`, and read each event page for its payload and cancellation rules. High-frequency events such as `Tick` and packet events need tight filtering.

### Core

Events raised by JsMacros itself rather than by the game.

- [Custom](./events/com/jsmacrosce/jsmacros/core/event/impl/EventCustom.md) — A named event with key-value arguments.
- [ProfileLoad](./events/com/jsmacrosce/jsmacros/core/event/impl/EventProfileLoad.md) — Fires after a profile's script triggers have been registered, including at startup and on profile switches.
- [Service](./events/com/jsmacrosce/jsmacros/core/service/EventService.md) — Event payload for a running service, including shared arguments and stop callbacks.
- [WrappedScript](./events/com/jsmacrosce/jsmacros/core/event/impl/EventWrappedScript.md) — Payload for scripts run through wrapScriptRun() or wrapScriptRunAsync.

### Inputs/Interactions

Keyboard, mouse, block, entity, and sign interactions.

- [AttackBlock](./events/com/jsmacrosce/jsmacros/client/api/event/impl/player/EventAttackBlock.md) — Fires when the client's startDestroyBlock call returns true for a block target.
- [AttackEntity](./events/com/jsmacrosce/jsmacros/client/api/event/impl/player/EventAttackEntity.md) — Fires after the local player's entity-attack action.
- [InteractBlock](./events/com/jsmacrosce/jsmacros/client/api/event/impl/player/EventInteractBlock.md) — Fires after a local block-use attempt returns, unless the result is FAIL.
- [InteractEntity](./events/com/jsmacrosce/jsmacros/client/api/event/impl/player/EventInteractEntity.md) — Fires after the local player's entity-interact action returns, except when it returns InteractionResult.FAIL.
- [Key](./events/com/jsmacrosce/jsmacros/client/api/event/impl/EventKey.md) — Fires for keyboard and mouse-button input before the game's input handling.
- [MouseScroll](./events/com/jsmacrosce/jsmacros/client/api/event/impl/EventMouseScroll.md) — Fires before the game handles a scroll input, only when no screen or overlay is open, a player is present, and at least one raw offset is nonzero.
- [SignEdit](./events/com/jsmacrosce/jsmacros/client/api/event/impl/player/EventSignEdit.md) — Fires when the local player opens a sign editing screen.

### Inventory

Container contents, slot changes, pickups, and item damage.

- [ClickSlot](./events/com/jsmacrosce/jsmacros/client/api/event/impl/inventory/EventClickSlot.md) — Fires when the local player clicks a slot in an open container screen, which includes the player's own inventory and the creative inventory.
- [ContainerUpdate](./events/com/jsmacrosce/jsmacros/client/api/event/impl/inventory/EventContainerUpdate.md) — Fires after the client handles a full container-content packet.
- [DropSlot](./events/com/jsmacrosce/jsmacros/client/api/event/impl/inventory/EventDropSlot.md) — Fires for drops from a container screen (including clicking outside it) and for hotbar-key drops when no screen is open.
- [HeldItemChange](./events/com/jsmacrosce/jsmacros/client/api/event/impl/player/EventHeldItemChange.md) — Fires when polling detects a change to the local player's main- or off-hand stack, at most once per client tick.
- [ItemDamage](./events/com/jsmacrosce/jsmacros/client/api/event/impl/inventory/EventItemDamage.md) — Fires when polling detects a main-hand, off-hand, or armor stack change attributable to its damage value.
- [ItemPickup](./events/com/jsmacrosce/jsmacros/client/api/event/impl/inventory/EventItemPickup.md) — Fires while handling an item-pickup packet for the local player, before the corresponding client inventory update.
- [OpenContainer](./events/com/jsmacrosce/jsmacros/client/api/event/impl/inventory/EventOpenContainer.md) — Fires after a container screen is set.
- [SlotUpdate](./events/com/jsmacrosce/jsmacros/client/api/event/impl/inventory/EventSlotUpdate.md) — Fires for a server update to one menu slot or the cursor stack.

### Network/Chat

Chat, packets, server joins, disconnects, and player-list changes.

- [Disconnect](./events/com/jsmacrosce/jsmacros/client/api/event/impl/world/EventDisconnect.md) — Fires when the client disconnects, including when leaving without a disconnection screen.
- [JoinServer](./events/com/jsmacrosce/jsmacros/client/api/event/impl/world/EventJoinServer.md) — Fires after the login packet is handled and the local player exists; the world may still be loading.
- [NameChange](./events/com/jsmacrosce/jsmacros/client/api/event/impl/world/EventNameChange.md) — Fires when an entity's custom-name data changes.
- [PlayerJoin](./events/com/jsmacrosce/jsmacros/client/api/event/impl/world/EventPlayerJoin.md) — Fired when a player-list entry is first added to the client player list.
- [PlayerLeave](./events/com/jsmacrosce/jsmacros/client/api/event/impl/world/EventPlayerLeave.md) — Fired when a matching player-list entry is removed from the client player list.
- [RecvMessage](./events/com/jsmacrosce/jsmacros/client/api/event/impl/EventRecvMessage.md) — Fired before a message is added to the chat HUD.
- [RecvPacket](./events/com/jsmacrosce/jsmacros/client/api/event/impl/EventRecvPacket.md) — Fires for an incoming packet before it is handled by the game.
- [SendMessage](./events/com/jsmacrosce/jsmacros/client/api/event/impl/EventSendMessage.md) — Fires for text submitted through the chat screen, before the game normalizes it.
- [SendPacket](./events/com/jsmacrosce/jsmacros/client/api/event/impl/EventSendPacket.md) — Fires synchronously at the client's packet-send path, including for non-gameplay packets.

### Player/Stats

Health, hunger, air, armor, effects, death, and riding changes.

- [AirChange](./events/com/jsmacrosce/jsmacros/client/api/event/impl/player/EventAirChange.md) — Fires before the local player's air supply is set to a value divisible by 20; it does not report other values.
- [ArmorChange](./events/com/jsmacrosce/jsmacros/client/api/event/impl/player/EventArmorChange.md) — Fires when client-tick polling detects a change to one of the local player's four armor slots.
- [Damage](./events/com/jsmacrosce/jsmacros/client/api/event/impl/player/EventDamage.md) — Fires when a call decreases the local player's health, before the incoming value is applied.
- [Death](./events/com/jsmacrosce/jsmacros/client/api/event/impl/player/EventDeath.md) — Fires while handling the server's player-combat-kill packet, before the client shows the death screen.
- [EXPChange](./events/com/jsmacrosce/jsmacros/client/api/event/impl/player/EventEXPChange.md) — Fires before the client writes the local player's experience values.
- [FallFlying](./events/com/jsmacrosce/jsmacros/client/api/event/impl/player/EventFallFlying.md) — Fires when the local player's polled fall-flying state differs from the previous sample.
- [Heal](./events/com/jsmacrosce/jsmacros/client/api/event/impl/player/EventHeal.md) — Fires before the local player's health is updated to a higher value.
- [HealthChange](./events/com/jsmacrosce/jsmacros/client/api/event/impl/player/EventHealthChange.md) — Fires before the local player's health is updated.
- [HungerChange](./events/com/jsmacrosce/jsmacros/client/api/event/impl/player/EventHungerChange.md) — Fires before the local player's food level is assigned, when setFoodLevel receives a value different from the current one.
- [Riding](./events/com/jsmacrosce/jsmacros/client/api/event/impl/player/EventRiding.md) — Fires from a startRiding return path when the local player attempts to mount, or when the player begins removing an existing vehicle.
- [StatusEffectUpdate](./events/com/jsmacrosce/jsmacros/client/api/event/impl/player/EventStatusEffectUpdate.md) — Fires while the client processes a status-effect update or removal packet for the local player.

### Render/UI

Titles, boss bars, opened screens, and editor code-render hooks.

- [Bossbar](./events/com/jsmacrosce/jsmacros/client/api/event/impl/world/EventBossbar.md) — Reports each boss-bar packet action after the client handles it.
- [CodeRender](./events/com/jsmacrosce/jsmacros/client/gui/editor/highlighting/scriptimpl/CodeCompileEvent.md) — Event passed to the editor's script-based code compiler.
- [OpenScreen](./events/com/jsmacrosce/jsmacros/client/api/event/impl/player/EventOpenScreen.md) — Fires when the client's current screen changes, including when a screen is closed.
- [Title](./events/com/jsmacrosce/jsmacros/client/api/event/impl/EventTitle.md) — Fires when the client receives a title, subtitle, or action-bar message; type identifies the HUD line.

### System/Lifecycle

Game launch and quit, resource packs, and command context.

- [CommandContext](./events/com/jsmacrosce/jsmacros/client/api/helper/CommandContextHelper.md) — The parsed context for a client command, containing its arguments and command source.
- [LaunchGame](./events/com/jsmacrosce/jsmacros/client/api/event/impl/EventLaunchGame.md) — Fires at the head of the client's run method and provides the client session's name.
- [QuitGame](./events/com/jsmacrosce/jsmacros/client/api/event/impl/EventQuitGame.md) — Fires during JVM shutdown from a shutdown hook registered by JsMacros.
- [ResourcePackLoaded](./events/com/jsmacrosce/jsmacros/client/api/event/impl/EventResourcePackLoaded.md) — Fires when a resource reload completes and the loading overlay begins fading out.

### World

Blocks, chunks, dimensions, entities, sounds, and ticks.

- [BlockUpdate](./events/com/jsmacrosce/jsmacros/client/api/event/impl/world/EventBlockUpdate.md) — Fires after a block-state or block-entity update packet is handled.
- [ChunkLoad](./events/com/jsmacrosce/jsmacros/client/api/event/impl/world/EventChunkLoad.md) — Fires after a full chunk-data packet has updated the client world.
- [ChunkUnload](./events/com/jsmacrosce/jsmacros/client/api/event/impl/world/EventChunkUnload.md) — Fires after the client processes a server packet to forget a chunk.
- [DimensionChange](./events/com/jsmacrosce/jsmacros/client/api/event/impl/world/EventDimensionChange.md) — Fires when the client begins setting a non-null world, such as when joining or changing dimensions.
- [EntityDamaged](./events/com/jsmacrosce/jsmacros/client/api/event/impl/world/EventEntityDamaged.md) — Fires before a client-side living entity's health decreases through setHealth; it does not identify a damage source.
- [EntityHealed](./events/com/jsmacrosce/jsmacros/client/api/event/impl/world/EventEntityHealed.md) — Fires before a client-side living entity's setHealth call when the supplied health is greater than its previous value.
- [EntityLoad](./events/com/jsmacrosce/jsmacros/client/api/event/impl/world/EventEntityLoad.md) — Fires after an entity is added to the client world.
- [EntityUnload](./events/com/jsmacrosce/jsmacros/client/api/event/impl/world/EventEntityUnload.md) — Fires when an entity is removed from the client world.
- [Sound](./events/com/jsmacrosce/jsmacros/client/api/event/impl/world/EventSound.md) — Fires when the sound engine receives a sound instance, before it attempts playback.
- [Tick](./events/com/jsmacrosce/jsmacros/client/api/event/impl/world/EventTick.md) — Fires after the key-macro check, tick synchronizer, and server-list pinger on each client tick.
