mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-15 18:29:46 +00:00
AddEntityPacket's attributes encoding is still non-standard -_-
I thought they fixed this...
This commit is contained in:
parent
789df942b6
commit
4341fb8347
@ -64,6 +64,7 @@ class Attribute{
|
||||
self::addAttribute(self::EXPERIENCE_LEVEL, "minecraft:player.level", 0.00, 24791.00, 0.00);
|
||||
self::addAttribute(self::EXPERIENCE, "minecraft:player.experience", 0.00, 1.00, 0.00);
|
||||
//TODO: minecraft:luck (for fishing?)
|
||||
//TODO: minecraft:fall_damage
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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){
|
||||
|
Loading…
x
Reference in New Issue
Block a user