Player: broadcast entity event to self as well when sending to all viewers

this fixes several bugs with entity events and removes the need for a hit animation hack.
This commit is contained in:
Dylan K. Taylor 2018-05-23 09:28:46 +01:00
parent faa88a55e4
commit 1c4dd4f280

View File

@ -3706,11 +3706,12 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
parent::attack($source);
}
protected function doHitAnimation() : void{
parent::doHitAnimation();
if($this->spawned){
$this->broadcastEntityEvent(EntityEventPacket::HURT_ANIMATION, null, [$this]);
public function broadcastEntityEvent(int $eventId, ?int $eventData = null, ?array $players = null) : void{
if($this->spawned and $players === null){
$players = $this->getViewers();
$players[] = $this;
}
parent::broadcastEntityEvent($eventId, $eventData, $players);
}
public function getOffsetPosition(Vector3 $vector3) : Vector3{