diff --git a/src/pocketmine/block/Rail.php b/src/pocketmine/block/Rail.php index 0afbd7bb0..dd20823a0 100644 --- a/src/pocketmine/block/Rail.php +++ b/src/pocketmine/block/Rail.php @@ -23,8 +23,24 @@ declare(strict_types=1); namespace pocketmine\block; +use pocketmine\item\Item; +use pocketmine\level\Level; +use pocketmine\math\Vector3; +use pocketmine\Player; + class Rail extends Flowable{ + const STRAIGHT_NORTH_SOUTH = 0; + const STRAIGHT_EAST_WEST = 1; + const ASCENDING_EAST = 2; + const ASCENDING_WEST = 3; + const ASCENDING_NORTH = 4; + const ASCENDING_SOUTH = 5; + const CURVE_SOUTHEAST = 6; + const CURVE_SOUTHWEST = 7; + const CURVE_NORTHWEST = 8; + const CURVE_NORTHEAST = 9; + protected $id = self::RAIL; public function __construct($meta = 0){ @@ -38,4 +54,25 @@ class Rail extends Flowable{ public function getHardness(){ return 0.7; } + + public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){ + if(!$block->getSide(Vector3::SIDE_DOWN)->isTransparent()){ + return $this->getLevel()->setBlock($block, $this, true, true); + } + + return false; + } + + public function onUpdate($type){ + if($type === Level::BLOCK_UPDATE_NORMAL){ + if($this->getSide(Vector3::SIDE_DOWN)->isTransparent()){ + $this->getLevel()->useBreakOn($this); + return $type; + }else{ + //TODO: Update rail connectivity + } + } + + return false; + } }