Added handling for attack-air action (#5912)

This commit is contained in:
ipad54
2023-07-25 16:50:28 +03:00
committed by GitHub
parent fb43f59458
commit 6086ef667c
3 changed files with 55 additions and 0 deletions

View File

@ -66,6 +66,7 @@ use pocketmine\event\player\PlayerItemUseEvent;
use pocketmine\event\player\PlayerJoinEvent;
use pocketmine\event\player\PlayerJumpEvent;
use pocketmine\event\player\PlayerKickEvent;
use pocketmine\event\player\PlayerMissedSwingEvent;
use pocketmine\event\player\PlayerMoveEvent;
use pocketmine\event\player\PlayerPostChunkSendEvent;
use pocketmine\event\player\PlayerQuitEvent;
@ -1894,6 +1895,18 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
return true;
}
/**
* Performs actions associated with the attack action (left-click) without a target entity.
* Under normal circumstances, this will play the no-damage attack sound and nothing else.
*/
public function missSwing() : void{
$ev = new PlayerMissedSwingEvent($this);
$ev->call();
if(!$ev->isCancelled()){
$this->broadcastSound(new EntityAttackNoDamageSound());
}
}
/**
* Interacts with the given entity using the currently-held item.
*/