PlayerItemHeldEvent
Extends PlayerEvent
Implements Cancellable
Called when a player's held item changes. This could be because they selected a different hotbar slot, or because the item in the selected hotbar slot was changed.
Methods
__construct()
php
public function __construct(\pocketmine\player\Player $player, \pocketmine\item\Item $item, int $hotbarSlot)getItem()
php
public function getItem() : \pocketmine\item\ItemReturns the item in the slot that the player is trying to equip.
getSlot()
php
public function getSlot() : intReturns the hotbar slot the player is attempting to hold.
NOTE: This event is called BEFORE the slot is equipped server-side. Setting the player's held item during this event will result in the old slot being changed, not this one.
To change the item in the slot that the player is attempting to hold, set the slot that this function reports.
