GenisysPro  for Minecraft PE/Windows 10 v1.1.x
Feature-rich server software for Minecraft PE and Windows 10 Edition
ListTag Class Reference

Public Member Functions

 __construct ($name="", $value=[])
 
getValue ()
 
 getCount ()
 
 offsetExists ($offset)
 
 offsetGet ($offset)
 
 offsetSet ($offset, $value)
 
 offsetUnset ($offset)
 
 count ($mode=COUNT_NORMAL)
 
 getType ()
 
 setTagType ($type)
 
 getTagType ()
 
 read (NBT $nbt, bool $network=false)
 
 __toString ()
 
- Public Member Functions inherited from NamedTag
 __construct ($name="", $value=null)
 
 getName ()
 
 setName ($name)
 
- Public Member Functions inherited from Tag
getValue ()
 
 getType ()
 
 setValue ($value)
 
 write (NBT $nbt, bool $network=false)
 
 read (NBT $nbt, bool $network=false)
 
 __toString ()
 

Additional Inherited Members

- Protected Attributes inherited from NamedTag
 $__name
 
- Protected Attributes inherited from Tag
 $value
 

Constructor & Destructor Documentation

◆ __construct()

__construct (   $name = "",
  $value = [] 
)

ListTag constructor.

Parameters
string$name
array$value
39  {
40  $this->__name = $name;
41  foreach($value as $k => $v){
42  $this->{$k} = $v;
43  }
44  }

Member Function Documentation

◆ __toString()

__toString ( )
Returns
string
272  {
273  $str = get_class($this) . "{\n";
274  foreach($this as $tag){
275  if($tag instanceof Tag){
276  $str .= get_class($tag) . ":" . $tag->__toString() . "\n";
277  }
278  }
279  return $str . "}";
280  }

◆ count()

count (   $mode = COUNT_NORMAL)
Parameters
int$mode
Returns
int
124  {
125  for($i = 0; true; $i++){
126  if(!isset($this->{$i})){
127  return $i;
128  }
129  if($mode === COUNT_RECURSIVE){
130  if($this->{$i} instanceof \Countable){
131  $i += count($this->{$i});
132  }
133  }
134  }
135 
136  return $i;
137  }

◆ getCount()

getCount ( )
Returns
int
63  {
64  $count = 0;
65  foreach($this as $tag){
66  if($tag instanceof Tag){
67  ++$count;
68  }
69  }
70 
71  return $count;
72  }

◆ getTagType()

getTagType ( )
Returns
mixed
156  {
157  return $this->tagType;
158  }

◆ getType()

getType ( )
Returns
int
142  {
143  return NBT::TAG_List;
144  }

◆ getValue()

& getValue ( )
Returns
array
49  {
50  $value = [];
51  foreach($this as $k => $v){
52  if($v instanceof Tag){
53  $value[$k] = $v;
54  }
55  }
56 
57  return $value;
58  }

◆ offsetExists()

offsetExists (   $offset)
Parameters
mixed$offset
Returns
bool
79  {
80  return isset($this->{$offset});
81  }

◆ offsetGet()

offsetGet (   $offset)
Parameters
mixed$offset
Returns
null
88  {
89  if(isset($this->{$offset}) and $this->{$offset} instanceof Tag){
90  if($this->{$offset} instanceof \ArrayAccess){
91  return $this->{$offset};
92  }else{
93  return $this->{$offset}->getValue();
94  }
95  }
96 
97  return null;
98  }

◆ offsetSet()

offsetSet (   $offset,
  $value 
)
Parameters
mixed$offset
mixed$value
104  {
105  if($value instanceof Tag){
106  $this->{$offset} = $value;
107  }elseif($this->{$offset} instanceof Tag){
108  $this->{$offset}->setValue($value);
109  }
110  }

◆ offsetUnset()

offsetUnset (   $offset)
Parameters
mixed$offset
115  {
116  unset($this->{$offset});
117  }

◆ read()

read ( NBT  $nbt,
bool  $network = false 
)
Parameters
NBT$nbt
bool$network
Returns
mixed|void
166  {
167  $this->value = [];
168  $this->tagType = $nbt->getByte();
169  $size = $nbt->getInt($network);
170  for($i = 0; $i < $size and !$nbt->feof(); ++$i){
171  switch($this->tagType){
172  case NBT::TAG_Byte:
173  $tag = new ByteTag("");
174  $tag->read($nbt, $network);
175  $this->{$i} = $tag;
176  break;
177  case NBT::TAG_Short:
178  $tag = new ShortTag("");
179  $tag->read($nbt, $network);
180  $this->{$i} = $tag;
181  break;
182  case NBT::TAG_Int:
183  $tag = new IntTag("");
184  $tag->read($nbt, $network);
185  $this->{$i} = $tag;
186  break;
187  case NBT::TAG_Long:
188  $tag = new LongTag("");
189  $tag->read($nbt, $network);
190  $this->{$i} = $tag;
191  break;
192  case NBT::TAG_Float:
193  $tag = new FloatTag("");
194  $tag->read($nbt, $network);
195  $this->{$i} = $tag;
196  break;
197  case NBT::TAG_Double:
198  $tag = new DoubleTag("");
199  $tag->read($nbt, $network);
200  $this->{$i} = $tag;
201  break;
202  case NBT::TAG_ByteArray:
203  $tag = new ByteArrayTag("");
204  $tag->read($nbt, $network);
205  $this->{$i} = $tag;
206  break;
207  case NBT::TAG_String:
208  $tag = new StringTag("");
209  $tag->read($nbt, $network);
210  $this->{$i} = $tag;
211  break;
212  case NBT::TAG_List:
213  $tag = new TagEnum("");
214  $tag->read($nbt, $network);
215  $this->{$i} = $tag;
216  break;
217  case NBT::TAG_Compound:
218  $tag = new CompoundTag("");
219  $tag->read($nbt, $network);
220  $this->{$i} = $tag;
221  break;
222  case NBT::TAG_IntArray:
223  $tag = new IntArrayTag("");
224  $tag->read($nbt, $network);
225  $this->{$i} = $tag;
226  break;
227  }
228  }
229  }

◆ setTagType()

setTagType (   $type)
Parameters
$type
149  {
150  $this->tagType = $type;
151  }

The documentation for this class was generated from the following file: