ItemFrame: added ROTATIONS constant

This commit is contained in:
Dylan K. Taylor 2019-02-23 18:27:47 +00:00
parent 998dcb421e
commit ff35736bf9

View File

@ -32,6 +32,7 @@ use pocketmine\tile\ItemFrame as TileItemFrame;
use function lcg_value; use function lcg_value;
class ItemFrame extends Flowable{ class ItemFrame extends Flowable{
public const ROTATIONS = 8;
/** @var int */ /** @var int */
protected $facing = Facing::NORTH; protected $facing = Facing::NORTH;
@ -61,7 +62,7 @@ class ItemFrame extends Flowable{
if($this->framedItem->isNull()){ if($this->framedItem->isNull()){
$this->framedItem = null; $this->framedItem = null;
} }
$this->itemRotation = $tile->getItemRotation() % 8; $this->itemRotation = $tile->getItemRotation() % self::ROTATIONS;
$this->itemDropChance = $tile->getItemDropChance(); $this->itemDropChance = $tile->getItemDropChance();
} }
} }
@ -143,8 +144,7 @@ class ItemFrame extends Flowable{
public function onActivate(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ public function onActivate(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
if($this->framedItem !== null){ if($this->framedItem !== null){
$this->itemRotation = ($this->itemRotation + 1) % 8; $this->itemRotation = ($this->itemRotation + 1) % self::ROTATIONS;
$this->itemRotation %= 8;
}elseif(!$item->isNull()){ }elseif(!$item->isNull()){
$this->framedItem = $item->pop(); $this->framedItem = $item->pop();
}else{ }else{