PocketMine-MP
5.35.1 git-d241807752ab518f2ffc7e3b71f6a72f9cdf0c30
Loading...
Searching...
No Matches
CeilingEdgesHangingSign.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
22
declare(strict_types=1);
23
24
namespace
pocketmine\block
;
25
26
use
pocketmine\block\utils\HorizontalFacing
;
27
use pocketmine\block\utils\HorizontalFacingTrait;
28
use pocketmine\block\utils\SupportType;
29
use
pocketmine\item\Item
;
30
use
pocketmine\math\Facing
;
31
use
pocketmine\math\Vector3
;
32
use
pocketmine\player\Player
;
33
use
pocketmine\utils\AssumptionFailedError
;
34
use
pocketmine\world\BlockTransaction
;
35
36
final
class
CeilingEdgesHangingSign
extends
BaseSign
implements
HorizontalFacing
{
37
use HorizontalFacingTrait;
38
39
protected
function
getSupportingFace() :
int
{
40
return
Facing::UP;
41
}
42
43
public
function
place
(
BlockTransaction
$tx,
Item
$item,
Block
$blockReplace,
Block
$blockClicked,
int
$face,
Vector3
$clickVector, ?
Player
$player =
null
) : bool{
44
if($face !==
Facing
::DOWN){
45
return
false
;
46
}
47
if
($player !==
null
){
48
$this->facing = Facing::opposite($player->getHorizontalFacing());
49
}
50
if
(!$this->canBeSupportedAt($blockReplace)){
51
return
false
;
52
}
53
54
return
parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
55
}
56
57
public
function
onNearbyBlockChange
() : void{
58
if(!$this->canBeSupportedAt($this)){
59
$this->position->getWorld()->useBreakOn($this->position);
60
}
61
}
62
63
private
function
canBeSupportedAt(Block $block) : bool{
64
$supportBlock = $block->getSide(Facing::UP);
65
return
66
$supportBlock->getSupportType(Facing::DOWN) === SupportType::FULL ||
67
(($supportBlock instanceof WallHangingSign || $supportBlock instanceof CeilingEdgesHangingSign) && Facing::axis($supportBlock->getFacing()) === Facing::axis($this->facing));
68
}
69
70
protected
function
getFacingDegrees
() : float{
71
return match($this->facing){
72
Facing::SOUTH => 0,
73
Facing::WEST => 90,
74
Facing::NORTH => 180,
75
Facing::EAST => 270,
76
default
=>
throw
new
AssumptionFailedError
(
"Invalid facing direction: "
. $this->facing),
77
};
78
}
79
}
pocketmine\block\BaseSign
Definition
BaseSign.php:52
pocketmine\block\Block
Definition
Block.php:63
pocketmine\block\CeilingEdgesHangingSign
Definition
CeilingEdgesHangingSign.php:36
pocketmine\block\CeilingEdgesHangingSign\getFacingDegrees
getFacingDegrees()
Definition
CeilingEdgesHangingSign.php:70
pocketmine\block\CeilingEdgesHangingSign\onNearbyBlockChange
onNearbyBlockChange()
Definition
CeilingEdgesHangingSign.php:57
pocketmine\block\CeilingEdgesHangingSign\place
place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player=null)
Definition
CeilingEdgesHangingSign.php:43
pocketmine\item\Item
Definition
Item.php:61
pocketmine\math\Facing
Definition
Facing.php:28
pocketmine\math\Vector3
Definition
Vector3.php:36
pocketmine\player\Player
Definition
Player.php:173
pocketmine\utils\AssumptionFailedError
Definition
AssumptionFailedError.php:31
pocketmine\world\BlockTransaction
Definition
BlockTransaction.php:30
pocketmine\block\utils\HorizontalFacing
Definition
HorizontalFacing.php:28
pocketmine\block
Definition
ActivatorRail.php:24
src
block
CeilingEdgesHangingSign.php
Generated by
1.12.0