From 504cc3bf8bd87557ed0a0fc8cf76e5da1fd2b6bb Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Thu, 3 Jan 2019 17:00:16 +0000 Subject: [PATCH] AddEntityPacket: fix some bugs in legacy ID conversion handling --- src/pocketmine/network/mcpe/protocol/AddEntityPacket.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pocketmine/network/mcpe/protocol/AddEntityPacket.php b/src/pocketmine/network/mcpe/protocol/AddEntityPacket.php index 75d1d8571..4e0dde196 100644 --- a/src/pocketmine/network/mcpe/protocol/AddEntityPacket.php +++ b/src/pocketmine/network/mcpe/protocol/AddEntityPacket.php @@ -169,7 +169,7 @@ class AddEntityPacket 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); + $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"); } @@ -207,6 +207,9 @@ class AddEntityPacket 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->putVector3($this->position); $this->putVector3Nullable($this->motion);