mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 16:51:42 +00:00
AddActorPacket: move BC hack to higher level
we shouldn't hack the protocol impl for BC.
This commit is contained in:
parent
dbaf851be7
commit
c19ab97610
@ -1914,7 +1914,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
|
||||
protected function sendSpawnPacket(Player $player) : void{
|
||||
$pk = new AddActorPacket();
|
||||
$pk->entityRuntimeId = $this->getId();
|
||||
$pk->type = static::NETWORK_ID;
|
||||
$pk->type = AddActorPacket::LEGACY_ID_MAP_BC[static::NETWORK_ID];
|
||||
$pk->position = $this->asVector3();
|
||||
$pk->motion = $this->getMotion();
|
||||
$pk->yaw = $this->yaw;
|
||||
|
@ -148,7 +148,7 @@ class AddActorPacket extends DataPacket{
|
||||
public $entityUniqueId = null; //TODO
|
||||
/** @var int */
|
||||
public $entityRuntimeId;
|
||||
/** @var int */
|
||||
/** @var string */
|
||||
public $type;
|
||||
/** @var Vector3 */
|
||||
public $position;
|
||||
@ -174,10 +174,7 @@ class AddActorPacket extends DataPacket{
|
||||
protected function decodePayload(){
|
||||
$this->entityUniqueId = $this->getEntityUniqueId();
|
||||
$this->entityRuntimeId = $this->getEntityRuntimeId();
|
||||
$this->type = array_search($t = $this->getString(), self::LEGACY_ID_MAP_BC, true);
|
||||
if($this->type === false){
|
||||
throw new \UnexpectedValueException("Can't map ID $t to legacy ID");
|
||||
}
|
||||
$this->type = $this->getString();
|
||||
$this->position = $this->getVector3();
|
||||
$this->motion = $this->getVector3();
|
||||
$this->pitch = $this->getLFloat();
|
||||
@ -212,10 +209,7 @@ class AddActorPacket extends DataPacket{
|
||||
protected function encodePayload(){
|
||||
$this->putEntityUniqueId($this->entityUniqueId ?? $this->entityRuntimeId);
|
||||
$this->putEntityRuntimeId($this->entityRuntimeId);
|
||||
if(!isset(self::LEGACY_ID_MAP_BC[$this->type])){
|
||||
throw new \InvalidArgumentException("Unknown entity numeric ID $this->type");
|
||||
}
|
||||
$this->putString(self::LEGACY_ID_MAP_BC[$this->type]);
|
||||
$this->putString($this->type);
|
||||
$this->putVector3($this->position);
|
||||
$this->putVector3Nullable($this->motion);
|
||||
$this->putLFloat($this->pitch);
|
||||
|
Loading…
x
Reference in New Issue
Block a user