mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-16 16:34:05 +00:00
Added getShape() and setShape() APIs to StraightOnlyRail and Rail
This commit is contained in:
parent
e97234d420
commit
5c609cc1c1
@ -26,6 +26,8 @@ namespace pocketmine\block;
|
|||||||
use pocketmine\block\utils\InvalidBlockStateException;
|
use pocketmine\block\utils\InvalidBlockStateException;
|
||||||
use pocketmine\block\utils\RailConnectionInfo;
|
use pocketmine\block\utils\RailConnectionInfo;
|
||||||
use pocketmine\math\Facing;
|
use pocketmine\math\Facing;
|
||||||
|
use function array_keys;
|
||||||
|
use function implode;
|
||||||
|
|
||||||
class Rail extends BaseRail{
|
class Rail extends BaseRail{
|
||||||
|
|
||||||
@ -77,4 +79,15 @@ class Rail extends BaseRail{
|
|||||||
|
|
||||||
return $possible;
|
return $possible;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getShape() : int{ return $this->railShape; }
|
||||||
|
|
||||||
|
/** @return $this */
|
||||||
|
public function setShape(int $shape) : self{
|
||||||
|
if(!isset(RailConnectionInfo::CONNECTIONS[$shape]) && !isset(RailConnectionInfo::CURVE_CONNECTIONS[$shape])){
|
||||||
|
throw new \InvalidArgumentException("Invalid shape, must be one of " . implode(", ", [...array_keys(RailConnectionInfo::CONNECTIONS), ...array_keys(RailConnectionInfo::CURVE_CONNECTIONS)]));
|
||||||
|
}
|
||||||
|
$this->railShape = $shape;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,8 @@ namespace pocketmine\block;
|
|||||||
|
|
||||||
use pocketmine\block\utils\InvalidBlockStateException;
|
use pocketmine\block\utils\InvalidBlockStateException;
|
||||||
use pocketmine\block\utils\RailConnectionInfo;
|
use pocketmine\block\utils\RailConnectionInfo;
|
||||||
|
use function array_keys;
|
||||||
|
use function implode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple non-curvable rail.
|
* Simple non-curvable rail.
|
||||||
@ -61,4 +63,16 @@ class StraightOnlyRail extends BaseRail{
|
|||||||
protected function getCurrentShapeConnections() : array{
|
protected function getCurrentShapeConnections() : array{
|
||||||
return RailConnectionInfo::CONNECTIONS[$this->railShape];
|
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;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user