The PlayerHotbarSelectedSlotChangeAfterEvent interface in @minecraft/server.
Interface in @minecraft/server
import type { PlayerHotbarSelectedSlotChangeAfterEvent } from '@minecraft/server';Subscribe to it with world.afterEvents.playerHotbarSelectedSlotChange.
Example
Section titled “Example”import { world, type PlayerHotbarSelectedSlotChangeAfterEvent } from '@minecraft/server';
world.afterEvents.playerHotbarSelectedSlotChange.subscribe((event: PlayerHotbarSelectedSlotChangeAfterEvent) => { console.log('playerHotbarSelectedSlotChange', event.player.name, event.newSlotSelected, event.previousSlotSelected);});import { world } from '@minecraft/server';
world.afterEvents.playerHotbarSelectedSlotChange.subscribe((event) => { console.log('playerHotbarSelectedSlotChange', event.player.name, event.newSlotSelected, event.previousSlotSelected);});Properties
Section titled “Properties”player
Section titled “player”read-only
readonly player: Player;Types
newSlotSelected
Section titled “newSlotSelected”read-only
readonly newSlotSelected: number;previousSlotSelected
Section titled “previousSlotSelected”read-only
readonly previousSlotSelected: number;The slot held before.
itemStack
Section titled “itemStack”read-only
readonly itemStack: ItemStack | undefined;Types
Used by
Section titled “Used by”WorldAfterEvents.playerHotbarSelectedSlotChange, PlayerHotbarSelectedSlotChangeAfterEventSignal.subscribe, PlayerHotbarSelectedSlotChangeAfterEventSignal.unsubscribe