Ejemplo n.º 1
0
 /**
  * Get Nether Wart at the given stage of growth.
  *
  * @param int $note Note the block should play (0-15)
  *
  * @throws \Exception
  */
 public function __construct($note)
 {
     $this->setBlockIDAndDataFor(Ref::NOTE_BLOCK);
     $this->checkValue($note, 0, 15, 'Invalid note for note block');
     $this->initEntityData('Music');
     $this->entityData->addChild(\Nbt\Tag::tagByte('note', $note));
 }
 /**
  * Add a command block.
  *
  * @param string         $command      Command that the block will run
  * @param int            $trackOutput  [optional] Either CommandBlock::TRACK_OUTPUT or CommandBlock::NO_TRACK_OUTPUT
  * @param \Nbt\Node|null $commandStats [optional] Command stats compound tag, if required.
  * @param string|null    $customName   [optional]
  * @param string|null    $lock         [optional]
  *
  * @throws \Exception
  */
 public function __construct($command, $trackOutput = self::TRACK_OUTPUT, $commandStats = null, $customName = null, $lock = null)
 {
     $this->setBlockIDAndDataFor(Ref::COMMAND_BLOCK);
     $this->initEntityData('Control');
     $this->entityData->addChild(\Nbt\Tag::tagString('Command', $command));
     $this->entityData->addChild(\Nbt\Tag::tagByte('TrackOutput', $trackOutput));
     $this->setCustomName($customName);
     $this->setLock($lock);
     if ($commandStats !== null) {
         $this->entityData->addChild($commandStats);
     }
 }
Ejemplo n.º 3
0
 /**
  * Check the orientation of the mob head based on the placement.
  *
  * @param int $placement
  * @param int $orientation
  */
 protected function checkOrientation($placement, $orientation)
 {
     $rotValue = 0;
     switch ($placement) {
         case self::PLACE_WALL:
             $this->checkWallOrientation($orientation);
             break;
         case self::PLACE_FLOOR:
             $this->setBlockData(1);
             $rotValue = $orientation;
             break;
     }
     $this->entityData->addChild(\Nbt\Tag::tagByte('Rot', $rotValue));
 }
Ejemplo n.º 4
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;
 }
Ejemplo n.º 5
0
 public function providerTestTagCompound()
 {
     return [['CompoundTag', [\Nbt\Tag::tagByte('b1', 0x1), \Nbt\Tag::tagString('s2', 'astring')]]];
 }
Ejemplo n.º 6
0
 /**
  * Get multiple copies of this stack for certain slots.
  *
  * @param int[] $slots
  *
  * @return \MME\Stack[]
  */
 public function getForSlots($slots)
 {
     $stackList = [];
     foreach ($slots as $slot) {
         $x = clone $this;
         $x->node->addChild(\Nbt\Tag::tagByte('Slot', $slot));
         $stackList[] = $x;
         unset($x);
     }
     return $stackList;
 }