mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 09:56:06 +00:00
Improved trees, improved inventory transactions, improved snowball/bow usage
This commit is contained in:
@ -24,6 +24,8 @@ namespace pocketmine\event\player;
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\event\Cancellable;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\level\Position;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\Player;
|
||||
|
||||
/**
|
||||
@ -43,6 +45,8 @@ class PlayerInteractEvent extends PlayerEvent implements Cancellable{
|
||||
*/
|
||||
protected $blockTouched;
|
||||
|
||||
protected $touchVector;
|
||||
|
||||
/** @var int */
|
||||
protected $blockFace;
|
||||
|
||||
@ -51,26 +55,51 @@ class PlayerInteractEvent extends PlayerEvent implements Cancellable{
|
||||
|
||||
protected $action;
|
||||
|
||||
public function __construct(Player $player, Item $item, Block $block, $face, $action = PlayerInteractEvent::RIGHT_CLICK){
|
||||
$this->blockTouched = $block;
|
||||
public function __construct(Player $player, Item $item, Vector3 $block, $face, $action = PlayerInteractEvent::RIGHT_CLICK_BLOCK){
|
||||
if($block instanceof Block){
|
||||
$this->blockTouched = $block;
|
||||
$this->touchVector = new Vector3(0, 0, 0);
|
||||
}else{
|
||||
$this->touchVector = $block;
|
||||
Block::get(0, 0, new Position(0, 0, 0, $player->level));
|
||||
}
|
||||
$this->player = $player;
|
||||
$this->item = $item;
|
||||
$this->blockFace = (int) $face;
|
||||
$this->action = (int) $action;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getAction(){
|
||||
return $this->action;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Item
|
||||
*/
|
||||
public function getItem(){
|
||||
return $this->item;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Block
|
||||
*/
|
||||
public function getBlock(){
|
||||
return $this->blockTouched;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Vector3
|
||||
*/
|
||||
public function getTouchVector(){
|
||||
return $this->touchVector;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getFace(){
|
||||
return $this->blockFace;
|
||||
}
|
||||
|
Reference in New Issue
Block a user