22declare(strict_types=1);
 
   24namespace pocketmine\block\utils;
 
   29trait SignLikeRotationTrait{
 
   31    private $rotation = 0;
 
   33    protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
 
   34        $w->boundedIntAuto(0, 15, $this->rotation);
 
   37    public function getRotation() : int{ return $this->rotation; }
 
   40    public function setRotation(
int $rotation) : self{
 
   41        if($rotation < 0 || $rotation > 15){
 
   42            throw new \InvalidArgumentException(
"Rotation must be in range 0-15");
 
   44        $this->rotation = $rotation;
 
   48    private static function getRotationFromYaw(
float $yaw) : int{
 
   49        return ((int) floor((($yaw + 180) * 16 / 360) + 0.5)) & 0xf;