Added PlayerEntityInteractEvent (#4374)

This commit is contained in:
marshall
2021-08-24 18:56:10 +08:00
committed by GitHub
parent 224d71f272
commit 6e68e99ec0
3 changed files with 75 additions and 1 deletions

View File

@ -53,6 +53,7 @@ use pocketmine\event\player\PlayerChatEvent;
use pocketmine\event\player\PlayerCommandPreprocessEvent;
use pocketmine\event\player\PlayerDeathEvent;
use pocketmine\event\player\PlayerDisplayNameChangeEvent;
use pocketmine\event\player\PlayerEntityInteractEvent;
use pocketmine\event\player\PlayerExhaustEvent;
use pocketmine\event\player\PlayerGameModeChangeEvent;
use pocketmine\event\player\PlayerInteractEvent;
@ -1684,7 +1685,17 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
* Interacts with the given entity using the currently-held item.
*/
public function interactEntity(Entity $entity, Vector3 $clickPos) : bool{
//TODO
$ev = new PlayerEntityInteractEvent($this, $entity, $clickPos);
if(!$this->canInteract($entity->getLocation(), 8)){
$ev->cancel();
}
$ev->call();
if(!$ev->isCancelled()){
return $entity->onInteract($this, $clickPos);
}
return false;
}