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); parent::attack($source);
} }
protected function doHitAnimation() : void{ public function broadcastEntityEvent(int $eventId, ?int $eventData = null, ?array $players = null) : void{
parent::doHitAnimation(); if($this->spawned and $players === null){
if($this->spawned){ $players = $this->getViewers();
$this->broadcastEntityEvent(EntityEventPacket::HURT_ANIMATION, null, [$this]); $players[] = $this;
} }
parent::broadcastEntityEvent($eventId, $eventData, $players);
} }
public function getOffsetPosition(Vector3 $vector3) : Vector3{ public function getOffsetPosition(Vector3 $vector3) : Vector3{