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

Public Member Functions

 __construct ($name="", $value=[])
 
 getCount ()
 
 offsetExists ($offset)
 
 offsetGet ($offset)
 
 offsetSet ($offset, $value)
 
 offsetUnset ($offset)
 
 getType ()
 
 read (NBT $nbt, bool $network=false)
 
 write (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 = [] 
)
Parameters
string$name
NamedTag[]$value
34  {
35  $this->__name = $name;
36  foreach($value as $tag){
37  $this->{$tag->getName()} = $tag;
38  }
39  }

Member Function Documentation

◆ __toString()

__toString ( )
Returns
string
142  {
143  $str = get_class($this) . "{\n";
144  foreach($this as $tag){
145  if($tag instanceof Tag){
146  $str .= get_class($tag) . ":" . $tag->__toString() . "\n";
147  }
148  }
149  return $str . "}";
150  }

◆ getCount()

getCount ( )
Returns
int
44  {
45  $count = 0;
46  foreach($this as $tag){
47  if($tag instanceof Tag){
48  ++$count;
49  }
50  }
51 
52  return $count;
53  }

◆ getType()

getType ( )
Returns
int
103  {
104  return NBT::TAG_Compound;
105  }

◆ offsetExists()

offsetExists (   $offset)
Parameters
mixed$offset
Returns
bool
60  {
61  return isset($this->{$offset}) and $this->{$offset} instanceof Tag;
62  }

◆ offsetGet()

offsetGet (   $offset)
Parameters
mixed$offset
Returns
null
69  {
70  if(isset($this->{$offset}) and $this->{$offset} instanceof Tag){
71  if($this->{$offset} instanceof \ArrayAccess){
72  return $this->{$offset};
73  }else{
74  return $this->{$offset}->getValue();
75  }
76  }
77 
78  return null;
79  }

◆ offsetSet()

offsetSet (   $offset,
  $value 
)
Parameters
mixed$offset
mixed$value
85  {
86  if($value instanceof Tag){
87  $this->{$offset} = $value;
88  }elseif(isset($this->{$offset}) and $this->{$offset} instanceof Tag){
89  $this->{$offset}->setValue($value);
90  }
91  }

◆ offsetUnset()

offsetUnset (   $offset)
Parameters
mixed$offset
96  {
97  unset($this->{$offset});
98  }

◆ read()

read ( NBT  $nbt,
bool  $network = false 
)
Parameters
NBT$nbt
bool$network
Returns
mixed|void
113  {
114  $this->value = [];
115  do{
116  $tag = $nbt->readTag($network);
117  if($tag instanceof NamedTag and $tag->getName() !== ""){
118  $this->{$tag->getName()} = $tag;
119  }
120  }while(!($tag instanceof EndTag) and !$nbt->feof());
121  }

◆ write()

write ( NBT  $nbt,
bool  $network = false 
)
Parameters
NBT$nbt
bool$network
Returns
mixed|void
129  {
130  foreach($this as $tag){
131  if($tag instanceof Tag and !($tag instanceof EndTag)){
132  $nbt->writeTag($tag, $network);
133  }
134  }
135 
136  $nbt->writeTag(new EndTag, $network);
137  }

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