meta = $meta; } public function getName() : string{ return "Item Frame"; } public function onActivate(Item $item, Player $player = null) : bool{ $tile = $this->level->getTile($this); if(!($tile instanceof TileItemFrame)){ $tile = Tile::createTile(Tile::ITEM_FRAME, $this->getLevel(), TileItemFrame::createNBT($this)); } if($tile->hasItem()){ $tile->setItemRotation(($tile->getItemRotation() + 1) % 8); }elseif(!$item->isNull()){ $tile->setItem($item->pop()); } return true; } public function onUpdate(int $type){ if($type === Level::BLOCK_UPDATE_NORMAL){ $sides = [ 0 => Vector3::SIDE_WEST, 1 => Vector3::SIDE_EAST, 2 => Vector3::SIDE_NORTH, 3 => Vector3::SIDE_SOUTH ]; if(!$this->getSide($sides[$this->meta])->isSolid()){ $this->level->useBreakOn($this); return Level::BLOCK_UPDATE_NORMAL; } } return false; } public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{ if($face === Vector3::SIDE_DOWN or $face === Vector3::SIDE_UP or !$blockClicked->isSolid()){ return false; } $faces = [ Vector3::SIDE_NORTH => 3, Vector3::SIDE_SOUTH => 2, Vector3::SIDE_WEST => 1, Vector3::SIDE_EAST => 0 ]; $this->meta = $faces[$face]; $this->level->setBlock($blockReplace, $this, true, true); Tile::createTile(Tile::ITEM_FRAME, $this->getLevel(), TileItemFrame::createNBT($this, $face, $item, $player)); return true; } public function getVariantBitmask() : int{ return 0; } public function getDropsForCompatibleTool(Item $item) : array{ $drops = parent::getDropsForCompatibleTool($item); $tile = $this->level->getTile($this); if($tile instanceof TileItemFrame){ $tileItem = $tile->getItem(); if(lcg_value() <= $tile->getItemDropChance() and !$tileItem->isNull()){ $drops[] = $tileItem; } } return $drops; } }