/**
  * Get a repeater, with the given orientation and delay ticks.
  *
  * @param int $blockRef Which repeater (on/off)
  * @param int $facing   One of the FACING_ class constants
  * @param int $delay    One of the DELAY_ class constants
  *
  * @throws \Exception
  */
 public function __construct($blockRef, $facing, $delay)
 {
     $this->checkBlock($blockRef, Ref::getStartsWith('REDSTONE_REPEATER_'));
     $this->checkDataRefValidStartsWith($facing, 'FACING_', 'Invalid facing setting for redstone repeater');
     $this->checkDataRefValidStartsWith($delay, 'DELAY_', 'Invalid delay setting for redstone repeater');
     $this->setBlockData($facing | $delay);
 }
 /**
  * Get a 'redstone rail' (powered, activator, detector), with the given
  * orientation and active status.
  *
  * @param int $blockRef    One of the Ref constants
  * @param int $orientation One of the ORIENT_ class constants (in StraightRail)
  * @param int $active      Either RedstoneRail::INACTIVE or RedstoneRail::ACTIVE
  *
  * @throws \Exception
  */
 public function __construct($blockRef, $orientation, $active = self::INACTIVE)
 {
     $this->checkBlock($blockRef, Ref::getStartsWith('RAIL_'));
     $this->checkDataRefValidStartsWith($orientation, 'ORIENT_', 'Invalid orientation for redstone rail');
     $this->checkInList($active, [self::INACTIVE, self::ACTIVE], 'Invalid active setting for redstone rail');
     $this->setBlockData($orientation | $active);
 }
示例#3
0
 /**
  * Get a button, in the given position.
  *
  * @param int $blockRef One of the BUTTON_ blockRefs
  * @param int $position The position of the button; one of the POSITION_ class constants
  * @param int $active   [Optional] Either Button::INACTIVE or Button::ACTIVE
  *
  * @throws \Exception
  */
 public function __construct($blockRef, $position, $active = self::INACTIVE)
 {
     $this->checkBlock($blockRef, Ref::getStartsWith('BUTTON_'));
     $this->checkDataRefValidStartsWith($position, 'ATTACH_', 'Invalid position for button');
     $this->checkInList($active, [self::INACTIVE, self::ACTIVE], 'Invalid active setting for button');
     $this->setBlockData($position | $active);
 }
示例#4
0
 /**
  * Get stairs, with the given orientation and way up.
  *
  * @param int $blockRef    Which type of stairs
  * @param int $orientation One of the ORIENT_ class constants
  * @param int $wayUp       [Optional] Either Stairs::RIGHT_WAY_UP or Stairs::UPSIDE_DOWN
  */
 public function __construct($blockRef, $orientation, $wayUp = self::RIGHT_WAY_UP)
 {
     $this->checkBlock($blockRef, Ref::getStartsWith('STAIRS_'));
     $this->checkDataRefValidStartsWith($orientation, 'ORIENT_', 'Invalid orientation for stairs');
     $this->checkInList($wayUp, [self::RIGHT_WAY_UP, self::UPSIDE_DOWN], 'Invalid way up for stairs');
     $this->setBlockData($orientation | $wayUp);
 }
示例#5
0
 /**
  * Get a slab, positioned either top or bottom of the block.
  *
  * @param int $blockRef Block reference from Block\Ref
  * @param int $position Position of slab; one of the class constants
  *
  * @throws \Exception
  */
 public function __construct($blockRef, $position)
 {
     $block = $this->checkBlock($blockRef, Ref::getStartsWith('SLAB_'));
     // Check the orientation is valid
     $this->checkDataRefValidAll($position, 'Invalid position for slab');
     $this->setBlockData($block[1] | $position);
 }
 /**
  * Get a trap door, with the given hinge side, top/bottom, and state.
  *
  * @param type $blockRef Which trap door
  * @param type $hinge    One of the HINGE_ class constants
  * @param type $half     One of the ON_ class constants
  * @param type $state    One of the DOOR_ class constants
  *
  * @throws \Exception
  */
 public function __construct($blockRef, $hinge, $half, $state = self::STATE_CLOSED)
 {
     $this->checkBlock($blockRef, Ref::getStartsWith('TRAPDOOR_'));
     $this->checkDataRefValidStartsWith($hinge, 'HINGE_', 'Invalid hinge setting for trapdoor');
     $this->checkDataRefValidStartsWith($half, 'ON_', 'Invalid top/bottom setting for trapdoor');
     $this->checkDataRefValidStartsWith($state, 'STATE_', 'Invalid state for trapdoor');
     $this->setBlockData($hinge | $half | $state);
 }
 /**
  * Get a furnace facing in the given direction.
  *
  * @param int             $blockRef      Which furnace to use
  * @param int             $facing        The direction it faces; one of the class constants
  * @param \MME\Stack|null $input         Data for the stack in the input slot
  * @param \MME\Stack|null $fuel          Data for the stack in the fuel slot
  * @param \MME\Stack|null $output        Data for the stack in the output slot
  * @param int             $burnTime      Time left for fuel to burn
  * @param int             $cookTime      Time left for item to finish cooking
  * @param int             $cookTimeTotal Total time for item to cook
  *
  * @throws \Exception
  */
 public function __construct($blockRef, $facing, $input = null, $fuel = null, $output = null, $burnTime = 0, $cookTime = 0, $cookTimeTotal = 0)
 {
     $this->checkBlock($blockRef, Ref::getStartsWith('FURNACE'));
     $this->checkDataRefValidAll($facing, 'Invalid facing reference for furnace');
     $this->setBlockData($facing);
     $this->initEntityData('Furnace');
     $this->addItemsForSlots([0 => $input, 1 => $fuel, 2 => $output]);
     $this->entityData->addChild(\Nbt\Tag::tagShort('BurnTime', $burnTime));
     $this->entityData->addChild(\Nbt\Tag::tagShort('CookTime', $cookTime));
     $this->entityData->addChild(\Nbt\Tag::tagShort('CookTimeTotal', $cookTimeTotal));
 }
