mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 02:08:21 +00:00
Added getShape() and setShape() APIs to StraightOnlyRail and Rail
This commit is contained in:
@ -25,6 +25,8 @@ namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\InvalidBlockStateException;
|
||||
use pocketmine\block\utils\RailConnectionInfo;
|
||||
use function array_keys;
|
||||
use function implode;
|
||||
|
||||
/**
|
||||
* Simple non-curvable rail.
|
||||
@ -61,4 +63,16 @@ class StraightOnlyRail extends BaseRail{
|
||||
protected function getCurrentShapeConnections() : array{
|
||||
return RailConnectionInfo::CONNECTIONS[$this->railShape];
|
||||
}
|
||||
|
||||
public function getShape() : int{ return $this->railShape; }
|
||||
|
||||
/** @return $this */
|
||||
public function setShape(int $shape) : self{
|
||||
if(!isset(RailConnectionInfo::CONNECTIONS[$shape])){
|
||||
throw new \InvalidArgumentException("Invalid rail shape, must be one of " . implode(", ", array_keys(RailConnectionInfo::CONNECTIONS)));
|
||||
}
|
||||
$this->railShape = $shape;
|
||||
return $this;
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user