public function decode()
 {
     $this->eid = $this->getLong();
     $this->metadata = Binary::readMetadata($this->get(true), true, $offset);
     $this->offset += $offset;
     //print_r($this);
 }
 public function decode()
 {
     $this->eid = $this->getLong();
     $this->type = $this->getInt();
     $this->x = $this->getFloat();
     $this->y = $this->getFloat();
     $this->z = $this->getFloat();
     $this->speedX = $this->getFloat();
     $this->speedY = $this->getFloat();
     $this->speedZ = $this->getFloat();
     $this->yaw = $this->getFloat();
     $this->pitch = $this->getFloat();
     $this->metadata = Binary::readMetadata($this->get(true), true, $offset);
     $this->offset += $offset;
     if (!$this->feof()) {
         $offset = strlen($this->buffer) - $this->offset;
         if ($offset === 2) {
             $this->offset += 2;
         }
         echo "Type: " . $this->type . "\n";
     }
     //$this->links = [];
     //$count = $this->getShort();
     /*for($i = 0; $i < $count; $i++){
     			$to = $this->getLong();
     			$from = $this->getLong();
     			$mode = $this->getByte();
     			$this->links[] = [$to, $from, $mode];
     		}*/
     //print_r($this);
 }
 public function decode()
 {
     parent::decode();
     $this->buffers = [];
     $size = $this->getInt();
     $this->payload = $this->get($size);
     $str = zlib_decode($this->payload, 1024 * 1024 * 64);
     //Max 64MB
     $len = strlen($str);
     $offset = 0;
     while ($offset < $len) {
         $pkLen = Binary::readInt(substr($str, $offset, 4));
         $offset += 4;
         $buf = substr($str, $offset, $pkLen);
         $offset += $pkLen;
         $this->buffers[] = $buf;
     }
     //print_r($this);
 }
 public function decode()
 {
     $this->uuid = $this->getUUID();
     $this->username = $this->getString();
     $this->eid = $this->getLong();
     $this->x = $this->getFloat();
     $this->y = $this->getFloat();
     $this->z = $this->getFloat();
     $this->speedX = $this->getFloat();
     $this->speedY = $this->getFloat();
     $this->speedZ = $this->getFloat();
     $this->yaw = $this->getFloat();
     $this->headyaw = $this->getFloat();
     $this->pitch = $this->getFloat();
     $this->item = $this->getSlot();
     $this->metadata = Binary::readMetadata($this->get(true), true, $offset);
     $this->offset += $offset;
     //Buffer解析完了のため
     //print_r($this);
 }
 /**
  * @param bool $internal
  *
  * @return string
  */
 public function toBinary($internal = false)
 {
     return chr($this->reliability << 5 | ($this->hasSplit ? 0b10000 : 0)) . ($internal ? Binary::writeInt(strlen($this->buffer)) . Binary::writeInt($this->identifierACK) : Binary::writeShort(strlen($this->buffer) << 3)) . ($this->reliability > 0 ? (($this->reliability >= 2 and $this->reliability !== 5) ? Binary::writeLTriad($this->messageIndex) : "") . (($this->reliability <= 4 and $this->reliability !== 2) ? Binary::writeLTriad($this->orderIndex) . chr($this->orderChannel) : "") : "") . ($this->hasSplit ? Binary::writeInt($this->splitCount) . Binary::writeShort($this->splitID) . Binary::writeInt($this->splitIndex) : "") . $this->buffer;
 }
Example #6
0
 public function getSignedLShort()
 {
     return Binary::readSignedLShort($this->get(2));
 }
 public function getShort($signed = true)
 {
     return $signed ? Binary::readSignedShort($this->get(2)) : Binary::readShort($this->get(2));
 }