mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 02:08:21 +00:00
AddEntityPacket's attributes encoding is still non-standard -_-
I thought they fixed this...
This commit is contained in:
@ -55,7 +55,25 @@ class AddEntityPacket extends DataPacket{
|
||||
$this->getVector3f($this->speedX, $this->speedY, $this->speedZ);
|
||||
$this->pitch = $this->getLFloat();
|
||||
$this->yaw = $this->getLFloat();
|
||||
$this->attributes = $this->getAttributeList();
|
||||
|
||||
$attrCount = $this->getUnsignedVarInt();
|
||||
for($i = 0; $i < $attrCount; ++$i){
|
||||
$name = $this->getString();
|
||||
$min = $this->getLFloat();
|
||||
$current = $this->getLFloat();
|
||||
$max = $this->getLFloat();
|
||||
$attr = Attribute::getAttributeByName($name);
|
||||
|
||||
if($attr !== null){
|
||||
$attr->setMinValue($min);
|
||||
$attr->setMaxValue($max);
|
||||
$attr->setValue($current);
|
||||
$this->attributes[] = $attr;
|
||||
}else{
|
||||
throw new \UnexpectedValueException("Unknown attribute type \"$name\"");
|
||||
}
|
||||
}
|
||||
|
||||
$this->metadata = $this->getEntityMetadata();
|
||||
$linkCount = $this->getUnsignedVarInt();
|
||||
for($i = 0; $i < $linkCount; ++$i){
|
||||
@ -74,7 +92,15 @@ class AddEntityPacket extends DataPacket{
|
||||
$this->putVector3f($this->speedX, $this->speedY, $this->speedZ);
|
||||
$this->putLFloat($this->pitch);
|
||||
$this->putLFloat($this->yaw);
|
||||
$this->putAttributeList(...$this->attributes);
|
||||
|
||||
$this->putUnsignedVarInt(count($this->attributes));
|
||||
foreach($this->attributes as $attribute){
|
||||
$this->putString($attribute->getName());
|
||||
$this->putLFloat($attribute->getMinValue());
|
||||
$this->putLFloat($attribute->getValue());
|
||||
$this->putLFloat($attribute->getMaxValue());
|
||||
}
|
||||
|
||||
$this->putEntityMetadata($this->metadata);
|
||||
$this->putUnsignedVarInt(count($this->links));
|
||||
foreach($this->links as $link){
|
||||
|
Reference in New Issue
Block a user