Standardised attributes encoding

This commit is contained in:
Dylan K. Taylor
2017-05-10 10:48:53 +01:00
parent 713f3facf9
commit c51c8ae700
3 changed files with 51 additions and 16 deletions

View File

@ -30,7 +30,6 @@ use pocketmine\network\mcpe\NetworkSession;
class UpdateAttributesPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::UPDATE_ATTRIBUTES_PACKET;
public $entityId;
/** @var Attribute[] */
public $entries = [];
@ -42,14 +41,7 @@ class UpdateAttributesPacket extends DataPacket{
public function encode(){
$this->reset();
$this->putEntityRuntimeId($this->entityId);
$this->putUnsignedVarInt(count($this->entries));
foreach($this->entries as $entry){
$this->putLFloat($entry->getMinValue());
$this->putLFloat($entry->getMaxValue());
$this->putLFloat($entry->getValue());
$this->putLFloat($entry->getDefaultValue());
$this->putString($entry->getName());
}
$this->putAttributeList(...$this->entries);
}
public function handle(NetworkSession $session) : bool{