Added getShape() and setShape() APIs to StraightOnlyRail and Rail

This commit is contained in:
Dylan K. Taylor
2021-07-22 18:37:30 +01:00
parent e97234d420
commit 5c609cc1c1
2 changed files with 27 additions and 0 deletions

View File

@ -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;
}
}