/**
  * 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);
     }
 }
示例#2
0
 /**
  * Prepare a section node when first accessing it.
  *
  * @param \Nbt\Node $node
  */
 private function prepareSection(\Nbt\Node $node)
 {
     // Alter the block data to be unsigned bytes
     $this->signedToUnsignedByteValue($node->findChildByName('Blocks'));
 }