Inheritance: extends NamedTag
コード例 #1
0
ファイル: ListTag.php プロジェクト: xxFlare/PocketMine-MP
 public function read(NBT $nbt, bool $network = false)
 {
     $this->value = [];
     $this->tagType = $nbt->getByte();
     $size = $nbt->getInt($network);
     for ($i = 0; $i < $size and !$nbt->feof(); ++$i) {
         switch ($this->tagType) {
             case NBT::TAG_Byte:
                 $tag = new ByteTag("");
                 $tag->read($nbt, $network);
                 $this->{$i} = $tag;
                 break;
             case NBT::TAG_Short:
                 $tag = new ShortTag("");
                 $tag->read($nbt, $network);
                 $this->{$i} = $tag;
                 break;
             case NBT::TAG_Int:
                 $tag = new IntTag("");
                 $tag->read($nbt, $network);
                 $this->{$i} = $tag;
                 break;
             case NBT::TAG_Long:
                 $tag = new LongTag("");
                 $tag->read($nbt, $network);
                 $this->{$i} = $tag;
                 break;
             case NBT::TAG_Float:
                 $tag = new FloatTag("");
                 $tag->read($nbt, $network);
                 $this->{$i} = $tag;
                 break;
             case NBT::TAG_Double:
                 $tag = new DoubleTag("");
                 $tag->read($nbt, $network);
                 $this->{$i} = $tag;
                 break;
             case NBT::TAG_ByteArray:
                 $tag = new ByteArrayTag("");
                 $tag->read($nbt, $network);
                 $this->{$i} = $tag;
                 break;
             case NBT::TAG_String:
                 $tag = new StringTag("");
                 $tag->read($nbt, $network);
                 $this->{$i} = $tag;
                 break;
             case NBT::TAG_List:
                 $tag = new TagEnum("");
                 $tag->read($nbt, $network);
                 $this->{$i} = $tag;
                 break;
             case NBT::TAG_Compound:
                 $tag = new CompoundTag("");
                 $tag->read($nbt, $network);
                 $this->{$i} = $tag;
                 break;
             case NBT::TAG_IntArray:
                 $tag = new IntArrayTag("");
                 $tag->read($nbt, $network);
                 $this->{$i} = $tag;
                 break;
         }
     }
 }
コード例 #2
0
ファイル: NBT.php プロジェクト: ianju/PocketMine-MP
 public function readTag()
 {
     switch ($this->getByte()) {
         case NBT::TAG_Byte:
             $tag = new ByteTag($this->getString());
             $tag->read($this);
             break;
         case NBT::TAG_Short:
             $tag = new ShortTag($this->getString());
             $tag->read($this);
             break;
         case NBT::TAG_Int:
             $tag = new IntTag($this->getString());
             $tag->read($this);
             break;
         case NBT::TAG_Long:
             $tag = new LongTag($this->getString());
             $tag->read($this);
             break;
         case NBT::TAG_Float:
             $tag = new FloatTag($this->getString());
             $tag->read($this);
             break;
         case NBT::TAG_Double:
             $tag = new DoubleTag($this->getString());
             $tag->read($this);
             break;
         case NBT::TAG_ByteArray:
             $tag = new ByteArrayTag($this->getString());
             $tag->read($this);
             break;
         case NBT::TAG_String:
             $tag = new StringTag($this->getString());
             $tag->read($this);
             break;
         case NBT::TAG_List:
             $tag = new ListTag($this->getString());
             $tag->read($this);
             break;
         case NBT::TAG_Compound:
             $tag = new CompoundTag($this->getString());
             $tag->read($this);
             break;
         case NBT::TAG_IntArray:
             $tag = new IntArrayTag($this->getString());
             $tag->read($this);
             break;
         case NBT::TAG_End:
             //No named tag
         //No named tag
         default:
             $tag = new EndTag();
             break;
     }
     return $tag;
 }
コード例 #3
0
ファイル: NBT.php プロジェクト: ClearSkyTeam/ClearSky
 public function readTag(bool $network = false)
 {
     if ($this->feof()) {
         $tagType = -1;
         //prevent crashes for empty tags
     } else {
         $tagType = $this->getByte();
     }
     switch ($tagType) {
         case NBT::TAG_Byte:
             $tag = new ByteTag($this->getString($network));
             $tag->read($this, $network);
             break;
         case NBT::TAG_Short:
             $tag = new ShortTag($this->getString($network));
             $tag->read($this, $network);
             break;
         case NBT::TAG_Int:
             $tag = new IntTag($this->getString($network));
             $tag->read($this, $network);
             break;
         case NBT::TAG_Long:
             $tag = new LongTag($this->getString($network));
             $tag->read($this, $network);
             break;
         case NBT::TAG_Float:
             $tag = new FloatTag($this->getString($network));
             $tag->read($this, $network);
             break;
         case NBT::TAG_Double:
             $tag = new DoubleTag($this->getString($network));
             $tag->read($this, $network);
             break;
         case NBT::TAG_ByteArray:
             $tag = new ByteArrayTag($this->getString($network));
             $tag->read($this, $network);
             break;
         case NBT::TAG_String:
             $tag = new StringTag($this->getString($network));
             $tag->read($this, $network);
             break;
         case NBT::TAG_List:
             $tag = new ListTag($this->getString($network));
             $tag->read($this, $network);
             break;
         case NBT::TAG_Compound:
             $tag = new CompoundTag($this->getString($network));
             $tag->read($this, $network);
             break;
         case NBT::TAG_IntArray:
             $tag = new IntArrayTag($this->getString($network));
             $tag->read($this, $network);
             break;
         case NBT::TAG_End:
             //No named tag
         //No named tag
         default:
             $tag = new EndTag();
             break;
     }
     return $tag;
 }