예제 #1
0
 public function read(NBT $nbt)
 {
     $this->value = [];
     $this->tagType = $nbt->getByte();
     $size = $nbt->getInt();
     for ($i = 0; $i < $size and !$nbt->feof(); ++$i) {
         switch ($this->tagType) {
             case NBT::TAG_Byte:
                 $tag = new Byte("");
                 $tag->read($nbt);
                 $this->{$i} = $tag;
                 break;
             case NBT::TAG_Short:
                 $tag = new Short("");
                 $tag->read($nbt);
                 $this->{$i} = $tag;
                 break;
             case NBT::TAG_Int:
                 $tag = new Int("");
                 $tag->read($nbt);
                 $this->{$i} = $tag;
                 break;
             case NBT::TAG_Long:
                 $tag = new Long("");
                 $tag->read($nbt);
                 $this->{$i} = $tag;
                 break;
             case NBT::TAG_Float:
                 $tag = new Float("");
                 $tag->read($nbt);
                 $this->{$i} = $tag;
                 break;
             case NBT::TAG_Double:
                 $tag = new Double("");
                 $tag->read($nbt);
                 $this->{$i} = $tag;
                 break;
             case NBT::TAG_ByteArray:
                 $tag = new ByteArray("");
                 $tag->read($nbt);
                 $this->{$i} = $tag;
                 break;
             case NBT::TAG_String:
                 $tag = new String("");
                 $tag->read($nbt);
                 $this->{$i} = $tag;
                 break;
             case NBT::TAG_Enum:
                 $tag = new TagEnum("");
                 $tag->read($nbt);
                 $this->{$i} = $tag;
                 break;
             case NBT::TAG_Compound:
                 $tag = new Compound("");
                 $tag->read($nbt);
                 $this->{$i} = $tag;
                 break;
             case NBT::TAG_IntArray:
                 $tag = new IntArray("");
                 $tag->read($nbt);
                 $this->{$i} = $tag;
                 break;
         }
     }
 }
예제 #2
0
 public function read(NBT $nbt)
 {
     $this->value = [];
     $this->tagType = \ord($nbt->get(1));
     $size = $nbt->endianness === 1 ? \PHP_INT_SIZE === 8 ? \unpack("N", $nbt->get(4))[1] << 32 >> 32 : \unpack("N", $nbt->get(4))[1] : (\PHP_INT_SIZE === 8 ? \unpack("V", $nbt->get(4))[1] << 32 >> 32 : \unpack("V", $nbt->get(4))[1]);
     for ($i = 0; $i < $size and !$nbt->feof(); ++$i) {
         switch ($this->tagType) {
             case NBT::TAG_Byte:
                 $tag = new Byte("");
                 $tag->read($nbt);
                 $this->{$i} = $tag;
                 break;
             case NBT::TAG_Short:
                 $tag = new Short("");
                 $tag->read($nbt);
                 $this->{$i} = $tag;
                 break;
             case NBT::TAG_Int:
                 $tag = new Int("");
                 $tag->read($nbt);
                 $this->{$i} = $tag;
                 break;
             case NBT::TAG_Long:
                 $tag = new Long("");
                 $tag->read($nbt);
                 $this->{$i} = $tag;
                 break;
             case NBT::TAG_Float:
                 $tag = new Float("");
                 $tag->read($nbt);
                 $this->{$i} = $tag;
                 break;
             case NBT::TAG_Double:
                 $tag = new Double("");
                 $tag->read($nbt);
                 $this->{$i} = $tag;
                 break;
             case NBT::TAG_ByteArray:
                 $tag = new ByteArray("");
                 $tag->read($nbt);
                 $this->{$i} = $tag;
                 break;
             case NBT::TAG_String:
                 $tag = new String("");
                 $tag->read($nbt);
                 $this->{$i} = $tag;
                 break;
             case NBT::TAG_Enum:
                 $tag = new TagEnum("");
                 $tag->read($nbt);
                 $this->{$i} = $tag;
                 break;
             case NBT::TAG_Compound:
                 $tag = new Compound("");
                 $tag->read($nbt);
                 $this->{$i} = $tag;
                 break;
             case NBT::TAG_IntArray:
                 $tag = new IntArray("");
                 $tag->read($nbt);
                 $this->{$i} = $tag;
                 break;
         }
     }
 }
예제 #3
0
 public function readTag()
 {
     switch ($this->getByte()) {
         case NBT::TAG_Byte:
             $tag = new Byte($this->getString());
             $tag->read($this);
             break;
         case NBT::TAG_Short:
             $tag = new Short($this->getString());
             $tag->read($this);
             break;
         case NBT::TAG_Int:
             $tag = new Int($this->getString());
             $tag->read($this);
             break;
         case NBT::TAG_Long:
             $tag = new Long($this->getString());
             $tag->read($this);
             break;
         case NBT::TAG_Float:
             $tag = new Float($this->getString());
             $tag->read($this);
             break;
         case NBT::TAG_Double:
             $tag = new Double($this->getString());
             $tag->read($this);
             break;
         case NBT::TAG_ByteArray:
             $tag = new ByteArray($this->getString());
             $tag->read($this);
             break;
         case NBT::TAG_String:
             $tag = new String($this->getString());
             $tag->read($this);
             break;
         case NBT::TAG_Enum:
             $tag = new Enum($this->getString());
             $tag->read($this);
             break;
         case NBT::TAG_Compound:
             $tag = new Compound($this->getString());
             $tag->read($this);
             break;
         case NBT::TAG_IntArray:
             $tag = new IntArray($this->getString());
             $tag->read($this);
             break;
         case NBT::TAG_End:
             //No named tag
         //No named tag
         default:
             $tag = new End();
             break;
     }
     return $tag;
 }