Cleaned up EntityEventPacket handling

This commit is contained in:
Dylan K. Taylor
2017-11-04 18:31:35 +00:00
parent ddb7fd12f2
commit a66a757f56
4 changed files with 14 additions and 16 deletions

View File

@ -59,6 +59,7 @@ use pocketmine\nbt\tag\ListTag;
use pocketmine\nbt\tag\ShortTag;
use pocketmine\nbt\tag\StringTag;
use pocketmine\network\mcpe\protocol\AddEntityPacket;
use pocketmine\network\mcpe\protocol\EntityEventPacket;
use pocketmine\network\mcpe\protocol\MoveEntityPacket;
use pocketmine\network\mcpe\protocol\RemoveEntityPacket;
use pocketmine\network\mcpe\protocol\SetEntityDataPacket;
@ -2077,6 +2078,15 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
}
}
public function broadcastEntityEvent(int $eventId, ?int $eventData = null, ?array $players = null) : void{
$pk = new EntityEventPacket();
$pk->entityRuntimeId = $this->id;
$pk->event = $eventId;
$pk->data = $eventData ?? 0;
$this->server->broadcastPacket($players ?? $this->getViewers(), $pk);
}
public function __destruct(){
$this->close();
}