Ejemplo n.º 1
0
 /**
  * A flower pot, optionally containing a flower
  *
  * @param \MME\Block $contains The flower the block contains
  */
 public function __construct($contains = null)
 {
     // This is going to define the plant in the tile entity data
     // - which is to be done...
     $this->setBlockIDAndDataFor(Ref::FLOWER_POT);
     $this->initEntityData('FlowerPot');
     $this->entityData->addChild(\Nbt\Tag::tagString('Item', $contains ? Names::$list[$contains->ref] : ''));
     $this->entityData->addChild(\Nbt\Tag::tagInt('Data', $contains ? $contains->data : 0));
 }
 /**
  * Get a comparator with the given settings.
  *
  * @param int $facing  Direction the comparator is facing; one of the FACING_ class constants
  * @param int $mode    Which mode the comparator is in; one of the MODE_ class constants
  * @param int $powered Either RedstoneComparator::UNPOWERED or RedstoneComparator::POWERED#
  * @param int $outputSignal Strength of output signal
  *
  * @throws \Exception
  */
 public function __construct($facing, $mode, $powered = self::UNPOWERED, $outputSignal = 0)
 {
     $this->setBlockIDFor(Ref::REDSTONE_COMPARATOR);
     $this->checkDataRefValidStartsWith($facing, 'FACING_', 'Invalid facing status for comparator');
     $this->checkDataRefValidStartsWith($mode, 'MODE_', 'Invalid mode for comparator');
     $this->checkInList($powered, [self::UNPOWERED, self::POWERED], 'Invalid powered setting for comparator');
     $this->setBlockData($facing | $mode | $powered);
     $this->initEntityData('Comparator');
     $this->checkValue($outputSignal, 0, 15, 'Invalid Output Signal Stregth for comparator');
     $this->entityData->addChild(\Nbt\Tag::tagInt('OutputSignal', $outputSignal));
 }
Ejemplo n.º 3
0
 /**
  * Get a hopper, with the output in the given direction.
  *
  * @param int                         $output           Output direction; one of the OUTPUT_ class constants
  * @param \MME\Stack[] $items            Items in the dropper, with pre-set slots (0-8).
  *                                                      0 is the top-left corner.
  * @param int                         $active           [Optional] Either Hopper:INACTIVE or Hopper::ACTIVE
  * @param string                      $customName       Custom name for the chest, appears in GUI
  * @param string                      $lock             Lock the dropper so it can only be opened if the player
  *                                                      is holding an item whose name matches this string
  * @param int                         $transferCooldown Time to next transfer in game ticks.
  *
  * @throws \Exception
  */
 public function __construct($output, $items = [], $active = self::ACTIVE, $customName = null, $lock = null, $transferCooldown = 0)
 {
     $this->setBlockIDFor(Ref::HOPPER);
     $this->checkDataRefValidStartsWith($output, 'OUTPUT_', 'Invalid output reference for hopper');
     $this->checkInList($active, [self::ACTIVE, self::DISABLED], 'Invalid active reference for hopper');
     $this->setBlockData($output | $active);
     $this->initEntityData('Hopper');
     $this->addItemStacks($items);
     $this->setCustomName($customName);
     $this->setLock($lock);
     $this->entityData->addChild(\Nbt\Tag::tagInt('TransferCooldown', $transferCooldown));
 }
Ejemplo n.º 4
0
 /**
  * Set the patterns for the banner.
  *
  * @param array $patterns
  */
 protected function bannerPatterns($patterns)
 {
     if (count($patterns)) {
         // Set up the pattern list
         $patternList = \Nbt\Tag::tagList('Patterns', \Nbt\Tag::TAG_COMPOUND, []);
         $this->entityData->addChild($patternList);
         foreach ($patterns as $pattern) {
             // Check the pattern details are valid
             $this->checkDataRefValidStartsWith($pattern['color'], 'COLOR_', 'Invalid base color for banner pattern');
             $this->checkDataRefValidStartsWith($pattern['pattern'], 'PATTERN_', 'Invalid pattern reference for banner pattern');
             // Add the pattern to the list
             $patternList->addChild(\Nbt\Tag::tagCompound('', [\Nbt\Tag::tagInt('Color', $this->bannerConvertColor($pattern['color'])), \Nbt\Tag::tagString('Pattern', $pattern['pattern'])]));
         }
     }
 }
Ejemplo n.º 5
0
 /**
  * Set options in the display properties compound tag.
  *
  * @param string $name  Name of the item
  * @param string $lore  List of strings to display as lore for the item
  * @param int    $color Color, for leather armour.
  */
 public function setDisplayProperties($name, $lore = '', $color = null)
 {
     $this->addTag();
     $display = \Nbt\Tag::tagCompound('display', []);
     if ($name) {
         $display->addChild(\Nbt\Tag::tagString('Name', $name));
     }
     if ($lore) {
         $loreTag = \Nbt\Tag::tagList('Lore', \Nbt\Tag::TAG_STRING, []);
         foreach ($lore as $line) {
             $loreTag->addChild(\Nbt\Tag::tagString('', $line));
         }
         $display->addChild($loreTag);
     }
     if ($color) {
         $display->addChild(\Nbt\Tag::tagInt('color', $color));
     }
     $this->tag->addChild($display);
 }
 /**
  * Get a brewing stand with the given bottles in place.
  *
  * @param \MME\Stack|null $eastItem       Data for the stack in the east bottle slot
  * @param \MME\Stack|null $southWestItem  Data for the stack in the south west bottle slot
  * @param \MME\Stack|null $northWestItem  Data for the stack in the north west bottle slot
  * @param \MME\Stack|null $ingredientItem Data for the stack in the ingredient slot
  * @param int                            $brewTime       The number of ticks the potions have been brewing for
  * @param string|null                    $customName     Custom name for the container, shows in GUI
  * @param string|null                    $lock           Lock the brewing stand so it can only be opened if the player
  *                                                       is holding an item whose name matches this string
  *
  * @throws \Exception
  */
 public function __construct($eastItem, $southWestItem, $northWestItem, $ingredientItem, $brewTime, $customName = null, $lock = null)
 {
     $this->setBlockIDFor(Ref::BREWING_STAND);
     $data = 0;
     if ($eastItem) {
         $data |= 0b1;
     }
     if ($southWestItem) {
         $data |= 0b10;
     }
     if ($northWestItem) {
         $data |= 0b100;
     }
     $this->setBlockData($data);
     // Yes, this says Cauldron, it's on purpose, it's how it's coded in the game
     $this->initEntityData('Cauldron');
     $this->entityData->addChild(\Nbt\Tag::tagInt('BrewTime', $brewTime));
     $this->setCustomName($customName);
     $this->setLock($lock);
     $this->addItemsForSlots([0 => $eastItem, 1 => $northWestItem, 2 => $southWestItem, 3 => $ingredientItem]);
 }