Added glowing item frames

This commit is contained in:
Dylan K. Taylor
2022-07-14 16:24:20 +01:00
parent 0c7370e564
commit 323d31005f
8 changed files with 44 additions and 15 deletions

View File

@ -41,12 +41,24 @@ class ItemFrame extends Flowable{
public const ROTATIONS = 8;
protected bool $glowing = false;
protected bool $hasMap = false; //makes frame appear large if set
protected ?Item $framedItem = null;
protected int $itemRotation = 0;
protected float $itemDropChance = 1.0;
public function getRequiredTypeDataBits() : int{ return 1; }
protected function decodeType(RuntimeDataReader $r) : void{
$this->glowing = $r->readBool();
}
protected function encodeType(RuntimeDataWriter $w) : void{
$w->writeBool($this->glowing);
}
public function getRequiredStateDataBits() : int{ return 4; }
protected function decodeState(RuntimeDataReader $r) : void{
@ -133,6 +145,14 @@ class ItemFrame extends Flowable{
return $this;
}
public function isGlowing() : bool{ return $this->glowing; }
/** @return $this */
public function setGlowing(bool $glowing) : self{
$this->glowing = $glowing;
return $this;
}
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
if($this->framedItem !== null){
$this->itemRotation = ($this->itemRotation + 1) % self::ROTATIONS;