PocketMine-MP 5.33.2 git-09cc76ae2b49f1fe3ab0253e6e987fb82bd0a08f
Loading...
Searching...
No Matches
item/HangingSign.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\item;
25
31
32final class HangingSign extends Item{
33
34 public function __construct(
35 ItemIdentifier $identifier,
36 string $name,
37 private Block $centerPointCeilingVariant,
38 private Block $edgePointCeilingVariant,
39 private Block $wallVariant
40 ){
41 parent::__construct($identifier, $name);
42 }
43
44 public function getPlacementTransaction(Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : ?BlockTransaction{
45 if($face !== Facing::DOWN){
46 return $this->tryPlacementTransaction(clone $this->wallVariant, $blockReplace, $blockClicked, $face, $clickVector, $player);
47 }
48 //ceiling edges sign has stricter placement conditions than ceiling center sign, so try that first
49 $ceilingEdgeTx = $player === null || !$player->isSneaking() ?
50 $this->tryPlacementTransaction(clone $this->edgePointCeilingVariant, $blockReplace, $blockClicked, $face, $clickVector, $player) :
51 null;
52 return $ceilingEdgeTx ?? $this->tryPlacementTransaction(clone $this->centerPointCeilingVariant, $blockReplace, $blockClicked, $face, $clickVector, $player);
53 }
54
55 public function getBlock(?int $clickedFace = null) : Block{
56 //we don't have enough information here to decide which ceiling type to use
57 return $clickedFace === Facing::DOWN ? clone $this->centerPointCeilingVariant : clone $this->wallVariant;
58 }
59
60 public function getMaxStackSize() : int{
61 return 16;
62 }
63
64 public function getFuelTime() : int{
65 return 200;
66 }
67}
getBlock(?int $clickedFace=null)