PocketMine-MP 5.35.1 git-e32e836dad793a3a3c8ddd8927c00e112b1e576a
Loading...
Searching...
No Matches
BaseOminousBanner.php
1<?php
2
3/*
4 *
5 * ____ _ _ __ __ _ __ __ ____
6 * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
7 * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
8 * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
9 * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
10 *
11 * This program is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License as published by
13 * the Free Software Foundation, either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * @author PocketMine Team
17 * @link http://www.pocketmine.net/
18 *
19 *
20 */
21
22declare(strict_types=1);
23
24namespace pocketmine\block;
25
26use pocketmine\block\tile\Banner as TileBanner;
27use pocketmine\block\utils\DyeColor;
28use pocketmine\block\utils\SupportType;
35use function assert;
36
37abstract class BaseOminousBanner extends Transparent{
38
39 public function writeStateToWorld() : void{
40 parent::writeStateToWorld();
41 $tile = $this->position->getWorld()->getTile($this->position);
42 assert($tile instanceof TileBanner);
43 $tile->setBaseColor(DyeColor::WHITE);
44 $tile->setPatterns([]);
45 $tile->setType(TileBanner::TYPE_OMINOUS);
46 }
47
48 public function isSolid() : bool{
49 return false;
50 }
51
52 public function getMaxStackSize() : int{
53 return 16;
54 }
55
56 public function getFuelTime() : int{
57 return 300;
58 }
59
60 protected function recalculateCollisionBoxes() : array{
61 return [];
62 }
63
64 public function getSupportType(Facing $facing) : SupportType{
65 return SupportType::NONE;
66 }
67
68 private function canBeSupportedBy(Block $block) : bool{
69 return $block->isSolid();
70 }
71
72 public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, Facing $face, Vector3 $clickVector, ?Player $player = null) : bool{
73 if(!$this->canBeSupportedBy($blockReplace->getSide($this->getSupportingFace()))){
74 return false;
75 }
76
77 return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
78 }
79
80 abstract protected function getSupportingFace() : Facing;
81
82 public function onNearbyBlockChange() : void{
83 if(!$this->canBeSupportedBy($this->getSide($this->getSupportingFace()))){
84 $this->position->getWorld()->useBreakOn($this->position);
85 }
86 }
87
88 public function asItem() : Item{
89 return VanillaItems::OMINOUS_BANNER();
90 }
91}
place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, Facing $face, Vector3 $clickVector, ?Player $player=null)