Example #1
0
 public static function readFrom(Reader $file, TAG_Array $into = null)
 {
     $self = $into ?: new static();
     $type = $self->type = Dictionary::mapType($file->fread(1));
     $size = TAG_Int::readFrom($file);
     if (\tool::debug()) {
         \tool::fprint("Reading {$size} elements of type {$self->type}");
     }
     for ($i = 0; $i < $size; $i++) {
         $self[] = $type::readFrom($file);
     }
     return $self;
 }
Example #2
0
 public static function readFrom(Reader $file, TAG_Array $into = null)
 {
     \tool::fprint("Reading ... " . get_called_class() . "::" . __FUNCTION__);
     $self = $into ?: new static();
     while ($tag = $file->read()) {
         if ($tag instanceof TAG_End) {
             break;
         } else {
             $self[] = $tag;
         }
     }
     return $self;
 }
Example #3
0
 public static function readFrom(Reader $file)
 {
     \tool::fprint("Reading ... " . get_called_class());
     return (string) $file->fread(TAG_Short::readFrom($file));
 }
Example #4
0
 public static function readFrom(Reader $file)
 {
     \tool::fprint("Reading ... " . get_called_class() . "::" . __FUNCTION__);
     return Reader::convert('d', $file->fread(8));
 }
Example #5
0
#!/usr/bin/env php -f
<?php 
if (version_compare(PHP_VERSION, '7.0', '<')) {
    throw new Exception('Go upgrade, k?');
}
require_once dirname(__DIR__) . '/vendor/autoload.php';
use AnrDaemon\Minecraft\NBT;
$file = new NBT\Reader(new \SplFileObject('compress.zlib://' . __DIR__ . '/level.dat', 'rb'));
$nbt = $file->read();
unset($file);
var_dump($nbt);
$file = new NBT\Writer(new \SplFileObject(__DIR__ . '/level.flat', 'wb'));
$file->write($nbt);
unset($file);