Clean up some AnimatePacket boilerplate code

This commit is contained in:
Dylan K. Taylor
2018-08-05 12:39:36 +01:00
parent d81388f62c
commit 5df56a1bac
2 changed files with 19 additions and 16 deletions

View File

@ -63,6 +63,7 @@ use pocketmine\nbt\tag\FloatTag;
use pocketmine\nbt\tag\ListTag;
use pocketmine\nbt\tag\StringTag;
use pocketmine\network\mcpe\protocol\AddEntityPacket;
use pocketmine\network\mcpe\protocol\AnimatePacket;
use pocketmine\network\mcpe\protocol\EntityEventPacket;
use pocketmine\network\mcpe\protocol\MoveEntityAbsolutePacket;
use pocketmine\network\mcpe\protocol\RemoveEntityPacket;
@ -2118,6 +2119,13 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
$this->server->broadcastPacket($players ?? $this->getViewers(), $pk);
}
public function broadcastAnimation(?array $players, int $animationId) : void{
$pk = new AnimatePacket();
$pk->entityRuntimeId = $this->id;
$pk->action = $animationId;
$this->server->broadcastPacket($players ?? $this->getViewers(), $pk);
}
public function __destruct(){
$this->close();
}