示例#8
0
 /**
  * Get a chest, facing in the given direction.
  *
  * @param int                         $blockRef   Chest block reference
  * @param int                         $direction  Direction the chest is facing; one of the class constants
  * @param \MME\Stack[] $items      Items in the chest, with pre-set slots (0-26).
  *                                                0 is the top-left corner.
  * @param string                      $customName Custom name for the chest, appears in GUI
  * @param string                      $lock       Lock the chest so it can only be opened if the player
  *                                                is holding an item whose name matches this string
  *
  * @throws \Exception
  */
 public function __construct($blockRef, $direction, $items = [], $customName = null, $lock = null)
 {
     $this->checkBlock($blockRef, Ref::getStartsWith('CHEST'));
     $this->checkDataRefValidAll($direction, 'Invalid direction for chest');
     $this->setBlockData($direction);
     if ($blockRef == Ref::CHEST_ENDER) {
         $this->initEntityData('EnderChest');
         // No more data for Ender Chests.
     } else {
         $this->initEntityData('Chest');
         $this->addItemStacks($items);
         $this->setCustomName($customName);
         $this->setLock($lock);
     }
 }
示例#9
0
 /**
  * Get half of a door. Certain settings are used on certain halves, but we
  * ask for them all anyway. Saves two separate functions.
  *
  * @param int $blockRef BlockRef for the type of door
  * @param int $half     Which half of the door; one of the HALF_ class consts
  * @param int $hinge    Which side the door is hinged on; one of the HINGE_ class constants
  * @param int $state    Whether the door is open or closed; one of the STATE_ class constants
  * @param int $facing   Which direction the door faces when closed; one of the FACING_ class constants
  * @param int $power    Whether the door is powered or not; one of the POWER_ class constants
  *
  * @throws \Exception
  */
 public function __construct($blockRef, $half, $hinge, $state, $facing, $power)
 {
     $this->checkBlock($blockRef, Ref::getStartsWith('DOOR_'));
     $this->checkDataRefValidStartsWith($half, 'HALF_', 'Invalid half for door');
     $this->checkDataRefValidStartsWith($hinge, 'HINGE_', 'Invalid hinge for door');
     $this->checkDataRefValidStartsWith($state, 'STATE_', 'Invalid state for door');
     $this->checkDataRefValidStartsWith($facing, 'FACING_', 'Invalid facing for door');
     $this->checkDataRefValidStartsWith($power, 'POWER_', 'Invalid power for door');
     switch ($half) {
         case self::HALF_BOTTOM:
             $this->setBlockData($half | $facing | $state);
             break;
         case self::HALF_TOP:
             $this->setBlockData($half | $hinge | $power);
             break;
     }
 }
示例#10
0
 /**
  * Get a stem with the given growth setting (7 = ready to spawn item).
  *
  * @param int $blockRef Which stem to place
  * @param int $growth   Growth level, 0-7
  *
  * @throws \Exception
  */
 public function __construct($blockRef, $growth)
 {
     $this->checkBlock($blockRef, Ref::getStartsWith('STEM_'));
     $this->checkValue($growth, 0, 7, 'Invalid growth for stem');
 }
 /**
  * Get a double slab block. Optionally set the block to use the top texture
  * on all sides.
  *
  * @param int  $blockRef   Block reference from Block\Ref
  * @param bool $topTexture [Optional] Use the top texture on all sides?
  *                         One of the TEXTURE_ class constants
  *
  * @throws \Exception
  */
 public function __construct($blockRef, $topTexture = self::TEXTURE_NORMAL)
 {
     $block = $this->checkBlock($blockRef, Ref::getStartsWith('DOUBLE_SLAB'));
     $this->checkDataRefValidStartsWith($topTexture, 'TEXTURE_', 'Invalid texture setting for double slab');
     $this->setBlockData($block[1] | $topTexture);
 }
 /**
  * Get the given pressure plate, active or not.
  *
  * @param int $blockRef The appropriate PRESSURE_PLATE_ reference
  * @param int $active   One of the class constants
  *
  * @throws \Exception
  */
 public function __construct($blockRef, $active = self::INACTIVE)
 {
     $this->checkBlock($blockRef, Ref::getStartsWith('PRESSURE_PLATE_'));
     $this->checkDataRefValidAll($active, 'Invalid active setting for pressure plate');
     $this->setBlockData($active);
 }
示例#13
0
 /**
  * Get a mushroom block of the given type with the given texture layout.
  *
  * @param int $blockRef One of the MUSHROOM_BLOCKs
  * @param int $texture  One of the class constants
  */
 public function __construct($blockRef, $texture)
 {
     $this->checkBlock($blockRef, Ref::getStartsWith('MUSHROOM_BLOCK_'));
     $this->checkDataRefValidAll($texture, 'Invalid texture setting for mushroom block');
     $this->setBlockData($texture);
 }
 /**
  * Get a daylight sensor (regular or inverted) with the given power.
  *
  * @param int $blockRef The Daylight sensor type
  * @param int $power    Power level (0-15)
  *
  * @throws \Exception
  */
 public function __construct($blockRef, $power)
 {
     $this->checkBlock($blockRef, Ref::getStartsWith('DAYLIGHT_SENSOR'));
     $this->checkValue($power, 0, 15, 'Invalid power for Daylight Sensor');
     $this->initEntityData('DLDetector');
 }