Added right and left click interaction events

This commit is contained in:
Shoghi Cervantes
2015-03-13 14:39:37 +01:00
parent e48a3e5713
commit 9e0b9a6e5b
3 changed files with 23 additions and 5 deletions

View File

@ -32,6 +32,12 @@ use pocketmine\Player;
class PlayerInteractEvent extends PlayerEvent implements Cancellable{
public static $handlerList = null;
const LEFT_CLICK_BLOCK = 0;
const RIGHT_CLICK_BLOCK = 1;
const LEFT_CLICK_AIR = 2;
const RIGHT_CLICK_AIR = 3;
const PHYSICAL = 4;
/**
* @var \pocketmine\block\Block;
*/
@ -42,12 +48,19 @@ class PlayerInteractEvent extends PlayerEvent implements Cancellable{
/** @var \pocketmine\item\Item */
protected $item;
protected $action;
public function __construct(Player $player, Item $item, Block $block, $face){
public function __construct(Player $player, Item $item, Block $block, $face, $action = PlayerInteractEvent::RIGHT_CLICK){
$this->blockTouched = $block;
$this->player = $player;
$this->item = $item;
$this->blockFace = (int) $face;
$this->action = (int) $action;
}
public function getAction(){
return $this->action;
}
public function getItem(){
@ -61,4 +74,4 @@ class PlayerInteractEvent extends PlayerEvent implements Cancellable{
public function getFace(){
return $this->blockFace;
}
}
}