コード例 #1
0
 /**
  * Add the 'tag' compount tag, if it doesn't already exist.
  */
 protected function addTag()
 {
     if (!isset($this->tag)) {
         $this->tag = \Nbt\Tag::tagCompound('tag', []);
         $this->node->addChild($this->tag);
     }
 }
コード例 #2
0
 /**
  * Create a child if it doesn't exist; don't do anything if it does.
  *
  * @param \Nbt\Node $parent
  * @param string    $childName
  * @param int       $childType
  * @param mixed     $childValue
  */
 protected function createChildOnly(\Nbt\Node $parent, $childName, $childType, $childValue)
 {
     if (!$parent->findChildByName($childName)) {
         $child = (new \Nbt\Node())->setType($childType)->setName($childName)->setValue($childValue);
         $parent->addChild($child);
     }
 }