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);