PlayerInteractEvent
Extends PlayerEvent
Implements Cancellable
Called when a player interacts or touches a block. This is called for both left click (start break) and right click (use).
Constants
LEFT_CLICK_BLOCK
public const LEFT_CLICK_BLOCK = 0RIGHT_CLICK_BLOCK
public const RIGHT_CLICK_BLOCK = 1Properties
$action
public int $action$blockFace
public int $blockFace$blockTouched
public \pocketmine\block\Block $blockTouched$item
public \pocketmine\item\Item $item$touchVector protected
protected \pocketmine\math\Vector3 $touchVector$useBlock protected
protected bool $useBlock$useItem protected
protected bool $useItemMethods
__construct()
public function __construct(\pocketmine\player\Player $player, \pocketmine\item\Item $item, \pocketmine\block\Block $blockTouched, ?\pocketmine\math\Vector3 $touchVector, int $blockFace, int $action = \pocketmine\event\player\PlayerInteractEvent::RIGHT_CLICK_BLOCK)getAction()
public function getAction() : intgetBlock()
public function getBlock() : \pocketmine\block\BlockgetFace()
public function getFace() : intgetItem()
public function getItem() : \pocketmine\item\ItemgetTouchVector()
public function getTouchVector() : \pocketmine\math\Vector3setUseBlock()
public function setUseBlock(bool $useBlock) : voidSets whether the block may react to the interaction. If false, doors, fence gates and trapdoors will not respond, containers will not open, etc.
setUseItem()
public function setUseItem(bool $useItem) : voidSets whether the used item may react to the interaction. If false, items such as spawn eggs will not activate. This does NOT prevent blocks from being placed - it makes the item behave as if the player is sneaking.
useBlock()
public function useBlock() : boolReturns whether the block may react to the interaction. If false, doors, fence gates and trapdoors will not respond, containers will not open, etc.
useItem()
public function useItem() : boolReturns whether the item may react to the interaction. If disabled, items such as spawn eggs will not activate. This does NOT prevent blocks from being placed - it makes the item behave as if the player is sneaking.
