mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 09:56:06 +00:00
Drop useless numeric IDs for attributes, use strings instead
This commit is contained in:
@ -236,9 +236,9 @@ class NetworkBinaryStream extends BinaryStream{
|
||||
$max = $this->getLFloat();
|
||||
$current = $this->getLFloat();
|
||||
$default = $this->getLFloat();
|
||||
$name = $this->getString();
|
||||
$id = $this->getString();
|
||||
|
||||
$attr = Attribute::getAttributeByName($name);
|
||||
$attr = Attribute::getAttribute($id);
|
||||
if($attr !== null){
|
||||
$attr->setMinValue($min);
|
||||
$attr->setMaxValue($max);
|
||||
@ -247,7 +247,7 @@ class NetworkBinaryStream extends BinaryStream{
|
||||
|
||||
$list[] = $attr;
|
||||
}else{
|
||||
throw new \UnexpectedValueException("Unknown attribute type \"$name\"");
|
||||
throw new \UnexpectedValueException("Unknown attribute type \"$id\"");
|
||||
}
|
||||
}
|
||||
|
||||
@ -266,7 +266,7 @@ class NetworkBinaryStream extends BinaryStream{
|
||||
$this->putLFloat($attribute->getMaxValue());
|
||||
$this->putLFloat($attribute->getValue());
|
||||
$this->putLFloat($attribute->getDefaultValue());
|
||||
$this->putString($attribute->getName());
|
||||
$this->putString($attribute->getId());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -69,11 +69,11 @@ class AddEntityPacket extends DataPacket{
|
||||
|
||||
$attrCount = $this->getUnsignedVarInt();
|
||||
for($i = 0; $i < $attrCount; ++$i){
|
||||
$name = $this->getString();
|
||||
$id = $this->getString();
|
||||
$min = $this->getLFloat();
|
||||
$current = $this->getLFloat();
|
||||
$max = $this->getLFloat();
|
||||
$attr = Attribute::getAttributeByName($name);
|
||||
$attr = Attribute::getAttribute($id);
|
||||
|
||||
if($attr !== null){
|
||||
$attr->setMinValue($min);
|
||||
@ -81,7 +81,7 @@ class AddEntityPacket extends DataPacket{
|
||||
$attr->setValue($current);
|
||||
$this->attributes[] = $attr;
|
||||
}else{
|
||||
throw new \UnexpectedValueException("Unknown attribute type \"$name\"");
|
||||
throw new \UnexpectedValueException("Unknown attribute type \"$id\"");
|
||||
}
|
||||
}
|
||||
|
||||
@ -104,7 +104,7 @@ class AddEntityPacket extends DataPacket{
|
||||
|
||||
$this->putUnsignedVarInt(count($this->attributes));
|
||||
foreach($this->attributes as $attribute){
|
||||
$this->putString($attribute->getName());
|
||||
$this->putString($attribute->getId());
|
||||
$this->putLFloat($attribute->getMinValue());
|
||||
$this->putLFloat($attribute->getValue());
|
||||
$this->putLFloat($attribute->getMaxValue());
|
||||
|
@ -44,7 +44,7 @@ class UpdateAttributesPacket extends DataPacket{
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->putAttributeList(...$this->entries);
|
||||
$this->putAttributeList(...array_values($this->entries));
|
||||
}
|
||||
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
|
Reference in New Issue
Block a user