/**
  * 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);
 }
Ejemplo n.º 2
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 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);
 }
Ejemplo n.º 4
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);
 }
Ejemplo n.º 5
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);
 }
Ejemplo n.º 6
0
 /**
  * Get the given fence gate, with the given direction and state.
  *
  * @param int $blockRef BlockRef for the fence gate
  * @param int $facing   Direction the gate is facing; one of the FACING_ class constants
  * @param int $open     Either FenceGate::CLOSED or FenceGate::OPEN
  *
  * @throws \Exception
  */
 public function __construct($blockRef, $facing, $open)
 {
     $this->checkBlock($blockRef, Ref::getRegexp('/^FENCE_GATE_/'));
     $this->checkDataRefValidStartsWith($facing, 'FACING_', 'Invalid facing for fence gate');
     $this->checkInList($open, [self::CLOSED, self::OPEN], 'Invalid open for fence gate');
     $this->setBlockData($facing | $open);
 }
Ejemplo n.º 7
0
 private function find_by_name($ref_type, $ref_name)
 {
     $data = array();
     if (!empty($ref_name)) {
         $data = RKUtils::model_to_array(Ref::where_ref_type($ref_type)->where('ref_name', 'like', $ref_name . '%')->get(array('ref_name')), 'ref_name');
     }
     return $data;
 }
Ejemplo n.º 8
0
 /**
  * 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);
 }
Ejemplo n.º 9
0
 /**
  * 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));
 }
Ejemplo n.º 10
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);
     }
 }
Ejemplo n.º 11
0
 static function import($export_filename, $owner = NULL)
 {
     $rep = @user_config($export_filename . '.0');
     if (!$rep) {
         return NULL;
     }
     $rep = $rep[0];
     $obj = unserialize($rep);
     if ($owner) {
         $obj->__owner = ref($owner);
     }
     $obj->is_imported = TRUE;
     Ref::resolve_back_references();
     return ref($obj);
 }
Ejemplo n.º 12
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;
     }
 }
Ejemplo n.º 13
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);
     }
 }
 /**
  * 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);
 }
Ejemplo n.º 15
0
{
}
class B
{
    public function __construct(\stdClass $abc, $xyz = 123)
    {
        echo $xyz;
    }
}
class C
{
    public function __construct(\Jelly $abc1, $xyz1 = 123456)
    {
        echo $xyz1;
        var_dump($abc1);
    }
}
$obj = new Ref();
try {
    //$jelly = $obj->build('Jelly', array(1111, 222));
} catch (Exception $e) {
    echo $e->getMessage();
}
//$obj->build('Jelly');exit;
try {
    //$jelly = $obj->build('B', array(new stdClass));
    $jelly = $obj->build('C', array($obj->build('Jelly')));
    //$jelly = $obj->build('C');
} catch (Exception $e) {
    echo $e->getMessage();
}
Ejemplo n.º 16
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));
 }
 /**
  * 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));
 }
Ejemplo n.º 18
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');
 }
Ejemplo n.º 19
0
 public function get_auto_type_name()
 {
     return Ref::ref_name_by_id($this->auto_type);
 }
Ejemplo n.º 20
0
            }
            // add file pointer to array
            if (strstr($fp, '.xml') && $fp != 'blank.xml') {
                $files[$lang][] = $fp;
            }
        }
    } else {
        echo 'Could not open directory ' . $lang;
    }
}
echo 'parsing xml files<br/>';
$names = array();
// create Ref objects for each file
foreach ($files as $lang => $array) {
    foreach ($array as $file) {
        $ref = new Ref(CONTENTDIR . "api_{$lang}/" . $file);
        $names[$ref->name] = $ref->name();
    }
}
echo '<table>';
foreach ($names as $name => $file) {
    echo '<tr>';
    echo "<td width=\"200\">{$name}</td>";
    echo "<td>{$file}</td>";
    echo "<td>" . convertToFilename($name, $lang == 'zh') . "</td>";
    echo '</tr>';
}
echo '</table>';
/*
echo '<table>';
foreach ($names as $name) {
Ejemplo n.º 21
0
 public static function ref_name_by_id($for_id)
 {
     $ref = Ref::where_ref_id($for_id)->first(array('ref_name'));
     return $ref->ref_name;
 }
Ejemplo n.º 22
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);
 }
 /**
  * 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');
 }
Ejemplo n.º 24
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);
 }
Ejemplo n.º 25
0
 public function source($name)
 {
     $recs = Ref::by_model_name($name);
     $this->data['source'] = $recs;
     return $this;
 }
Ejemplo n.º 26
0
 /**
  * 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);
 }