PocketMine-MP
5.23.3 git-f7687af337d001ddbcc47b8e773f014a33faa662
Loading...
Searching...
No Matches
Note.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\tile\Note
as TileNote;
27
use
function
assert;
28
29
class
Note
extends
Opaque
{
30
public
const
MIN_PITCH = 0;
31
public
const
MAX_PITCH = 24;
32
33
private
int
$pitch = self::MIN_PITCH;
34
35
public
function
readStateFromWorld
() :
Block
{
36
parent::
readStateFromWorld
();
37
$tile = $this->position->getWorld()->getTile($this->position);
38
if
($tile instanceof TileNote){
39
$this->pitch = $tile->getPitch();
40
}
else
{
41
$this->pitch = self::MIN_PITCH;
42
}
43
44
return
$this;
45
}
46
47
public
function
writeStateToWorld
() : void{
48
parent::writeStateToWorld();
49
$tile = $this->position->getWorld()->getTile($this->position);
50
assert($tile instanceof TileNote);
51
$tile->setPitch($this->pitch);
52
}
53
54
public
function
getFuelTime
() : int{
55
return 300;
56
}
57
58
public
function
getPitch() : int{
59
return $this->pitch;
60
}
61
63
public
function
setPitch
(
int
$pitch) : self{
64
if($pitch < self::MIN_PITCH || $pitch > self::MAX_PITCH){
65
throw
new \InvalidArgumentException(
"Pitch must be in range "
. self::MIN_PITCH .
" - "
. self::MAX_PITCH);
66
}
67
$this->pitch = $pitch;
68
return
$this;
69
}
70
71
//TODO
72
}
pocketmine\block\Block
Definition
Block.php:62
pocketmine\block\Note
Definition
Note.php:29
pocketmine\block\Note\readStateFromWorld
readStateFromWorld()
Definition
Note.php:35
pocketmine\block\Note\getFuelTime
getFuelTime()
Definition
Note.php:54
pocketmine\block\Note\writeStateToWorld
writeStateToWorld()
Definition
Note.php:47
pocketmine\block\Note\setPitch
setPitch(int $pitch)
Definition
Note.php:63
pocketmine\block\Opaque
Definition
Opaque.php:30
pocketmine\block\tile\Note
Definition
tile/Note.php:32
pocketmine\block
Definition
ActivatorRail.php:24
src
block
Note.php
Generated by
1.12.0