/**
  * 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);
     }
 }
 /**
  * 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);
     }
 }
 /**
  * Convert a signed value to an unsigned value.
  * The NBT spec calls for signed values, but some bytes should be unsigned,
  * so we need to fiddle them.
  *
  * @param \Nbt\Node $node
  */
 private function signedToUnsignedByteValue(\Nbt\Node $node)
 {
     $value = $node->getValue();
     if (is_array($value)) {
         array_walk($value, function (&$byte) {
             $byte = $this->signedToUnsigedByte($byte);
         });
         $node->setValue($value);
     } else {
         $node->setValue($this->signedToUnsigedByte($value));
     }
 }