putLFloat() public method

public putLFloat ( $v )
Beispiel #1
0
 /**
  * Writes a coded metadata string
  *
  * @param array $data
  *
  * @return string
  */
 public static function writeMetadata(array $data)
 {
     $stream = new BinaryStream();
     $stream->putUnsignedVarInt(count($data));
     foreach ($data as $key => $d) {
         $stream->putUnsignedVarInt($key);
         //data key
         $stream->putUnsignedVarInt($d[0]);
         //data type
         switch ($d[0]) {
             case Entity::DATA_TYPE_BYTE:
                 $stream->putByte($d[1]);
                 break;
             case Entity::DATA_TYPE_SHORT:
                 $stream->putLShort($d[1]);
                 //SIGNED short!
                 break;
             case Entity::DATA_TYPE_INT:
                 $stream->putVarInt($d[1]);
                 break;
             case Entity::DATA_TYPE_FLOAT:
                 $stream->putLFloat($d[1]);
                 break;
             case Entity::DATA_TYPE_STRING:
                 $stream->putString($d[1]);
                 break;
             case Entity::DATA_TYPE_SLOT:
                 //TODO: change this implementation (use objects)
                 $stream->putSlot(Item::get($d[1][0], $d[1][2], $d[1][1]));
                 //ID, damage, count
                 break;
             case Entity::DATA_TYPE_POS:
                 //TODO: change this implementation (use objects)
                 $stream->putBlockCoords($d[1][0], $d[1][1], $d[1][2]);
                 //x, y, z
                 break;
             case Entity::DATA_TYPE_LONG:
                 $stream->putVarInt($d[1]);
                 //TODO: varint64 support
                 break;
             case Entity::DATA_TYPE_VECTOR3F:
                 //TODO: change this implementation (use objects)
                 $stream->putVector3f($d[1][0], $d[1][1], $d[1][2]);
                 //x, y, z
         }
     }
     return $stream->getBuffer();
 }