예제 #1
0
 /**
  * Get the correct section from within the Sections tag (based on Y index).
  *
  * @param int $yRef
  *
  * @return \Nbt\Node
  */
 private function getSection($yRef)
 {
     if (isset($this->sectionsList[$yRef])) {
         return $this->sectionsList[$yRef];
     }
     foreach ($this->sectionsTag->getChildren() as $childNode) {
         if ($childNode->findChildByName('Y')->getValue() == $yRef) {
             $this->prepareSection($childNode);
             $this->sectionsList[$yRef] = $childNode;
             return $childNode;
         }
     }
     // If we didn't find one, we must create one
     // Doesn't need a name, it's part of a list
     $newY = \Nbt\Tag::tagCompound('', [\Nbt\Tag::tagByte('Y', $yRef), \Nbt\Tag::tagByteArray('Blocks', array_fill(0, 4096, 0)), \Nbt\Tag::tagByteArray('Data', array_fill(0, 2048, 0)), \Nbt\Tag::tagByteArray('BlockLight', array_fill(0, 2048, 0)), \Nbt\Tag::tagByteArray('SkyLight', array_fill(0, 2048, 0))]);
     // Add it to the list
     $this->sectionsTag->addChild($newY);
     $this->sectionsList[$yRef] = $newY;
     return $newY;
 }