PocketMine-MP
5.33.2 git-1133d49c924b4358c79d44eeb97dcbf56cb4d1eb
Loading...
Searching...
No Matches
BlockStateWriter.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\data\bedrock\block\convert;
25
26
use
pocketmine\data\bedrock\block\BlockStateData
;
27
use
pocketmine\nbt\tag\ByteTag
;
28
use
pocketmine\nbt\tag\IntTag
;
29
use
pocketmine\nbt\tag\StringTag
;
30
use
pocketmine\nbt\tag\Tag
;
31
32
final
class
BlockStateWriter
{
33
38
private
array $states = [];
39
40
public
function
__construct(
41
private
string
$id
42
){}
43
44
public
static
function
create(
string
$id) :
self
{
45
return
new
self
($id);
46
}
47
49
public
function
writeBool
(
string
$name,
bool
$value) : self{
50
$this->states[$name] = new
ByteTag
($value ? 1 : 0);
51
return
$this;
52
}
53
55
public
function
writeInt
(
string
$name,
int
$value) : self{
56
$this->states[$name] = new
IntTag
($value);
57
return
$this;
58
}
59
61
public
function
writeString
(
string
$name,
string
$value) : self{
62
$this->states[$name] = new
StringTag
($value);
63
return
$this;
64
}
65
66
public
function
getBlockStateData() :
BlockStateData
{
67
return
BlockStateData
::current($this->id, $this->states);
68
}
69
}
pocketmine\data\bedrock\block\BlockStateData
Definition
BlockStateData.php:39
pocketmine\data\bedrock\block\convert\BlockStateWriter
Definition
BlockStateWriter.php:32
pocketmine\data\bedrock\block\convert\BlockStateWriter\writeString
writeString(string $name, string $value)
Definition
BlockStateWriter.php:61
pocketmine\data\bedrock\block\convert\BlockStateWriter\writeBool
writeBool(string $name, bool $value)
Definition
BlockStateWriter.php:49
pocketmine\data\bedrock\block\convert\BlockStateWriter\writeInt
writeInt(string $name, int $value)
Definition
BlockStateWriter.php:55
pocketmine\nbt\tag\ByteTag
Definition
ByteTag.php:30
pocketmine\nbt\tag\IntTag
Definition
IntTag.php:30
pocketmine\nbt\tag\StringTag
Definition
StringTag.php:33
pocketmine\nbt\tag\Tag
Definition
Tag.php:28
src
data
bedrock
block
convert
BlockStateWriter.php
Generated by
1.12.0