mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 08:44:01 +00:00
AddEntityPacket: fix some bugs in legacy ID conversion handling
This commit is contained in:
parent
6bd1491b8b
commit
504cc3bf8b
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user