Ejemplo n.º 1
0
 /**
  * Get a simple block - one with no fancy settings.
  *
  * @param int $blockRef Block reference - one of the BlockRef class constants.
  *
  * @throws \Exception
  */
 public function __construct($blockRef)
 {
     // The 3rd value in the array shows if it's a simple block or not.
     // Here, we're only dealing with simple blocks.
     $block = IDs::$list[$blockRef];
     if (!isset($block[2])) {
         $this->setBlockID($block[0]);
         $this->setBlockData($block[1]);
         $this->setBlockRef($blockRef);
     } else {
         $blockName = Ref::getNameFor($blockRef);
         if ($blockName !== false) {
             $exceptionMessage = 'Cannot declare block ' . $blockName . ' in Simple; use ' . $block[2] . ' instead';
         } else {
             $exceptionMessage = 'Unknown block reference';
         }
         throw new \Exception($exceptionMessage, E_ERROR);
     }
 }
Ejemplo n.º 2
0
 /**
  * Get a crop (wheat, carrots, potatoes) at the given growth.
  *
  * @param int $blockRef Block reference for the required crop
  * @param int $growth   Growth level, 0-7
  */
 public function __construct($blockRef, $growth)
 {
     $this->checkBlock($blockRef, [Ref::WHEAT, Ref::CARROTS, Ref::POTATOES]);
     $this->checkValue($growth, 0, 7, 'Invalid growth for crop ' . Ref::getNameFor($blockRef));
 }
Ejemplo n.º 3
0
 /**
  * Get a colored block.
  *
  * @param int $blockRef One of the blocks that can be different colors
  * @param int $color    One of the class constants
  *
  * @throws \Exception
  */
 public function __construct($blockRef, $color)
 {
     $block = $this->checkBlock($blockRef, [Ref::WOOL, Ref::CARPET, Ref::CLAY_STAINED, Ref::GLASS_STAINED, Ref::GLASS_PANE_STAINED]);
     $this->checkDataRefValidAll($color, 'Invalid color for ' . Ref::getNameFor($blockRef));
     $this->setBlockData($color);
 }
 /**
  * Flowing water or lava. Set the level - 0 is the highest, to 7 the lowest.
  * If level is 8, then it's a full block that is falling and only spreads downwards.
  *
  * @param int $blockRef Block reference
  * @param int $level    Level of liquid
  *
  * @throws \Exception
  */
 public function __construct($blockRef, $level)
 {
     $this->checkBlock($blockRef, [Ref::LAVA_FLOWING, Ref::WATER_FLOWING]);
     $this->checkValue($level, 0, 15, 'Invalid level for ' . Ref::getNameFor($blockRef));
 }