mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-12 12:55:21 +00:00
82 lines
2.2 KiB
PHP
82 lines
2.2 KiB
PHP
<?php
|
|
|
|
/*
|
|
*
|
|
* ____ _ _ __ __ _ __ __ ____
|
|
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
|
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
|
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Lesser General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* @author PocketMine Team
|
|
* @link http://www.pocketmine.net/
|
|
*
|
|
*
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace pocketmine\network\mcpe\protocol;
|
|
|
|
#include <rules/DataPacket.h>
|
|
|
|
use pocketmine\network\mcpe\handler\PacketHandler;
|
|
|
|
class EmotePacket extends DataPacket implements ClientboundPacket, ServerboundPacket{
|
|
public const NETWORK_ID = ProtocolInfo::EMOTE_PACKET;
|
|
|
|
private const FLAG_SERVER = 1 << 0;
|
|
|
|
/** @var int */
|
|
private $entityRuntimeId;
|
|
/** @var string */
|
|
private $emoteId;
|
|
/** @var int */
|
|
private $flags;
|
|
|
|
public static function create(int $entityRuntimeId, string $emoteId, int $flags) : self{
|
|
$result = new self;
|
|
$result->entityRuntimeId = $entityRuntimeId;
|
|
$result->emoteId = $emoteId;
|
|
$result->flags = $flags;
|
|
return $result;
|
|
}
|
|
|
|
/**
|
|
* TODO: we can't call this getEntityRuntimeId() because of base class collision (crap architecture, thanks Shoghi)
|
|
* @return int
|
|
*/
|
|
public function getEntityRuntimeIdField() : int{
|
|
return $this->entityRuntimeId;
|
|
}
|
|
|
|
public function getEmoteId() : string{
|
|
return $this->emoteId;
|
|
}
|
|
|
|
public function getFlags() : int{
|
|
return $this->flags;
|
|
}
|
|
|
|
protected function decodePayload() : void{
|
|
$this->entityRuntimeId = $this->getEntityRuntimeId();
|
|
$this->emoteId = $this->getString();
|
|
$this->flags = $this->getByte();
|
|
}
|
|
|
|
protected function encodePayload() : void{
|
|
$this->putEntityRuntimeId($this->entityRuntimeId);
|
|
$this->putString($this->emoteId);
|
|
$this->putByte($this->flags);
|
|
}
|
|
|
|
public function handle(PacketHandler $handler) : bool{
|
|
return $handler->handleEmote($this);
|
|
}
|
|
}
|