mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-08 10:53:05 +00:00
Compare commits
384 Commits
4.12.11
...
5.0.0-ALPH
Author | SHA1 | Date | |
---|---|---|---|
66f2116e57 | |||
c15c59ae0d | |||
07786dc4bc | |||
259f44e57c | |||
e5804df24b | |||
c8320fe849 | |||
21ed5a450f | |||
ba2baba7cc | |||
d4f4fda442 | |||
b4ce5ed515 | |||
eb8fb63409 | |||
91719051e2 | |||
d321094081 | |||
323d31005f | |||
0c7370e564 | |||
3dd4c42fd3 | |||
7dd8876515 | |||
d0067cfac5 | |||
eafc23c756 | |||
20cb67461f | |||
8b2d941502 | |||
dea0207e4e | |||
32f9fcd4e9 | |||
2ba51567d8 | |||
14933a731b | |||
a22276e679 | |||
260e54e4b1 | |||
a44c089f98 | |||
5e70ae2066 | |||
ad7528e3f3 | |||
99ff78a8a5 | |||
9ffee7cfc3 | |||
ccb3c3cb05 | |||
151f2c3f3a | |||
66d655731a | |||
54a773be0c | |||
d894c5e97f | |||
419b21281d | |||
56e6a55645 | |||
c67e42a723 | |||
3e4f01d85e | |||
da9937933b | |||
2142eb3cc9 | |||
690efb09e3 | |||
e4d24e1edd | |||
4d6fb2b925 | |||
976502e3db | |||
b0c76f4db5 | |||
8886a023f1 | |||
ae70c63798 | |||
986daab511 | |||
eb404bddb4 | |||
30079f6fd0 | |||
ce87424336 | |||
06d3fc2880 | |||
d40e864821 | |||
88a5a95479 | |||
00db73a5b2 | |||
a377795db9 | |||
a8728a02f6 | |||
dc8f65c0dd | |||
5c4288de01 | |||
46b79fbe85 | |||
494cb580f3 | |||
64e93ae4e1 | |||
fe93609c8d | |||
ebe6782295 | |||
638d03846c | |||
f57cd95ad5 | |||
d725ded7b6 | |||
a8dae96bb0 | |||
e5b038ebcd | |||
a005cd6e33 | |||
5536672e4b | |||
a42bb9626d | |||
3c017af6a0 | |||
412dcaa744 | |||
51ce358734 | |||
d09c45e362 | |||
86d2ecfaff | |||
68cbe46600 | |||
c5282b059b | |||
4e71cc7d79 | |||
6be92ea6f7 | |||
325f1cf82e | |||
1714e2fd35 | |||
0a23e91329 | |||
a059d03b37 | |||
bd773c2f84 | |||
d9544b5d0e | |||
4909c0f257 | |||
56cf59355f | |||
9f0b32e748 | |||
59c5770cf2 | |||
45be6e19f3 | |||
405e552efd | |||
e44a291697 | |||
d9c61f0492 | |||
afd37ca892 | |||
03b8077054 | |||
17abd50f69 | |||
2c33d8429e | |||
cbebb70af6 | |||
6604d22ceb | |||
ce59228688 | |||
386c385a08 | |||
dd615c775d | |||
6176f0d9df | |||
33eef99d1f | |||
3e7d34c8ad | |||
e302e5a85f | |||
4acf7aadbd | |||
227a481473 | |||
a3016abf53 | |||
89632f3514 | |||
c7ba791ff8 | |||
db9c7de35c | |||
017ebb9b47 | |||
3f937605ac | |||
b818ed0d08 | |||
0e0b858b69 | |||
0d0296d535 | |||
2a0fade893 | |||
30149c6ed4 | |||
c84033213f | |||
c4fc352db1 | |||
172214386a | |||
b661c94915 | |||
7750f9581a | |||
451971b866 | |||
d49597fe5f | |||
bcdbb09c2c | |||
ff90c83d66 | |||
248eacd042 | |||
7430e1fbc0 | |||
b125d4d25f | |||
323c563684 | |||
9740891a2f | |||
b5914f4587 | |||
3792ef5a50 | |||
7994da07be | |||
8858b16a25 | |||
a64adbfffe | |||
ba079bd9aa | |||
db2b523762 | |||
4bd087fc83 | |||
af8f2c47f3 | |||
2a0b500010 | |||
c22a840d27 | |||
f8547ad57c | |||
cab56b0479 | |||
ff96f1b93c | |||
09c1e161e0 | |||
66c09fdc3b | |||
4d9f2bc9b1 | |||
de917afc6f | |||
5e4e5147d9 | |||
8831dff61b | |||
83c46a4b54 | |||
ea3d5ac563 | |||
ce6b09291a | |||
2cb722b674 | |||
dd63681f94 | |||
56428e8a4e | |||
6058032807 | |||
c0e178c19c | |||
541a624d48 | |||
2fd9b751b6 | |||
7deee31502 | |||
0afb67be7d | |||
bedc9cf518 | |||
b61a934c9f | |||
65ed7d7794 | |||
55cb68e5b5 | |||
bc5a600d59 | |||
3d61345543 | |||
b56d049103 | |||
27d7672273 | |||
db8bf672f0 | |||
f57e02849a | |||
03fdbd9f7b | |||
1da4c45979 | |||
b9542b4908 | |||
00b4e4016c | |||
cac72d73fb | |||
b268818eda | |||
e3a9324e8d | |||
8e002fc1ca | |||
61da920db0 | |||
1bce583cf3 | |||
5f7521027e | |||
f24f2d9ca9 | |||
be2fe160b3 | |||
8b80c70b9c | |||
9cc24c2c39 | |||
04b855235a | |||
72d8b54188 | |||
1c689b10b9 | |||
82f9a25d88 | |||
8822bdbefa | |||
21cf3813be | |||
adf8a61814 | |||
6964012464 | |||
5ed75731f2 | |||
d8bba6ed3d | |||
0da174842e | |||
1533fcf8f6 | |||
301b0aba82 | |||
c8e318df8c | |||
4aa1a3da8b | |||
680615eed8 | |||
1da6202e6e | |||
831738b29c | |||
e78f20391e | |||
0a22e4606d | |||
0bb30b6201 | |||
bd2516eded | |||
e956cfed1c | |||
cf7d42b3ea | |||
1ff69136a3 | |||
aa9f8781ff | |||
1f8009954c | |||
3a9e4bc357 | |||
3ce1be2a23 | |||
fe4ff3325b | |||
c29e23b2f1 | |||
57132204ec | |||
860fa719b2 | |||
c89f7f8e5e | |||
13bb1c26fb | |||
86e7ae341f | |||
93124c79ea | |||
08fbf92d8d | |||
f08f82edfd | |||
b57f0a2b7e | |||
5c85aa6e58 | |||
02568bb049 | |||
d2613039ed | |||
f97c22c341 | |||
2a24982bc4 | |||
f2dc9187f0 | |||
5a43db1c6d | |||
dab7686656 | |||
38cf9fc6e6 | |||
083a35f970 | |||
01af70f671 | |||
23695fb900 | |||
2bb99fa677 | |||
7b8eeb42f6 | |||
2029e3be20 | |||
6ee551c5e1 | |||
b7e2b3e94a | |||
f3c9b59856 | |||
ef15dc883a | |||
bf199d3a74 | |||
bd8dd48dee | |||
adfabca684 | |||
776b8d2f95 | |||
2b27b8a230 | |||
383be5426e | |||
81b51c0791 | |||
d8dc32ec4b | |||
0fc24c94cd | |||
24bd403e23 | |||
81eafde074 | |||
a2ea0cea86 | |||
5ce5e1d2b0 | |||
901a51a9dd | |||
567bd8e330 | |||
03c505aaa7 | |||
f67104c81e | |||
68491be847 | |||
d807840d57 | |||
2f2ffe0aa4 | |||
4430f6c5fd | |||
a75bc5d537 | |||
643556a366 | |||
1a598bdfd8 | |||
e27f80fd85 | |||
d922f003f6 | |||
d17032dd8c | |||
4c03aabe0f | |||
3ae9341c52 | |||
d10d660a4d | |||
107b0e1728 | |||
7769857f6a | |||
cb97f37d13 | |||
6c92e73b46 | |||
c1a01e91bf | |||
60d3bddfbc | |||
0326c4964b | |||
37f0ccdb7e | |||
43e61336cf | |||
e383f6d8f8 | |||
6dbfdd970f | |||
cfea0dac76 | |||
be863015bf | |||
8edf2c4507 | |||
42474c14aa | |||
63b2e7cc4f | |||
3edb735850 | |||
eafbc3a468 | |||
c1c3475e5a | |||
ede9e78fbd | |||
4c433fd75b | |||
53c2c4939e | |||
993adc8c82 | |||
9f4418e01d | |||
8bf1fb7b1d | |||
3c5300556a | |||
334c9daa6a | |||
b52bb5016c | |||
310104f786 | |||
ed95679953 | |||
a95749f968 | |||
5415ca2fa9 | |||
e98cf39b47 | |||
dda2f42e59 | |||
bc46e148df | |||
169a3217de | |||
905eee3198 | |||
8a11ed70e3 | |||
db9d769db6 | |||
45150f1a52 | |||
0f07b2499c | |||
0a0383d9bd | |||
1b3e50d0a3 | |||
dc5ddf1c1b | |||
03cf635adc | |||
77ba8b81f8 | |||
0ce3f763db | |||
0226f5466c | |||
166ffe430a | |||
1905f87942 | |||
c2d3b23449 | |||
fe2c3d08a0 | |||
7a0f62ce5a | |||
e58b3ba46c | |||
dd3b79b142 | |||
863f9560b0 | |||
f870568e62 | |||
9e03136861 | |||
1b48603d07 | |||
4e6fb4b12c | |||
d55eed803d | |||
8f5813b003 | |||
337aab4f0d | |||
1155f91574 | |||
9fbb2ef46a | |||
4d88f8f7f4 | |||
f33633efcb | |||
324d203f4e | |||
0cc997f531 | |||
f85f2cae98 | |||
6644fd472c | |||
101b71ed02 | |||
e808b7aac4 | |||
f4f4ea1483 | |||
979f6f3d57 | |||
cab9b6c862 | |||
4d935aa8b6 | |||
ccfe485c06 | |||
1a800cf4df | |||
fe7d942500 | |||
f323e3c43f | |||
40e46dbca2 | |||
7d70865db0 | |||
dbe99e5821 | |||
25fdf7e442 | |||
a91e7f7202 | |||
cdafb1b0c4 | |||
69db9f8a30 | |||
c4228edf3c | |||
03e3ecdbd3 | |||
0626edbcdd | |||
d03f4d76a2 | |||
710201fd51 | |||
ab5a7b0d04 | |||
440a48b973 | |||
f01887fb1e | |||
d6dfcb11e8 | |||
8a84f87879 | |||
57341d8a1b | |||
40cf66a730 |
3
.github/workflows/main.yml
vendored
3
.github/workflows/main.yml
vendored
@ -180,6 +180,9 @@ jobs:
|
||||
- name: Regenerate KnownTranslation APIs
|
||||
run: php build/generate-known-translation-apis.php
|
||||
|
||||
- name: Regenerate RuntimeEnum(De)serializer
|
||||
run: php build/generate-runtime-enum-serializers.php
|
||||
|
||||
- name: Verify code is unchanged
|
||||
run: |
|
||||
git diff
|
||||
|
195
build/generate-block-serializer-consts.php
Normal file
195
build/generate-block-serializer-consts.php
Normal file
@ -0,0 +1,195 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\build\generate_block_serializer_consts;
|
||||
|
||||
use pocketmine\data\bedrock\block\BlockStateData;
|
||||
use pocketmine\data\bedrock\block\BlockStateNames;
|
||||
use pocketmine\data\bedrock\block\BlockStateStringValues;
|
||||
use pocketmine\data\bedrock\block\BlockTypeNames;
|
||||
use pocketmine\errorhandler\ErrorToExceptionHandler;
|
||||
use pocketmine\nbt\NbtException;
|
||||
use pocketmine\network\mcpe\convert\BlockStateDictionary;
|
||||
use pocketmine\utils\AssumptionFailedError;
|
||||
use pocketmine\utils\Utils;
|
||||
use function array_values;
|
||||
use function asort;
|
||||
use function count;
|
||||
use function dirname;
|
||||
use function explode;
|
||||
use function fclose;
|
||||
use function file_get_contents;
|
||||
use function fopen;
|
||||
use function fwrite;
|
||||
use function is_string;
|
||||
use function ksort;
|
||||
use function mb_strtoupper;
|
||||
use function sort;
|
||||
use function strrpos;
|
||||
use function strtoupper;
|
||||
use function substr;
|
||||
|
||||
require dirname(__DIR__) . '/vendor/autoload.php';
|
||||
|
||||
class BlockPaletteReport{
|
||||
/**
|
||||
* @var string[]
|
||||
* @phpstan-var array<string, string>
|
||||
*/
|
||||
public array $seenTypes = [];
|
||||
/**
|
||||
* @var string[][]
|
||||
* @phpstan-var array<string, array<mixed, mixed>>
|
||||
*/
|
||||
public array $seenStateValues = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param BlockStateData[] $states
|
||||
* @phpstan-param list<BlockStateData> $states
|
||||
*/
|
||||
function generateBlockPaletteReport(array $states) : BlockPaletteReport{
|
||||
$result = new BlockPaletteReport();
|
||||
|
||||
foreach($states as $stateData){
|
||||
$name = $stateData->getName();
|
||||
$result->seenTypes[$name] = $name;
|
||||
foreach(Utils::stringifyKeys($stateData->getStates()) as $k => $v){
|
||||
$result->seenStateValues[$k][$v->getValue()] = $v->getValue();
|
||||
asort($result->seenStateValues[$k]);
|
||||
}
|
||||
}
|
||||
|
||||
ksort($result->seenTypes, SORT_STRING);
|
||||
ksort($result->seenStateValues, SORT_STRING);
|
||||
return $result;
|
||||
}
|
||||
|
||||
function constifyMcId(string $id) : string{
|
||||
return strtoupper(explode(":", $id, 2)[1]);
|
||||
}
|
||||
|
||||
function generateClassHeader(string $className) : string{
|
||||
$backslashPos = strrpos($className, "\\");
|
||||
if($backslashPos === false){
|
||||
throw new AssumptionFailedError("Expected a namespaced class FQN");
|
||||
}
|
||||
$namespace = substr($className, 0, $backslashPos);
|
||||
$shortName = substr($className, $backslashPos + 1);
|
||||
return <<<HEADER
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace $namespace;
|
||||
|
||||
/**
|
||||
* This class is generated automatically from the block palette for the current version. Do not edit it manually.
|
||||
*/
|
||||
final class $shortName{
|
||||
private function __construct(){
|
||||
//NOOP
|
||||
}
|
||||
|
||||
|
||||
HEADER;
|
||||
}
|
||||
|
||||
/**
|
||||
* @phpstan-param list<string> $seenIds
|
||||
*/
|
||||
function generateBlockIds(array $seenIds) : void{
|
||||
$output = ErrorToExceptionHandler::trapAndRemoveFalse(fn() => fopen(dirname(__DIR__) . '/src/data/bedrock/block/BlockTypeNames.php', 'wb'));
|
||||
|
||||
fwrite($output, generateClassHeader(BlockTypeNames::class));
|
||||
|
||||
foreach($seenIds as $id){
|
||||
fwrite($output, "\tpublic const " . constifyMcId($id) . " = \"" . $id . "\";\n");
|
||||
}
|
||||
|
||||
fwrite($output, "}\n");
|
||||
fclose($output);
|
||||
}
|
||||
|
||||
function generateBlockStateNames(BlockPaletteReport $data) : void{
|
||||
$output = ErrorToExceptionHandler::trapAndRemoveFalse(fn() => fopen(dirname(__DIR__) . '/src/data/bedrock/block/BlockStateNames.php', 'wb'));
|
||||
|
||||
fwrite($output, generateClassHeader(BlockStateNames::class));
|
||||
foreach(Utils::stringifyKeys($data->seenStateValues) as $state => $values){
|
||||
$constName = mb_strtoupper($state, 'US-ASCII');
|
||||
fwrite($output, "\tpublic const $constName = \"$state\";\n");
|
||||
}
|
||||
|
||||
fwrite($output, "}\n");
|
||||
fclose($output);
|
||||
}
|
||||
|
||||
function generateBlockStringValues(BlockPaletteReport $data) : void{
|
||||
$output = ErrorToExceptionHandler::trapAndRemoveFalse(fn() => fopen(dirname(__DIR__) . '/src/data/bedrock/block/BlockStateStringValues.php', 'wb'));
|
||||
|
||||
fwrite($output, generateClassHeader(BlockStateStringValues::class));
|
||||
foreach(Utils::stringifyKeys($data->seenStateValues) as $stateName => $values){
|
||||
$anyWritten = false;
|
||||
sort($values, SORT_STRING);
|
||||
foreach($values as $value){
|
||||
if(!is_string($value)){
|
||||
continue;
|
||||
}
|
||||
$anyWritten = true;
|
||||
$constName = mb_strtoupper($stateName . "_" . $value, 'US-ASCII');
|
||||
fwrite($output, "\tpublic const $constName = \"$value\";\n");
|
||||
}
|
||||
if($anyWritten){
|
||||
fwrite($output, "\n");
|
||||
}
|
||||
}
|
||||
fwrite($output, "}\n");
|
||||
fclose($output);
|
||||
}
|
||||
|
||||
if(count($argv) !== 2){
|
||||
fwrite(STDERR, "This script regenerates BlockTypeNames, BlockStateNames and BlockStateStringValues from a given palette file\n");
|
||||
fwrite(STDERR, "Required arguments: path to block palette file\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$palettePath = $argv[1];
|
||||
$paletteRaw = file_get_contents($palettePath);
|
||||
if($paletteRaw === false){
|
||||
fwrite(STDERR, "Failed to read block palette file\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
try{
|
||||
$states = BlockStateDictionary::loadPaletteFromString($paletteRaw);
|
||||
}catch(NbtException){
|
||||
fwrite(STDERR, "Invalid block palette file $argv[1]\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$report = generateBlockPaletteReport($states);
|
||||
generateBlockIds(array_values($report->seenTypes));
|
||||
generateBlockStateNames($report);
|
||||
generateBlockStringValues($report);
|
||||
|
||||
echo "Done. Don't forget to run CS fixup after generating code.\n";
|
95
build/generate-item-type-names.php
Normal file
95
build/generate-item-type-names.php
Normal file
@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\build\generate_item_serializer_ids;
|
||||
|
||||
use pocketmine\errorhandler\ErrorToExceptionHandler;
|
||||
use pocketmine\network\mcpe\convert\ItemTypeDictionaryFromDataHelper;
|
||||
use pocketmine\network\mcpe\protocol\serializer\ItemTypeDictionary;
|
||||
use pocketmine\utils\Utils;
|
||||
use function asort;
|
||||
use function count;
|
||||
use function dirname;
|
||||
use function explode;
|
||||
use function fclose;
|
||||
use function file_get_contents;
|
||||
use function fopen;
|
||||
use function fwrite;
|
||||
use function strtoupper;
|
||||
|
||||
require dirname(__DIR__) . '/vendor/autoload.php';
|
||||
|
||||
function constifyMcId(string $id) : string{
|
||||
return strtoupper(explode(":", $id, 2)[1]);
|
||||
}
|
||||
|
||||
function generateItemIds(ItemTypeDictionary $dictionary) : void{
|
||||
$ids = [];
|
||||
foreach($dictionary->getEntries() as $entry){
|
||||
if($entry->getNumericId() < 256){ //blockitems are serialized via BlockStateSerializer
|
||||
continue;
|
||||
}
|
||||
$ids[$entry->getStringId()] = $entry->getStringId();
|
||||
}
|
||||
asort($ids, SORT_STRING);
|
||||
|
||||
$file = ErrorToExceptionHandler::trapAndRemoveFalse(fn() => fopen(dirname(__DIR__) . '/src/data/bedrock/item/ItemTypeNames.php', 'wb'));
|
||||
|
||||
fwrite($file, <<<'HEADER'
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\data\bedrock\item;
|
||||
|
||||
/**
|
||||
* This class is generated automatically from the item type dictionary for the current version. Do not edit it manually.
|
||||
*/
|
||||
final class ItemTypeNames{
|
||||
|
||||
HEADER
|
||||
);
|
||||
|
||||
foreach(Utils::stringifyKeys($ids) as $id){
|
||||
fwrite($file, "\tpublic const " . constifyMcId($id) . " = \"" . $id . "\";\n");
|
||||
}
|
||||
fwrite($file, "}\n");
|
||||
fclose($file);
|
||||
}
|
||||
|
||||
if(count($argv) !== 2){
|
||||
fwrite(STDERR, "This script regenerates ItemTypeNames from a given item dictionary file\n");
|
||||
fwrite(STDERR, "Required argument: path to item type dictionary file\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$raw = file_get_contents($argv[1]);
|
||||
if($raw === false){
|
||||
fwrite(STDERR, "Failed to read item type dictionary file\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$dictionary = ItemTypeDictionaryFromDataHelper::loadFromString($raw);
|
||||
generateItemIds($dictionary);
|
||||
|
||||
echo "Done. Don't forget to run CS fixup after generating code.\n";
|
233
build/generate-runtime-enum-serializers.php
Normal file
233
build/generate-runtime-enum-serializers.php
Normal file
@ -0,0 +1,233 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\build\generate_runtime_enum_serializers;
|
||||
|
||||
use pocketmine\block\utils\BellAttachmentType;
|
||||
use pocketmine\block\utils\CopperOxidation;
|
||||
use pocketmine\block\utils\CoralType;
|
||||
use pocketmine\block\utils\DyeColor;
|
||||
use pocketmine\block\utils\LeverFacing;
|
||||
use pocketmine\block\utils\MushroomBlockType;
|
||||
use pocketmine\block\utils\SkullType;
|
||||
use pocketmine\block\utils\SlabType;
|
||||
use pocketmine\item\PotionType;
|
||||
use function array_key_first;
|
||||
use function array_keys;
|
||||
use function array_map;
|
||||
use function ceil;
|
||||
use function count;
|
||||
use function dirname;
|
||||
use function file_put_contents;
|
||||
use function implode;
|
||||
use function ksort;
|
||||
use function log;
|
||||
use function ob_get_clean;
|
||||
use function ob_start;
|
||||
|
||||
require dirname(__DIR__) . '/vendor/autoload.php';
|
||||
|
||||
/**
|
||||
* @param string[] $memberNames
|
||||
* @phpstan-param list<string> $memberNames
|
||||
*
|
||||
* @return string[]
|
||||
* @phpstan-return list<string>
|
||||
*/
|
||||
function buildWriterFunc(string $virtualTypeName, string $nativeTypeName, array $memberNames, string &$functionName) : array{
|
||||
$bits = getBitsRequired($memberNames);
|
||||
$lines = [];
|
||||
|
||||
$functionName = "write$virtualTypeName";
|
||||
$lines[] = "public static function $functionName(RuntimeDataWriter \$w, \\$nativeTypeName \$value) : void{";
|
||||
$lines[] = "\t\$w->writeInt($bits, match(\$value){";
|
||||
|
||||
foreach($memberNames as $key => $memberName){
|
||||
$lines[] = "\t\t$memberName => $key,";
|
||||
}
|
||||
$lines[] = "\t\tdefault => throw new \pocketmine\utils\AssumptionFailedError(\"All $virtualTypeName cases should be covered\")";
|
||||
$lines[] = "\t});";
|
||||
$lines[] = "}";
|
||||
|
||||
return $lines;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string[] $memberNames
|
||||
* @phpstan-param list<string> $memberNames
|
||||
*
|
||||
* @return string[]
|
||||
* @phpstan-return list<string>
|
||||
*/
|
||||
function buildReaderFunc(string $virtualTypeName, string $nativeTypeName, array $memberNames, string &$functionName) : array{
|
||||
$bits = getBitsRequired($memberNames);
|
||||
$lines = [];
|
||||
|
||||
$functionName = "read$virtualTypeName";
|
||||
$lines[] = "public static function $functionName(RuntimeDataReader \$r) : \\$nativeTypeName{";
|
||||
$lines[] = "\treturn match(\$r->readInt($bits)){";
|
||||
|
||||
foreach($memberNames as $key => $memberName){
|
||||
$lines[] = "\t\t$key => $memberName,";
|
||||
}
|
||||
$lines[] = "\t\tdefault => throw new InvalidSerializedRuntimeDataException(\"Invalid serialized value for $virtualTypeName\")";
|
||||
$lines[] = "\t};";
|
||||
$lines[] = "}";
|
||||
|
||||
return $lines;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[] $members
|
||||
*/
|
||||
function getBitsRequired(array $members) : int{
|
||||
return (int) ceil(log(count($members), 2));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param object[] $members
|
||||
* @phpstan-param array<string, object> $members
|
||||
*
|
||||
* @return string[]
|
||||
* @phpstan-return list<string>
|
||||
*/
|
||||
function stringifyEnumMembers(array $members, string $enumClass) : array{
|
||||
ksort($members, SORT_STRING);
|
||||
return array_map(fn(string $enumCaseName) => "\\$enumClass::$enumCaseName()", array_keys($members));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param object[] $enumMembers
|
||||
* @phpstan-param array<string, object> $enumMembers
|
||||
*
|
||||
* @return string[]
|
||||
* @phpstan-return list<string>
|
||||
*/
|
||||
function buildEnumWriterFunc(array $enumMembers, string &$functionName) : array{
|
||||
$reflect = new \ReflectionClass($enumMembers[array_key_first($enumMembers)]);
|
||||
return buildWriterFunc(
|
||||
$reflect->getShortName(),
|
||||
$reflect->getName(),
|
||||
stringifyEnumMembers($enumMembers, $reflect->getName()),
|
||||
$functionName
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param object[] $enumMembers
|
||||
* @phpstan-param array<string, object> $enumMembers
|
||||
*
|
||||
* @return string[]
|
||||
* @phpstan-return list<string>
|
||||
*/
|
||||
function buildEnumReaderFunc(array $enumMembers, string &$functionName) : array{
|
||||
if(count($enumMembers) === 0){
|
||||
throw new \InvalidArgumentException("Enum members cannot be empty");
|
||||
}
|
||||
$reflect = new \ReflectionClass($enumMembers[array_key_first($enumMembers)]);
|
||||
return buildReaderFunc(
|
||||
$reflect->getShortName(),
|
||||
$reflect->getName(),
|
||||
stringifyEnumMembers($enumMembers, $reflect->getName()),
|
||||
$functionName
|
||||
);
|
||||
}
|
||||
|
||||
$enumsUsed = [
|
||||
BellAttachmentType::getAll(),
|
||||
CopperOxidation::getAll(),
|
||||
CoralType::getAll(),
|
||||
DyeColor::getAll(),
|
||||
LeverFacing::getAll(),
|
||||
MushroomBlockType::getAll(),
|
||||
SkullType::getAll(),
|
||||
SlabType::getAll(),
|
||||
PotionType::getAll()
|
||||
];
|
||||
|
||||
$readerFuncs = [];
|
||||
$writerFuncs = [];
|
||||
$functionName = "";
|
||||
|
||||
foreach($enumsUsed as $enumMembers){
|
||||
$writerF = buildEnumWriterFunc($enumMembers, $functionName);
|
||||
/** @var string $functionName */
|
||||
$writerFuncs[$functionName] = $writerF;
|
||||
$readerF = buildEnumReaderFunc($enumMembers, $functionName);
|
||||
/** @var string $functionName */
|
||||
$readerFuncs[$functionName] = $readerF;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string[][] $functions
|
||||
* @phpstan-param array<string, list<string>> $functions
|
||||
*/
|
||||
function printFunctions(array $functions, string $className) : void{
|
||||
ksort($functions, SORT_STRING);
|
||||
|
||||
ob_start();
|
||||
|
||||
echo <<<'HEADER'
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\data\runtime;
|
||||
|
||||
/**
|
||||
* This class is auto-generated. Do not edit it manually.
|
||||
* @see build/generate-runtime-enum-serializers.php
|
||||
*/
|
||||
|
||||
HEADER;
|
||||
|
||||
echo "final class $className{\n\n";
|
||||
echo implode("\n\n", array_map(fn(array $functionLines) => "\t" . implode("\n\t", $functionLines), $functions));
|
||||
echo "\n\n}\n";
|
||||
|
||||
file_put_contents(dirname(__DIR__) . '/src/data/runtime/' . $className . '.php', ob_get_clean());
|
||||
}
|
||||
|
||||
printFunctions($writerFuncs, "RuntimeEnumSerializer");
|
||||
printFunctions($readerFuncs, "RuntimeEnumDeserializer");
|
||||
|
||||
echo "Done. Don't forget to run CS fixup after generating code.\n";
|
422
changelogs/5.0-alpha.md
Normal file
422
changelogs/5.0-alpha.md
Normal file
@ -0,0 +1,422 @@
|
||||
**For Minecraft: Bedrock Edition 1.19.0**
|
||||
|
||||
# 5.0.0-ALPHA1
|
||||
Released 6th July 2022.
|
||||
|
||||
This is a development snapshot of 5.0.0, an upcoming major update to PocketMine-MP. This version includes many new improvements, including support for Bedrock worlds from 1.13 onwards, a large array of new blocks, and various changes to the plugin API.
|
||||
|
||||
## WARNING
|
||||
**This is an ALPHA release.** It is an early development snapshot of the upcoming 5.0.0 release.
|
||||
This means it is LIKELY to be unstable, and/or have performance issues not found in the latest stable releases.
|
||||
|
||||
**BACK UP your data before testing this.** This version will work with worlds and player data from 4.x, **BUT** any world or player data loaded in 5.0.0 **will not work in 4.x** due to backwards-incompatible storage format changes.
|
||||
|
||||
In addition, there are a number of breaking API changes. Plugins for 4.x may require code changes to run on this version.
|
||||
|
||||
The API is **not finalized**. You should expect further changes in later alphas.
|
||||
|
||||
## Core
|
||||
- Worlds are now saved according to the Bedrock 1.19.0 format.
|
||||
- Worlds generated by Bedrock from 1.13.0 and up are now supported (previously, only worlds up to 1.12 were supported).
|
||||
- `/particle` now accepts strings for particle data instead of integers.
|
||||
- `/particle` no longer accepts integers for block or item IDs.
|
||||
- The usage of `blockcrack`, `iconcrack` and `blockdust` particle types in `/particle` now follows the same pattern as other particle types, with the data for each being passed in the `data` parameter instead of being baked into the particle name.
|
||||
|
||||
## Tools
|
||||
- The following tool scripts have been added:
|
||||
- `generate-block-palette-spec.php` - generates a JSON file with a readable overview of blocks, their state properties, and their possible values
|
||||
- `generate-blockstate-upgrade-schema.php` - generates JSON blockstate upgrade schemas like those found in [BedrockBlockUpgradeSchema](https://github.com/pmmp/BedrockBlockUpgradeSchema)
|
||||
- `generate-item-upgrade-schema.php` - generates JSON item ID/meta upgrade schemas like those found in [BedrockItemUpgradeSchema](https://github.com/pmmp/BedrockItemUpgradeSchema)
|
||||
|
||||
## Gameplay
|
||||
### Blocks
|
||||
- Added the following new blocks:
|
||||
- Amethyst Block
|
||||
- Ancient Debris
|
||||
- Basalt
|
||||
- Blackstone blocks, slabs, stairs, and walls
|
||||
- Calcite
|
||||
- Chiseled Deepslate
|
||||
- Chiseled Nether Bricks
|
||||
- Chiseled Polished Blackstone
|
||||
- Cobbled Deepslate blocks, slabs, stairs, and walls
|
||||
- Copper Ore
|
||||
- Cracked Deepslate Bricks
|
||||
- Crached Deepslate Tiles
|
||||
- Cracked Nether Bricks
|
||||
- Cracked Polished Blackstone Bricks
|
||||
- Crimson buttons, doors, fences, fence gates, hyphae, planks, pressure plates, signs, slabs, stairs, stems, and trapdoors
|
||||
- Deepslate
|
||||
- Deepslate Bricks blocks, slabs, stairs, and walls
|
||||
- Deepslate Ores (coal, copper, diamond, emerald, gold, iron, lapis lazuli, redstone)
|
||||
- Deepslate Tiles blocks, slabs, stairs, and walls
|
||||
- Honeycomb Block
|
||||
- Light Block
|
||||
- Mangrove buttons, doors, fences, fence gates, logs, planks, pressure plates, signs, slabs, stairs, trapdoors, and wood
|
||||
- Mud Bricks blocks, slabs, stairs, and walls
|
||||
- Nether Gold Ore
|
||||
- Polished Basalt
|
||||
- Polished Blackstone blocks, buttons, pressure plates, slabs, stairs, and walls
|
||||
- Polished Blackstone Bricks blocks, slabs, stairs, and walls
|
||||
- Polished Deepslate blocks, slabs, stairs, and walls
|
||||
- Quartz Bricks
|
||||
- Shroomlight
|
||||
- Smooth Basalt
|
||||
- Soul Fire
|
||||
- Soul Lantern
|
||||
- Soul Soil
|
||||
- Soul Torch
|
||||
- Tuff
|
||||
- Warped buttons, doors, fences, fence gates, hyphae, planks, pressure plates, signs, slabs, stairs, stems, and trapdoors
|
||||
- Added support for basalt generators
|
||||
- Iron Ore and Gold Ore now drop Raw Iron and Raw Gold respectively, instead of the ore blocks.
|
||||
- Item frames can now be placed on the top and bottom of blocks.
|
||||
- All-sided logs ("wood", for want of a better name) can now be placed in X, Y, and Z orientations.
|
||||
- Walls now connect when placed, following the pre-1.16 logic. (1.16 logic is planned to be implemented, but currently low priority.)
|
||||
- Stripping logs by right-clicking them with an axe is now supported.
|
||||
|
||||
### Items
|
||||
- Added the following new items:
|
||||
- Amethyst Shard
|
||||
- Copper Ingot
|
||||
- Disc Fragment (5)
|
||||
- Echo Shard
|
||||
- Glow Ink Sac
|
||||
- Honeycomb
|
||||
- Phantom Membrane
|
||||
- Raw Copper
|
||||
- Raw Gold
|
||||
- Raw Iron
|
||||
- Spyglass
|
||||
|
||||
## API
|
||||
### General
|
||||
- Protected and public properties now use native property types wherever possible.
|
||||
- Parameter and return typehints have been applied in many places where it wasn't previously possible.
|
||||
|
||||
### `pocketmine\block`
|
||||
#### Runtime block representation
|
||||
- Blocks no longer use internal Minecraft IDs and metadata to identify themselves. All APIs associated with legacy IDs and meta have been removed.
|
||||
- A new set of runtime IDs generated from `VanillaBlocks` is used to identify block types. These IDs are defined in `BlockTypeIds`.
|
||||
- These new IDs are used for runtime representation of blocks on chunks, and for type comparison purposes.
|
||||
- Block type IDs are used at **runtime only**. They should **NOT** be stored in configs or databases, as they are subject to change without warning.
|
||||
- Block state properties (e.g. facing, colour, etc.) are now represented by PM-specific state data instead of legacy metadata. The state data consists of:
|
||||
- Dynamic type data - this is retained by items when the block is broken (colour, wet/dry, coral type, etc.) - handled by `Block->decodeType()` and `Block->encodeType()`
|
||||
- State data - this is discarded when the block is broken (facing direction, lit/unlit, powered/unpowered, etc.) - handled by `Block->decodeState()` and `Block->encodeState()`
|
||||
|
||||
**Block type IDs, and state/type data, are intended for use at RUNTIME only. The values of type IDs and state data may change without warning. They should NOT be saved in configs or databases.**
|
||||
|
||||
#### Implementing new blocks
|
||||
To register a new block, the following changes are now required:
|
||||
|
||||
- Add a new type ID to `BlockTypeIds`
|
||||
- Register the block in `BlockFactory`
|
||||
- Amend `VanillaBlocks` to include the new block
|
||||
- Amend `BlockStateToBlockObjectDeserializer` to deserialize the block from disk
|
||||
- Amend `BlockObjectToBlockStateSerializer` to serialize the block for disk
|
||||
- Optionally, amend `StringToItemParser` to add string alias(es) for the block, so that it can be given via `/give`
|
||||
|
||||
This is admittedly rather more of a hassle than in the old days, but that's the price of abstraction. Research is underway for ways to improve this without spaghettifying the code again.
|
||||
|
||||
#### Change list
|
||||
- The following classes have been removed:
|
||||
- `BlockIdentifierFlattened`
|
||||
- `BlockLegacyIds`
|
||||
- `BlockLegacyMetadata`
|
||||
- `utils\ColorInMetadataTrait` - `utils\ColoredTrait` now implements colour type data serialization uniformly
|
||||
- `utils\InvalidBlockStateException` - this has been superseded by `pocketmine\data\runtime\InvalidSerializedRuntimeDataException`
|
||||
- `utils\NormalHorizontalFacingInMetadataTrait` - `utils\HorizontalFacingTrait` now implements facing type data serialization uniformly
|
||||
- `utils\PillarRotationInMetadataTrait` - `utils\PillarRotationTrait` now implements rotation type data serialization uniformly
|
||||
- `utils\BlockDataSerializer`
|
||||
- The following classes have been added:
|
||||
- `BaseFire`
|
||||
- `SoulFire`
|
||||
- `BlockTypeIds`
|
||||
- This is a generated enum of PocketMine-MP-specific block type IDs
|
||||
- There is one for every entry in `VanillaBlocks`
|
||||
- Do NOT save these IDs in a config or database, as they may change without warning
|
||||
- Block type IDs are intended for comparison purposes only
|
||||
- Block type IDs cannot be negative
|
||||
- `CopperOre`
|
||||
- `GoldOre`
|
||||
- `IronOre`
|
||||
- `Light`
|
||||
- `NetherGoldOre`
|
||||
- `utils\WallConnectionType` - enum of all possible wall connection types
|
||||
- `utils\WoodType` - enum of all possible wood types, used for wood material blocks like planks and logs
|
||||
- `utils\WoodTypeTrait`
|
||||
- The following API methods have been removed:
|
||||
- `Block->getId()` - for type comparisons, use `Block->getTypeId()` instead
|
||||
- `Block->getMeta()` - for state comparisons, use `Block->getStateId()` instead
|
||||
- `Block->readStateFromData()`
|
||||
- `Block->writeStateToMeta()`
|
||||
- `Block->writeStateToItemMeta()`
|
||||
- `Block->getStateBitmask()`
|
||||
- `BlockFactory->get()`
|
||||
- To get a block at runtime, e.g. stone, use `VanillaBlocks::STONE()`
|
||||
- To load a block from old config or database data:
|
||||
1. Use `GlobalBlockStateHandlers::getUpgrader()->upgradeIntIdMeta()` to convert it to modern data
|
||||
2. Pass the data to `GlobalBlockStateHandlers::getDeserializer()` to get a blockstate ID
|
||||
3. Pass the blockstate ID to `BlockFactory::fromStateId()` to get a `Block` instance
|
||||
- `BlockIdentifier->getBlockId()`
|
||||
- `BlockIdentifier->getAllBlockIds()`
|
||||
- `BlockIdentifier->getVariant()`
|
||||
- `BlockIdentifier->getItemId()`
|
||||
- `Door->isPowered()`
|
||||
- `Door->setPowered()`
|
||||
- `Skull->isNoDrops()`
|
||||
- `Skull->setNoDrops()`
|
||||
- `VanillaBlocks::*_GLAZED_TERRACOTTA()` - use `VanillaBlocks::GLAZED_TERRACOTTA()->setColor(DyeColor::WHATEVER())` instead
|
||||
- `utils\FallableTrait->getId()` is no longer required
|
||||
- `utils\FallableTrait->getMeta()` is no longer required
|
||||
- The following constants have been renamed:
|
||||
- `Block::INTERNAL_METADATA_BITS` -> `Block::INTERNAL_STATE_DATA_BITS`
|
||||
- `Block::INTERNAL_METADATA_MASK` -> `Block::INTERNAL_STATE_DATA_MASK`
|
||||
- The following API methods have been renamed:
|
||||
- `Block->getFullId()` -> `Block->getStateId()`
|
||||
- The following API methods have signature changes:
|
||||
- `BlockIdentifier->__construct()` now accepts `int $blockTypeId`, and no longer accepts `int $blockId, int $variant, ?int $itemId`
|
||||
- `ItemFrame->getFacing()` may now return `Facing::UP` and `Facing::DOWN`
|
||||
- `ItemFrame->setFacing()` now accepts `Facing::UP` and `Facing::DOWN`
|
||||
- The following API methods have been added:
|
||||
- `protected Block->decodeState()` - encodes the block's state properties, e.g. facing, powered/unpowered, etc.
|
||||
- `protected Block->decodeType()` - encodes the block's type properties, e.g. colour, wet/dry, coral type, etc.
|
||||
- `public Block->getRequiredStateDataBits()` - returns the number of bits required to encode the block's state data
|
||||
- `public Block->getRequiredTypeDataBits()` - returns the number of bits required to encode the block's type data
|
||||
- `public BlockIdentifier->getBlockTypeId()` - returns the block's type ID according to `BlockTypeIds`
|
||||
- `public GlazedTerracotta->getColor()` (from `ColoredTrait`) - this was previously unsupported due to legacy limitations
|
||||
- `public GlazedTerracotta->setColor()` (from `ColoredTrait`) - this was previously unsupported due to legacy limitations
|
||||
- `public Wall->getConnections()` - returns the wall's connections and their types (see `utils\WallConnectionType`)
|
||||
- `public Wall->setConnections()` - sets the wall's connections and their types (see `utils\WallConnectionType`)
|
||||
- `public Wall->getConnection()`
|
||||
- `public Wall->setConnection()`
|
||||
- `public Wall->isPost()`
|
||||
- `public Wall->setPost()`
|
||||
- `public Wood->isStripped()`
|
||||
- `public Wood->setStripped()`
|
||||
- The following classes now use new traits, adding API methods and/or properties:
|
||||
- `FenceGate` uses `utils\WoodTypeTrait`
|
||||
- `GlazedTerracotta` uses `utils\ColoredTrait`
|
||||
- `Planks` uses `utils\WoodTypeTrait`
|
||||
- `Wood` uses `utils\WoodTypeTrait`
|
||||
- `WoodenButton` uses `utils\WoodTypeTrait`
|
||||
- `WoodenDoor` uses `utils\WoodTypeTrait`
|
||||
- `WoodenFence` uses `utils\WoodTypeTrait`
|
||||
- `WoodenPressurePlate` uses `utils\WoodTypeTrait`
|
||||
- `WoodenSlab` uses `utils\WoodTypeTrait`
|
||||
- `WoodenStairs` uses `utils\WoodTypeTrait`
|
||||
- `WoodenTrapdoor` uses `utils\WoodTypeTrait`
|
||||
|
||||
### `pocketmine\crafting`
|
||||
- The following classes have been added:
|
||||
- `RecipeIngredient` interface
|
||||
- `ExactRecipeIngredient` - matches an exact item
|
||||
- `MetaWildcardRecipeIngredient` - matches an item with the given legacy Minecraft ID, but any metadata value
|
||||
- The following API methods have signature changes:
|
||||
- `FurnaceRecipe->__construct()` now accepts `RecipeIngredient` instead of `Item`
|
||||
- `FurnaceRecipe->getInput()` now returns `RecipeIngredient` instead of `Item`
|
||||
- `PotionContainerChangeRecipe->__construct()` now accepts `string, RecipeIngredient, string` (using Minecraft string IDs instead of legacy integers).
|
||||
- `PotionContainerChangeRecipe->getIngredient()` now returns `RecipeIngredient` instead of `Item`.
|
||||
- `PotionContainerChangeRecipe->getInputItemId()` now returns `string` (using Minecraft string IDs instead of legacy integers).
|
||||
- `PotionContainerChangeRecipe->getOutputItemId()` now returns `string` (using Minecraft string IDs instead of legacy integers).
|
||||
- `PotionTypeRecipe->__construct()` now accepts `RecipeIngredient` instead of `Item`
|
||||
- `PotionTypeRecipe->getIngredient()` now returns `RecipeIngredient` instead of `Item`
|
||||
- `PotionTypeRecipe->getInput()` now returns `RecipeIngredient` instead of `Item`
|
||||
- `ShapedRecipe->__construct()` now accepts `RecipeIngredient` instead of `Item`
|
||||
- `ShapedRecipe->getIngredient()` now returns `?RecipeIngredient` instead of `?Item`
|
||||
- `ShapedRecipe->getIngredientList()` now returns `RecipeIngredient[]` instead of `Item[]`
|
||||
- `ShapedRecipe->getIngredientMap()` now returns `RecipeIngredient[][]` instead of `Item[][]`
|
||||
- `ShapelessRecipe->__construct()` now accepts `RecipeIngredient` instead of `Item`
|
||||
- `ShapelessRecipe->getIngredientList()` now returns `RecipeIngredient[]` instead of `Item[]`
|
||||
|
||||
### `pocketmine\entity`
|
||||
- `Entity` now declares new abstract methods which must be implemented by subclasses:
|
||||
- `public Entity->getInitialDragMultiplier()`
|
||||
- `public Entity->getInitialGravity()`
|
||||
|
||||
### `pocketmine\item`
|
||||
#### Runtime item representation
|
||||
- Items no longer use internal Minecraft string IDs and metadata to identify themselves. All APIs associated with legacy IDs and/or meta have been removed.
|
||||
- A new set of runtime item IDs generated from `VanillaItems` is now used to identify item types. These IDs are defined in `ItemTypeIds`.
|
||||
- These new IDs are primarily intended for type comparison purposes.
|
||||
- Item type IDs are used at **runtime only**. They should **NOT** be stored in configs or databases, as they are not guaranteed to remain the same between versions.
|
||||
- In some cases, items may have additional "type data" which provides extra type information about an item. This replaces item metadata in some cases.
|
||||
- Type data may be used to store dynamic type information such as dye colour, potion type, etc.
|
||||
- Items must have the same type ID **and** type data in order to be stackable.
|
||||
- Blocks, when represented as items:
|
||||
- retain their block type data, but not state data (for example, different colours of concrete don't stack, but things like facing don't affect stackability)
|
||||
- use the negative of their block type ID (e.g. a block with type ID `1` will have an item type ID of `-1`).
|
||||
- Durable items (e.g. tools, armour) now use NBT `Damage` tag to store durability (like Minecraft 1.13+), instead of legacy meta values.
|
||||
|
||||
**Item type IDs and type data are intended for RUNTIME use only. The values of type IDs and/or type data may change without warning. They should NOT be saved in configs or databases.**
|
||||
|
||||
#### Implementing new items
|
||||
To register a new item, the following changes are now required:
|
||||
|
||||
- Add a new ID to `ItemTypeIds`
|
||||
- Register the item in `ItemFactory`
|
||||
- Amend `VanillaItems` to add the item
|
||||
- Amend `ItemDeserializer` to add a deserializer for loading the item from disk
|
||||
- Amend `ItemSerializer` to add a serializer for saving the item to disk
|
||||
- Optionally, amend `StringToItemParser` to add string alias(es) for the item, so it can be given via `/give`
|
||||
|
||||
Again, it's acknowledged this is rather more cumbersome than it should be, but this is an ongoing process.
|
||||
|
||||
#### Change list
|
||||
- `Item` is no longer `json_encode()`-able.
|
||||
- The original purpose of this was to allow items to be serialized to JSON for crafting data generated from `CraftingDataPacket`. Due to changes in the generation methodology, bypassing `Item`s entirely, this is no longer necessary.
|
||||
- `jsonSerialize()` requires the item to know about the method by which it will be serialized, creating a cyclic dependency between the `Item` implementation and its serialization method.
|
||||
- It's relatively easy to write a replacement method to encode items to JSON as you desire.
|
||||
- The following classes have been removed:
|
||||
- `ItemIds`
|
||||
- `Skull`
|
||||
- `Bed`
|
||||
- The following classes have been added:
|
||||
- `CoralFan`
|
||||
- `Spyglass`
|
||||
- The following API methods have been added:
|
||||
- `public Dye->setColor()`
|
||||
- `public ItemIdentifer->getTypeId()`
|
||||
- `public static ItemIdentifier::fromBlock()`
|
||||
- `public Potion->setType()`
|
||||
- `public SplashPotion->setType()`
|
||||
- The following API methods have been removed:
|
||||
- `Item->getId()` - for type comparisons, use `Item->getTypeId()` instead
|
||||
- `Item->getMeta()` - use the item's specific API methods to compare information such as colour, potion type etc.
|
||||
- `Item->hasAnyDamageValue()` - for meta wildcard recipe ingredients, use `pocketmine\crafting\MetaWildcardRecipeIngredient` instead
|
||||
- `ItemFactory->get()`
|
||||
- To get an item at runtime, e.g. iron ingot, use `VanillaItems::IRON_INGOT()`
|
||||
- To get a block as an item, e.g. stone, use `VanillaBlocks::STONE()->asItem()`
|
||||
- To load an item from legacy ID and meta:
|
||||
1. Use `GlobalItemDataHandlers::getUpgrader()->upgradeItemTypeDataInt()` to convert the legacy ID and meta to `ItemStackData`
|
||||
2. Pass the itemstack data to `GlobalItemDataHandlers::getDeserializer()` to get an `Item` instance
|
||||
- `ItemFactory->remap()`
|
||||
- `ItemIdentifier->getId()`
|
||||
- `ItemIdentifier->getMeta()`
|
||||
- The following API methods have been renamed:
|
||||
- `Item::jsonDeserialize()` -> `Item::legacyJsonDeserialize()`
|
||||
- `ItemFactory->getAllRegistered()` -> `ItemFactory->getAllKnownTypes()`
|
||||
- The following API methods have signature changes:
|
||||
- `ItemFactory->isRegistered()` no longer accepts a `$variant` parameter, and now expects an item type ID for the ID parameter
|
||||
- `ItemIdentifier->__construct()` no longer accepts a `$variant` parameter, and now expects an item type ID for the ID parameter
|
||||
- `LegacyStringToItemParser->addMapping()` now accepts a string for ID, instead of an integer
|
||||
|
||||
### `pocketmine\world`
|
||||
- The following classes have been added:
|
||||
- `pocketmine\world\format\io\GlobalBlockStateHandlers`
|
||||
- `pocketmine\world\format\io\GlobalItemDataHandlers`
|
||||
|
||||
# 5.0.0-ALPHA2
|
||||
Released 14th July 2022.
|
||||
|
||||
## Core
|
||||
- Reduced memory usage of the server on startup.
|
||||
- Fixed error spam when loading item frames without items in them.
|
||||
|
||||
## Gameplay
|
||||
### Blocks
|
||||
- Added the following new blocks:
|
||||
- Cakes with Candle & Dyed Candle
|
||||
- Candle & Dyed Candle
|
||||
- Cartography Table (not currently usable due to maps not being implemented)
|
||||
- Copper block (random oxidation not yet implemented)
|
||||
- Cut Copper block, stairs and slabs (random oxidation not yet implemented)
|
||||
- Crying Obsidian
|
||||
- Gilded Blackstone
|
||||
- Glow Item Frame
|
||||
- Hanging Roots
|
||||
- Lightning Rod
|
||||
- Netherite Block
|
||||
- Smithing Table
|
||||
- Tinted Glass
|
||||
- Warped Wart Block
|
||||
- Wither Rose
|
||||
|
||||
### Items
|
||||
- Added the following new items:
|
||||
- Honey Bottle
|
||||
- Netherite Axe
|
||||
- Netherite Boots
|
||||
- Netherite Chestplate
|
||||
- Netherite Helmet
|
||||
- Netherite Ingot
|
||||
- Netherite Leggings
|
||||
- Netherite Pickaxe
|
||||
- Netherite Scrap
|
||||
- Netherite Shovel
|
||||
- Netherite Sword
|
||||
|
||||
## API
|
||||
### `pocketmine\block`
|
||||
- Dependency between `BlockFactory` and `VanillaBlocks` has been inverted.
|
||||
- Now, blocks are defined in `VanillaBlocks`, and automatically registered in `BlockFactory`.
|
||||
- Manual registration in `BlockFactory` is still required for custom blocks.
|
||||
- `BlockFactory` now has only one purpose, which is to map internal blockstate IDs to `Block` objects when reading blocks from chunks.
|
||||
- The following new API methods have been added:
|
||||
- `public Block->isFireProofAsItem()`
|
||||
- `public Block->onProjectileHit()`
|
||||
- `public ItemFrame->isGlowing()`
|
||||
- `public ItemFrame->setGlowing()`
|
||||
- The following new classes have been added:
|
||||
- `BaseCake`
|
||||
- `CakeWithCandle`
|
||||
- `CakeWithDyedCandle`
|
||||
- `Candle`
|
||||
- `CartographyTable`
|
||||
- `CopperSlab`
|
||||
- `CopperStairs`
|
||||
- `Copper`
|
||||
- `DyedCandle`
|
||||
- `GildedBlackstone`
|
||||
- `HangingRoots`
|
||||
- `LightningRod`
|
||||
- `SmithingTable`
|
||||
- `WitherRose`
|
||||
- `utils\CandleTrait`
|
||||
- `utils\CopperOxidation`
|
||||
- `utils\CopperTrait`
|
||||
|
||||
### `pocketmine\crafting`
|
||||
- JSON models have been updated to reflect updated crafting data format.
|
||||
- The following enum classes have new members:
|
||||
- `ShapelessRecipeType` has new members `CARTOGRAPHY` and `SMITHING`
|
||||
|
||||
### `pocketmine\data`
|
||||
- `LegacyToStringBidirectionalIdMap` has been reduced to `LegacyToStringIdMap`.
|
||||
- Since we never map from string ID to legacy ID, bidirectional mapping is no longer necessary.
|
||||
- This affects the following subclasses:
|
||||
- `LegacyBiomeIdToStringIdMap`
|
||||
- `LegacyBlockIdToStringIdMap`
|
||||
- `LegacyEntityIdToStringIdMap`
|
||||
- `LegacyItemIdToStringIdMap`
|
||||
- The following internal API methods have been added:
|
||||
- `public LegacyToStringIdMap->add(string $string, int $legacy) : void` - adds a mapping from a custom legacy ID to custom string ID, needed for upgrading old saved data
|
||||
- `public LegacyBlockStateMapper->addMapping(string $stringId, int $intId, int $meta, BlockStateData $stateData) : void` - adds a mapping from legacy block data to a modern blockstate, needed for upgrading old saved data
|
||||
- `public BlockStateData->getState(string $name) : ?Tag`
|
||||
- The following internal API methods have signature changes:
|
||||
- `BlockStateData->__construct()` now accepts `array<string, Tag`> for `$states` instead of `CompoundTag`
|
||||
- `BlockStateData->getStates()` now returns `array<string, Tag>` instead of `CompoundTag` (allows reducing memory usage)
|
||||
- The following classes have been added:
|
||||
- `UnsupportedItemTypeException`
|
||||
|
||||
### `pocketmine\item`
|
||||
- `ItemFactory` has been removed.
|
||||
- Vanilla item registration is now done via `VanillaItems`.
|
||||
- The procedure for registering a custom item is the same as in ALPHA1, minus the `ItemFactory` step.
|
||||
- The following API methods have been added:
|
||||
- `public ArmorTypeInfo->getToughness() : int`
|
||||
- `public ArmorTypeInfo->isFireProof() : bool`
|
||||
- `public Item->isFireProof() : bool`
|
||||
- The following API methods have signature changes:
|
||||
- `ArmorTypeInfo->__construct()` now accepts optional parameters `int $toughness` and `bool $fireProof`
|
||||
- The following classes have been added:
|
||||
- `HoneyBottle`
|
||||
- The following enums have new members:
|
||||
- `ToolTier` has new member `NETHERITE`
|
||||
|
||||
### `pocketmine\world`
|
||||
- The following API methods have signature changes:
|
||||
- `SubChunk->__construct()` parameter `$blocks` has been renamed to `$blockLayers`.
|
||||
- The following classes have been added:
|
||||
- `CopperWaxApplySound`
|
||||
- `CopperWaxRemoveSound`
|
@ -34,7 +34,9 @@
|
||||
"adhocore/json-comment": "^1.1",
|
||||
"fgrosse/phpasn1": "^2.3",
|
||||
"netresearch/jsonmapper": "^4.0",
|
||||
"pocketmine/bedrock-data": "~1.9.0+bedrock-1.19.10",
|
||||
"pocketmine/bedrock-block-upgrade-schema": "dev-master@dev",
|
||||
"pocketmine/bedrock-data": "dev-modern-world-support@dev",
|
||||
"pocketmine/bedrock-item-upgrade-schema": "dev-master",
|
||||
"pocketmine/bedrock-protocol": "~11.0.0+bedrock-1.19.10",
|
||||
"pocketmine/binaryutils": "^0.2.1",
|
||||
"pocketmine/callback-validator": "^1.0.2",
|
||||
|
94
composer.lock
generated
94
composer.lock
generated
@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "e03c7f446cee1fdb97ee79817c78470a",
|
||||
"content-hash": "dbdbe7338c5646763ad82e6eb47d70bd",
|
||||
"packages": [
|
||||
{
|
||||
"name": "adhocore/json-comment",
|
||||
@ -248,17 +248,44 @@
|
||||
"time": "2020-12-01T19:48:11+00:00"
|
||||
},
|
||||
{
|
||||
"name": "pocketmine/bedrock-data",
|
||||
"version": "1.9.0+bedrock-1.19.10",
|
||||
"name": "pocketmine/bedrock-block-upgrade-schema",
|
||||
"version": "dev-master",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/pmmp/BedrockData.git",
|
||||
"reference": "ecd798a3e7ead50b7da73141bbb0c4ba14dd76a1"
|
||||
"url": "https://github.com/pmmp/BedrockBlockUpgradeSchema.git",
|
||||
"reference": "680ed5e351b92959c365b36bebc2698228b59834"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/pmmp/BedrockData/zipball/ecd798a3e7ead50b7da73141bbb0c4ba14dd76a1",
|
||||
"reference": "ecd798a3e7ead50b7da73141bbb0c4ba14dd76a1",
|
||||
"url": "https://api.github.com/repos/pmmp/BedrockBlockUpgradeSchema/zipball/680ed5e351b92959c365b36bebc2698228b59834",
|
||||
"reference": "680ed5e351b92959c365b36bebc2698228b59834",
|
||||
"shasum": ""
|
||||
},
|
||||
"default-branch": true,
|
||||
"type": "library",
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"CC0-1.0"
|
||||
],
|
||||
"description": "Schemas describing how to upgrade saved block data in older Minecraft: Bedrock Edition world saves",
|
||||
"support": {
|
||||
"issues": "https://github.com/pmmp/BedrockBlockUpgradeSchema/issues",
|
||||
"source": "https://github.com/pmmp/BedrockBlockUpgradeSchema/tree/master"
|
||||
},
|
||||
"time": "2022-07-03T19:17:51+00:00"
|
||||
},
|
||||
{
|
||||
"name": "pocketmine/bedrock-data",
|
||||
"version": "dev-modern-world-support",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/pmmp/BedrockData.git",
|
||||
"reference": "5d7add6b08c7168747c0dda1f5d3599b5c4aaca9"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/pmmp/BedrockData/zipball/5d7add6b08c7168747c0dda1f5d3599b5c4aaca9",
|
||||
"reference": "5d7add6b08c7168747c0dda1f5d3599b5c4aaca9",
|
||||
"shasum": ""
|
||||
},
|
||||
"type": "library",
|
||||
@ -269,22 +296,49 @@
|
||||
"description": "Blobs of data generated from Minecraft: Bedrock Edition, used by PocketMine-MP",
|
||||
"support": {
|
||||
"issues": "https://github.com/pmmp/BedrockData/issues",
|
||||
"source": "https://github.com/pmmp/BedrockData/tree/bedrock-1.19.10"
|
||||
"source": "https://github.com/pmmp/BedrockData/tree/modern-world-support"
|
||||
},
|
||||
"time": "2022-07-12T19:33:21+00:00"
|
||||
"time": "2022-07-12T19:40:28+00:00"
|
||||
},
|
||||
{
|
||||
"name": "pocketmine/bedrock-protocol",
|
||||
"version": "11.0.0+bedrock-1.19.10",
|
||||
"name": "pocketmine/bedrock-item-upgrade-schema",
|
||||
"version": "dev-master",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/pmmp/BedrockProtocol.git",
|
||||
"reference": "705f928bd010ba093d8781d20006e4cd5f79f335"
|
||||
"url": "https://github.com/pmmp/BedrockItemUpgradeSchema.git",
|
||||
"reference": "d984d2ee7283bc52e8733e7c7da1d0f6b6dc501f"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/pmmp/BedrockProtocol/zipball/705f928bd010ba093d8781d20006e4cd5f79f335",
|
||||
"reference": "705f928bd010ba093d8781d20006e4cd5f79f335",
|
||||
"url": "https://api.github.com/repos/pmmp/BedrockItemUpgradeSchema/zipball/d984d2ee7283bc52e8733e7c7da1d0f6b6dc501f",
|
||||
"reference": "d984d2ee7283bc52e8733e7c7da1d0f6b6dc501f",
|
||||
"shasum": ""
|
||||
},
|
||||
"default-branch": true,
|
||||
"type": "library",
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"CC0-1.0"
|
||||
],
|
||||
"description": "JSON schemas for upgrading items found in older Minecraft: Bedrock world saves",
|
||||
"support": {
|
||||
"issues": "https://github.com/pmmp/BedrockItemUpgradeSchema/issues",
|
||||
"source": "https://github.com/pmmp/BedrockItemUpgradeSchema/tree/master"
|
||||
},
|
||||
"time": "2022-06-08T13:47:48+00:00"
|
||||
},
|
||||
{
|
||||
"name": "pocketmine/bedrock-protocol",
|
||||
"version": "11.0.3+bedrock-1.19.10",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/pmmp/BedrockProtocol.git",
|
||||
"reference": "18879218f9d05685ab6f8f68df4cb9c548978657"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/pmmp/BedrockProtocol/zipball/18879218f9d05685ab6f8f68df4cb9c548978657",
|
||||
"reference": "18879218f9d05685ab6f8f68df4cb9c548978657",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -316,9 +370,9 @@
|
||||
"description": "An implementation of the Minecraft: Bedrock Edition protocol in PHP",
|
||||
"support": {
|
||||
"issues": "https://github.com/pmmp/BedrockProtocol/issues",
|
||||
"source": "https://github.com/pmmp/BedrockProtocol/tree/11.0.0+bedrock-1.19.10"
|
||||
"source": "https://github.com/pmmp/BedrockProtocol/tree/11.0.3+bedrock-1.19.10"
|
||||
},
|
||||
"time": "2022-07-12T23:47:47+00:00"
|
||||
"time": "2022-07-14T16:54:49+00:00"
|
||||
},
|
||||
{
|
||||
"name": "pocketmine/binaryutils",
|
||||
@ -3331,7 +3385,11 @@
|
||||
],
|
||||
"aliases": [],
|
||||
"minimum-stability": "stable",
|
||||
"stability-flags": [],
|
||||
"stability-flags": {
|
||||
"pocketmine/bedrock-block-upgrade-schema": 20,
|
||||
"pocketmine/bedrock-data": 20,
|
||||
"pocketmine/bedrock-item-upgrade-schema": 20
|
||||
},
|
||||
"prefer-stable": false,
|
||||
"prefer-lowest": false,
|
||||
"platform": {
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -37,4 +37,6 @@ define('pocketmine\PATH', dirname(__DIR__) . '/');
|
||||
define('pocketmine\RESOURCE_PATH', dirname(__DIR__) . '/resources/');
|
||||
define('pocketmine\BEDROCK_DATA_PATH', dirname(__DIR__) . '/vendor/pocketmine/bedrock-data/');
|
||||
define('pocketmine\LOCALE_DATA_PATH', dirname(__DIR__) . '/vendor/pocketmine/locale-data/');
|
||||
define('pocketmine\BEDROCK_BLOCK_UPGRADE_SCHEMA_PATH', dirname(__DIR__) . '/vendor/pocketmine/bedrock-block-upgrade-schema/');
|
||||
define('pocketmine\BEDROCK_ITEM_UPGRADE_SCHEMA_PATH', dirname(__DIR__) . '/vendor/pocketmine/bedrock-item-upgrade-schema/');
|
||||
define('pocketmine\COMPOSER_AUTOLOADER_PATH', dirname(__DIR__) . '/vendor/autoload.php');
|
||||
|
@ -963,7 +963,7 @@ class Server{
|
||||
|
||||
$this->commandMap = new SimpleCommandMap($this);
|
||||
|
||||
$this->craftingManager = CraftingManagerFromDataHelper::make(Path::join(\pocketmine\BEDROCK_DATA_PATH, "recipes.json"));
|
||||
$this->craftingManager = CraftingManagerFromDataHelper::make(Path::join(\pocketmine\BEDROCK_DATA_PATH, "recipes"));
|
||||
|
||||
$this->resourceManager = new ResourcePackManager(Path::join($this->getDataPath(), "resource_packs"), $this->logger);
|
||||
|
||||
|
@ -31,9 +31,9 @@ use function str_repeat;
|
||||
|
||||
final class VersionInfo{
|
||||
public const NAME = "PocketMine-MP";
|
||||
public const BASE_VERSION = "4.6.1";
|
||||
public const IS_DEVELOPMENT_BUILD = true;
|
||||
public const BUILD_CHANNEL = "beta";
|
||||
public const BASE_VERSION = "5.0.0-ALPHA2";
|
||||
public const IS_DEVELOPMENT_BUILD = false;
|
||||
public const BUILD_CHANNEL = "alpha";
|
||||
|
||||
private function __construct(){
|
||||
//NOOP
|
||||
|
@ -24,11 +24,12 @@ declare(strict_types=1);
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\inventory\AnvilInventory;
|
||||
use pocketmine\block\utils\BlockDataSerializer;
|
||||
use pocketmine\block\utils\Fallable;
|
||||
use pocketmine\block\utils\FallableTrait;
|
||||
use pocketmine\block\utils\HorizontalFacingTrait;
|
||||
use pocketmine\block\utils\SupportType;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Facing;
|
||||
@ -46,21 +47,24 @@ class Anvil extends Transparent implements Fallable{
|
||||
|
||||
private int $damage = self::UNDAMAGED;
|
||||
|
||||
protected function writeStateToMeta() : int{
|
||||
return BlockDataSerializer::writeLegacyHorizontalFacing($this->facing) | ($this->damage << 2);
|
||||
public function getRequiredTypeDataBits() : int{ return 2; }
|
||||
|
||||
protected function decodeType(RuntimeDataReader $r) : void{
|
||||
$this->setDamage($r->readBoundedInt(2, self::UNDAMAGED, self::VERY_DAMAGED));
|
||||
}
|
||||
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->facing = BlockDataSerializer::readLegacyHorizontalFacing($stateMeta & 0x3);
|
||||
$this->damage = BlockDataSerializer::readBoundedInt("damage", $stateMeta >> 2, self::UNDAMAGED, self::VERY_DAMAGED);
|
||||
protected function encodeType(RuntimeDataWriter $w) : void{
|
||||
$w->writeBoundedInt(2, self::UNDAMAGED, self::VERY_DAMAGED, $this->getDamage());
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b1111;
|
||||
public function getRequiredStateDataBits() : int{ return 2; }
|
||||
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->setFacing($r->readHorizontalFacing());
|
||||
}
|
||||
|
||||
protected function writeStateToItemMeta() : int{
|
||||
return $this->damage << 2;
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeHorizontalFacing($this->getFacing());
|
||||
}
|
||||
|
||||
public function getDamage() : int{ return $this->damage; }
|
||||
|
@ -23,12 +23,14 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\BlockDataSerializer;
|
||||
use pocketmine\block\utils\SupportType;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\event\block\StructureGrowEvent;
|
||||
use pocketmine\item\Bamboo as ItemBamboo;
|
||||
use pocketmine\item\Fertilizer;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\VanillaItems;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\math\Vector3;
|
||||
@ -54,18 +56,18 @@ class Bamboo extends Transparent{
|
||||
protected bool $ready = false;
|
||||
protected int $leafSize = self::NO_LEAVES;
|
||||
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->thick = ($stateMeta & BlockLegacyMetadata::BAMBOO_FLAG_THICK) !== 0;
|
||||
$this->leafSize = BlockDataSerializer::readBoundedInt("leafSize", ($stateMeta >> BlockLegacyMetadata::BAMBOO_LEAF_SIZE_SHIFT) & BlockLegacyMetadata::BAMBOO_LEAF_SIZE_MASK, self::NO_LEAVES, self::LARGE_LEAVES);
|
||||
$this->ready = ($stateMeta & BlockLegacyMetadata::BAMBOO_FLAG_READY) !== 0;
|
||||
public function getRequiredStateDataBits() : int{ return 4; }
|
||||
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->setLeafSize($r->readBoundedInt(2, self::NO_LEAVES, self::LARGE_LEAVES));
|
||||
$this->setThick($r->readBool());
|
||||
$this->setReady($r->readBool());
|
||||
}
|
||||
|
||||
public function writeStateToMeta() : int{
|
||||
return ($this->thick ? BlockLegacyMetadata::BAMBOO_FLAG_THICK : 0) | ($this->leafSize << BlockLegacyMetadata::BAMBOO_LEAF_SIZE_SHIFT) | ($this->ready ? BlockLegacyMetadata::BAMBOO_FLAG_READY : 0);
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b1111;
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeBoundedInt(2, self::NO_LEAVES, self::LARGE_LEAVES, $this->getLeafSize());
|
||||
$w->writeBool($this->isThick());
|
||||
$w->writeBool($this->isReady());
|
||||
}
|
||||
|
||||
public function isThick() : bool{ return $this->thick; }
|
||||
@ -242,4 +244,8 @@ class Bamboo extends Transparent{
|
||||
$world->setBlock($this->position, $this);
|
||||
}
|
||||
}
|
||||
|
||||
public function asItem() : Item{
|
||||
return VanillaItems::BAMBOO();
|
||||
}
|
||||
}
|
||||
|
@ -23,28 +23,30 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\event\block\StructureGrowEvent;
|
||||
use pocketmine\item\Bamboo as ItemBamboo;
|
||||
use pocketmine\item\Fertilizer;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\VanillaItems;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\player\Player;
|
||||
use pocketmine\world\BlockTransaction;
|
||||
|
||||
final class BambooSapling extends Flowable{
|
||||
|
||||
private bool $ready = false;
|
||||
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->ready = ($stateMeta & BlockLegacyMetadata::BAMBOO_SAPLING_FLAG_READY) !== 0;
|
||||
public function getRequiredStateDataBits() : int{ return 1; }
|
||||
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->setReady($r->readBool());
|
||||
}
|
||||
|
||||
protected function writeStateToMeta() : int{
|
||||
return $this->ready ? BlockLegacyMetadata::BAMBOO_SAPLING_FLAG_READY : 0;
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeBool($this->isReady());
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{ return 0b1; }
|
||||
|
||||
public function isReady() : bool{ return $this->ready; }
|
||||
|
||||
/** @return $this */
|
||||
@ -125,6 +127,6 @@ final class BambooSapling extends Flowable{
|
||||
}
|
||||
|
||||
public function asItem() : Item{
|
||||
return VanillaBlocks::BAMBOO()->asItem();
|
||||
return VanillaItems::BAMBOO();
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,8 @@ namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\tile\Barrel as TileBarrel;
|
||||
use pocketmine\block\utils\AnyFacingTrait;
|
||||
use pocketmine\block\utils\BlockDataSerializer;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\math\Vector3;
|
||||
@ -38,17 +39,16 @@ class Barrel extends Opaque{
|
||||
|
||||
protected bool $open = false;
|
||||
|
||||
protected function writeStateToMeta() : int{
|
||||
return BlockDataSerializer::writeFacing($this->facing) | ($this->open ? BlockLegacyMetadata::BARREL_FLAG_OPEN : 0);
|
||||
public function getRequiredStateDataBits() : int{ return 4; }
|
||||
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->setFacing($r->readFacing());
|
||||
$this->setOpen($r->readBool());
|
||||
}
|
||||
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->facing = BlockDataSerializer::readFacing($stateMeta & 0x07);
|
||||
$this->open = ($stateMeta & BlockLegacyMetadata::BARREL_FLAG_OPEN) === BlockLegacyMetadata::BARREL_FLAG_OPEN;
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b1111;
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeFacing($this->getFacing());
|
||||
$w->writeBool($this->isOpen());
|
||||
}
|
||||
|
||||
public function isOpen() : bool{
|
||||
|
@ -28,9 +28,9 @@ use pocketmine\block\utils\BannerPatternLayer;
|
||||
use pocketmine\block\utils\ColoredTrait;
|
||||
use pocketmine\block\utils\DyeColor;
|
||||
use pocketmine\block\utils\SupportType;
|
||||
use pocketmine\data\bedrock\DyeColorIdMap;
|
||||
use pocketmine\item\Banner as ItemBanner;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\VanillaItems;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\player\Player;
|
||||
@ -124,15 +124,11 @@ abstract class BaseBanner extends Transparent{
|
||||
abstract protected function getSupportingFace() : int;
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
if($this->getSide($this->getSupportingFace())->getId() === BlockLegacyIds::AIR){
|
||||
if($this->getSide($this->getSupportingFace())->getTypeId() === BlockTypeIds::AIR){
|
||||
$this->position->getWorld()->useBreakOn($this->position);
|
||||
}
|
||||
}
|
||||
|
||||
protected function writeStateToItemMeta() : int{
|
||||
return DyeColorIdMap::getInstance()->toInvertedId($this->color);
|
||||
}
|
||||
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
$drop = $this->asItem();
|
||||
if($drop instanceof ItemBanner && count($this->patterns) > 0){
|
||||
@ -149,4 +145,8 @@ abstract class BaseBanner extends Transparent{
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function asItem() : Item{
|
||||
return VanillaItems::BANNER()->setColor($this->color);
|
||||
}
|
||||
}
|
||||
|
89
src/block/BaseCake.php
Normal file
89
src/block/BaseCake.php
Normal file
@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\SupportType;
|
||||
use pocketmine\entity\effect\EffectInstance;
|
||||
use pocketmine\entity\FoodSource;
|
||||
use pocketmine\entity\Living;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\player\Player;
|
||||
use pocketmine\world\BlockTransaction;
|
||||
|
||||
abstract class BaseCake extends Transparent implements FoodSource{
|
||||
|
||||
public function getSupportType(int $facing) : SupportType{
|
||||
return SupportType::NONE();
|
||||
}
|
||||
|
||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
$down = $this->getSide(Facing::DOWN);
|
||||
if($down->getTypeId() !== BlockTypeIds::AIR){
|
||||
return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
if($this->getSide(Facing::DOWN)->getTypeId() === BlockTypeIds::AIR){ //Replace with common break method
|
||||
$this->position->getWorld()->useBreakOn($this->position);
|
||||
}
|
||||
}
|
||||
|
||||
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
if($player !== null){
|
||||
return $player->consumeObject($this);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getFoodRestore() : int{
|
||||
return 2;
|
||||
}
|
||||
|
||||
public function getSaturationRestore() : float{
|
||||
return 0.4;
|
||||
}
|
||||
|
||||
public function requiresHunger() : bool{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return EffectInstance[]
|
||||
*/
|
||||
public function getAdditionalEffects() : array{
|
||||
return [];
|
||||
}
|
||||
|
||||
abstract public function getResidue() : Block;
|
||||
|
||||
public function onConsume(Living $consumer) : void{
|
||||
$this->position->getWorld()->setBlock($this->position, $this->getResidue());
|
||||
}
|
||||
}
|
63
src/block/BaseFire.php
Normal file
63
src/block/BaseFire.php
Normal file
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\entity\Entity;
|
||||
use pocketmine\entity\projectile\Arrow;
|
||||
use pocketmine\event\entity\EntityCombustByBlockEvent;
|
||||
use pocketmine\event\entity\EntityDamageByBlockEvent;
|
||||
use pocketmine\event\entity\EntityDamageEvent;
|
||||
use pocketmine\item\Item;
|
||||
|
||||
abstract class BaseFire extends Flowable{
|
||||
|
||||
public function hasEntityCollision() : bool{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function canBeReplaced() : bool{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function onEntityInside(Entity $entity) : bool{
|
||||
$ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_FIRE, $this->getFireDamage());
|
||||
$entity->attack($ev);
|
||||
|
||||
$ev = new EntityCombustByBlockEvent($this, $entity, 8);
|
||||
if($entity instanceof Arrow){
|
||||
$ev->cancel();
|
||||
}
|
||||
$ev->call();
|
||||
if(!$ev->isCancelled()){
|
||||
$entity->setOnFire($ev->getDuration());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
abstract protected function getFireDamage() : int;
|
||||
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
return [];
|
||||
}
|
||||
}
|
@ -26,6 +26,8 @@ namespace pocketmine\block;
|
||||
use pocketmine\block\tile\Sign as TileSign;
|
||||
use pocketmine\block\utils\SignText;
|
||||
use pocketmine\block\utils\SupportType;
|
||||
use pocketmine\block\utils\WoodType;
|
||||
use pocketmine\block\utils\WoodTypeTrait;
|
||||
use pocketmine\event\block\SignChangeEvent;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
@ -38,12 +40,22 @@ use function assert;
|
||||
use function strlen;
|
||||
|
||||
abstract class BaseSign extends Transparent{
|
||||
use WoodTypeTrait;
|
||||
|
||||
protected SignText $text;
|
||||
protected ?int $editorEntityRuntimeId = null;
|
||||
|
||||
public function __construct(BlockIdentifier $idInfo, string $name, BlockBreakInfo $breakInfo){
|
||||
/** @var \Closure() : Item */
|
||||
private \Closure $asItemCallback;
|
||||
|
||||
/**
|
||||
* @param \Closure() : Item $asItemCallback
|
||||
*/
|
||||
public function __construct(BlockIdentifier $idInfo, string $name, BlockBreakInfo $breakInfo, WoodType $woodType, \Closure $asItemCallback){
|
||||
$this->woodType = $woodType;
|
||||
parent::__construct($idInfo, $name, $breakInfo);
|
||||
$this->text = new SignText();
|
||||
$this->asItemCallback = $asItemCallback;
|
||||
}
|
||||
|
||||
public function readStateFromWorld() : void{
|
||||
@ -85,7 +97,7 @@ abstract class BaseSign extends Transparent{
|
||||
abstract protected function getSupportingFace() : int;
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
if($this->getSide($this->getSupportingFace())->getId() === BlockLegacyIds::AIR){
|
||||
if($this->getSide($this->getSupportingFace())->getTypeId() === BlockTypeIds::AIR){
|
||||
$this->position->getWorld()->useBreakOn($this->position);
|
||||
}
|
||||
}
|
||||
@ -139,4 +151,8 @@ abstract class BaseSign extends Transparent{
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function asItem() : Item{
|
||||
return ($this->asItemCallback)();
|
||||
}
|
||||
}
|
||||
|
@ -24,12 +24,12 @@ declare(strict_types=1);
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\tile\Bed as TileBed;
|
||||
use pocketmine\block\utils\BlockDataSerializer;
|
||||
use pocketmine\block\utils\ColoredTrait;
|
||||
use pocketmine\block\utils\DyeColor;
|
||||
use pocketmine\block\utils\HorizontalFacingTrait;
|
||||
use pocketmine\block\utils\SupportType;
|
||||
use pocketmine\data\bedrock\DyeColorIdMap;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\entity\Entity;
|
||||
use pocketmine\entity\Living;
|
||||
use pocketmine\item\Item;
|
||||
@ -54,20 +54,18 @@ class Bed extends Transparent{
|
||||
parent::__construct($idInfo, $name, $breakInfo);
|
||||
}
|
||||
|
||||
protected function writeStateToMeta() : int{
|
||||
return BlockDataSerializer::writeLegacyHorizontalFacing($this->facing) |
|
||||
($this->occupied ? BlockLegacyMetadata::BED_FLAG_OCCUPIED : 0) |
|
||||
($this->head ? BlockLegacyMetadata::BED_FLAG_HEAD : 0);
|
||||
public function getRequiredStateDataBits() : int{ return 4; }
|
||||
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->facing = $r->readHorizontalFacing();
|
||||
$this->occupied = $r->readBool();
|
||||
$this->head = $r->readBool();
|
||||
}
|
||||
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->facing = BlockDataSerializer::readLegacyHorizontalFacing($stateMeta & 0x03);
|
||||
$this->occupied = ($stateMeta & BlockLegacyMetadata::BED_FLAG_OCCUPIED) !== 0;
|
||||
$this->head = ($stateMeta & BlockLegacyMetadata::BED_FLAG_HEAD) !== 0;
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b1111;
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeHorizontalFacing($this->facing);
|
||||
$w->writeBool($this->occupied);
|
||||
$w->writeBool($this->head);
|
||||
}
|
||||
|
||||
public function readStateFromWorld() : void{
|
||||
@ -209,10 +207,6 @@ class Bed extends Transparent{
|
||||
return [];
|
||||
}
|
||||
|
||||
protected function writeStateToItemMeta() : int{
|
||||
return DyeColorIdMap::getInstance()->toId($this->color);
|
||||
}
|
||||
|
||||
public function getAffectedBlocks() : array{
|
||||
if(($other = $this->getOtherHalf()) !== null){
|
||||
return [$this, $other];
|
||||
@ -224,4 +218,6 @@ class Bed extends Transparent{
|
||||
private function canBeSupportedBy(Block $block) : bool{
|
||||
return !$block->getSupportType(Facing::UP)->equals(SupportType::NONE());
|
||||
}
|
||||
|
||||
public function getMaxStackSize() : int{ return 1; }
|
||||
}
|
||||
|
@ -23,20 +23,20 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
class Bedrock extends Opaque{
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
|
||||
class Bedrock extends Opaque{
|
||||
private bool $burnsForever = false;
|
||||
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->burnsForever = ($stateMeta & BlockLegacyMetadata::BEDROCK_FLAG_INFINIBURN) !== 0;
|
||||
public function getRequiredStateDataBits() : int{ return 1; }
|
||||
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->burnsForever = $r->readBool();
|
||||
}
|
||||
|
||||
protected function writeStateToMeta() : int{
|
||||
return $this->burnsForever ? BlockLegacyMetadata::BEDROCK_FLAG_INFINIBURN : 0;
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b1;
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeBool($this->burnsForever);
|
||||
}
|
||||
|
||||
public function burnsForever() : bool{
|
||||
|
@ -42,7 +42,7 @@ class Beetroot extends Crops{
|
||||
];
|
||||
}
|
||||
|
||||
public function getPickedItem(bool $addUserData = false) : Item{
|
||||
public function asItem() : Item{
|
||||
return VanillaItems::BEETROOT_SEEDS();
|
||||
}
|
||||
}
|
||||
|
@ -25,16 +25,17 @@ namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\tile\Bell as TileBell;
|
||||
use pocketmine\block\utils\BellAttachmentType;
|
||||
use pocketmine\block\utils\BlockDataSerializer;
|
||||
use pocketmine\block\utils\HorizontalFacingTrait;
|
||||
use pocketmine\block\utils\InvalidBlockStateException;
|
||||
use pocketmine\block\utils\SupportType;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeEnumDeserializer;
|
||||
use pocketmine\data\runtime\RuntimeEnumSerializer;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\player\Player;
|
||||
use pocketmine\utils\AssumptionFailedError;
|
||||
use pocketmine\world\BlockTransaction;
|
||||
use pocketmine\world\sound\BellRingSound;
|
||||
|
||||
@ -48,36 +49,16 @@ final class Bell extends Transparent{
|
||||
parent::__construct($idInfo, $name, $breakInfo);
|
||||
}
|
||||
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->setFacing(BlockDataSerializer::readLegacyHorizontalFacing($stateMeta & 0x03));
|
||||
public function getRequiredStateDataBits() : int{ return 4; }
|
||||
|
||||
$attachmentType = [
|
||||
BlockLegacyMetadata::BELL_ATTACHMENT_FLOOR => BellAttachmentType::FLOOR(),
|
||||
BlockLegacyMetadata::BELL_ATTACHMENT_CEILING => BellAttachmentType::CEILING(),
|
||||
BlockLegacyMetadata::BELL_ATTACHMENT_ONE_WALL => BellAttachmentType::ONE_WALL(),
|
||||
BlockLegacyMetadata::BELL_ATTACHMENT_TWO_WALLS => BellAttachmentType::TWO_WALLS()
|
||||
][($stateMeta >> 2) & 0b11] ?? null;
|
||||
if($attachmentType === null){
|
||||
throw new InvalidBlockStateException("No such attachment type");
|
||||
}
|
||||
$this->setAttachmentType($attachmentType);
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->attachmentType = RuntimeEnumDeserializer::readBellAttachmentType($r);
|
||||
$this->facing = $r->readHorizontalFacing();
|
||||
}
|
||||
|
||||
public function writeStateToMeta() : int{
|
||||
$attachmentTypeMeta = [
|
||||
BellAttachmentType::FLOOR()->id() => BlockLegacyMetadata::BELL_ATTACHMENT_FLOOR,
|
||||
BellAttachmentType::CEILING()->id() => BlockLegacyMetadata::BELL_ATTACHMENT_CEILING,
|
||||
BellAttachmentType::ONE_WALL()->id() => BlockLegacyMetadata::BELL_ATTACHMENT_ONE_WALL,
|
||||
BellAttachmentType::TWO_WALLS()->id() => BlockLegacyMetadata::BELL_ATTACHMENT_TWO_WALLS
|
||||
][$this->getAttachmentType()->id()] ?? null;
|
||||
if($attachmentTypeMeta === null){
|
||||
throw new AssumptionFailedError("Mapping should cover all cases");
|
||||
}
|
||||
return BlockDataSerializer::writeLegacyHorizontalFacing($this->getFacing()) | ($attachmentTypeMeta << 2);
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b1111;
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
RuntimeEnumSerializer::writeBellAttachmentType($w, $this->attachmentType);
|
||||
$w->writeHorizontalFacing($this->facing);
|
||||
}
|
||||
|
||||
protected function recalculateCollisionBoxes() : array{
|
||||
|
@ -28,12 +28,14 @@ namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\tile\Spawnable;
|
||||
use pocketmine\block\tile\Tile;
|
||||
use pocketmine\block\utils\InvalidBlockStateException;
|
||||
use pocketmine\block\utils\SupportType;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\entity\Entity;
|
||||
use pocketmine\entity\projectile\Projectile;
|
||||
use pocketmine\item\enchantment\VanillaEnchantments;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\ItemFactory;
|
||||
use pocketmine\item\ItemBlock;
|
||||
use pocketmine\math\Axis;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\RayTraceResult;
|
||||
@ -44,14 +46,13 @@ use pocketmine\world\BlockTransaction;
|
||||
use pocketmine\world\format\Chunk;
|
||||
use pocketmine\world\Position;
|
||||
use pocketmine\world\World;
|
||||
use function assert;
|
||||
use function count;
|
||||
use function dechex;
|
||||
use function get_class;
|
||||
use const PHP_INT_MAX;
|
||||
|
||||
class Block{
|
||||
public const INTERNAL_METADATA_BITS = 4;
|
||||
public const INTERNAL_METADATA_MASK = ~(~0 << self::INTERNAL_METADATA_BITS);
|
||||
public const INTERNAL_STATE_DATA_BITS = 9;
|
||||
public const INTERNAL_STATE_DATA_MASK = ~(~0 << self::INTERNAL_STATE_DATA_BITS);
|
||||
|
||||
protected BlockIdentifier $idInfo;
|
||||
protected string $fallbackName;
|
||||
@ -65,9 +66,6 @@ class Block{
|
||||
* @param string $name English name of the block type (TODO: implement translations)
|
||||
*/
|
||||
public function __construct(BlockIdentifier $idInfo, string $name, BlockBreakInfo $breakInfo){
|
||||
if(($idInfo->getVariant() & $this->getStateBitmask()) !== 0){
|
||||
throw new \InvalidArgumentException("Variant 0x" . dechex($idInfo->getVariant()) . " collides with state bitmask 0x" . dechex($this->getStateBitmask()));
|
||||
}
|
||||
$this->idInfo = $idInfo;
|
||||
$this->fallbackName = $name;
|
||||
$this->breakInfo = $breakInfo;
|
||||
@ -86,49 +84,102 @@ class Block{
|
||||
return $this->fallbackName;
|
||||
}
|
||||
|
||||
public function getId() : int{
|
||||
return $this->idInfo->getBlockId();
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function getStateId() : int{
|
||||
return ($this->getTypeId() << self::INTERNAL_STATE_DATA_BITS) | $this->computeStateData();
|
||||
}
|
||||
|
||||
public function asItem() : Item{
|
||||
return new ItemBlock($this);
|
||||
}
|
||||
|
||||
public function getRequiredTypeDataBits() : int{ return 0; }
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 0; }
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final public function decodeTypeData(int $data) : void{
|
||||
$typeBits = $this->getRequiredTypeDataBits();
|
||||
$givenBits = $typeBits;
|
||||
$reader = new RuntimeDataReader($givenBits, $data);
|
||||
|
||||
$this->decodeType($reader);
|
||||
$readBits = $reader->getOffset();
|
||||
if($typeBits !== $readBits){
|
||||
throw new \LogicException(get_class($this) . ": Exactly $typeBits bits of type data were provided, but $readBits were read");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function getFullId() : int{
|
||||
return ($this->getId() << self::INTERNAL_METADATA_BITS) | $this->getMeta();
|
||||
final public function decodeStateData(int $data) : void{
|
||||
$typeBits = $this->getRequiredTypeDataBits();
|
||||
$stateBits = $this->getRequiredStateDataBits();
|
||||
$givenBits = $typeBits + $stateBits;
|
||||
$reader = new RuntimeDataReader($givenBits, $data);
|
||||
$this->decodeTypeData($reader->readInt($typeBits));
|
||||
|
||||
$this->decodeState($reader);
|
||||
$readBits = $reader->getOffset() - $typeBits;
|
||||
if($stateBits !== $readBits){
|
||||
throw new \LogicException(get_class($this) . ": Exactly $stateBits bits of state data were provided, but $readBits were read");
|
||||
}
|
||||
}
|
||||
|
||||
public function asItem() : Item{
|
||||
return ItemFactory::getInstance()->get(
|
||||
$this->idInfo->getItemId(),
|
||||
$this->idInfo->getVariant() | $this->writeStateToItemMeta()
|
||||
);
|
||||
protected function decodeType(RuntimeDataReader $r) : void{
|
||||
//NOOP
|
||||
}
|
||||
|
||||
public function getMeta() : int{
|
||||
$stateMeta = $this->writeStateToMeta();
|
||||
assert(($stateMeta & ~$this->getStateBitmask()) === 0);
|
||||
return $this->idInfo->getVariant() | $stateMeta;
|
||||
}
|
||||
|
||||
protected function writeStateToItemMeta() : int{
|
||||
return 0;
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
//NOOP
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a bitmask used to extract state bits from block metadata.
|
||||
* @internal
|
||||
*/
|
||||
public function getStateBitmask() : int{
|
||||
return 0;
|
||||
}
|
||||
final public function computeTypeData() : int{
|
||||
$typeBits = $this->getRequiredTypeDataBits();
|
||||
$requiredBits = $typeBits;
|
||||
$writer = new RuntimeDataWriter($requiredBits);
|
||||
|
||||
protected function writeStateToMeta() : int{
|
||||
return 0;
|
||||
$this->encodeType($writer);
|
||||
$writtenBits = $writer->getOffset();
|
||||
if($typeBits !== $writtenBits){
|
||||
throw new \LogicException(get_class($this) . ": Exactly $typeBits bits of type data were expected, but $writtenBits were written");
|
||||
}
|
||||
|
||||
return $writer->getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws InvalidBlockStateException
|
||||
* @internal
|
||||
*/
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
final public function computeStateData() : int{
|
||||
$typeBits = $this->getRequiredTypeDataBits();
|
||||
$stateBits = $this->getRequiredStateDataBits();
|
||||
$requiredBits = $typeBits + $stateBits;
|
||||
$writer = new RuntimeDataWriter($requiredBits);
|
||||
$writer->writeInt($typeBits, $this->computeTypeData());
|
||||
|
||||
$this->encodeState($writer);
|
||||
$writtenBits = $writer->getOffset() - $typeBits;
|
||||
if($stateBits !== $writtenBits){
|
||||
throw new \LogicException(get_class($this) . ": Exactly $stateBits bits of state data were expected, but $writtenBits were written");
|
||||
}
|
||||
|
||||
return $writer->getValue();
|
||||
}
|
||||
|
||||
protected function encodeType(RuntimeDataWriter $w) : void{
|
||||
//NOOP
|
||||
}
|
||||
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
//NOOP
|
||||
}
|
||||
|
||||
@ -144,7 +195,7 @@ class Block{
|
||||
}
|
||||
|
||||
public function writeStateToWorld() : void{
|
||||
$this->position->getWorld()->getOrLoadChunkAtPosition($this->position)->setFullBlock($this->position->x & Chunk::COORD_MASK, $this->position->y, $this->position->z & Chunk::COORD_MASK, $this->getFullId());
|
||||
$this->position->getWorld()->getOrLoadChunkAtPosition($this->position)->setFullBlock($this->position->x & Chunk::COORD_MASK, $this->position->y, $this->position->z & Chunk::COORD_MASK, $this->getStateId());
|
||||
|
||||
$tileType = $this->idInfo->getTileClass();
|
||||
$oldTile = $this->position->getWorld()->getTile($this->position);
|
||||
@ -171,14 +222,11 @@ class Block{
|
||||
* powered/unpowered, etc.
|
||||
*/
|
||||
public function getTypeId() : int{
|
||||
return ($this->idInfo->getBlockId() << Block::INTERNAL_METADATA_BITS) | $this->idInfo->getVariant();
|
||||
return $this->idInfo->getBlockTypeId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the given block has an equivalent type to this one. This compares the type IDs.
|
||||
*
|
||||
* Note: This ignores additional IDs used to represent additional states. This means that, for example, a lit
|
||||
* furnace and unlit furnace are considered the same type.
|
||||
*/
|
||||
public function isSameType(Block $other) : bool{
|
||||
return $this->getTypeId() === $other->getTypeId();
|
||||
@ -188,7 +236,7 @@ class Block{
|
||||
* Returns whether the given block has the same type and properties as this block.
|
||||
*/
|
||||
public function isSameState(Block $other) : bool{
|
||||
return $this->getFullId() === $other->getFullId();
|
||||
return $this->getStateId() === $other->getStateId();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -456,6 +504,10 @@ class Block{
|
||||
return 64;
|
||||
}
|
||||
|
||||
public function isFireProofAsItem() : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the chance that the block will catch fire from nearby fire sources. Higher values lead to faster catching
|
||||
* fire.
|
||||
@ -545,7 +597,7 @@ class Block{
|
||||
* @return string
|
||||
*/
|
||||
public function __toString(){
|
||||
return "Block[" . $this->getName() . "] (" . $this->getId() . ":" . $this->getMeta() . ")";
|
||||
return "Block[" . $this->getName() . "] (" . $this->getTypeId() . ":" . $this->computeStateData() . ")";
|
||||
}
|
||||
|
||||
/**
|
||||
@ -580,6 +632,13 @@ class Block{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a projectile collides with one of this block's collision boxes.
|
||||
*/
|
||||
public function onProjectileHit(Projectile $projectile, RayTraceResult $hitResult) : void{
|
||||
//NOOP
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AxisAlignedBB[]
|
||||
*/
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -31,34 +31,18 @@ class BlockIdentifier{
|
||||
* @phpstan-param class-string<Tile>|null $tileClass
|
||||
*/
|
||||
public function __construct(
|
||||
private int $blockId,
|
||||
private int $variant,
|
||||
private ?int $itemId = null,
|
||||
private int $blockTypeId,
|
||||
private ?string $tileClass = null
|
||||
){
|
||||
if($blockTypeId < 0){
|
||||
throw new \InvalidArgumentException("Block type ID may not be negative");
|
||||
}
|
||||
if($tileClass !== null){
|
||||
Utils::testValidInstance($tileClass, Tile::class);
|
||||
}
|
||||
}
|
||||
|
||||
public function getBlockId() : int{
|
||||
return $this->blockId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int[]
|
||||
*/
|
||||
public function getAllBlockIds() : array{
|
||||
return [$this->blockId];
|
||||
}
|
||||
|
||||
public function getVariant() : int{
|
||||
return $this->variant;
|
||||
}
|
||||
|
||||
public function getItemId() : int{
|
||||
return $this->itemId ?? ($this->blockId > 255 ? 255 - $this->blockId : $this->blockId);
|
||||
}
|
||||
public function getBlockTypeId() : int{ return $this->blockTypeId; }
|
||||
|
||||
/**
|
||||
* @phpstan-return class-string<Tile>|null
|
||||
|
@ -1,59 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use function count;
|
||||
|
||||
class BlockIdentifierFlattened extends BlockIdentifier{
|
||||
|
||||
/** @var int[] */
|
||||
private array $additionalIds;
|
||||
|
||||
/**
|
||||
* @param int[] $additionalIds
|
||||
*/
|
||||
public function __construct(int $blockId, array $additionalIds, int $variant, ?int $itemId = null, ?string $tileClass = null){
|
||||
if(count($additionalIds) === 0){
|
||||
throw new \InvalidArgumentException("Expected at least 1 additional ID");
|
||||
}
|
||||
parent::__construct($blockId, $variant, $itemId, $tileClass);
|
||||
|
||||
$this->additionalIds = $additionalIds;
|
||||
}
|
||||
|
||||
public function getAdditionalId(int $index) : int{
|
||||
if(!isset($this->additionalIds[$index])){
|
||||
throw new \InvalidArgumentException("No such ID at index $index");
|
||||
}
|
||||
return $this->additionalIds[$index];
|
||||
}
|
||||
|
||||
public function getSecondId() : int{
|
||||
return $this->getAdditionalId(0);
|
||||
}
|
||||
|
||||
public function getAllBlockIds() : array{
|
||||
return [$this->getBlockId(), ...$this->additionalIds];
|
||||
}
|
||||
}
|
@ -24,225 +24,266 @@ declare(strict_types=1);
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\BlockIdentifier as BID;
|
||||
use pocketmine\block\BlockLegacyIds as Ids;
|
||||
use pocketmine\block\BlockTypeIds as Ids;
|
||||
use pocketmine\block\tile\Sign as TileSign;
|
||||
use pocketmine\block\utils\DyeColor;
|
||||
use pocketmine\block\utils\TreeType;
|
||||
use pocketmine\item\ItemIds;
|
||||
use pocketmine\block\utils\WoodType;
|
||||
use pocketmine\item\VanillaItems;
|
||||
use pocketmine\utils\AssumptionFailedError;
|
||||
|
||||
final class BlockLegacyIdHelper{
|
||||
|
||||
public static function getWoodenFloorSignIdentifier(TreeType $treeType) : BID{
|
||||
public static function getWoodenPlanksIdentifier(WoodType $type) : BID{
|
||||
return new BID(match($type->id()){
|
||||
WoodType::OAK()->id() => Ids::OAK_PLANKS,
|
||||
WoodType::SPRUCE()->id() => Ids::SPRUCE_PLANKS,
|
||||
WoodType::BIRCH()->id() => Ids::BIRCH_PLANKS,
|
||||
WoodType::JUNGLE()->id() => Ids::JUNGLE_PLANKS,
|
||||
WoodType::ACACIA()->id() => Ids::ACACIA_PLANKS,
|
||||
WoodType::DARK_OAK()->id() => Ids::DARK_OAK_PLANKS,
|
||||
WoodType::MANGROVE()->id() => Ids::MANGROVE_PLANKS,
|
||||
WoodType::CRIMSON()->id() => Ids::CRIMSON_PLANKS,
|
||||
WoodType::WARPED()->id() => Ids::WARPED_PLANKS,
|
||||
default => throw new AssumptionFailedError("All tree types should be covered")
|
||||
});
|
||||
}
|
||||
|
||||
public static function getWoodenFenceIdentifier(WoodType $type) : BID{
|
||||
return new BID(match($type->id()){
|
||||
WoodType::OAK()->id() => Ids::OAK_FENCE,
|
||||
WoodType::SPRUCE()->id() => Ids::SPRUCE_FENCE,
|
||||
WoodType::BIRCH()->id() => Ids::BIRCH_FENCE,
|
||||
WoodType::JUNGLE()->id() => Ids::JUNGLE_FENCE,
|
||||
WoodType::ACACIA()->id() => Ids::ACACIA_FENCE,
|
||||
WoodType::DARK_OAK()->id() => Ids::DARK_OAK_FENCE,
|
||||
WoodType::MANGROVE()->id() => Ids::MANGROVE_FENCE,
|
||||
WoodType::CRIMSON()->id() => Ids::CRIMSON_FENCE,
|
||||
WoodType::WARPED()->id() => Ids::WARPED_FENCE,
|
||||
default => throw new AssumptionFailedError("All tree types should be covered")
|
||||
});
|
||||
}
|
||||
|
||||
public static function getWoodenSlabIdentifier(WoodType $type) : BID{
|
||||
return new BID(match($type->id()){
|
||||
WoodType::OAK()->id() => Ids::OAK_SLAB,
|
||||
WoodType::SPRUCE()->id() => Ids::SPRUCE_SLAB,
|
||||
WoodType::BIRCH()->id() => Ids::BIRCH_SLAB,
|
||||
WoodType::JUNGLE()->id() => Ids::JUNGLE_SLAB,
|
||||
WoodType::ACACIA()->id() => Ids::ACACIA_SLAB,
|
||||
WoodType::DARK_OAK()->id() => Ids::DARK_OAK_SLAB,
|
||||
WoodType::MANGROVE()->id() => Ids::MANGROVE_SLAB,
|
||||
WoodType::CRIMSON()->id() => Ids::CRIMSON_SLAB,
|
||||
WoodType::WARPED()->id() => Ids::WARPED_SLAB,
|
||||
default => throw new AssumptionFailedError("All tree types should be covered")
|
||||
});
|
||||
}
|
||||
|
||||
public static function getLogIdentifier(WoodType $treeType) : BID{
|
||||
return new BID(match($treeType->id()){
|
||||
WoodType::OAK()->id() => Ids::OAK_LOG,
|
||||
WoodType::SPRUCE()->id() => Ids::SPRUCE_LOG,
|
||||
WoodType::BIRCH()->id() => Ids::BIRCH_LOG,
|
||||
WoodType::JUNGLE()->id() => Ids::JUNGLE_LOG,
|
||||
WoodType::ACACIA()->id() => Ids::ACACIA_LOG,
|
||||
WoodType::DARK_OAK()->id() => Ids::DARK_OAK_LOG,
|
||||
WoodType::MANGROVE()->id() => Ids::MANGROVE_LOG,
|
||||
WoodType::CRIMSON()->id() => Ids::CRIMSON_STEM,
|
||||
WoodType::WARPED()->id() => Ids::WARPED_STEM,
|
||||
default => throw new AssumptionFailedError("All tree types should be covered")
|
||||
});
|
||||
}
|
||||
|
||||
public static function getAllSidedLogIdentifier(WoodType $treeType) : BID{
|
||||
return new BID(match($treeType->id()){
|
||||
WoodType::OAK()->id() => Ids::OAK_WOOD,
|
||||
WoodType::SPRUCE()->id() => Ids::SPRUCE_WOOD,
|
||||
WoodType::BIRCH()->id() => Ids::BIRCH_WOOD,
|
||||
WoodType::JUNGLE()->id() => Ids::JUNGLE_WOOD,
|
||||
WoodType::ACACIA()->id() => Ids::ACACIA_WOOD,
|
||||
WoodType::DARK_OAK()->id() => Ids::DARK_OAK_WOOD,
|
||||
WoodType::MANGROVE()->id() => Ids::MANGROVE_WOOD,
|
||||
WoodType::CRIMSON()->id() => Ids::CRIMSON_HYPHAE,
|
||||
WoodType::WARPED()->id() => Ids::WARPED_HYPHAE,
|
||||
default => throw new AssumptionFailedError("All tree types should be covered")
|
||||
});
|
||||
}
|
||||
|
||||
public static function getLeavesIdentifier(TreeType $treeType) : BID{
|
||||
return new BID(match($treeType->id()){
|
||||
TreeType::OAK()->id() => Ids::OAK_LEAVES,
|
||||
TreeType::SPRUCE()->id() => Ids::SPRUCE_LEAVES,
|
||||
TreeType::BIRCH()->id() => Ids::BIRCH_LEAVES,
|
||||
TreeType::JUNGLE()->id() => Ids::JUNGLE_LEAVES,
|
||||
TreeType::ACACIA()->id() => Ids::ACACIA_LEAVES,
|
||||
TreeType::DARK_OAK()->id() => Ids::DARK_OAK_LEAVES,
|
||||
default => throw new AssumptionFailedError("All tree types should be covered")
|
||||
});
|
||||
}
|
||||
|
||||
public static function getSaplingIdentifier(TreeType $treeType) : BID{
|
||||
return new BID(match($treeType->id()){
|
||||
TreeType::OAK()->id() => Ids::OAK_SAPLING,
|
||||
TreeType::SPRUCE()->id() => Ids::SPRUCE_SAPLING,
|
||||
TreeType::BIRCH()->id() => Ids::BIRCH_SAPLING,
|
||||
TreeType::JUNGLE()->id() => Ids::JUNGLE_SAPLING,
|
||||
TreeType::ACACIA()->id() => Ids::ACACIA_SAPLING,
|
||||
TreeType::DARK_OAK()->id() => Ids::DARK_OAK_SAPLING,
|
||||
default => throw new AssumptionFailedError("All tree types should be covered")
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BID[]|\Closure[]
|
||||
* @phpstan-return array{BID, BID, \Closure() : \pocketmine\item\Item}
|
||||
*/
|
||||
public static function getWoodenSignInfo(WoodType $treeType) : array{
|
||||
switch($treeType->id()){
|
||||
case TreeType::OAK()->id():
|
||||
return new BID(Ids::SIGN_POST, 0, ItemIds::SIGN, TileSign::class);
|
||||
case TreeType::SPRUCE()->id():
|
||||
return new BID(Ids::SPRUCE_STANDING_SIGN, 0, ItemIds::SPRUCE_SIGN, TileSign::class);
|
||||
case TreeType::BIRCH()->id():
|
||||
return new BID(Ids::BIRCH_STANDING_SIGN, 0, ItemIds::BIRCH_SIGN, TileSign::class);
|
||||
case TreeType::JUNGLE()->id():
|
||||
return new BID(Ids::JUNGLE_STANDING_SIGN, 0, ItemIds::JUNGLE_SIGN, TileSign::class);
|
||||
case TreeType::ACACIA()->id():
|
||||
return new BID(Ids::ACACIA_STANDING_SIGN,0, ItemIds::ACACIA_SIGN, TileSign::class);
|
||||
case TreeType::DARK_OAK()->id():
|
||||
return new BID(Ids::DARKOAK_STANDING_SIGN, 0, ItemIds::DARKOAK_SIGN, TileSign::class);
|
||||
case WoodType::OAK()->id():
|
||||
return [
|
||||
new BID(Ids::OAK_SIGN, TileSign::class),
|
||||
new BID(Ids::OAK_WALL_SIGN, TileSign::class),
|
||||
fn() => VanillaItems::OAK_SIGN()
|
||||
];
|
||||
case WoodType::SPRUCE()->id():
|
||||
return [
|
||||
new BID(Ids::SPRUCE_SIGN, TileSign::class),
|
||||
new BID(Ids::SPRUCE_WALL_SIGN, TileSign::class),
|
||||
fn() => VanillaItems::SPRUCE_SIGN()
|
||||
];
|
||||
case WoodType::BIRCH()->id():
|
||||
return [
|
||||
new BID(Ids::BIRCH_SIGN, TileSign::class),
|
||||
new BID(Ids::BIRCH_WALL_SIGN, TileSign::class),
|
||||
fn() => VanillaItems::BIRCH_SIGN()
|
||||
];
|
||||
case WoodType::JUNGLE()->id():
|
||||
return [
|
||||
new BID(Ids::JUNGLE_SIGN, TileSign::class),
|
||||
new BID(Ids::JUNGLE_WALL_SIGN, TileSign::class),
|
||||
fn() => VanillaItems::JUNGLE_SIGN()
|
||||
];
|
||||
case WoodType::ACACIA()->id():
|
||||
return [
|
||||
new BID(Ids::ACACIA_SIGN, TileSign::class),
|
||||
new BID(Ids::ACACIA_WALL_SIGN, TileSign::class),
|
||||
fn() => VanillaItems::ACACIA_SIGN()
|
||||
];
|
||||
case WoodType::DARK_OAK()->id():
|
||||
return [
|
||||
new BID(Ids::DARK_OAK_SIGN, TileSign::class),
|
||||
new BID(Ids::DARK_OAK_WALL_SIGN, TileSign::class),
|
||||
fn() => VanillaItems::DARK_OAK_SIGN()
|
||||
];
|
||||
case WoodType::MANGROVE()->id():
|
||||
return [
|
||||
new BID(Ids::MANGROVE_SIGN, TileSign::class),
|
||||
new BID(Ids::MANGROVE_WALL_SIGN, TileSign::class),
|
||||
fn() => VanillaItems::MANGROVE_SIGN()
|
||||
];
|
||||
case WoodType::CRIMSON()->id():
|
||||
return [
|
||||
new BID(Ids::CRIMSON_SIGN, TileSign::class),
|
||||
new BID(Ids::CRIMSON_WALL_SIGN, TileSign::class),
|
||||
fn() => VanillaItems::CRIMSON_SIGN()
|
||||
];
|
||||
case WoodType::WARPED()->id():
|
||||
return [
|
||||
new BID(Ids::WARPED_SIGN, TileSign::class),
|
||||
new BID(Ids::WARPED_WALL_SIGN, TileSign::class),
|
||||
fn() => VanillaItems::WARPED_SIGN()
|
||||
];
|
||||
|
||||
}
|
||||
throw new AssumptionFailedError("Switch should cover all wood types");
|
||||
}
|
||||
|
||||
public static function getWoodenWallSignIdentifier(TreeType $treeType) : BID{
|
||||
switch($treeType->id()){
|
||||
case TreeType::OAK()->id():
|
||||
return new BID(Ids::WALL_SIGN, 0, ItemIds::SIGN, TileSign::class);
|
||||
case TreeType::SPRUCE()->id():
|
||||
return new BID(Ids::SPRUCE_WALL_SIGN, 0, ItemIds::SPRUCE_SIGN, TileSign::class);
|
||||
case TreeType::BIRCH()->id():
|
||||
return new BID(Ids::BIRCH_WALL_SIGN, 0, ItemIds::BIRCH_SIGN, TileSign::class);
|
||||
case TreeType::JUNGLE()->id():
|
||||
return new BID(Ids::JUNGLE_WALL_SIGN, 0, ItemIds::JUNGLE_SIGN, TileSign::class);
|
||||
case TreeType::ACACIA()->id():
|
||||
return new BID(Ids::ACACIA_WALL_SIGN, 0, ItemIds::ACACIA_SIGN, TileSign::class);
|
||||
case TreeType::DARK_OAK()->id():
|
||||
return new BID(Ids::DARKOAK_WALL_SIGN, 0, ItemIds::DARKOAK_SIGN, TileSign::class);
|
||||
}
|
||||
throw new AssumptionFailedError("Switch should cover all wood types");
|
||||
public static function getWoodenTrapdoorIdentifier(WoodType $treeType) : BlockIdentifier{
|
||||
return new BID(match($treeType->id()){
|
||||
WoodType::OAK()->id() => Ids::OAK_TRAPDOOR,
|
||||
WoodType::SPRUCE()->id() => Ids::SPRUCE_TRAPDOOR,
|
||||
WoodType::BIRCH()->id() => Ids::BIRCH_TRAPDOOR,
|
||||
WoodType::JUNGLE()->id() => Ids::JUNGLE_TRAPDOOR,
|
||||
WoodType::ACACIA()->id() => Ids::ACACIA_TRAPDOOR,
|
||||
WoodType::DARK_OAK()->id() => Ids::DARK_OAK_TRAPDOOR,
|
||||
WoodType::MANGROVE()->id() => Ids::MANGROVE_TRAPDOOR,
|
||||
WoodType::CRIMSON()->id() => Ids::CRIMSON_TRAPDOOR,
|
||||
WoodType::WARPED()->id() => Ids::WARPED_TRAPDOOR,
|
||||
default => throw new AssumptionFailedError("All wood types should be covered")
|
||||
});
|
||||
}
|
||||
|
||||
public static function getWoodenTrapdoorIdentifier(TreeType $treeType) : BlockIdentifier{
|
||||
switch($treeType->id()){
|
||||
case TreeType::OAK()->id():
|
||||
return new BlockIdentifier(Ids::WOODEN_TRAPDOOR, 0);
|
||||
case TreeType::SPRUCE()->id():
|
||||
return new BlockIdentifier(Ids::SPRUCE_TRAPDOOR, 0);
|
||||
case TreeType::BIRCH()->id():
|
||||
return new BlockIdentifier(Ids::BIRCH_TRAPDOOR, 0);
|
||||
case TreeType::JUNGLE()->id():
|
||||
return new BlockIdentifier(Ids::JUNGLE_TRAPDOOR, 0);
|
||||
case TreeType::ACACIA()->id():
|
||||
return new BlockIdentifier(Ids::ACACIA_TRAPDOOR, 0);
|
||||
case TreeType::DARK_OAK()->id():
|
||||
return new BlockIdentifier(Ids::DARK_OAK_TRAPDOOR, 0);
|
||||
}
|
||||
throw new AssumptionFailedError("Switch should cover all wood types");
|
||||
public static function getWoodenButtonIdentifier(WoodType $treeType) : BlockIdentifier{
|
||||
return new BID(match($treeType->id()){
|
||||
WoodType::OAK()->id() => Ids::OAK_BUTTON,
|
||||
WoodType::SPRUCE()->id() => Ids::SPRUCE_BUTTON,
|
||||
WoodType::BIRCH()->id() => Ids::BIRCH_BUTTON,
|
||||
WoodType::JUNGLE()->id() => Ids::JUNGLE_BUTTON,
|
||||
WoodType::ACACIA()->id() => Ids::ACACIA_BUTTON,
|
||||
WoodType::DARK_OAK()->id() => Ids::DARK_OAK_BUTTON,
|
||||
WoodType::MANGROVE()->id() => Ids::MANGROVE_BUTTON,
|
||||
WoodType::CRIMSON()->id() => Ids::CRIMSON_BUTTON,
|
||||
WoodType::WARPED()->id() => Ids::WARPED_BUTTON,
|
||||
default => throw new AssumptionFailedError("All wood types should be covered")
|
||||
});
|
||||
}
|
||||
|
||||
public static function getWoodenButtonIdentifier(TreeType $treeType) : BlockIdentifier{
|
||||
switch($treeType->id()){
|
||||
case TreeType::OAK()->id():
|
||||
return new BlockIdentifier(Ids::WOODEN_BUTTON, 0);
|
||||
case TreeType::SPRUCE()->id():
|
||||
return new BlockIdentifier(Ids::SPRUCE_BUTTON, 0);
|
||||
case TreeType::BIRCH()->id():
|
||||
return new BlockIdentifier(Ids::BIRCH_BUTTON, 0);
|
||||
case TreeType::JUNGLE()->id():
|
||||
return new BlockIdentifier(Ids::JUNGLE_BUTTON, 0);
|
||||
case TreeType::ACACIA()->id():
|
||||
return new BlockIdentifier(Ids::ACACIA_BUTTON, 0);
|
||||
case TreeType::DARK_OAK()->id():
|
||||
return new BlockIdentifier(Ids::DARK_OAK_BUTTON, 0);
|
||||
}
|
||||
throw new AssumptionFailedError("Switch should cover all wood types");
|
||||
public static function getWoodenPressurePlateIdentifier(WoodType $treeType) : BlockIdentifier{
|
||||
return new BID(match($treeType->id()){
|
||||
WoodType::OAK()->id() => Ids::OAK_PRESSURE_PLATE,
|
||||
WoodType::SPRUCE()->id() => Ids::SPRUCE_PRESSURE_PLATE,
|
||||
WoodType::BIRCH()->id() => Ids::BIRCH_PRESSURE_PLATE,
|
||||
WoodType::JUNGLE()->id() => Ids::JUNGLE_PRESSURE_PLATE,
|
||||
WoodType::ACACIA()->id() => Ids::ACACIA_PRESSURE_PLATE,
|
||||
WoodType::DARK_OAK()->id() => Ids::DARK_OAK_PRESSURE_PLATE,
|
||||
WoodType::MANGROVE()->id() => Ids::MANGROVE_PRESSURE_PLATE,
|
||||
WoodType::CRIMSON()->id() => Ids::CRIMSON_PRESSURE_PLATE,
|
||||
WoodType::WARPED()->id() => Ids::WARPED_PRESSURE_PLATE,
|
||||
default => throw new AssumptionFailedError("All wood types should be covered")
|
||||
});
|
||||
}
|
||||
|
||||
public static function getWoodenPressurePlateIdentifier(TreeType $treeType) : BlockIdentifier{
|
||||
switch($treeType->id()){
|
||||
case TreeType::OAK()->id():
|
||||
return new BlockIdentifier(Ids::WOODEN_PRESSURE_PLATE, 0);
|
||||
case TreeType::SPRUCE()->id():
|
||||
return new BlockIdentifier(Ids::SPRUCE_PRESSURE_PLATE, 0);
|
||||
case TreeType::BIRCH()->id():
|
||||
return new BlockIdentifier(Ids::BIRCH_PRESSURE_PLATE, 0);
|
||||
case TreeType::JUNGLE()->id():
|
||||
return new BlockIdentifier(Ids::JUNGLE_PRESSURE_PLATE, 0);
|
||||
case TreeType::ACACIA()->id():
|
||||
return new BlockIdentifier(Ids::ACACIA_PRESSURE_PLATE, 0);
|
||||
case TreeType::DARK_OAK()->id():
|
||||
return new BlockIdentifier(Ids::DARK_OAK_PRESSURE_PLATE, 0);
|
||||
}
|
||||
throw new AssumptionFailedError("Switch should cover all wood types");
|
||||
public static function getWoodenDoorIdentifier(WoodType $treeType) : BlockIdentifier{
|
||||
return new BID(match($treeType->id()){
|
||||
WoodType::OAK()->id() => Ids::OAK_DOOR,
|
||||
WoodType::SPRUCE()->id() => Ids::SPRUCE_DOOR,
|
||||
WoodType::BIRCH()->id() => Ids::BIRCH_DOOR,
|
||||
WoodType::JUNGLE()->id() => Ids::JUNGLE_DOOR,
|
||||
WoodType::ACACIA()->id() => Ids::ACACIA_DOOR,
|
||||
WoodType::DARK_OAK()->id() => Ids::DARK_OAK_DOOR,
|
||||
WoodType::MANGROVE()->id() => Ids::MANGROVE_DOOR,
|
||||
WoodType::CRIMSON()->id() => Ids::CRIMSON_DOOR,
|
||||
WoodType::WARPED()->id() => Ids::WARPED_DOOR,
|
||||
default => throw new AssumptionFailedError("All wood types should be covered")
|
||||
});
|
||||
}
|
||||
|
||||
public static function getWoodenDoorIdentifier(TreeType $treeType) : BlockIdentifier{
|
||||
switch($treeType->id()){
|
||||
case TreeType::OAK()->id():
|
||||
return new BID(Ids::OAK_DOOR_BLOCK, 0, ItemIds::OAK_DOOR);
|
||||
case TreeType::SPRUCE()->id():
|
||||
return new BID(Ids::SPRUCE_DOOR_BLOCK, 0, ItemIds::SPRUCE_DOOR);
|
||||
case TreeType::BIRCH()->id():
|
||||
return new BID(Ids::BIRCH_DOOR_BLOCK, 0, ItemIds::BIRCH_DOOR);
|
||||
case TreeType::JUNGLE()->id():
|
||||
return new BID(Ids::JUNGLE_DOOR_BLOCK, 0, ItemIds::JUNGLE_DOOR);
|
||||
case TreeType::ACACIA()->id():
|
||||
return new BID(Ids::ACACIA_DOOR_BLOCK, 0, ItemIds::ACACIA_DOOR);
|
||||
case TreeType::DARK_OAK()->id():
|
||||
return new BID(Ids::DARK_OAK_DOOR_BLOCK, 0, ItemIds::DARK_OAK_DOOR);
|
||||
}
|
||||
throw new AssumptionFailedError("Switch should cover all wood types");
|
||||
public static function getWoodenFenceGateIdentifier(WoodType $treeType) : BlockIdentifier{
|
||||
return new BID(match($treeType->id()){
|
||||
WoodType::OAK()->id() => Ids::OAK_FENCE_GATE,
|
||||
WoodType::SPRUCE()->id() => Ids::SPRUCE_FENCE_GATE,
|
||||
WoodType::BIRCH()->id() => Ids::BIRCH_FENCE_GATE,
|
||||
WoodType::JUNGLE()->id() => Ids::JUNGLE_FENCE_GATE,
|
||||
WoodType::ACACIA()->id() => Ids::ACACIA_FENCE_GATE,
|
||||
WoodType::DARK_OAK()->id() => Ids::DARK_OAK_FENCE_GATE,
|
||||
WoodType::MANGROVE()->id() => Ids::MANGROVE_FENCE_GATE,
|
||||
WoodType::CRIMSON()->id() => Ids::CRIMSON_FENCE_GATE,
|
||||
WoodType::WARPED()->id() => Ids::WARPED_FENCE_GATE,
|
||||
default => throw new AssumptionFailedError("All wood types should be covered")
|
||||
});
|
||||
}
|
||||
|
||||
public static function getWoodenFenceIdentifier(TreeType $treeType) : BlockIdentifier{
|
||||
switch($treeType->id()){
|
||||
case TreeType::OAK()->id():
|
||||
return new BlockIdentifier(Ids::OAK_FENCE_GATE, 0);
|
||||
case TreeType::SPRUCE()->id():
|
||||
return new BlockIdentifier(Ids::SPRUCE_FENCE_GATE, 0);
|
||||
case TreeType::BIRCH()->id():
|
||||
return new BlockIdentifier(Ids::BIRCH_FENCE_GATE, 0);
|
||||
case TreeType::JUNGLE()->id():
|
||||
return new BlockIdentifier(Ids::JUNGLE_FENCE_GATE, 0);
|
||||
case TreeType::ACACIA()->id():
|
||||
return new BlockIdentifier(Ids::ACACIA_FENCE_GATE, 0);
|
||||
case TreeType::DARK_OAK()->id():
|
||||
return new BlockIdentifier(Ids::DARK_OAK_FENCE_GATE, 0);
|
||||
}
|
||||
throw new AssumptionFailedError("Switch should cover all wood types");
|
||||
}
|
||||
|
||||
public static function getWoodenStairsIdentifier(TreeType $treeType) : BlockIdentifier{
|
||||
switch($treeType->id()){
|
||||
case TreeType::OAK()->id():
|
||||
return new BlockIdentifier(Ids::OAK_STAIRS, 0);
|
||||
case TreeType::SPRUCE()->id():
|
||||
return new BlockIdentifier(Ids::SPRUCE_STAIRS, 0);
|
||||
case TreeType::BIRCH()->id():
|
||||
return new BlockIdentifier(Ids::BIRCH_STAIRS, 0);
|
||||
case TreeType::JUNGLE()->id():
|
||||
return new BlockIdentifier(Ids::JUNGLE_STAIRS, 0);
|
||||
case TreeType::ACACIA()->id():
|
||||
return new BlockIdentifier(Ids::ACACIA_STAIRS, 0);
|
||||
case TreeType::DARK_OAK()->id():
|
||||
return new BlockIdentifier(Ids::DARK_OAK_STAIRS, 0);
|
||||
}
|
||||
throw new AssumptionFailedError("Switch should cover all wood types");
|
||||
}
|
||||
|
||||
public static function getStrippedLogIdentifier(TreeType $treeType) : BlockIdentifier{
|
||||
switch($treeType->id()){
|
||||
case TreeType::OAK()->id():
|
||||
return new BlockIdentifier(Ids::STRIPPED_OAK_LOG, 0);
|
||||
case TreeType::SPRUCE()->id():
|
||||
return new BlockIdentifier(Ids::STRIPPED_SPRUCE_LOG, 0);
|
||||
case TreeType::BIRCH()->id():
|
||||
return new BlockIdentifier(Ids::STRIPPED_BIRCH_LOG, 0);
|
||||
case TreeType::JUNGLE()->id():
|
||||
return new BlockIdentifier(Ids::STRIPPED_JUNGLE_LOG, 0);
|
||||
case TreeType::ACACIA()->id():
|
||||
return new BlockIdentifier(Ids::STRIPPED_ACACIA_LOG, 0);
|
||||
case TreeType::DARK_OAK()->id():
|
||||
return new BlockIdentifier(Ids::STRIPPED_DARK_OAK_LOG, 0);
|
||||
}
|
||||
throw new AssumptionFailedError("Switch should cover all wood types");
|
||||
}
|
||||
|
||||
public static function getGlazedTerracottaIdentifier(DyeColor $color) : BlockIdentifier{
|
||||
switch($color->id()){
|
||||
case DyeColor::WHITE()->id():
|
||||
return new BlockIdentifier(Ids::WHITE_GLAZED_TERRACOTTA, 0);
|
||||
case DyeColor::ORANGE()->id():
|
||||
return new BlockIdentifier(Ids::ORANGE_GLAZED_TERRACOTTA, 0);
|
||||
case DyeColor::MAGENTA()->id():
|
||||
return new BlockIdentifier(Ids::MAGENTA_GLAZED_TERRACOTTA, 0);
|
||||
case DyeColor::LIGHT_BLUE()->id():
|
||||
return new BlockIdentifier(Ids::LIGHT_BLUE_GLAZED_TERRACOTTA, 0);
|
||||
case DyeColor::YELLOW()->id():
|
||||
return new BlockIdentifier(Ids::YELLOW_GLAZED_TERRACOTTA, 0);
|
||||
case DyeColor::LIME()->id():
|
||||
return new BlockIdentifier(Ids::LIME_GLAZED_TERRACOTTA, 0);
|
||||
case DyeColor::PINK()->id():
|
||||
return new BlockIdentifier(Ids::PINK_GLAZED_TERRACOTTA, 0);
|
||||
case DyeColor::GRAY()->id():
|
||||
return new BlockIdentifier(Ids::GRAY_GLAZED_TERRACOTTA, 0);
|
||||
case DyeColor::LIGHT_GRAY()->id():
|
||||
return new BlockIdentifier(Ids::SILVER_GLAZED_TERRACOTTA, 0);
|
||||
case DyeColor::CYAN()->id():
|
||||
return new BlockIdentifier(Ids::CYAN_GLAZED_TERRACOTTA, 0);
|
||||
case DyeColor::PURPLE()->id():
|
||||
return new BlockIdentifier(Ids::PURPLE_GLAZED_TERRACOTTA, 0);
|
||||
case DyeColor::BLUE()->id():
|
||||
return new BlockIdentifier(Ids::BLUE_GLAZED_TERRACOTTA, 0);
|
||||
case DyeColor::BROWN()->id():
|
||||
return new BlockIdentifier(Ids::BROWN_GLAZED_TERRACOTTA, 0);
|
||||
case DyeColor::GREEN()->id():
|
||||
return new BlockIdentifier(Ids::GREEN_GLAZED_TERRACOTTA, 0);
|
||||
case DyeColor::RED()->id():
|
||||
return new BlockIdentifier(Ids::RED_GLAZED_TERRACOTTA, 0);
|
||||
case DyeColor::BLACK()->id():
|
||||
return new BlockIdentifier(Ids::BLACK_GLAZED_TERRACOTTA, 0);
|
||||
}
|
||||
throw new AssumptionFailedError("Switch should cover all colours");
|
||||
}
|
||||
|
||||
public static function getStoneSlabIdentifier(int $stoneSlabId, int $meta) : BlockIdentifierFlattened{
|
||||
$id = [
|
||||
1 => [Ids::STONE_SLAB, Ids::DOUBLE_STONE_SLAB],
|
||||
2 => [Ids::STONE_SLAB2, Ids::DOUBLE_STONE_SLAB2],
|
||||
3 => [Ids::STONE_SLAB3, Ids::DOUBLE_STONE_SLAB3],
|
||||
4 => [Ids::STONE_SLAB4, Ids::DOUBLE_STONE_SLAB4]
|
||||
][$stoneSlabId] ?? null;
|
||||
if($id === null){
|
||||
throw new \InvalidArgumentException("Stone slab type should be 1, 2, 3 or 4");
|
||||
}
|
||||
return new BlockIdentifierFlattened($id[0], [$id[1]], $meta);
|
||||
public static function getWoodenStairsIdentifier(WoodType $treeType) : BlockIdentifier{
|
||||
return new BID(match($treeType->id()){
|
||||
WoodType::OAK()->id() => Ids::OAK_STAIRS,
|
||||
WoodType::SPRUCE()->id() => Ids::SPRUCE_STAIRS,
|
||||
WoodType::BIRCH()->id() => Ids::BIRCH_STAIRS,
|
||||
WoodType::JUNGLE()->id() => Ids::JUNGLE_STAIRS,
|
||||
WoodType::ACACIA()->id() => Ids::ACACIA_STAIRS,
|
||||
WoodType::DARK_OAK()->id() => Ids::DARK_OAK_STAIRS,
|
||||
WoodType::MANGROVE()->id() => Ids::MANGROVE_STAIRS,
|
||||
WoodType::CRIMSON()->id() => Ids::CRIMSON_STAIRS,
|
||||
WoodType::WARPED()->id() => Ids::WARPED_STAIRS,
|
||||
default => throw new AssumptionFailedError("All wood types should be covered")
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,501 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
final class BlockLegacyIds{
|
||||
|
||||
private function __construct(){
|
||||
//NOOP
|
||||
}
|
||||
|
||||
public const AIR = 0;
|
||||
public const STONE = 1;
|
||||
public const GRASS = 2;
|
||||
public const DIRT = 3;
|
||||
public const COBBLESTONE = 4;
|
||||
public const PLANKS = 5, WOODEN_PLANKS = 5;
|
||||
public const SAPLING = 6;
|
||||
public const BEDROCK = 7;
|
||||
public const FLOWING_WATER = 8;
|
||||
public const STILL_WATER = 9, WATER = 9;
|
||||
public const FLOWING_LAVA = 10;
|
||||
public const LAVA = 11, STILL_LAVA = 11;
|
||||
public const SAND = 12;
|
||||
public const GRAVEL = 13;
|
||||
public const GOLD_ORE = 14;
|
||||
public const IRON_ORE = 15;
|
||||
public const COAL_ORE = 16;
|
||||
public const LOG = 17;
|
||||
public const LEAVES = 18;
|
||||
public const SPONGE = 19;
|
||||
public const GLASS = 20;
|
||||
public const LAPIS_ORE = 21;
|
||||
public const LAPIS_BLOCK = 22;
|
||||
public const DISPENSER = 23;
|
||||
public const SANDSTONE = 24;
|
||||
public const NOTEBLOCK = 25, NOTE_BLOCK = 25;
|
||||
public const BED_BLOCK = 26;
|
||||
public const GOLDEN_RAIL = 27, POWERED_RAIL = 27;
|
||||
public const DETECTOR_RAIL = 28;
|
||||
public const STICKY_PISTON = 29;
|
||||
public const COBWEB = 30, WEB = 30;
|
||||
public const TALLGRASS = 31, TALL_GRASS = 31;
|
||||
public const DEADBUSH = 32, DEAD_BUSH = 32;
|
||||
public const PISTON = 33;
|
||||
public const PISTONARMCOLLISION = 34, PISTON_ARM_COLLISION = 34;
|
||||
public const WOOL = 35;
|
||||
public const ELEMENT_0 = 36;
|
||||
public const DANDELION = 37, YELLOW_FLOWER = 37;
|
||||
public const POPPY = 38, RED_FLOWER = 38;
|
||||
public const BROWN_MUSHROOM = 39;
|
||||
public const RED_MUSHROOM = 40;
|
||||
public const GOLD_BLOCK = 41;
|
||||
public const IRON_BLOCK = 42;
|
||||
public const DOUBLE_STONE_SLAB = 43;
|
||||
public const STONE_SLAB = 44;
|
||||
public const BRICK_BLOCK = 45;
|
||||
public const TNT = 46;
|
||||
public const BOOKSHELF = 47;
|
||||
public const MOSSY_COBBLESTONE = 48, MOSS_STONE = 48;
|
||||
public const OBSIDIAN = 49;
|
||||
public const TORCH = 50;
|
||||
public const FIRE = 51;
|
||||
public const MOB_SPAWNER = 52, MONSTER_SPAWNER = 52;
|
||||
public const OAK_STAIRS = 53, WOODEN_STAIRS = 53;
|
||||
public const CHEST = 54;
|
||||
public const REDSTONE_WIRE = 55;
|
||||
public const DIAMOND_ORE = 56;
|
||||
public const DIAMOND_BLOCK = 57;
|
||||
public const CRAFTING_TABLE = 58, WORKBENCH = 58;
|
||||
public const WHEAT_BLOCK = 59;
|
||||
public const FARMLAND = 60;
|
||||
public const FURNACE = 61;
|
||||
public const BURNING_FURNACE = 62, LIT_FURNACE = 62;
|
||||
public const SIGN_POST = 63, STANDING_SIGN = 63;
|
||||
public const OAK_DOOR_BLOCK = 64, WOODEN_DOOR_BLOCK = 64;
|
||||
public const LADDER = 65;
|
||||
public const RAIL = 66;
|
||||
public const COBBLESTONE_STAIRS = 67, STONE_STAIRS = 67;
|
||||
public const WALL_SIGN = 68;
|
||||
public const LEVER = 69;
|
||||
public const STONE_PRESSURE_PLATE = 70;
|
||||
public const IRON_DOOR_BLOCK = 71;
|
||||
public const WOODEN_PRESSURE_PLATE = 72;
|
||||
public const REDSTONE_ORE = 73;
|
||||
public const GLOWING_REDSTONE_ORE = 74, LIT_REDSTONE_ORE = 74;
|
||||
public const UNLIT_REDSTONE_TORCH = 75;
|
||||
public const LIT_REDSTONE_TORCH = 76, REDSTONE_TORCH = 76;
|
||||
public const STONE_BUTTON = 77;
|
||||
public const SNOW_LAYER = 78;
|
||||
public const ICE = 79;
|
||||
public const SNOW = 80, SNOW_BLOCK = 80;
|
||||
public const CACTUS = 81;
|
||||
public const CLAY_BLOCK = 82;
|
||||
public const REEDS_BLOCK = 83, SUGARCANE_BLOCK = 83;
|
||||
public const JUKEBOX = 84;
|
||||
public const FENCE = 85;
|
||||
public const PUMPKIN = 86;
|
||||
public const NETHERRACK = 87;
|
||||
public const SOUL_SAND = 88;
|
||||
public const GLOWSTONE = 89;
|
||||
public const PORTAL = 90;
|
||||
public const JACK_O_LANTERN = 91, LIT_PUMPKIN = 91;
|
||||
public const CAKE_BLOCK = 92;
|
||||
public const REPEATER_BLOCK = 93, UNPOWERED_REPEATER = 93;
|
||||
public const POWERED_REPEATER = 94;
|
||||
public const INVISIBLEBEDROCK = 95, INVISIBLE_BEDROCK = 95;
|
||||
public const TRAPDOOR = 96, WOODEN_TRAPDOOR = 96;
|
||||
public const MONSTER_EGG = 97;
|
||||
public const STONEBRICK = 98, STONE_BRICK = 98, STONE_BRICKS = 98;
|
||||
public const BROWN_MUSHROOM_BLOCK = 99;
|
||||
public const RED_MUSHROOM_BLOCK = 100;
|
||||
public const IRON_BARS = 101;
|
||||
public const GLASS_PANE = 102;
|
||||
public const MELON_BLOCK = 103;
|
||||
public const PUMPKIN_STEM = 104;
|
||||
public const MELON_STEM = 105;
|
||||
public const VINE = 106, VINES = 106;
|
||||
public const FENCE_GATE = 107, OAK_FENCE_GATE = 107;
|
||||
public const BRICK_STAIRS = 108;
|
||||
public const STONE_BRICK_STAIRS = 109;
|
||||
public const MYCELIUM = 110;
|
||||
public const LILY_PAD = 111, WATERLILY = 111, WATER_LILY = 111;
|
||||
public const NETHER_BRICK_BLOCK = 112;
|
||||
public const NETHER_BRICK_FENCE = 113;
|
||||
public const NETHER_BRICK_STAIRS = 114;
|
||||
public const NETHER_WART_PLANT = 115;
|
||||
public const ENCHANTING_TABLE = 116, ENCHANTMENT_TABLE = 116;
|
||||
public const BREWING_STAND_BLOCK = 117;
|
||||
public const CAULDRON_BLOCK = 118;
|
||||
public const END_PORTAL = 119;
|
||||
public const END_PORTAL_FRAME = 120;
|
||||
public const END_STONE = 121;
|
||||
public const DRAGON_EGG = 122;
|
||||
public const REDSTONE_LAMP = 123;
|
||||
public const LIT_REDSTONE_LAMP = 124;
|
||||
public const DROPPER = 125;
|
||||
public const ACTIVATOR_RAIL = 126;
|
||||
public const COCOA = 127, COCOA_BLOCK = 127;
|
||||
public const SANDSTONE_STAIRS = 128;
|
||||
public const EMERALD_ORE = 129;
|
||||
public const ENDER_CHEST = 130;
|
||||
public const TRIPWIRE_HOOK = 131;
|
||||
public const TRIPWIRE = 132, TRIP_WIRE = 132;
|
||||
public const EMERALD_BLOCK = 133;
|
||||
public const SPRUCE_STAIRS = 134;
|
||||
public const BIRCH_STAIRS = 135;
|
||||
public const JUNGLE_STAIRS = 136;
|
||||
public const COMMAND_BLOCK = 137;
|
||||
public const BEACON = 138;
|
||||
public const COBBLESTONE_WALL = 139, STONE_WALL = 139;
|
||||
public const FLOWER_POT_BLOCK = 140;
|
||||
public const CARROTS = 141, CARROT_BLOCK = 141;
|
||||
public const POTATOES = 142, POTATO_BLOCK = 142;
|
||||
public const WOODEN_BUTTON = 143;
|
||||
public const MOB_HEAD_BLOCK = 144, SKULL_BLOCK = 144;
|
||||
public const ANVIL = 145;
|
||||
public const TRAPPED_CHEST = 146;
|
||||
public const LIGHT_WEIGHTED_PRESSURE_PLATE = 147;
|
||||
public const HEAVY_WEIGHTED_PRESSURE_PLATE = 148;
|
||||
public const COMPARATOR_BLOCK = 149, UNPOWERED_COMPARATOR = 149;
|
||||
public const POWERED_COMPARATOR = 150;
|
||||
public const DAYLIGHT_DETECTOR = 151, DAYLIGHT_SENSOR = 151;
|
||||
public const REDSTONE_BLOCK = 152;
|
||||
public const NETHER_QUARTZ_ORE = 153, QUARTZ_ORE = 153;
|
||||
public const HOPPER_BLOCK = 154;
|
||||
public const QUARTZ_BLOCK = 155;
|
||||
public const QUARTZ_STAIRS = 156;
|
||||
public const DOUBLE_WOODEN_SLAB = 157;
|
||||
public const WOODEN_SLAB = 158;
|
||||
public const STAINED_CLAY = 159, STAINED_HARDENED_CLAY = 159, TERRACOTTA = 159;
|
||||
public const STAINED_GLASS_PANE = 160;
|
||||
public const LEAVES2 = 161;
|
||||
public const LOG2 = 162;
|
||||
public const ACACIA_STAIRS = 163;
|
||||
public const DARK_OAK_STAIRS = 164;
|
||||
public const SLIME = 165, SLIME_BLOCK = 165;
|
||||
public const GLOW_STICK = 166;
|
||||
public const IRON_TRAPDOOR = 167;
|
||||
public const PRISMARINE = 168;
|
||||
public const SEALANTERN = 169, SEA_LANTERN = 169;
|
||||
public const HAY_BALE = 170, HAY_BLOCK = 170;
|
||||
public const CARPET = 171;
|
||||
public const HARDENED_CLAY = 172;
|
||||
public const COAL_BLOCK = 173;
|
||||
public const PACKED_ICE = 174;
|
||||
public const DOUBLE_PLANT = 175;
|
||||
public const STANDING_BANNER = 176;
|
||||
public const WALL_BANNER = 177;
|
||||
public const DAYLIGHT_DETECTOR_INVERTED = 178, DAYLIGHT_SENSOR_INVERTED = 178;
|
||||
public const RED_SANDSTONE = 179;
|
||||
public const RED_SANDSTONE_STAIRS = 180;
|
||||
public const DOUBLE_STONE_SLAB2 = 181;
|
||||
public const STONE_SLAB2 = 182;
|
||||
public const SPRUCE_FENCE_GATE = 183;
|
||||
public const BIRCH_FENCE_GATE = 184;
|
||||
public const JUNGLE_FENCE_GATE = 185;
|
||||
public const DARK_OAK_FENCE_GATE = 186;
|
||||
public const ACACIA_FENCE_GATE = 187;
|
||||
public const REPEATING_COMMAND_BLOCK = 188;
|
||||
public const CHAIN_COMMAND_BLOCK = 189;
|
||||
public const HARD_GLASS_PANE = 190;
|
||||
public const HARD_STAINED_GLASS_PANE = 191;
|
||||
public const CHEMICAL_HEAT = 192;
|
||||
public const SPRUCE_DOOR_BLOCK = 193;
|
||||
public const BIRCH_DOOR_BLOCK = 194;
|
||||
public const JUNGLE_DOOR_BLOCK = 195;
|
||||
public const ACACIA_DOOR_BLOCK = 196;
|
||||
public const DARK_OAK_DOOR_BLOCK = 197;
|
||||
public const GRASS_PATH = 198;
|
||||
public const FRAME_BLOCK = 199, ITEM_FRAME_BLOCK = 199;
|
||||
public const CHORUS_FLOWER = 200;
|
||||
public const PURPUR_BLOCK = 201;
|
||||
public const COLORED_TORCH_RG = 202;
|
||||
public const PURPUR_STAIRS = 203;
|
||||
public const COLORED_TORCH_BP = 204;
|
||||
public const UNDYED_SHULKER_BOX = 205;
|
||||
public const END_BRICKS = 206;
|
||||
public const FROSTED_ICE = 207;
|
||||
public const END_ROD = 208;
|
||||
public const END_GATEWAY = 209;
|
||||
|
||||
public const MAGMA = 213;
|
||||
public const NETHER_WART_BLOCK = 214;
|
||||
public const RED_NETHER_BRICK = 215;
|
||||
public const BONE_BLOCK = 216;
|
||||
|
||||
public const SHULKER_BOX = 218;
|
||||
public const PURPLE_GLAZED_TERRACOTTA = 219;
|
||||
public const WHITE_GLAZED_TERRACOTTA = 220;
|
||||
public const ORANGE_GLAZED_TERRACOTTA = 221;
|
||||
public const MAGENTA_GLAZED_TERRACOTTA = 222;
|
||||
public const LIGHT_BLUE_GLAZED_TERRACOTTA = 223;
|
||||
public const YELLOW_GLAZED_TERRACOTTA = 224;
|
||||
public const LIME_GLAZED_TERRACOTTA = 225;
|
||||
public const PINK_GLAZED_TERRACOTTA = 226;
|
||||
public const GRAY_GLAZED_TERRACOTTA = 227;
|
||||
public const SILVER_GLAZED_TERRACOTTA = 228;
|
||||
public const CYAN_GLAZED_TERRACOTTA = 229;
|
||||
|
||||
public const BLUE_GLAZED_TERRACOTTA = 231;
|
||||
public const BROWN_GLAZED_TERRACOTTA = 232;
|
||||
public const GREEN_GLAZED_TERRACOTTA = 233;
|
||||
public const RED_GLAZED_TERRACOTTA = 234;
|
||||
public const BLACK_GLAZED_TERRACOTTA = 235;
|
||||
public const CONCRETE = 236;
|
||||
public const CONCRETEPOWDER = 237, CONCRETE_POWDER = 237;
|
||||
public const CHEMISTRY_TABLE = 238;
|
||||
public const UNDERWATER_TORCH = 239;
|
||||
public const CHORUS_PLANT = 240;
|
||||
public const STAINED_GLASS = 241;
|
||||
|
||||
public const PODZOL = 243;
|
||||
public const BEETROOT_BLOCK = 244;
|
||||
public const STONECUTTER = 245;
|
||||
public const GLOWINGOBSIDIAN = 246, GLOWING_OBSIDIAN = 246;
|
||||
public const NETHERREACTOR = 247, NETHER_REACTOR = 247;
|
||||
public const INFO_UPDATE = 248;
|
||||
public const INFO_UPDATE2 = 249;
|
||||
public const MOVINGBLOCK = 250, MOVING_BLOCK = 250;
|
||||
public const OBSERVER = 251;
|
||||
public const STRUCTURE_BLOCK = 252;
|
||||
public const HARD_GLASS = 253;
|
||||
public const HARD_STAINED_GLASS = 254;
|
||||
public const RESERVED6 = 255;
|
||||
|
||||
public const PRISMARINE_STAIRS = 257;
|
||||
public const DARK_PRISMARINE_STAIRS = 258;
|
||||
public const PRISMARINE_BRICKS_STAIRS = 259;
|
||||
public const STRIPPED_SPRUCE_LOG = 260;
|
||||
public const STRIPPED_BIRCH_LOG = 261;
|
||||
public const STRIPPED_JUNGLE_LOG = 262;
|
||||
public const STRIPPED_ACACIA_LOG = 263;
|
||||
public const STRIPPED_DARK_OAK_LOG = 264;
|
||||
public const STRIPPED_OAK_LOG = 265;
|
||||
public const BLUE_ICE = 266;
|
||||
public const ELEMENT_1 = 267;
|
||||
public const ELEMENT_2 = 268;
|
||||
public const ELEMENT_3 = 269;
|
||||
public const ELEMENT_4 = 270;
|
||||
public const ELEMENT_5 = 271;
|
||||
public const ELEMENT_6 = 272;
|
||||
public const ELEMENT_7 = 273;
|
||||
public const ELEMENT_8 = 274;
|
||||
public const ELEMENT_9 = 275;
|
||||
public const ELEMENT_10 = 276;
|
||||
public const ELEMENT_11 = 277;
|
||||
public const ELEMENT_12 = 278;
|
||||
public const ELEMENT_13 = 279;
|
||||
public const ELEMENT_14 = 280;
|
||||
public const ELEMENT_15 = 281;
|
||||
public const ELEMENT_16 = 282;
|
||||
public const ELEMENT_17 = 283;
|
||||
public const ELEMENT_18 = 284;
|
||||
public const ELEMENT_19 = 285;
|
||||
public const ELEMENT_20 = 286;
|
||||
public const ELEMENT_21 = 287;
|
||||
public const ELEMENT_22 = 288;
|
||||
public const ELEMENT_23 = 289;
|
||||
public const ELEMENT_24 = 290;
|
||||
public const ELEMENT_25 = 291;
|
||||
public const ELEMENT_26 = 292;
|
||||
public const ELEMENT_27 = 293;
|
||||
public const ELEMENT_28 = 294;
|
||||
public const ELEMENT_29 = 295;
|
||||
public const ELEMENT_30 = 296;
|
||||
public const ELEMENT_31 = 297;
|
||||
public const ELEMENT_32 = 298;
|
||||
public const ELEMENT_33 = 299;
|
||||
public const ELEMENT_34 = 300;
|
||||
public const ELEMENT_35 = 301;
|
||||
public const ELEMENT_36 = 302;
|
||||
public const ELEMENT_37 = 303;
|
||||
public const ELEMENT_38 = 304;
|
||||
public const ELEMENT_39 = 305;
|
||||
public const ELEMENT_40 = 306;
|
||||
public const ELEMENT_41 = 307;
|
||||
public const ELEMENT_42 = 308;
|
||||
public const ELEMENT_43 = 309;
|
||||
public const ELEMENT_44 = 310;
|
||||
public const ELEMENT_45 = 311;
|
||||
public const ELEMENT_46 = 312;
|
||||
public const ELEMENT_47 = 313;
|
||||
public const ELEMENT_48 = 314;
|
||||
public const ELEMENT_49 = 315;
|
||||
public const ELEMENT_50 = 316;
|
||||
public const ELEMENT_51 = 317;
|
||||
public const ELEMENT_52 = 318;
|
||||
public const ELEMENT_53 = 319;
|
||||
public const ELEMENT_54 = 320;
|
||||
public const ELEMENT_55 = 321;
|
||||
public const ELEMENT_56 = 322;
|
||||
public const ELEMENT_57 = 323;
|
||||
public const ELEMENT_58 = 324;
|
||||
public const ELEMENT_59 = 325;
|
||||
public const ELEMENT_60 = 326;
|
||||
public const ELEMENT_61 = 327;
|
||||
public const ELEMENT_62 = 328;
|
||||
public const ELEMENT_63 = 329;
|
||||
public const ELEMENT_64 = 330;
|
||||
public const ELEMENT_65 = 331;
|
||||
public const ELEMENT_66 = 332;
|
||||
public const ELEMENT_67 = 333;
|
||||
public const ELEMENT_68 = 334;
|
||||
public const ELEMENT_69 = 335;
|
||||
public const ELEMENT_70 = 336;
|
||||
public const ELEMENT_71 = 337;
|
||||
public const ELEMENT_72 = 338;
|
||||
public const ELEMENT_73 = 339;
|
||||
public const ELEMENT_74 = 340;
|
||||
public const ELEMENT_75 = 341;
|
||||
public const ELEMENT_76 = 342;
|
||||
public const ELEMENT_77 = 343;
|
||||
public const ELEMENT_78 = 344;
|
||||
public const ELEMENT_79 = 345;
|
||||
public const ELEMENT_80 = 346;
|
||||
public const ELEMENT_81 = 347;
|
||||
public const ELEMENT_82 = 348;
|
||||
public const ELEMENT_83 = 349;
|
||||
public const ELEMENT_84 = 350;
|
||||
public const ELEMENT_85 = 351;
|
||||
public const ELEMENT_86 = 352;
|
||||
public const ELEMENT_87 = 353;
|
||||
public const ELEMENT_88 = 354;
|
||||
public const ELEMENT_89 = 355;
|
||||
public const ELEMENT_90 = 356;
|
||||
public const ELEMENT_91 = 357;
|
||||
public const ELEMENT_92 = 358;
|
||||
public const ELEMENT_93 = 359;
|
||||
public const ELEMENT_94 = 360;
|
||||
public const ELEMENT_95 = 361;
|
||||
public const ELEMENT_96 = 362;
|
||||
public const ELEMENT_97 = 363;
|
||||
public const ELEMENT_98 = 364;
|
||||
public const ELEMENT_99 = 365;
|
||||
public const ELEMENT_100 = 366;
|
||||
public const ELEMENT_101 = 367;
|
||||
public const ELEMENT_102 = 368;
|
||||
public const ELEMENT_103 = 369;
|
||||
public const ELEMENT_104 = 370;
|
||||
public const ELEMENT_105 = 371;
|
||||
public const ELEMENT_106 = 372;
|
||||
public const ELEMENT_107 = 373;
|
||||
public const ELEMENT_108 = 374;
|
||||
public const ELEMENT_109 = 375;
|
||||
public const ELEMENT_110 = 376;
|
||||
public const ELEMENT_111 = 377;
|
||||
public const ELEMENT_112 = 378;
|
||||
public const ELEMENT_113 = 379;
|
||||
public const ELEMENT_114 = 380;
|
||||
public const ELEMENT_115 = 381;
|
||||
public const ELEMENT_116 = 382;
|
||||
public const ELEMENT_117 = 383;
|
||||
public const ELEMENT_118 = 384;
|
||||
public const SEAGRASS = 385;
|
||||
public const CORAL = 386;
|
||||
public const CORAL_BLOCK = 387;
|
||||
public const CORAL_FAN = 388;
|
||||
public const CORAL_FAN_DEAD = 389;
|
||||
public const CORAL_FAN_HANG = 390;
|
||||
public const CORAL_FAN_HANG2 = 391;
|
||||
public const CORAL_FAN_HANG3 = 392;
|
||||
public const KELP = 393;
|
||||
public const DRIED_KELP_BLOCK = 394;
|
||||
public const ACACIA_BUTTON = 395;
|
||||
public const BIRCH_BUTTON = 396;
|
||||
public const DARK_OAK_BUTTON = 397;
|
||||
public const JUNGLE_BUTTON = 398;
|
||||
public const SPRUCE_BUTTON = 399;
|
||||
public const ACACIA_TRAPDOOR = 400;
|
||||
public const BIRCH_TRAPDOOR = 401;
|
||||
public const DARK_OAK_TRAPDOOR = 402;
|
||||
public const JUNGLE_TRAPDOOR = 403;
|
||||
public const SPRUCE_TRAPDOOR = 404;
|
||||
public const ACACIA_PRESSURE_PLATE = 405;
|
||||
public const BIRCH_PRESSURE_PLATE = 406;
|
||||
public const DARK_OAK_PRESSURE_PLATE = 407;
|
||||
public const JUNGLE_PRESSURE_PLATE = 408;
|
||||
public const SPRUCE_PRESSURE_PLATE = 409;
|
||||
public const CARVED_PUMPKIN = 410;
|
||||
public const SEA_PICKLE = 411;
|
||||
public const CONDUIT = 412;
|
||||
|
||||
public const TURTLE_EGG = 414;
|
||||
public const BUBBLE_COLUMN = 415;
|
||||
public const BARRIER = 416;
|
||||
public const STONE_SLAB3 = 417;
|
||||
public const BAMBOO = 418;
|
||||
public const BAMBOO_SAPLING = 419;
|
||||
public const SCAFFOLDING = 420;
|
||||
public const STONE_SLAB4 = 421;
|
||||
public const DOUBLE_STONE_SLAB3 = 422;
|
||||
public const DOUBLE_STONE_SLAB4 = 423;
|
||||
public const GRANITE_STAIRS = 424;
|
||||
public const DIORITE_STAIRS = 425;
|
||||
public const ANDESITE_STAIRS = 426;
|
||||
public const POLISHED_GRANITE_STAIRS = 427;
|
||||
public const POLISHED_DIORITE_STAIRS = 428;
|
||||
public const POLISHED_ANDESITE_STAIRS = 429;
|
||||
public const MOSSY_STONE_BRICK_STAIRS = 430;
|
||||
public const SMOOTH_RED_SANDSTONE_STAIRS = 431;
|
||||
public const SMOOTH_SANDSTONE_STAIRS = 432;
|
||||
public const END_BRICK_STAIRS = 433;
|
||||
public const MOSSY_COBBLESTONE_STAIRS = 434;
|
||||
public const NORMAL_STONE_STAIRS = 435;
|
||||
public const SPRUCE_STANDING_SIGN = 436;
|
||||
public const SPRUCE_WALL_SIGN = 437;
|
||||
public const SMOOTH_STONE = 438;
|
||||
public const RED_NETHER_BRICK_STAIRS = 439;
|
||||
public const SMOOTH_QUARTZ_STAIRS = 440;
|
||||
public const BIRCH_STANDING_SIGN = 441;
|
||||
public const BIRCH_WALL_SIGN = 442;
|
||||
public const JUNGLE_STANDING_SIGN = 443;
|
||||
public const JUNGLE_WALL_SIGN = 444;
|
||||
public const ACACIA_STANDING_SIGN = 445;
|
||||
public const ACACIA_WALL_SIGN = 446;
|
||||
public const DARKOAK_STANDING_SIGN = 447;
|
||||
public const DARKOAK_WALL_SIGN = 448;
|
||||
public const LECTERN = 449;
|
||||
public const GRINDSTONE = 450;
|
||||
public const BLAST_FURNACE = 451;
|
||||
public const STONECUTTER_BLOCK = 452;
|
||||
public const SMOKER = 453;
|
||||
public const LIT_SMOKER = 454;
|
||||
public const CARTOGRAPHY_TABLE = 455;
|
||||
public const FLETCHING_TABLE = 456;
|
||||
public const SMITHING_TABLE = 457;
|
||||
public const BARREL = 458;
|
||||
public const LOOM = 459;
|
||||
|
||||
public const BELL = 461;
|
||||
public const SWEET_BERRY_BUSH = 462;
|
||||
public const LANTERN = 463;
|
||||
public const CAMPFIRE = 464;
|
||||
public const LAVA_CAULDRON = 465;
|
||||
public const JIGSAW = 466;
|
||||
public const WOOD = 467;
|
||||
public const COMPOSTER = 468;
|
||||
public const LIT_BLAST_FURNACE = 469;
|
||||
|
||||
}
|
@ -1,303 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
/**
|
||||
* Constants for legacy metadata for various blocks.
|
||||
*/
|
||||
final class BlockLegacyMetadata{
|
||||
|
||||
private function __construct(){
|
||||
//NOOP
|
||||
}
|
||||
|
||||
public const ANVIL_NORMAL = 0;
|
||||
public const ANVIL_SLIGHTLY_DAMAGED = 4;
|
||||
public const ANVIL_VERY_DAMAGED = 8;
|
||||
|
||||
public const BAMBOO_FLAG_THICK = 0x01;
|
||||
public const BAMBOO_FLAG_READY = 0x08;
|
||||
|
||||
public const BAMBOO_LEAF_SIZE_SHIFT = 1;
|
||||
public const BAMBOO_LEAF_SIZE_MASK = 0x03;
|
||||
|
||||
public const BAMBOO_SAPLING_FLAG_READY = 0x01;
|
||||
|
||||
public const BARREL_FLAG_OPEN = 0x08;
|
||||
|
||||
public const BED_FLAG_HEAD = 0x08;
|
||||
public const BED_FLAG_OCCUPIED = 0x04;
|
||||
|
||||
public const BEDROCK_FLAG_INFINIBURN = 0x01;
|
||||
|
||||
public const BELL_ATTACHMENT_FLOOR = 0;
|
||||
public const BELL_ATTACHMENT_CEILING = 1;
|
||||
public const BELL_ATTACHMENT_ONE_WALL = 2;
|
||||
public const BELL_ATTACHMENT_TWO_WALLS = 3;
|
||||
|
||||
public const BREWING_STAND_FLAG_EAST = 0x01;
|
||||
public const BREWING_STAND_FLAG_SOUTHWEST = 0x02;
|
||||
public const BREWING_STAND_FLAG_NORTHWEST = 0x04;
|
||||
|
||||
public const BUTTON_FLAG_POWERED = 0x08;
|
||||
|
||||
public const CHEMISTRY_COMPOUND_CREATOR = 0;
|
||||
public const CHEMISTRY_MATERIAL_REDUCER = 4;
|
||||
public const CHEMISTRY_ELEMENT_CONSTRUCTOR = 8;
|
||||
public const CHEMISTRY_LAB_TABLE = 12;
|
||||
|
||||
public const COLORED_TORCH_BP_BLUE = 0;
|
||||
public const COLORED_TORCH_BP_PURPLE = 8;
|
||||
public const COLORED_TORCH_RG_RED = 0;
|
||||
public const COLORED_TORCH_RG_GREEN = 8;
|
||||
|
||||
public const CORAL_BLOCK_FLAG_DEAD = 0x8;
|
||||
|
||||
public const CORAL_FAN_EAST_WEST = 0;
|
||||
public const CORAL_FAN_NORTH_SOUTH = 1;
|
||||
public const CORAL_FAN_TYPE_MASK = 0x7;
|
||||
|
||||
public const CORAL_FAN_HANG_FLAG_DEAD = 0x2;
|
||||
|
||||
public const CORAL_FAN_HANG_TUBE = 0;
|
||||
public const CORAL_FAN_HANG_BRAIN = 1;
|
||||
public const CORAL_FAN_HANG2_BUBBLE = 0;
|
||||
public const CORAL_FAN_HANG2_FIRE = 1;
|
||||
public const CORAL_FAN_HANG3_HORN = 0;
|
||||
public const CORAL_FAN_HANG_TYPE_MASK = 0x1;
|
||||
|
||||
public const CORAL_VARIANT_TUBE = 0;
|
||||
public const CORAL_VARIANT_BRAIN = 1;
|
||||
public const CORAL_VARIANT_BUBBLE = 2;
|
||||
public const CORAL_VARIANT_FIRE = 3;
|
||||
public const CORAL_VARIANT_HORN = 4;
|
||||
|
||||
public const DIRT_FLAG_COARSE = 0x1;
|
||||
|
||||
public const DOOR_FLAG_TOP = 0x08;
|
||||
public const DOOR_BOTTOM_FLAG_OPEN = 0x04;
|
||||
public const DOOR_TOP_FLAG_RIGHT = 0x01;
|
||||
public const DOOR_TOP_FLAG_POWERED = 0x02;
|
||||
|
||||
public const DOUBLE_PLANT_SUNFLOWER = 0;
|
||||
public const DOUBLE_PLANT_LILAC = 1;
|
||||
public const DOUBLE_PLANT_TALLGRASS = 2;
|
||||
public const DOUBLE_PLANT_LARGE_FERN = 3;
|
||||
public const DOUBLE_PLANT_ROSE_BUSH = 4;
|
||||
public const DOUBLE_PLANT_PEONY = 5;
|
||||
|
||||
public const DOUBLE_PLANT_FLAG_TOP = 0x08;
|
||||
|
||||
public const END_PORTAL_FRAME_FLAG_EYE = 0x04;
|
||||
|
||||
public const FENCE_GATE_FLAG_OPEN = 0x04;
|
||||
public const FENCE_GATE_FLAG_IN_WALL = 0x08;
|
||||
|
||||
public const FLOWER_POPPY = 0;
|
||||
public const FLOWER_BLUE_ORCHID = 1;
|
||||
public const FLOWER_ALLIUM = 2;
|
||||
public const FLOWER_AZURE_BLUET = 3;
|
||||
public const FLOWER_RED_TULIP = 4;
|
||||
public const FLOWER_ORANGE_TULIP = 5;
|
||||
public const FLOWER_WHITE_TULIP = 6;
|
||||
public const FLOWER_PINK_TULIP = 7;
|
||||
public const FLOWER_OXEYE_DAISY = 8;
|
||||
public const FLOWER_CORNFLOWER = 9;
|
||||
public const FLOWER_LILY_OF_THE_VALLEY = 10;
|
||||
|
||||
public const FLOWER_POT_FLAG_OCCUPIED = 0x01;
|
||||
|
||||
public const HOPPER_FLAG_POWERED = 0x08;
|
||||
|
||||
public const INFESTED_STONE = 0;
|
||||
public const INFESTED_COBBLESTONE = 1;
|
||||
public const INFESTED_STONE_BRICK = 2;
|
||||
public const INFESTED_STONE_BRICK_MOSSY = 3;
|
||||
public const INFESTED_STONE_BRICK_CRACKED = 4;
|
||||
public const INFESTED_STONE_BRICK_CHISELED = 5;
|
||||
|
||||
public const ITEM_FRAME_FLAG_HAS_MAP = 0x04;
|
||||
|
||||
public const LANTERN_FLAG_HANGING = 0x01;
|
||||
|
||||
public const LEAVES_FLAG_NO_DECAY = 0x04;
|
||||
public const LEAVES_FLAG_CHECK_DECAY = 0x08;
|
||||
|
||||
public const LECTERN_FLAG_POWERED = 0x04;
|
||||
|
||||
public const LEVER_FLAG_POWERED = 0x08;
|
||||
|
||||
public const LIQUID_FLAG_FALLING = 0x08;
|
||||
|
||||
public const MUSHROOM_BLOCK_ALL_PORES = 0;
|
||||
public const MUSHROOM_BLOCK_CAP_NORTHWEST_CORNER = 1;
|
||||
public const MUSHROOM_BLOCK_CAP_NORTH_SIDE = 2;
|
||||
public const MUSHROOM_BLOCK_CAP_NORTHEAST_CORNER = 3;
|
||||
public const MUSHROOM_BLOCK_CAP_WEST_SIDE = 4;
|
||||
public const MUSHROOM_BLOCK_CAP_TOP_ONLY = 5;
|
||||
public const MUSHROOM_BLOCK_CAP_EAST_SIDE = 6;
|
||||
public const MUSHROOM_BLOCK_CAP_SOUTHWEST_CORNER = 7;
|
||||
public const MUSHROOM_BLOCK_CAP_SOUTH_SIDE = 8;
|
||||
public const MUSHROOM_BLOCK_CAP_SOUTHEAST_CORNER = 9;
|
||||
public const MUSHROOM_BLOCK_STEM = 10;
|
||||
//11, 12 and 13 appear the same as 0
|
||||
public const MUSHROOM_BLOCK_ALL_CAP = 14;
|
||||
public const MUSHROOM_BLOCK_ALL_STEM = 15;
|
||||
|
||||
public const NETHER_PORTAL_AXIS_X = 1;
|
||||
public const NETHER_PORTAL_AXIS_Z = 2;
|
||||
|
||||
public const NETHER_REACTOR_INACTIVE = 0;
|
||||
public const NETHER_REACTOR_ACTIVE = 1;
|
||||
public const NETHER_REACTOR_USED = 2;
|
||||
|
||||
public const PRESSURE_PLATE_FLAG_POWERED = 0x01;
|
||||
|
||||
public const PRISMARINE_NORMAL = 0;
|
||||
public const PRISMARINE_DARK = 1;
|
||||
public const PRISMARINE_BRICKS = 2;
|
||||
|
||||
public const PURPUR_NORMAL = 0;
|
||||
public const PURPUR_PILLAR = 2;
|
||||
|
||||
public const QUARTZ_NORMAL = 0;
|
||||
public const QUARTZ_CHISELED = 1;
|
||||
public const QUARTZ_PILLAR = 2;
|
||||
public const QUARTZ_SMOOTH = 3;
|
||||
|
||||
public const RAIL_STRAIGHT_NORTH_SOUTH = 0;
|
||||
public const RAIL_STRAIGHT_EAST_WEST = 1;
|
||||
public const RAIL_ASCENDING_EAST = 2;
|
||||
public const RAIL_ASCENDING_WEST = 3;
|
||||
public const RAIL_ASCENDING_NORTH = 4;
|
||||
public const RAIL_ASCENDING_SOUTH = 5;
|
||||
public const RAIL_CURVE_SOUTHEAST = 6;
|
||||
public const RAIL_CURVE_SOUTHWEST = 7;
|
||||
public const RAIL_CURVE_NORTHWEST = 8;
|
||||
public const RAIL_CURVE_NORTHEAST = 9;
|
||||
|
||||
public const REDSTONE_COMPARATOR_FLAG_SUBTRACT = 0x04;
|
||||
public const REDSTONE_COMPARATOR_FLAG_POWERED = 0x08;
|
||||
|
||||
public const REDSTONE_RAIL_FLAG_POWERED = 0x08;
|
||||
|
||||
public const SANDSTONE_NORMAL = 0;
|
||||
public const SANDSTONE_CHISELED = 1;
|
||||
public const SANDSTONE_CUT = 2;
|
||||
public const SANDSTONE_SMOOTH = 3;
|
||||
|
||||
public const SAPLING_FLAG_READY = 0x08;
|
||||
|
||||
public const SEA_PICKLE_FLAG_NOT_UNDERWATER = 0x04;
|
||||
|
||||
public const SKULL_FLAG_NO_DROPS = 0x08;
|
||||
|
||||
public const SLAB_FLAG_UPPER = 0x08;
|
||||
|
||||
public const SPONGE_FLAG_WET = 0x01;
|
||||
|
||||
public const STAIR_FLAG_UPSIDE_DOWN = 0x04;
|
||||
|
||||
public const STONE_NORMAL = 0;
|
||||
public const STONE_GRANITE = 1;
|
||||
public const STONE_POLISHED_GRANITE = 2;
|
||||
public const STONE_DIORITE = 3;
|
||||
public const STONE_POLISHED_DIORITE = 4;
|
||||
public const STONE_ANDESITE = 5;
|
||||
public const STONE_POLISHED_ANDESITE = 6;
|
||||
|
||||
public const STONE_BRICK_NORMAL = 0;
|
||||
public const STONE_BRICK_MOSSY = 1;
|
||||
public const STONE_BRICK_CRACKED = 2;
|
||||
public const STONE_BRICK_CHISELED = 3;
|
||||
|
||||
public const STONE_SLAB_SMOOTH_STONE = 0;
|
||||
public const STONE_SLAB_SANDSTONE = 1;
|
||||
public const STONE_SLAB_FAKE_WOODEN = 2;
|
||||
public const STONE_SLAB_COBBLESTONE = 3;
|
||||
public const STONE_SLAB_BRICK = 4;
|
||||
public const STONE_SLAB_STONE_BRICK = 5;
|
||||
public const STONE_SLAB_QUARTZ = 6;
|
||||
public const STONE_SLAB_NETHER_BRICK = 7;
|
||||
public const STONE_SLAB2_RED_SANDSTONE = 0;
|
||||
public const STONE_SLAB2_PURPUR = 1;
|
||||
public const STONE_SLAB2_PRISMARINE = 2;
|
||||
public const STONE_SLAB2_DARK_PRISMARINE = 3;
|
||||
public const STONE_SLAB2_PRISMARINE_BRICKS = 4;
|
||||
public const STONE_SLAB2_MOSSY_COBBLESTONE = 5;
|
||||
public const STONE_SLAB2_SMOOTH_SANDSTONE = 6;
|
||||
public const STONE_SLAB2_RED_NETHER_BRICK = 7;
|
||||
public const STONE_SLAB3_END_STONE_BRICK = 0;
|
||||
public const STONE_SLAB3_SMOOTH_RED_SANDSTONE = 1;
|
||||
public const STONE_SLAB3_POLISHED_ANDESITE = 2;
|
||||
public const STONE_SLAB3_ANDESITE = 3;
|
||||
public const STONE_SLAB3_DIORITE = 4;
|
||||
public const STONE_SLAB3_POLISHED_DIORITE = 5;
|
||||
public const STONE_SLAB3_GRANITE = 6;
|
||||
public const STONE_SLAB3_POLISHED_GRANITE = 7;
|
||||
public const STONE_SLAB4_MOSSY_STONE_BRICK = 0;
|
||||
public const STONE_SLAB4_SMOOTH_QUARTZ = 1;
|
||||
public const STONE_SLAB4_STONE = 2;
|
||||
public const STONE_SLAB4_CUT_SANDSTONE = 3;
|
||||
public const STONE_SLAB4_CUT_RED_SANDSTONE = 4;
|
||||
|
||||
public const TALLGRASS_NORMAL = 1;
|
||||
public const TALLGRASS_FERN = 2;
|
||||
|
||||
public const TNT_FLAG_UNSTABLE = 0x01;
|
||||
public const TNT_FLAG_UNDERWATER = 0x02;
|
||||
|
||||
public const TRAPDOOR_FLAG_UPPER = 0x04;
|
||||
public const TRAPDOOR_FLAG_OPEN = 0x08;
|
||||
|
||||
public const TRIPWIRE_FLAG_TRIGGERED = 0x01;
|
||||
public const TRIPWIRE_FLAG_SUSPENDED = 0x02;
|
||||
public const TRIPWIRE_FLAG_CONNECTED = 0x04;
|
||||
public const TRIPWIRE_FLAG_DISARMED = 0x08;
|
||||
|
||||
public const TRIPWIRE_HOOK_FLAG_CONNECTED = 0x04;
|
||||
public const TRIPWIRE_HOOK_FLAG_POWERED = 0x08;
|
||||
|
||||
public const VINE_FLAG_SOUTH = 0x01;
|
||||
public const VINE_FLAG_WEST = 0x02;
|
||||
public const VINE_FLAG_NORTH = 0x04;
|
||||
public const VINE_FLAG_EAST = 0x08;
|
||||
|
||||
public const WALL_COBBLESTONE = 0;
|
||||
public const WALL_MOSSY_COBBLESTONE = 1;
|
||||
public const WALL_GRANITE = 2;
|
||||
public const WALL_DIORITE = 3;
|
||||
public const WALL_ANDESITE = 4;
|
||||
public const WALL_SANDSTONE = 5;
|
||||
public const WALL_BRICK = 6;
|
||||
public const WALL_STONE_BRICK = 7;
|
||||
public const WALL_MOSSY_STONE_BRICK = 8;
|
||||
public const WALL_NETHER_BRICK = 9;
|
||||
public const WALL_END_STONE_BRICK = 10;
|
||||
public const WALL_PRISMARINE = 11;
|
||||
public const WALL_RED_SANDSTONE = 12;
|
||||
public const WALL_RED_NETHER_BRICK = 13;
|
||||
|
||||
public const WOOD_FLAG_STRIPPED = 0x8;
|
||||
}
|
698
src/block/BlockTypeIds.php
Normal file
698
src/block/BlockTypeIds.php
Normal file
@ -0,0 +1,698 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
/**
|
||||
* Enum of all the block runtime IDs used by PocketMine-MP. These IDs are specific to PocketMine-MP and have no
|
||||
* relevance to any Minecraft vanilla things.
|
||||
*
|
||||
* WARNING: DO NOT STORE THESE IDS. They can and will change without warning.
|
||||
* They should ONLY be used to IDENTIFY blocks at runtime.
|
||||
*/
|
||||
final class BlockTypeIds{
|
||||
|
||||
private function __construct(){
|
||||
//NOOP
|
||||
}
|
||||
|
||||
public const AIR = 10000;
|
||||
|
||||
public const ACACIA_BUTTON = 10001;
|
||||
public const ACACIA_DOOR = 10002;
|
||||
public const ACACIA_FENCE = 10003;
|
||||
public const ACACIA_FENCE_GATE = 10004;
|
||||
public const ACACIA_LEAVES = 10005;
|
||||
public const ACACIA_LOG = 10006;
|
||||
public const ACACIA_PLANKS = 10007;
|
||||
public const ACACIA_PRESSURE_PLATE = 10008;
|
||||
public const ACACIA_SAPLING = 10009;
|
||||
public const ACACIA_SIGN = 10010;
|
||||
public const ACACIA_SLAB = 10011;
|
||||
public const ACACIA_STAIRS = 10012;
|
||||
public const ACACIA_TRAPDOOR = 10013;
|
||||
public const ACACIA_WALL_SIGN = 10014;
|
||||
public const ACACIA_WOOD = 10015;
|
||||
public const ACTIVATOR_RAIL = 10016;
|
||||
public const ALL_SIDED_MUSHROOM_STEM = 10017;
|
||||
public const ALLIUM = 10018;
|
||||
public const ANDESITE = 10019;
|
||||
public const ANDESITE_SLAB = 10020;
|
||||
public const ANDESITE_STAIRS = 10021;
|
||||
public const ANDESITE_WALL = 10022;
|
||||
public const ANVIL = 10023;
|
||||
public const AZURE_BLUET = 10024;
|
||||
public const BAMBOO = 10025;
|
||||
public const BAMBOO_SAPLING = 10026;
|
||||
public const BANNER = 10027;
|
||||
public const BARREL = 10028;
|
||||
public const BARRIER = 10029;
|
||||
public const BEACON = 10030;
|
||||
public const BED = 10031;
|
||||
public const BEDROCK = 10032;
|
||||
public const BEETROOTS = 10033;
|
||||
public const BELL = 10034;
|
||||
public const BIRCH_BUTTON = 10035;
|
||||
public const BIRCH_DOOR = 10036;
|
||||
public const BIRCH_FENCE = 10037;
|
||||
public const BIRCH_FENCE_GATE = 10038;
|
||||
public const BIRCH_LEAVES = 10039;
|
||||
public const BIRCH_LOG = 10040;
|
||||
public const BIRCH_PLANKS = 10041;
|
||||
public const BIRCH_PRESSURE_PLATE = 10042;
|
||||
public const BIRCH_SAPLING = 10043;
|
||||
public const BIRCH_SIGN = 10044;
|
||||
public const BIRCH_SLAB = 10045;
|
||||
public const BIRCH_STAIRS = 10046;
|
||||
public const BIRCH_TRAPDOOR = 10047;
|
||||
public const BIRCH_WALL_SIGN = 10048;
|
||||
public const BIRCH_WOOD = 10049;
|
||||
|
||||
public const BLAST_FURNACE = 10051;
|
||||
|
||||
public const BLUE_ICE = 10053;
|
||||
public const BLUE_ORCHID = 10054;
|
||||
public const BLUE_TORCH = 10055;
|
||||
public const BONE_BLOCK = 10056;
|
||||
public const BOOKSHELF = 10057;
|
||||
public const BREWING_STAND = 10058;
|
||||
public const BRICK_SLAB = 10059;
|
||||
public const BRICK_STAIRS = 10060;
|
||||
public const BRICK_WALL = 10061;
|
||||
public const BRICKS = 10062;
|
||||
|
||||
public const BROWN_MUSHROOM = 10064;
|
||||
public const BROWN_MUSHROOM_BLOCK = 10065;
|
||||
public const CACTUS = 10066;
|
||||
public const CAKE = 10067;
|
||||
public const CARPET = 10068;
|
||||
public const CARROTS = 10069;
|
||||
public const CARVED_PUMPKIN = 10070;
|
||||
public const CHEMICAL_HEAT = 10071;
|
||||
public const CHEST = 10072;
|
||||
public const CHISELED_QUARTZ = 10073;
|
||||
public const CHISELED_RED_SANDSTONE = 10074;
|
||||
public const CHISELED_SANDSTONE = 10075;
|
||||
public const CHISELED_STONE_BRICKS = 10076;
|
||||
public const CLAY = 10077;
|
||||
public const COAL = 10078;
|
||||
public const COAL_ORE = 10079;
|
||||
public const COBBLESTONE = 10080;
|
||||
public const COBBLESTONE_SLAB = 10081;
|
||||
public const COBBLESTONE_STAIRS = 10082;
|
||||
public const COBBLESTONE_WALL = 10083;
|
||||
public const COBWEB = 10084;
|
||||
public const COCOA_POD = 10085;
|
||||
public const COMPOUND_CREATOR = 10086;
|
||||
public const CONCRETE = 10087;
|
||||
public const CONCRETE_POWDER = 10088;
|
||||
public const CORAL = 10089;
|
||||
public const CORAL_BLOCK = 10090;
|
||||
public const CORAL_FAN = 10091;
|
||||
public const CORNFLOWER = 10092;
|
||||
public const CRACKED_STONE_BRICKS = 10093;
|
||||
public const CRAFTING_TABLE = 10094;
|
||||
public const CUT_RED_SANDSTONE = 10095;
|
||||
public const CUT_RED_SANDSTONE_SLAB = 10096;
|
||||
public const CUT_SANDSTONE = 10097;
|
||||
public const CUT_SANDSTONE_SLAB = 10098;
|
||||
|
||||
public const DANDELION = 10100;
|
||||
public const DARK_OAK_BUTTON = 10101;
|
||||
public const DARK_OAK_DOOR = 10102;
|
||||
public const DARK_OAK_FENCE = 10103;
|
||||
public const DARK_OAK_FENCE_GATE = 10104;
|
||||
public const DARK_OAK_LEAVES = 10105;
|
||||
public const DARK_OAK_LOG = 10106;
|
||||
public const DARK_OAK_PLANKS = 10107;
|
||||
public const DARK_OAK_PRESSURE_PLATE = 10108;
|
||||
public const DARK_OAK_SAPLING = 10109;
|
||||
public const DARK_OAK_SIGN = 10110;
|
||||
public const DARK_OAK_SLAB = 10111;
|
||||
public const DARK_OAK_STAIRS = 10112;
|
||||
public const DARK_OAK_TRAPDOOR = 10113;
|
||||
public const DARK_OAK_WALL_SIGN = 10114;
|
||||
public const DARK_OAK_WOOD = 10115;
|
||||
public const DARK_PRISMARINE = 10116;
|
||||
public const DARK_PRISMARINE_SLAB = 10117;
|
||||
public const DARK_PRISMARINE_STAIRS = 10118;
|
||||
public const DAYLIGHT_SENSOR = 10119;
|
||||
public const DEAD_BUSH = 10120;
|
||||
public const DETECTOR_RAIL = 10121;
|
||||
public const DIAMOND = 10122;
|
||||
public const DIAMOND_ORE = 10123;
|
||||
public const DIORITE = 10124;
|
||||
public const DIORITE_SLAB = 10125;
|
||||
public const DIORITE_STAIRS = 10126;
|
||||
public const DIORITE_WALL = 10127;
|
||||
public const DIRT = 10128;
|
||||
public const DOUBLE_TALLGRASS = 10129;
|
||||
public const DRAGON_EGG = 10130;
|
||||
public const DRIED_KELP = 10131;
|
||||
public const DYED_SHULKER_BOX = 10132;
|
||||
public const ELEMENT_ACTINIUM = 10133;
|
||||
public const ELEMENT_ALUMINUM = 10134;
|
||||
public const ELEMENT_AMERICIUM = 10135;
|
||||
public const ELEMENT_ANTIMONY = 10136;
|
||||
public const ELEMENT_ARGON = 10137;
|
||||
public const ELEMENT_ARSENIC = 10138;
|
||||
public const ELEMENT_ASTATINE = 10139;
|
||||
public const ELEMENT_BARIUM = 10140;
|
||||
public const ELEMENT_BERKELIUM = 10141;
|
||||
public const ELEMENT_BERYLLIUM = 10142;
|
||||
public const ELEMENT_BISMUTH = 10143;
|
||||
public const ELEMENT_BOHRIUM = 10144;
|
||||
public const ELEMENT_BORON = 10145;
|
||||
public const ELEMENT_BROMINE = 10146;
|
||||
public const ELEMENT_CADMIUM = 10147;
|
||||
public const ELEMENT_CALCIUM = 10148;
|
||||
public const ELEMENT_CALIFORNIUM = 10149;
|
||||
public const ELEMENT_CARBON = 10150;
|
||||
public const ELEMENT_CERIUM = 10151;
|
||||
public const ELEMENT_CESIUM = 10152;
|
||||
public const ELEMENT_CHLORINE = 10153;
|
||||
public const ELEMENT_CHROMIUM = 10154;
|
||||
public const ELEMENT_COBALT = 10155;
|
||||
public const ELEMENT_CONSTRUCTOR = 10156;
|
||||
public const ELEMENT_COPERNICIUM = 10157;
|
||||
public const ELEMENT_COPPER = 10158;
|
||||
public const ELEMENT_CURIUM = 10159;
|
||||
public const ELEMENT_DARMSTADTIUM = 10160;
|
||||
public const ELEMENT_DUBNIUM = 10161;
|
||||
public const ELEMENT_DYSPROSIUM = 10162;
|
||||
public const ELEMENT_EINSTEINIUM = 10163;
|
||||
public const ELEMENT_ERBIUM = 10164;
|
||||
public const ELEMENT_EUROPIUM = 10165;
|
||||
public const ELEMENT_FERMIUM = 10166;
|
||||
public const ELEMENT_FLEROVIUM = 10167;
|
||||
public const ELEMENT_FLUORINE = 10168;
|
||||
public const ELEMENT_FRANCIUM = 10169;
|
||||
public const ELEMENT_GADOLINIUM = 10170;
|
||||
public const ELEMENT_GALLIUM = 10171;
|
||||
public const ELEMENT_GERMANIUM = 10172;
|
||||
public const ELEMENT_GOLD = 10173;
|
||||
public const ELEMENT_HAFNIUM = 10174;
|
||||
public const ELEMENT_HASSIUM = 10175;
|
||||
public const ELEMENT_HELIUM = 10176;
|
||||
public const ELEMENT_HOLMIUM = 10177;
|
||||
public const ELEMENT_HYDROGEN = 10178;
|
||||
public const ELEMENT_INDIUM = 10179;
|
||||
public const ELEMENT_IODINE = 10180;
|
||||
public const ELEMENT_IRIDIUM = 10181;
|
||||
public const ELEMENT_IRON = 10182;
|
||||
public const ELEMENT_KRYPTON = 10183;
|
||||
public const ELEMENT_LANTHANUM = 10184;
|
||||
public const ELEMENT_LAWRENCIUM = 10185;
|
||||
public const ELEMENT_LEAD = 10186;
|
||||
public const ELEMENT_LITHIUM = 10187;
|
||||
public const ELEMENT_LIVERMORIUM = 10188;
|
||||
public const ELEMENT_LUTETIUM = 10189;
|
||||
public const ELEMENT_MAGNESIUM = 10190;
|
||||
public const ELEMENT_MANGANESE = 10191;
|
||||
public const ELEMENT_MEITNERIUM = 10192;
|
||||
public const ELEMENT_MENDELEVIUM = 10193;
|
||||
public const ELEMENT_MERCURY = 10194;
|
||||
public const ELEMENT_MOLYBDENUM = 10195;
|
||||
public const ELEMENT_MOSCOVIUM = 10196;
|
||||
public const ELEMENT_NEODYMIUM = 10197;
|
||||
public const ELEMENT_NEON = 10198;
|
||||
public const ELEMENT_NEPTUNIUM = 10199;
|
||||
public const ELEMENT_NICKEL = 10200;
|
||||
public const ELEMENT_NIHONIUM = 10201;
|
||||
public const ELEMENT_NIOBIUM = 10202;
|
||||
public const ELEMENT_NITROGEN = 10203;
|
||||
public const ELEMENT_NOBELIUM = 10204;
|
||||
public const ELEMENT_OGANESSON = 10205;
|
||||
public const ELEMENT_OSMIUM = 10206;
|
||||
public const ELEMENT_OXYGEN = 10207;
|
||||
public const ELEMENT_PALLADIUM = 10208;
|
||||
public const ELEMENT_PHOSPHORUS = 10209;
|
||||
public const ELEMENT_PLATINUM = 10210;
|
||||
public const ELEMENT_PLUTONIUM = 10211;
|
||||
public const ELEMENT_POLONIUM = 10212;
|
||||
public const ELEMENT_POTASSIUM = 10213;
|
||||
public const ELEMENT_PRASEODYMIUM = 10214;
|
||||
public const ELEMENT_PROMETHIUM = 10215;
|
||||
public const ELEMENT_PROTACTINIUM = 10216;
|
||||
public const ELEMENT_RADIUM = 10217;
|
||||
public const ELEMENT_RADON = 10218;
|
||||
public const ELEMENT_RHENIUM = 10219;
|
||||
public const ELEMENT_RHODIUM = 10220;
|
||||
public const ELEMENT_ROENTGENIUM = 10221;
|
||||
public const ELEMENT_RUBIDIUM = 10222;
|
||||
public const ELEMENT_RUTHENIUM = 10223;
|
||||
public const ELEMENT_RUTHERFORDIUM = 10224;
|
||||
public const ELEMENT_SAMARIUM = 10225;
|
||||
public const ELEMENT_SCANDIUM = 10226;
|
||||
public const ELEMENT_SEABORGIUM = 10227;
|
||||
public const ELEMENT_SELENIUM = 10228;
|
||||
public const ELEMENT_SILICON = 10229;
|
||||
public const ELEMENT_SILVER = 10230;
|
||||
public const ELEMENT_SODIUM = 10231;
|
||||
public const ELEMENT_STRONTIUM = 10232;
|
||||
public const ELEMENT_SULFUR = 10233;
|
||||
public const ELEMENT_TANTALUM = 10234;
|
||||
public const ELEMENT_TECHNETIUM = 10235;
|
||||
public const ELEMENT_TELLURIUM = 10236;
|
||||
public const ELEMENT_TENNESSINE = 10237;
|
||||
public const ELEMENT_TERBIUM = 10238;
|
||||
public const ELEMENT_THALLIUM = 10239;
|
||||
public const ELEMENT_THORIUM = 10240;
|
||||
public const ELEMENT_THULIUM = 10241;
|
||||
public const ELEMENT_TIN = 10242;
|
||||
public const ELEMENT_TITANIUM = 10243;
|
||||
public const ELEMENT_TUNGSTEN = 10244;
|
||||
public const ELEMENT_URANIUM = 10245;
|
||||
public const ELEMENT_VANADIUM = 10246;
|
||||
public const ELEMENT_XENON = 10247;
|
||||
public const ELEMENT_YTTERBIUM = 10248;
|
||||
public const ELEMENT_YTTRIUM = 10249;
|
||||
public const ELEMENT_ZERO = 10250;
|
||||
public const ELEMENT_ZINC = 10251;
|
||||
public const ELEMENT_ZIRCONIUM = 10252;
|
||||
public const EMERALD = 10253;
|
||||
public const EMERALD_ORE = 10254;
|
||||
public const ENCHANTING_TABLE = 10255;
|
||||
public const END_PORTAL_FRAME = 10256;
|
||||
public const END_ROD = 10257;
|
||||
public const END_STONE = 10258;
|
||||
public const END_STONE_BRICK_SLAB = 10259;
|
||||
public const END_STONE_BRICK_STAIRS = 10260;
|
||||
public const END_STONE_BRICK_WALL = 10261;
|
||||
public const END_STONE_BRICKS = 10262;
|
||||
public const ENDER_CHEST = 10263;
|
||||
public const FAKE_WOODEN_SLAB = 10264;
|
||||
public const FARMLAND = 10265;
|
||||
public const FERN = 10266;
|
||||
public const FIRE = 10267;
|
||||
public const FLETCHING_TABLE = 10268;
|
||||
public const FLOWER_POT = 10269;
|
||||
public const FROSTED_ICE = 10270;
|
||||
public const FURNACE = 10271;
|
||||
public const GLASS = 10272;
|
||||
public const GLASS_PANE = 10273;
|
||||
public const GLOWING_OBSIDIAN = 10274;
|
||||
public const GLOWSTONE = 10275;
|
||||
public const GOLD = 10276;
|
||||
public const GOLD_ORE = 10277;
|
||||
public const GRANITE = 10278;
|
||||
public const GRANITE_SLAB = 10279;
|
||||
public const GRANITE_STAIRS = 10280;
|
||||
public const GRANITE_WALL = 10281;
|
||||
public const GRASS = 10282;
|
||||
public const GRASS_PATH = 10283;
|
||||
public const GRAVEL = 10284;
|
||||
|
||||
public const GREEN_TORCH = 10287;
|
||||
public const HARDENED_CLAY = 10288;
|
||||
public const HARDENED_GLASS = 10289;
|
||||
public const HARDENED_GLASS_PANE = 10290;
|
||||
public const HAY_BALE = 10291;
|
||||
public const HOPPER = 10292;
|
||||
public const ICE = 10293;
|
||||
public const INFESTED_CHISELED_STONE_BRICK = 10294;
|
||||
public const INFESTED_COBBLESTONE = 10295;
|
||||
public const INFESTED_CRACKED_STONE_BRICK = 10296;
|
||||
public const INFESTED_MOSSY_STONE_BRICK = 10297;
|
||||
public const INFESTED_STONE = 10298;
|
||||
public const INFESTED_STONE_BRICK = 10299;
|
||||
public const INFO_UPDATE = 10300;
|
||||
public const INFO_UPDATE2 = 10301;
|
||||
public const INVISIBLE_BEDROCK = 10302;
|
||||
public const IRON = 10303;
|
||||
public const IRON_BARS = 10304;
|
||||
public const IRON_DOOR = 10305;
|
||||
public const IRON_ORE = 10306;
|
||||
public const IRON_TRAPDOOR = 10307;
|
||||
public const ITEM_FRAME = 10308;
|
||||
public const JUKEBOX = 10309;
|
||||
public const JUNGLE_BUTTON = 10310;
|
||||
public const JUNGLE_DOOR = 10311;
|
||||
public const JUNGLE_FENCE = 10312;
|
||||
public const JUNGLE_FENCE_GATE = 10313;
|
||||
public const JUNGLE_LEAVES = 10314;
|
||||
public const JUNGLE_LOG = 10315;
|
||||
public const JUNGLE_PLANKS = 10316;
|
||||
public const JUNGLE_PRESSURE_PLATE = 10317;
|
||||
public const JUNGLE_SAPLING = 10318;
|
||||
public const JUNGLE_SIGN = 10319;
|
||||
public const JUNGLE_SLAB = 10320;
|
||||
public const JUNGLE_STAIRS = 10321;
|
||||
public const JUNGLE_TRAPDOOR = 10322;
|
||||
public const JUNGLE_WALL_SIGN = 10323;
|
||||
public const JUNGLE_WOOD = 10324;
|
||||
public const LAB_TABLE = 10325;
|
||||
public const LADDER = 10326;
|
||||
public const LANTERN = 10327;
|
||||
public const LAPIS_LAZULI = 10328;
|
||||
public const LAPIS_LAZULI_ORE = 10329;
|
||||
public const LARGE_FERN = 10330;
|
||||
public const LAVA = 10331;
|
||||
public const LECTERN = 10332;
|
||||
public const LEGACY_STONECUTTER = 10333;
|
||||
public const LEVER = 10334;
|
||||
|
||||
public const LILAC = 10337;
|
||||
public const LILY_OF_THE_VALLEY = 10338;
|
||||
public const LILY_PAD = 10339;
|
||||
|
||||
public const LIT_PUMPKIN = 10341;
|
||||
public const LOOM = 10342;
|
||||
|
||||
public const MAGMA = 10344;
|
||||
public const MATERIAL_REDUCER = 10345;
|
||||
public const MELON = 10346;
|
||||
public const MELON_STEM = 10347;
|
||||
public const MOB_HEAD = 10348;
|
||||
public const MONSTER_SPAWNER = 10349;
|
||||
public const MOSSY_COBBLESTONE = 10350;
|
||||
public const MOSSY_COBBLESTONE_SLAB = 10351;
|
||||
public const MOSSY_COBBLESTONE_STAIRS = 10352;
|
||||
public const MOSSY_COBBLESTONE_WALL = 10353;
|
||||
public const MOSSY_STONE_BRICK_SLAB = 10354;
|
||||
public const MOSSY_STONE_BRICK_STAIRS = 10355;
|
||||
public const MOSSY_STONE_BRICK_WALL = 10356;
|
||||
public const MOSSY_STONE_BRICKS = 10357;
|
||||
public const MUSHROOM_STEM = 10358;
|
||||
public const MYCELIUM = 10359;
|
||||
public const NETHER_BRICK_FENCE = 10360;
|
||||
public const NETHER_BRICK_SLAB = 10361;
|
||||
public const NETHER_BRICK_STAIRS = 10362;
|
||||
public const NETHER_BRICK_WALL = 10363;
|
||||
public const NETHER_BRICKS = 10364;
|
||||
public const NETHER_PORTAL = 10365;
|
||||
public const NETHER_QUARTZ_ORE = 10366;
|
||||
public const NETHER_REACTOR_CORE = 10367;
|
||||
public const NETHER_WART = 10368;
|
||||
public const NETHER_WART_BLOCK = 10369;
|
||||
public const NETHERRACK = 10370;
|
||||
public const NOTE_BLOCK = 10371;
|
||||
public const OAK_BUTTON = 10372;
|
||||
public const OAK_DOOR = 10373;
|
||||
public const OAK_FENCE = 10374;
|
||||
public const OAK_FENCE_GATE = 10375;
|
||||
public const OAK_LEAVES = 10376;
|
||||
public const OAK_LOG = 10377;
|
||||
public const OAK_PLANKS = 10378;
|
||||
public const OAK_PRESSURE_PLATE = 10379;
|
||||
public const OAK_SAPLING = 10380;
|
||||
public const OAK_SIGN = 10381;
|
||||
public const OAK_SLAB = 10382;
|
||||
public const OAK_STAIRS = 10383;
|
||||
public const OAK_TRAPDOOR = 10384;
|
||||
public const OAK_WALL_SIGN = 10385;
|
||||
public const OAK_WOOD = 10386;
|
||||
public const OBSIDIAN = 10387;
|
||||
|
||||
public const ORANGE_TULIP = 10389;
|
||||
public const OXEYE_DAISY = 10390;
|
||||
public const PACKED_ICE = 10391;
|
||||
public const PEONY = 10392;
|
||||
|
||||
public const PINK_TULIP = 10394;
|
||||
public const PODZOL = 10395;
|
||||
public const POLISHED_ANDESITE = 10396;
|
||||
public const POLISHED_ANDESITE_SLAB = 10397;
|
||||
public const POLISHED_ANDESITE_STAIRS = 10398;
|
||||
public const POLISHED_DIORITE = 10399;
|
||||
public const POLISHED_DIORITE_SLAB = 10400;
|
||||
public const POLISHED_DIORITE_STAIRS = 10401;
|
||||
public const POLISHED_GRANITE = 10402;
|
||||
public const POLISHED_GRANITE_SLAB = 10403;
|
||||
public const POLISHED_GRANITE_STAIRS = 10404;
|
||||
public const POPPY = 10405;
|
||||
public const POTATOES = 10406;
|
||||
public const POWERED_RAIL = 10407;
|
||||
public const PRISMARINE = 10408;
|
||||
public const PRISMARINE_BRICKS = 10409;
|
||||
public const PRISMARINE_BRICKS_SLAB = 10410;
|
||||
public const PRISMARINE_BRICKS_STAIRS = 10411;
|
||||
public const PRISMARINE_SLAB = 10412;
|
||||
public const PRISMARINE_STAIRS = 10413;
|
||||
public const PRISMARINE_WALL = 10414;
|
||||
public const PUMPKIN = 10415;
|
||||
public const PUMPKIN_STEM = 10416;
|
||||
|
||||
public const PURPLE_TORCH = 10418;
|
||||
public const PURPUR = 10419;
|
||||
public const PURPUR_PILLAR = 10420;
|
||||
public const PURPUR_SLAB = 10421;
|
||||
public const PURPUR_STAIRS = 10422;
|
||||
public const QUARTZ = 10423;
|
||||
public const QUARTZ_PILLAR = 10424;
|
||||
public const QUARTZ_SLAB = 10425;
|
||||
public const QUARTZ_STAIRS = 10426;
|
||||
public const RAIL = 10427;
|
||||
|
||||
public const RED_MUSHROOM = 10429;
|
||||
public const RED_MUSHROOM_BLOCK = 10430;
|
||||
public const RED_NETHER_BRICK_SLAB = 10431;
|
||||
public const RED_NETHER_BRICK_STAIRS = 10432;
|
||||
public const RED_NETHER_BRICK_WALL = 10433;
|
||||
public const RED_NETHER_BRICKS = 10434;
|
||||
public const RED_SAND = 10435;
|
||||
public const RED_SANDSTONE = 10436;
|
||||
public const RED_SANDSTONE_SLAB = 10437;
|
||||
public const RED_SANDSTONE_STAIRS = 10438;
|
||||
public const RED_SANDSTONE_WALL = 10439;
|
||||
public const RED_TORCH = 10440;
|
||||
public const RED_TULIP = 10441;
|
||||
public const REDSTONE = 10442;
|
||||
public const REDSTONE_COMPARATOR = 10443;
|
||||
public const REDSTONE_LAMP = 10444;
|
||||
public const REDSTONE_ORE = 10445;
|
||||
public const REDSTONE_REPEATER = 10446;
|
||||
public const REDSTONE_TORCH = 10447;
|
||||
public const REDSTONE_WIRE = 10448;
|
||||
public const RESERVED6 = 10449;
|
||||
public const ROSE_BUSH = 10450;
|
||||
public const SAND = 10451;
|
||||
public const SANDSTONE = 10452;
|
||||
public const SANDSTONE_SLAB = 10453;
|
||||
public const SANDSTONE_STAIRS = 10454;
|
||||
public const SANDSTONE_WALL = 10455;
|
||||
public const SEA_LANTERN = 10456;
|
||||
public const SEA_PICKLE = 10457;
|
||||
public const SHULKER_BOX = 10458;
|
||||
public const SLIME = 10459;
|
||||
public const SMOKER = 10460;
|
||||
public const SMOOTH_QUARTZ = 10461;
|
||||
public const SMOOTH_QUARTZ_SLAB = 10462;
|
||||
public const SMOOTH_QUARTZ_STAIRS = 10463;
|
||||
public const SMOOTH_RED_SANDSTONE = 10464;
|
||||
public const SMOOTH_RED_SANDSTONE_SLAB = 10465;
|
||||
public const SMOOTH_RED_SANDSTONE_STAIRS = 10466;
|
||||
public const SMOOTH_SANDSTONE = 10467;
|
||||
public const SMOOTH_SANDSTONE_SLAB = 10468;
|
||||
public const SMOOTH_SANDSTONE_STAIRS = 10469;
|
||||
public const SMOOTH_STONE = 10470;
|
||||
public const SMOOTH_STONE_SLAB = 10471;
|
||||
public const SNOW = 10472;
|
||||
public const SNOW_LAYER = 10473;
|
||||
public const SOUL_SAND = 10474;
|
||||
public const SPONGE = 10475;
|
||||
public const SPRUCE_BUTTON = 10476;
|
||||
public const SPRUCE_DOOR = 10477;
|
||||
public const SPRUCE_FENCE = 10478;
|
||||
public const SPRUCE_FENCE_GATE = 10479;
|
||||
public const SPRUCE_LEAVES = 10480;
|
||||
public const SPRUCE_LOG = 10481;
|
||||
public const SPRUCE_PLANKS = 10482;
|
||||
public const SPRUCE_PRESSURE_PLATE = 10483;
|
||||
public const SPRUCE_SAPLING = 10484;
|
||||
public const SPRUCE_SIGN = 10485;
|
||||
public const SPRUCE_SLAB = 10486;
|
||||
public const SPRUCE_STAIRS = 10487;
|
||||
public const SPRUCE_TRAPDOOR = 10488;
|
||||
public const SPRUCE_WALL_SIGN = 10489;
|
||||
public const SPRUCE_WOOD = 10490;
|
||||
public const STAINED_CLAY = 10491;
|
||||
public const STAINED_GLASS = 10492;
|
||||
public const STAINED_GLASS_PANE = 10493;
|
||||
public const STAINED_HARDENED_GLASS = 10494;
|
||||
public const STAINED_HARDENED_GLASS_PANE = 10495;
|
||||
public const STONE = 10496;
|
||||
public const STONE_BRICK_SLAB = 10497;
|
||||
public const STONE_BRICK_STAIRS = 10498;
|
||||
public const STONE_BRICK_WALL = 10499;
|
||||
public const STONE_BRICKS = 10500;
|
||||
public const STONE_BUTTON = 10501;
|
||||
public const STONE_PRESSURE_PLATE = 10502;
|
||||
public const STONE_SLAB = 10503;
|
||||
public const STONE_STAIRS = 10504;
|
||||
public const STONECUTTER = 10505;
|
||||
|
||||
public const SUGARCANE = 10518;
|
||||
public const SUNFLOWER = 10519;
|
||||
public const SWEET_BERRY_BUSH = 10520;
|
||||
public const TALL_GRASS = 10521;
|
||||
public const TNT = 10522;
|
||||
public const TORCH = 10523;
|
||||
public const TRAPPED_CHEST = 10524;
|
||||
public const TRIPWIRE = 10525;
|
||||
public const TRIPWIRE_HOOK = 10526;
|
||||
public const UNDERWATER_TORCH = 10527;
|
||||
public const VINES = 10528;
|
||||
public const WALL_BANNER = 10529;
|
||||
public const WALL_CORAL_FAN = 10530;
|
||||
public const WATER = 10531;
|
||||
public const WEIGHTED_PRESSURE_PLATE_HEAVY = 10532;
|
||||
public const WEIGHTED_PRESSURE_PLATE_LIGHT = 10533;
|
||||
public const WHEAT = 10534;
|
||||
|
||||
public const WHITE_TULIP = 10536;
|
||||
public const WOOL = 10537;
|
||||
|
||||
public const GLAZED_TERRACOTTA = 10539;
|
||||
public const AMETHYST = 10540;
|
||||
public const ANCIENT_DEBRIS = 10541;
|
||||
public const BASALT = 10542;
|
||||
public const POLISHED_BASALT = 10543;
|
||||
public const SMOOTH_BASALT = 10544;
|
||||
public const BLACKSTONE = 10545;
|
||||
public const BLACKSTONE_SLAB = 10546;
|
||||
public const BLACKSTONE_STAIRS = 10547;
|
||||
public const BLACKSTONE_WALL = 10548;
|
||||
public const POLISHED_BLACKSTONE = 10549;
|
||||
public const POLISHED_BLACKSTONE_BUTTON = 10550;
|
||||
public const POLISHED_BLACKSTONE_PRESSURE_PLATE = 10551;
|
||||
public const POLISHED_BLACKSTONE_SLAB = 10552;
|
||||
public const POLISHED_BLACKSTONE_STAIRS = 10553;
|
||||
public const POLISHED_BLACKSTONE_WALL = 10554;
|
||||
public const CHISELED_POLISHED_BLACKSTONE = 10555;
|
||||
public const POLISHED_BLACKSTONE_BRICKS = 10556;
|
||||
public const POLISHED_BLACKSTONE_BRICK_SLAB = 10557;
|
||||
public const POLISHED_BLACKSTONE_BRICK_STAIRS = 10558;
|
||||
public const POLISHED_BLACKSTONE_BRICK_WALL = 10559;
|
||||
public const CRACKED_POLISHED_BLACKSTONE_BRICKS = 10560;
|
||||
public const LIGHT = 10561;
|
||||
public const RAW_COPPER = 10562;
|
||||
public const RAW_GOLD = 10563;
|
||||
public const RAW_IRON = 10564;
|
||||
public const CALCITE = 10565;
|
||||
public const DEEPSLATE = 10566;
|
||||
public const DEEPSLATE_BRICKS = 10567;
|
||||
public const DEEPSLATE_BRICK_SLAB = 10568;
|
||||
public const DEEPSLATE_BRICK_STAIRS = 10569;
|
||||
public const DEEPSLATE_BRICK_WALL = 10570;
|
||||
public const CRACKED_DEEPSLATE_BRICKS = 10571;
|
||||
public const DEEPSLATE_TILES = 10572;
|
||||
public const DEEPSLATE_TILE_SLAB = 10573;
|
||||
public const DEEPSLATE_TILE_STAIRS = 10574;
|
||||
public const DEEPSLATE_TILE_WALL = 10575;
|
||||
public const CRACKED_DEEPSLATE_TILES = 10576;
|
||||
public const COBBLED_DEEPSLATE = 10577;
|
||||
public const COBBLED_DEEPSLATE_SLAB = 10578;
|
||||
public const COBBLED_DEEPSLATE_STAIRS = 10579;
|
||||
public const COBBLED_DEEPSLATE_WALL = 10580;
|
||||
public const POLISHED_DEEPSLATE = 10581;
|
||||
public const POLISHED_DEEPSLATE_SLAB = 10582;
|
||||
public const POLISHED_DEEPSLATE_STAIRS = 10583;
|
||||
public const POLISHED_DEEPSLATE_WALL = 10584;
|
||||
public const QUARTZ_BRICKS = 10585;
|
||||
public const CHISELED_DEEPSLATE = 10586;
|
||||
public const CHISELED_NETHER_BRICKS = 10587;
|
||||
public const CRACKED_NETHER_BRICKS = 10588;
|
||||
public const TUFF = 10589;
|
||||
public const SOUL_TORCH = 10590;
|
||||
public const SOUL_LANTERN = 10591;
|
||||
public const SOUL_SOIL = 10592;
|
||||
public const SOUL_FIRE = 10593;
|
||||
public const SHROOMLIGHT = 10594;
|
||||
public const MANGROVE_PLANKS = 10595;
|
||||
public const CRIMSON_PLANKS = 10596;
|
||||
public const WARPED_PLANKS = 10597;
|
||||
public const MANGROVE_FENCE = 10598;
|
||||
public const CRIMSON_FENCE = 10599;
|
||||
public const WARPED_FENCE = 10600;
|
||||
public const MANGROVE_SLAB = 10601;
|
||||
public const CRIMSON_SLAB = 10602;
|
||||
public const WARPED_SLAB = 10603;
|
||||
public const MANGROVE_LOG = 10604;
|
||||
public const CRIMSON_STEM = 10605;
|
||||
public const WARPED_STEM = 10606;
|
||||
public const MANGROVE_WOOD = 10607;
|
||||
public const CRIMSON_HYPHAE = 10608;
|
||||
public const WARPED_HYPHAE = 10609;
|
||||
public const MANGROVE_TRAPDOOR = 10610;
|
||||
public const CRIMSON_TRAPDOOR = 10611;
|
||||
public const WARPED_TRAPDOOR = 10612;
|
||||
public const MANGROVE_BUTTON = 10613;
|
||||
public const CRIMSON_BUTTON = 10614;
|
||||
public const WARPED_BUTTON = 10615;
|
||||
public const MANGROVE_PRESSURE_PLATE = 10616;
|
||||
public const CRIMSON_PRESSURE_PLATE = 10617;
|
||||
public const WARPED_PRESSURE_PLATE = 10618;
|
||||
public const MANGROVE_DOOR = 10619;
|
||||
public const CRIMSON_DOOR = 10620;
|
||||
public const WARPED_DOOR = 10621;
|
||||
public const MANGROVE_FENCE_GATE = 10622;
|
||||
public const CRIMSON_FENCE_GATE = 10623;
|
||||
public const WARPED_FENCE_GATE = 10624;
|
||||
public const MANGROVE_STAIRS = 10625;
|
||||
public const CRIMSON_STAIRS = 10626;
|
||||
public const WARPED_STAIRS = 10627;
|
||||
public const MANGROVE_SIGN = 10628;
|
||||
public const CRIMSON_SIGN = 10629;
|
||||
public const WARPED_SIGN = 10630;
|
||||
public const MANGROVE_WALL_SIGN = 10631;
|
||||
public const CRIMSON_WALL_SIGN = 10632;
|
||||
public const WARPED_WALL_SIGN = 10633;
|
||||
public const TINTED_GLASS = 10634;
|
||||
public const HONEYCOMB = 10635;
|
||||
public const DEEPSLATE_COAL_ORE = 10636;
|
||||
public const DEEPSLATE_DIAMOND_ORE = 10637;
|
||||
public const DEEPSLATE_EMERALD_ORE = 10638;
|
||||
public const DEEPSLATE_LAPIS_LAZULI_ORE = 10639;
|
||||
public const DEEPSLATE_REDSTONE_ORE = 10640;
|
||||
public const DEEPSLATE_IRON_ORE = 10641;
|
||||
public const DEEPSLATE_GOLD_ORE = 10642;
|
||||
public const DEEPSLATE_COPPER_ORE = 10643;
|
||||
public const COPPER_ORE = 10644;
|
||||
public const NETHER_GOLD_ORE = 10645;
|
||||
public const MUD = 10646;
|
||||
public const MUD_BRICKS = 10647;
|
||||
public const MUD_BRICK_SLAB = 10648;
|
||||
public const MUD_BRICK_STAIRS = 10649;
|
||||
public const MUD_BRICK_WALL = 10650;
|
||||
public const PACKED_MUD = 10651;
|
||||
public const WARPED_WART_BLOCK = 10652;
|
||||
public const CRYING_OBSIDIAN = 10653;
|
||||
public const GILDED_BLACKSTONE = 10654;
|
||||
public const LIGHTNING_ROD = 10655;
|
||||
public const COPPER = 10656;
|
||||
public const CUT_COPPER = 10657;
|
||||
public const CUT_COPPER_SLAB = 10658;
|
||||
public const CUT_COPPER_STAIRS = 10659;
|
||||
public const CANDLE = 10660;
|
||||
public const DYED_CANDLE = 10661;
|
||||
public const CAKE_WITH_CANDLE = 10662;
|
||||
public const CAKE_WITH_DYED_CANDLE = 10663;
|
||||
public const WITHER_ROSE = 10664;
|
||||
public const HANGING_ROOTS = 10665;
|
||||
public const CARTOGRAPHY_TABLE = 10666;
|
||||
public const SMITHING_TABLE = 10667;
|
||||
public const NETHERITE = 10668;
|
||||
|
||||
public const FIRST_UNUSED_BLOCK_ID = 10669;
|
||||
}
|
@ -23,8 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\PillarRotationInMetadataTrait;
|
||||
use pocketmine\block\utils\PillarRotationTrait;
|
||||
|
||||
class BoneBlock extends Opaque{
|
||||
use PillarRotationInMetadataTrait;
|
||||
use PillarRotationTrait;
|
||||
}
|
||||
|
@ -26,6 +26,8 @@ namespace pocketmine\block;
|
||||
use pocketmine\block\tile\BrewingStand as TileBrewingStand;
|
||||
use pocketmine\block\utils\BrewingStandSlot;
|
||||
use pocketmine\block\utils\SupportType;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Axis;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
@ -42,33 +44,31 @@ class BrewingStand extends Transparent{
|
||||
*/
|
||||
protected array $slots = [];
|
||||
|
||||
protected function writeStateToMeta() : int{
|
||||
$flags = 0;
|
||||
foreach([
|
||||
BlockLegacyMetadata::BREWING_STAND_FLAG_EAST => BrewingStandSlot::EAST(),
|
||||
BlockLegacyMetadata::BREWING_STAND_FLAG_NORTHWEST => BrewingStandSlot::NORTHWEST(),
|
||||
BlockLegacyMetadata::BREWING_STAND_FLAG_SOUTHWEST => BrewingStandSlot::SOUTHWEST(),
|
||||
] as $flag => $slot){
|
||||
$flags |= (array_key_exists($slot->id(), $this->slots) ? $flag : 0);
|
||||
}
|
||||
return $flags;
|
||||
}
|
||||
public function getRequiredStateDataBits() : int{ return 3; }
|
||||
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->slots = [];
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$result = [];
|
||||
foreach([
|
||||
BlockLegacyMetadata::BREWING_STAND_FLAG_EAST => BrewingStandSlot::EAST(),
|
||||
BlockLegacyMetadata::BREWING_STAND_FLAG_NORTHWEST => BrewingStandSlot::NORTHWEST(),
|
||||
BlockLegacyMetadata::BREWING_STAND_FLAG_SOUTHWEST => BrewingStandSlot::SOUTHWEST(),
|
||||
] as $flag => $slot){
|
||||
if(($stateMeta & $flag) !== 0){
|
||||
$this->slots[$slot->id()] = $slot;
|
||||
BrewingStandSlot::EAST(),
|
||||
BrewingStandSlot::NORTHWEST(),
|
||||
BrewingStandSlot::SOUTHWEST(),
|
||||
] as $member){
|
||||
if($r->readBool()){
|
||||
$result[$member->id()] = $member;
|
||||
}
|
||||
}
|
||||
|
||||
$this->setSlots($result);
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b111;
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
foreach([
|
||||
BrewingStandSlot::EAST(),
|
||||
BrewingStandSlot::NORTHWEST(),
|
||||
BrewingStandSlot::SOUTHWEST(),
|
||||
] as $member){
|
||||
$w->writeBool(isset($this->slots[$member->id()]));
|
||||
}
|
||||
}
|
||||
|
||||
protected function recalculateCollisionBoxes() : array{
|
||||
|
@ -24,7 +24,8 @@ declare(strict_types=1);
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\AnyFacingTrait;
|
||||
use pocketmine\block\utils\BlockDataSerializer;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\math\Vector3;
|
||||
@ -38,18 +39,16 @@ abstract class Button extends Flowable{
|
||||
|
||||
protected bool $pressed = false;
|
||||
|
||||
protected function writeStateToMeta() : int{
|
||||
return BlockDataSerializer::writeFacing($this->facing) | ($this->pressed ? BlockLegacyMetadata::BUTTON_FLAG_POWERED : 0);
|
||||
public function getRequiredStateDataBits() : int{ return 4; }
|
||||
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->facing = $r->readFacing();
|
||||
$this->pressed = $r->readBool();
|
||||
}
|
||||
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
//TODO: in PC it's (6 - facing) for every meta except 0 (down)
|
||||
$this->facing = BlockDataSerializer::readFacing($stateMeta & 0x07);
|
||||
$this->pressed = ($stateMeta & BlockLegacyMetadata::BUTTON_FLAG_POWERED) !== 0;
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b1111;
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeFacing($this->facing);
|
||||
$w->writeBool($this->pressed);
|
||||
}
|
||||
|
||||
public function isPressed() : bool{ return $this->pressed; }
|
||||
|
@ -23,8 +23,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\BlockDataSerializer;
|
||||
use pocketmine\block\utils\SupportType;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\entity\Entity;
|
||||
use pocketmine\event\block\BlockGrowEvent;
|
||||
use pocketmine\event\entity\EntityDamageByBlockEvent;
|
||||
@ -41,16 +42,14 @@ class Cactus extends Transparent{
|
||||
|
||||
protected int $age = 0;
|
||||
|
||||
protected function writeStateToMeta() : int{
|
||||
return $this->age;
|
||||
public function getRequiredStateDataBits() : int{ return 4; }
|
||||
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->age = $r->readBoundedInt(4, 0, self::MAX_AGE);
|
||||
}
|
||||
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->age = BlockDataSerializer::readBoundedInt("age", $stateMeta, 0, self::MAX_AGE);
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b1111;
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeBoundedInt(4, 0, self::MAX_AGE, $this->age);
|
||||
}
|
||||
|
||||
public function getAge() : int{ return $this->age; }
|
||||
@ -88,7 +87,7 @@ class Cactus extends Transparent{
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
$down = $this->getSide(Facing::DOWN);
|
||||
if($down->getId() !== BlockLegacyIds::SAND && !$down->isSameType($this)){
|
||||
if($down->getTypeId() !== BlockTypeIds::SAND && $down->getTypeId() !== BlockTypeIds::RED_SAND && !$down->isSameType($this)){
|
||||
$this->position->getWorld()->useBreakOn($this->position);
|
||||
}else{
|
||||
foreach(Facing::HORIZONTAL as $side){
|
||||
@ -113,7 +112,7 @@ class Cactus extends Transparent{
|
||||
break;
|
||||
}
|
||||
$b = $this->position->getWorld()->getBlockAt($this->position->x, $this->position->y + $y, $this->position->z);
|
||||
if($b->getId() === BlockLegacyIds::AIR){
|
||||
if($b->getTypeId() === BlockTypeIds::AIR){
|
||||
$ev = new BlockGrowEvent($b, VanillaBlocks::CACTUS());
|
||||
$ev->call();
|
||||
if($ev->isCancelled()){
|
||||
@ -135,7 +134,7 @@ class Cactus extends Transparent{
|
||||
|
||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
$down = $this->getSide(Facing::DOWN);
|
||||
if($down->getId() === BlockLegacyIds::SAND || $down->isSameType($this)){
|
||||
if($down->getTypeId() === BlockTypeIds::SAND || $down->getTypeId() === BlockTypeIds::RED_SAND || $down->isSameType($this)){
|
||||
foreach(Facing::HORIZONTAL as $side){
|
||||
if($this->getSide($side)->isSolid()){
|
||||
return false;
|
||||
|
@ -23,33 +23,28 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\BlockDataSerializer;
|
||||
use pocketmine\block\utils\SupportType;
|
||||
use pocketmine\entity\effect\EffectInstance;
|
||||
use pocketmine\entity\FoodSource;
|
||||
use pocketmine\entity\Living;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\ItemBlock;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\player\Player;
|
||||
use pocketmine\world\BlockTransaction;
|
||||
|
||||
class Cake extends Transparent implements FoodSource{
|
||||
class Cake extends BaseCake{
|
||||
public const MAX_BITES = 6;
|
||||
|
||||
protected int $bites = 0;
|
||||
|
||||
protected function writeStateToMeta() : int{
|
||||
return $this->bites;
|
||||
public function getRequiredStateDataBits() : int{ return 3; }
|
||||
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->bites = $r->readBoundedInt(3, 0, self::MAX_BITES);
|
||||
}
|
||||
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->bites = BlockDataSerializer::readBoundedInt("bites", $stateMeta, 0, self::MAX_BITES);
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b111;
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeBoundedInt(3, 0, self::MAX_BITES, $this->bites);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -64,10 +59,6 @@ class Cake extends Transparent implements FoodSource{
|
||||
];
|
||||
}
|
||||
|
||||
public function getSupportType(int $facing) : SupportType{
|
||||
return SupportType::NONE();
|
||||
}
|
||||
|
||||
public function getBites() : int{ return $this->bites; }
|
||||
|
||||
/** @return $this */
|
||||
@ -79,49 +70,27 @@ class Cake extends Transparent implements FoodSource{
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
$down = $this->getSide(Facing::DOWN);
|
||||
if($down->getId() !== BlockLegacyIds::AIR){
|
||||
return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
if($this->getSide(Facing::DOWN)->getId() === BlockLegacyIds::AIR){ //Replace with common break method
|
||||
$this->position->getWorld()->setBlock($this->position, VanillaBlocks::AIR());
|
||||
}
|
||||
}
|
||||
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
if($player !== null){
|
||||
return $player->consumeObject($this);
|
||||
if($item instanceof ItemBlock){
|
||||
$block = $item->getBlock();
|
||||
$resultBlock = null;
|
||||
if($block->getTypeId() === BlockTypeIds::CANDLE){
|
||||
$resultBlock = VanillaBlocks::CAKE_WITH_CANDLE();
|
||||
}elseif($block instanceof DyedCandle){
|
||||
$resultBlock = VanillaBlocks::CAKE_WITH_DYED_CANDLE()->setColor($block->getColor());
|
||||
}
|
||||
|
||||
if($resultBlock !== null){
|
||||
$this->position->getWorld()->setBlock($this->position, $resultBlock);
|
||||
$item->pop();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return parent::onInteract($item, $face, $clickVector, $player);
|
||||
}
|
||||
|
||||
public function getFoodRestore() : int{
|
||||
return 2;
|
||||
}
|
||||
|
||||
public function getSaturationRestore() : float{
|
||||
return 0.4;
|
||||
}
|
||||
|
||||
public function requiresHunger() : bool{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Block
|
||||
*/
|
||||
public function getResidue(){
|
||||
public function getResidue() : Block{
|
||||
$clone = clone $this;
|
||||
$clone->bites++;
|
||||
if($clone->bites > self::MAX_BITES){
|
||||
@ -129,15 +98,4 @@ class Cake extends Transparent implements FoodSource{
|
||||
}
|
||||
return $clone;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return EffectInstance[]
|
||||
*/
|
||||
public function getAdditionalEffects() : array{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function onConsume(Living $consumer) : void{
|
||||
$this->position->getWorld()->setBlock($this->position, $this->getResidue());
|
||||
}
|
||||
}
|
||||
|
78
src/block/CakeWithCandle.php
Normal file
78
src/block/CakeWithCandle.php
Normal file
@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\CandleTrait;
|
||||
use pocketmine\entity\Living;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\player\Player;
|
||||
|
||||
class CakeWithCandle extends BaseCake{
|
||||
use CandleTrait {
|
||||
onInteract as onInteractCandle;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AxisAlignedBB[]
|
||||
*/
|
||||
protected function recalculateCollisionBoxes() : array{
|
||||
return [
|
||||
AxisAlignedBB::one()
|
||||
->contract(1 / 16, 0, 1 / 16)
|
||||
->trim(Facing::UP, 0.5) //TODO: not sure if the candle affects height
|
||||
];
|
||||
}
|
||||
|
||||
public function getCandle() : Candle{
|
||||
return VanillaBlocks::CANDLE();
|
||||
}
|
||||
|
||||
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
if($this->onInteractCandle($item, $face, $clickVector, $player)){
|
||||
return true;
|
||||
}
|
||||
|
||||
return parent::onInteract($item, $face, $clickVector, $player);
|
||||
}
|
||||
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
return [$this->getCandle()->asItem()];
|
||||
}
|
||||
|
||||
public function getPickedItem(bool $addUserData = false) : Item{
|
||||
return VanillaBlocks::CAKE()->getPickedItem($addUserData);
|
||||
}
|
||||
|
||||
public function getResidue() : Block{
|
||||
return VanillaBlocks::CAKE()->setBites(1);
|
||||
}
|
||||
|
||||
public function onConsume(Living $consumer) : void{
|
||||
parent::onConsume($consumer);
|
||||
$this->position->getWorld()->dropItem($this->position->add(0.5, 0.5, 0.5), $this->getCandle()->asItem());
|
||||
}
|
||||
}
|
34
src/block/CakeWithDyedCandle.php
Normal file
34
src/block/CakeWithDyedCandle.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\ColoredTrait;
|
||||
|
||||
class CakeWithDyedCandle extends CakeWithCandle{
|
||||
use ColoredTrait;
|
||||
|
||||
public function getCandle() : Candle{
|
||||
return VanillaBlocks::DYED_CANDLE()->setColor($this->color);
|
||||
}
|
||||
}
|
132
src/block/Candle.php
Normal file
132
src/block/Candle.php
Normal file
@ -0,0 +1,132 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\CandleTrait;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Axis;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\player\Player;
|
||||
use pocketmine\utils\AssumptionFailedError;
|
||||
use pocketmine\world\BlockTransaction;
|
||||
|
||||
class Candle extends Transparent{
|
||||
use CandleTrait {
|
||||
decodeState as decodeLitState;
|
||||
encodeState as encodeLitState;
|
||||
getLightLevel as getBaseLightLevel;
|
||||
}
|
||||
|
||||
public const MIN_COUNT = 1;
|
||||
public const MAX_COUNT = 4;
|
||||
|
||||
private int $count = self::MIN_COUNT;
|
||||
|
||||
public function getRequiredStateDataBits() : int{
|
||||
return 3;
|
||||
}
|
||||
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->decodeLitState($r);
|
||||
$this->count = $r->readBoundedInt(2, self::MIN_COUNT, self::MAX_COUNT);
|
||||
}
|
||||
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$this->encodeLitState($w);
|
||||
$w->writeBoundedInt(2, self::MIN_COUNT, self::MAX_COUNT, $this->count);
|
||||
}
|
||||
|
||||
public function getCount() : int{ return $this->count; }
|
||||
|
||||
/** @return $this */
|
||||
public function setCount(int $count) : self{
|
||||
if($count < self::MIN_COUNT || $count > self::MAX_COUNT){
|
||||
throw new \InvalidArgumentException("Count must be in range " . self::MIN_COUNT . " ... " . self::MAX_COUNT);
|
||||
}
|
||||
$this->count = $count;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getLightLevel() : int{
|
||||
return $this->getBaseLightLevel() * $this->count;
|
||||
}
|
||||
|
||||
protected function recalculateCollisionBoxes() : array{
|
||||
return [
|
||||
(match($this->count){
|
||||
1 => AxisAlignedBB::one()
|
||||
->squash(Axis::X, 7 / 16)
|
||||
->squash(Axis::Z, 7 / 16),
|
||||
2 => AxisAlignedBB::one()
|
||||
->squash(Axis::X, 5 / 16)
|
||||
->trim(Facing::NORTH, 7 / 16) //0.3 thick on the Z axis
|
||||
->trim(Facing::SOUTH, 6 / 16),
|
||||
3 => AxisAlignedBB::one()
|
||||
->trim(Facing::WEST, 5 / 16)
|
||||
->trim(Facing::EAST, 6 / 16)
|
||||
->trim(Facing::NORTH, 6 / 16)
|
||||
->trim(Facing::SOUTH, 5 / 16),
|
||||
4 => AxisAlignedBB::one()
|
||||
->squash(Axis::X, 5 / 16)
|
||||
->trim(Facing::NORTH, 5 / 16)
|
||||
->trim(Facing::SOUTH, 6 / 16),
|
||||
default => throw new AssumptionFailedError("Unreachable")
|
||||
})->trim(Facing::UP, 10 / 16)
|
||||
];
|
||||
}
|
||||
|
||||
protected function getCandleIfCompatibleType(Block $block) : ?Candle{
|
||||
return $block instanceof Candle && $block->isSameType($this) ? $block : null;
|
||||
}
|
||||
|
||||
public function canBePlacedAt(Block $blockReplace, Vector3 $clickVector, int $face, bool $isClickedBlock) : bool{
|
||||
$candle = $this->getCandleIfCompatibleType($blockReplace);
|
||||
return $candle !== null ? $candle->count < self::MAX_COUNT : parent::canBePlacedAt($blockReplace, $clickVector, $face, $isClickedBlock);
|
||||
}
|
||||
|
||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
$down = $blockReplace->getSide(Facing::DOWN);
|
||||
if(!$down->getSupportType(Facing::UP)->hasCenterSupport()){
|
||||
return false;
|
||||
}
|
||||
$existing = $this->getCandleIfCompatibleType($blockReplace);
|
||||
if($existing !== null){
|
||||
if($existing->count >= self::MAX_COUNT){
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->count = $existing->count + 1;
|
||||
$this->lit = $existing->lit;
|
||||
}
|
||||
return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
||||
}
|
||||
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
return [$this->asItem()->setCount($this->count)];
|
||||
}
|
||||
}
|
@ -23,7 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\ColorInMetadataTrait;
|
||||
use pocketmine\block\utils\ColoredTrait;
|
||||
use pocketmine\block\utils\DyeColor;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
@ -33,7 +33,7 @@ use pocketmine\player\Player;
|
||||
use pocketmine\world\BlockTransaction;
|
||||
|
||||
class Carpet extends Flowable{
|
||||
use ColorInMetadataTrait;
|
||||
use ColoredTrait;
|
||||
|
||||
public function __construct(BlockIdentifier $idInfo, string $name, BlockBreakInfo $breakInfo){
|
||||
$this->color = DyeColor::WHITE();
|
||||
@ -53,7 +53,7 @@ class Carpet extends Flowable{
|
||||
|
||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
$down = $this->getSide(Facing::DOWN);
|
||||
if($down->getId() !== BlockLegacyIds::AIR){
|
||||
if($down->getTypeId() !== BlockTypeIds::AIR){
|
||||
return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
||||
}
|
||||
|
||||
@ -61,7 +61,7 @@ class Carpet extends Flowable{
|
||||
}
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
if($this->getSide(Facing::DOWN)->getId() === BlockLegacyIds::AIR){
|
||||
if($this->getSide(Facing::DOWN)->getTypeId() === BlockTypeIds::AIR){
|
||||
$this->position->getWorld()->useBreakOn($this->position);
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ class Carrot extends Crops{
|
||||
];
|
||||
}
|
||||
|
||||
public function getPickedItem(bool $addUserData = false) : Item{
|
||||
public function asItem() : Item{
|
||||
return VanillaItems::CARROT();
|
||||
}
|
||||
}
|
||||
|
44
src/block/CartographyTable.php
Normal file
44
src/block/CartographyTable.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\inventory\CartographyTableInventory;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\player\Player;
|
||||
|
||||
final class CartographyTable extends Opaque{
|
||||
|
||||
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
if($player !== null){
|
||||
$player->setCurrentWindow(new CartographyTableInventory($this->position));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getFuelTime() : int{
|
||||
return 300;
|
||||
}
|
||||
}
|
@ -23,23 +23,10 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\BlockDataSerializer;
|
||||
use pocketmine\block\utils\FacesOppositePlacingPlayerTrait;
|
||||
use pocketmine\block\utils\HorizontalFacingTrait;
|
||||
|
||||
class CarvedPumpkin extends Opaque{
|
||||
use FacesOppositePlacingPlayerTrait;
|
||||
use HorizontalFacingTrait;
|
||||
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->facing = BlockDataSerializer::readLegacyHorizontalFacing($stateMeta & 0x03);
|
||||
}
|
||||
|
||||
protected function writeStateToMeta() : int{
|
||||
return BlockDataSerializer::writeLegacyHorizontalFacing($this->facing);
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b11;
|
||||
}
|
||||
}
|
||||
|
@ -23,11 +23,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\BlockDataSerializer;
|
||||
use pocketmine\block\utils\FacesOppositePlacingPlayerTrait;
|
||||
use pocketmine\block\utils\HorizontalFacingTrait;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\player\Player;
|
||||
|
||||
@ -35,18 +33,6 @@ final class ChemistryTable extends Opaque{
|
||||
use FacesOppositePlacingPlayerTrait;
|
||||
use HorizontalFacingTrait;
|
||||
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->facing = Facing::opposite(BlockDataSerializer::readLegacyHorizontalFacing($stateMeta & 0x3));
|
||||
}
|
||||
|
||||
protected function writeStateToMeta() : int{
|
||||
return BlockDataSerializer::writeLegacyHorizontalFacing(Facing::opposite($this->facing));
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b0011;
|
||||
}
|
||||
|
||||
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
//TODO
|
||||
return false;
|
||||
|
@ -25,7 +25,7 @@ namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\tile\Chest as TileChest;
|
||||
use pocketmine\block\utils\FacesOppositePlacingPlayerTrait;
|
||||
use pocketmine\block\utils\NormalHorizontalFacingInMetadataTrait;
|
||||
use pocketmine\block\utils\HorizontalFacingTrait;
|
||||
use pocketmine\block\utils\SupportType;
|
||||
use pocketmine\event\block\ChestPairEvent;
|
||||
use pocketmine\item\Item;
|
||||
@ -36,7 +36,7 @@ use pocketmine\player\Player;
|
||||
|
||||
class Chest extends Transparent{
|
||||
use FacesOppositePlacingPlayerTrait;
|
||||
use NormalHorizontalFacingInMetadataTrait;
|
||||
use HorizontalFacingTrait;
|
||||
|
||||
/**
|
||||
* @return AxisAlignedBB[]
|
||||
|
@ -23,10 +23,11 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\BlockDataSerializer;
|
||||
use pocketmine\block\utils\HorizontalFacingTrait;
|
||||
use pocketmine\block\utils\SupportType;
|
||||
use pocketmine\block\utils\TreeType;
|
||||
use pocketmine\block\utils\WoodType;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\event\block\BlockGrowEvent;
|
||||
use pocketmine\item\Fertilizer;
|
||||
use pocketmine\item\Item;
|
||||
@ -46,17 +47,16 @@ class CocoaBlock extends Transparent{
|
||||
|
||||
protected int $age = 0;
|
||||
|
||||
protected function writeStateToMeta() : int{
|
||||
return BlockDataSerializer::writeLegacyHorizontalFacing(Facing::opposite($this->facing)) | ($this->age << 2);
|
||||
public function getRequiredStateDataBits() : int{ return 4; }
|
||||
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->facing = $r->readHorizontalFacing();
|
||||
$this->age = $r->readBoundedInt(2, 0, self::MAX_AGE);
|
||||
}
|
||||
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->facing = Facing::opposite(BlockDataSerializer::readLegacyHorizontalFacing($stateMeta & 0x03));
|
||||
$this->age = BlockDataSerializer::readBoundedInt("age", $stateMeta >> 2, 0, self::MAX_AGE);
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b1111;
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeHorizontalFacing($this->facing);
|
||||
$w->writeBoundedInt(2, 0, self::MAX_AGE, $this->age);
|
||||
}
|
||||
|
||||
public function getAge() : int{ return $this->age; }
|
||||
@ -89,7 +89,7 @@ class CocoaBlock extends Transparent{
|
||||
}
|
||||
|
||||
private function canAttachTo(Block $block) : bool{
|
||||
return $block instanceof Wood && $block->getTreeType()->equals(TreeType::JUNGLE());
|
||||
return $block instanceof Wood && $block->getWoodType()->equals(WoodType::JUNGLE());
|
||||
}
|
||||
|
||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
@ -147,7 +147,7 @@ class CocoaBlock extends Transparent{
|
||||
];
|
||||
}
|
||||
|
||||
public function getPickedItem(bool $addUserData = false) : Item{
|
||||
public function asItem() : Item{
|
||||
return VanillaItems::COCOA_BEANS();
|
||||
}
|
||||
}
|
||||
|
@ -23,11 +23,11 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\ColorInMetadataTrait;
|
||||
use pocketmine\block\utils\ColoredTrait;
|
||||
use pocketmine\block\utils\DyeColor;
|
||||
|
||||
class Concrete extends Opaque{
|
||||
use ColorInMetadataTrait;
|
||||
use ColoredTrait;
|
||||
|
||||
public function __construct(BlockIdentifier $idInfo, string $name, BlockBreakInfo $breakInfo){
|
||||
$this->color = DyeColor::WHITE();
|
||||
|
@ -23,7 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\ColorInMetadataTrait;
|
||||
use pocketmine\block\utils\ColoredTrait;
|
||||
use pocketmine\block\utils\DyeColor;
|
||||
use pocketmine\block\utils\Fallable;
|
||||
use pocketmine\block\utils\FallableTrait;
|
||||
@ -31,7 +31,7 @@ use pocketmine\event\block\BlockFormEvent;
|
||||
use pocketmine\math\Facing;
|
||||
|
||||
class ConcretePowder extends Opaque implements Fallable{
|
||||
use ColorInMetadataTrait;
|
||||
use ColoredTrait;
|
||||
use FallableTrait {
|
||||
onNearbyBlockChange as protected startFalling;
|
||||
}
|
||||
|
30
src/block/Copper.php
Normal file
30
src/block/Copper.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\CopperTrait;
|
||||
|
||||
class Copper extends Opaque{
|
||||
use CopperTrait;
|
||||
}
|
36
src/block/CopperOre.php
Normal file
36
src/block/CopperOre.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\VanillaItems;
|
||||
|
||||
final class CopperOre extends Opaque{
|
||||
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
return [VanillaItems::RAW_COPPER()];
|
||||
}
|
||||
|
||||
public function isAffectedBySilkTouch() : bool{ return true; }
|
||||
}
|
30
src/block/CopperSlab.php
Normal file
30
src/block/CopperSlab.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\CopperTrait;
|
||||
|
||||
class CopperSlab extends Slab{
|
||||
use CopperTrait;
|
||||
}
|
30
src/block/CopperStairs.php
Normal file
30
src/block/CopperStairs.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\CopperTrait;
|
||||
|
||||
class CopperStairs extends Stair{
|
||||
use CopperTrait;
|
||||
}
|
@ -23,8 +23,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\InvalidBlockStateException;
|
||||
use pocketmine\data\bedrock\CoralTypeIdMap;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\math\Vector3;
|
||||
@ -33,38 +31,6 @@ use pocketmine\world\BlockTransaction;
|
||||
|
||||
final class Coral extends BaseCoral{
|
||||
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$coralType = CoralTypeIdMap::getInstance()->fromId($stateMeta);
|
||||
if($coralType === null){
|
||||
throw new InvalidBlockStateException("No such coral type");
|
||||
}
|
||||
$this->coralType = $coralType;
|
||||
}
|
||||
|
||||
public function writeStateToMeta() : int{
|
||||
return CoralTypeIdMap::getInstance()->toId($this->coralType);
|
||||
}
|
||||
|
||||
protected function writeStateToItemMeta() : int{
|
||||
return $this->writeStateToMeta();
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b0111;
|
||||
}
|
||||
|
||||
public function readStateFromWorld() : void{
|
||||
//TODO: this hack ensures correct state of coral plants, because they don't retain their dead flag in metadata
|
||||
$world = $this->position->getWorld();
|
||||
$this->dead = true;
|
||||
foreach($this->position->sides() as $vector3){
|
||||
if($world->getBlock($vector3) instanceof Water){
|
||||
$this->dead = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
if(!$this->canBeSupportedBy($tx->fetchBlock($blockReplace->getPosition()->down()))){
|
||||
return false;
|
||||
|
@ -25,8 +25,6 @@ namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\CoralType;
|
||||
use pocketmine\block\utils\CoralTypeTrait;
|
||||
use pocketmine\block\utils\InvalidBlockStateException;
|
||||
use pocketmine\data\bedrock\CoralTypeIdMap;
|
||||
use pocketmine\item\Item;
|
||||
use function mt_rand;
|
||||
|
||||
@ -38,27 +36,6 @@ final class CoralBlock extends Opaque{
|
||||
parent::__construct($idInfo, $name, $breakInfo);
|
||||
}
|
||||
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$coralType = CoralTypeIdMap::getInstance()->fromId($stateMeta & 0x7);
|
||||
if($coralType === null){
|
||||
throw new InvalidBlockStateException("No such coral type");
|
||||
}
|
||||
$this->coralType = $coralType;
|
||||
$this->dead = ($stateMeta & BlockLegacyMetadata::CORAL_BLOCK_FLAG_DEAD) !== 0;
|
||||
}
|
||||
|
||||
protected function writeStateToMeta() : int{
|
||||
return ($this->dead ? BlockLegacyMetadata::CORAL_BLOCK_FLAG_DEAD : 0) | CoralTypeIdMap::getInstance()->toId($this->coralType);
|
||||
}
|
||||
|
||||
protected function writeStateToItemMeta() : int{
|
||||
return $this->writeStateToMeta();
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b1111;
|
||||
}
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
if(!$this->dead){
|
||||
$this->position->getWorld()->scheduleDelayedBlockUpdate($this->position, mt_rand(40, 200));
|
||||
|
@ -23,7 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\BlockDataSerializer;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\event\block\BlockGrowEvent;
|
||||
use pocketmine\item\Fertilizer;
|
||||
use pocketmine\item\Item;
|
||||
@ -38,16 +39,14 @@ abstract class Crops extends Flowable{
|
||||
|
||||
protected int $age = 0;
|
||||
|
||||
protected function writeStateToMeta() : int{
|
||||
return $this->age;
|
||||
public function getRequiredStateDataBits() : int{ return 3; }
|
||||
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->age = $r->readBoundedInt(3, 0, self::MAX_AGE);
|
||||
}
|
||||
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->age = BlockDataSerializer::readBoundedInt("age", $stateMeta, 0, self::MAX_AGE);
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b111;
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeBoundedInt(3, 0, self::MAX_AGE, $this->age);
|
||||
}
|
||||
|
||||
public function getAge() : int{ return $this->age; }
|
||||
@ -62,7 +61,7 @@ abstract class Crops extends Flowable{
|
||||
}
|
||||
|
||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
if($blockReplace->getSide(Facing::DOWN)->getId() === BlockLegacyIds::FARMLAND){
|
||||
if($blockReplace->getSide(Facing::DOWN)->getTypeId() === BlockTypeIds::FARMLAND){
|
||||
return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
||||
}
|
||||
|
||||
@ -91,7 +90,7 @@ abstract class Crops extends Flowable{
|
||||
}
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
if($this->getSide(Facing::DOWN)->getId() !== BlockLegacyIds::FARMLAND){
|
||||
if($this->getSide(Facing::DOWN)->getTypeId() !== BlockTypeIds::FARMLAND){
|
||||
$this->position->getWorld()->useBreakOn($this->position);
|
||||
}
|
||||
}
|
||||
|
@ -24,8 +24,9 @@ declare(strict_types=1);
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\AnalogRedstoneSignalEmitterTrait;
|
||||
use pocketmine\block\utils\BlockDataSerializer;
|
||||
use pocketmine\block\utils\SupportType;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Facing;
|
||||
@ -39,30 +40,18 @@ use const M_PI;
|
||||
class DaylightSensor extends Transparent{
|
||||
use AnalogRedstoneSignalEmitterTrait;
|
||||
|
||||
protected BlockIdentifierFlattened $idInfoFlattened;
|
||||
|
||||
protected bool $inverted = false;
|
||||
|
||||
public function __construct(BlockIdentifierFlattened $idInfo, string $name, BlockBreakInfo $breakInfo){
|
||||
$this->idInfoFlattened = $idInfo;
|
||||
parent::__construct($idInfo, $name, $breakInfo);
|
||||
public function getRequiredStateDataBits() : int{ return 5; }
|
||||
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->signalStrength = $r->readBoundedInt(4, 0, 15);
|
||||
$this->inverted = $r->readBool();
|
||||
}
|
||||
|
||||
public function getId() : int{
|
||||
return $this->inverted ? $this->idInfoFlattened->getSecondId() : parent::getId();
|
||||
}
|
||||
|
||||
protected function writeStateToMeta() : int{
|
||||
return $this->signalStrength;
|
||||
}
|
||||
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->signalStrength = BlockDataSerializer::readBoundedInt("signalStrength", $stateMeta, 0, 15);
|
||||
$this->inverted = $id === $this->idInfoFlattened->getSecondId();
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b1111;
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeBoundedInt(4, 0, 15, $this->signalStrength);
|
||||
$w->writeBool($this->inverted);
|
||||
}
|
||||
|
||||
public function isInverted() : bool{
|
||||
|
@ -23,9 +23,24 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
|
||||
class DetectorRail extends StraightOnlyRail{
|
||||
protected bool $activated = false;
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 4; }
|
||||
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
parent::decodeState($r);
|
||||
$this->activated = $r->readBool();
|
||||
}
|
||||
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
parent::encodeState($w);
|
||||
$w->writeBool($this->activated);
|
||||
}
|
||||
|
||||
public function isActivated() : bool{ return $this->activated; }
|
||||
|
||||
/** @return $this */
|
||||
@ -33,19 +48,5 @@ class DetectorRail extends StraightOnlyRail{
|
||||
$this->activated = $activated;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
parent::readStateFromData($id, $stateMeta & ~BlockLegacyMetadata::REDSTONE_RAIL_FLAG_POWERED);
|
||||
$this->activated = ($stateMeta & BlockLegacyMetadata::REDSTONE_RAIL_FLAG_POWERED) !== 0;
|
||||
}
|
||||
|
||||
protected function writeStateToMeta() : int{
|
||||
return parent::writeStateToMeta() | ($this->activated ? BlockLegacyMetadata::REDSTONE_RAIL_FLAG_POWERED : 0);
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b1111;
|
||||
}
|
||||
|
||||
//TODO
|
||||
}
|
||||
|
@ -23,6 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\item\Hoe;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Facing;
|
||||
@ -31,23 +33,16 @@ use pocketmine\player\Player;
|
||||
use pocketmine\world\sound\ItemUseOnBlockSound;
|
||||
|
||||
class Dirt extends Opaque{
|
||||
|
||||
protected bool $coarse = false;
|
||||
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->coarse = ($stateMeta & BlockLegacyMetadata::DIRT_FLAG_COARSE) !== 0;
|
||||
public function getRequiredTypeDataBits() : int{ return 1; }
|
||||
|
||||
protected function decodeType(RuntimeDataReader $r) : void{
|
||||
$this->coarse = $r->readBool();
|
||||
}
|
||||
|
||||
protected function writeStateToMeta() : int{
|
||||
return $this->coarse ? BlockLegacyMetadata::DIRT_FLAG_COARSE : 0;
|
||||
}
|
||||
|
||||
protected function writeStateToItemMeta() : int{
|
||||
return $this->writeStateToMeta();
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b1;
|
||||
protected function encodeType(RuntimeDataWriter $w) : void{
|
||||
$w->writeBool($this->coarse);
|
||||
}
|
||||
|
||||
public function isCoarse() : bool{ return $this->coarse; }
|
||||
|
@ -23,10 +23,10 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\BlockDataSerializer;
|
||||
use pocketmine\block\utils\HorizontalFacingTrait;
|
||||
use pocketmine\block\utils\PoweredByRedstoneTrait;
|
||||
use pocketmine\block\utils\SupportType;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Facing;
|
||||
@ -37,35 +37,25 @@ use pocketmine\world\sound\DoorSound;
|
||||
|
||||
class Door extends Transparent{
|
||||
use HorizontalFacingTrait;
|
||||
use PoweredByRedstoneTrait;
|
||||
|
||||
protected bool $top = false;
|
||||
protected bool $hingeRight = false;
|
||||
protected bool $open = false;
|
||||
|
||||
protected function writeStateToMeta() : int{
|
||||
if($this->top){
|
||||
return BlockLegacyMetadata::DOOR_FLAG_TOP |
|
||||
($this->hingeRight ? BlockLegacyMetadata::DOOR_TOP_FLAG_RIGHT : 0) |
|
||||
($this->powered ? BlockLegacyMetadata::DOOR_TOP_FLAG_POWERED : 0);
|
||||
}
|
||||
public function getRequiredStateDataBits() : int{ return 5; }
|
||||
|
||||
return BlockDataSerializer::writeLegacyHorizontalFacing(Facing::rotateY($this->facing, true)) | ($this->open ? BlockLegacyMetadata::DOOR_BOTTOM_FLAG_OPEN : 0);
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->facing = $r->readHorizontalFacing();
|
||||
$this->top = $r->readBool();
|
||||
$this->hingeRight = $r->readBool();
|
||||
$this->open = $r->readBool();
|
||||
}
|
||||
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->top = ($stateMeta & BlockLegacyMetadata::DOOR_FLAG_TOP) !== 0;
|
||||
if($this->top){
|
||||
$this->hingeRight = ($stateMeta & BlockLegacyMetadata::DOOR_TOP_FLAG_RIGHT) !== 0;
|
||||
$this->powered = ($stateMeta & BlockLegacyMetadata::DOOR_TOP_FLAG_POWERED) !== 0;
|
||||
}else{
|
||||
$this->facing = Facing::rotateY(BlockDataSerializer::readLegacyHorizontalFacing($stateMeta & 0x03), false);
|
||||
$this->open = ($stateMeta & BlockLegacyMetadata::DOOR_BOTTOM_FLAG_OPEN) !== 0;
|
||||
}
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b1111;
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeHorizontalFacing($this->facing);
|
||||
$w->writeBool($this->top);
|
||||
$w->writeBool($this->hingeRight);
|
||||
$w->writeBool($this->open);
|
||||
}
|
||||
|
||||
public function readStateFromWorld() : void{
|
||||
@ -79,7 +69,6 @@ class Door extends Transparent{
|
||||
$this->open = $other->open;
|
||||
}else{
|
||||
$this->hingeRight = $other->hingeRight;
|
||||
$this->powered = $other->powered;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\math\Vector3;
|
||||
@ -30,19 +32,16 @@ use pocketmine\player\Player;
|
||||
use pocketmine\world\BlockTransaction;
|
||||
|
||||
class DoublePlant extends Flowable{
|
||||
|
||||
protected bool $top = false;
|
||||
|
||||
protected function writeStateToMeta() : int{
|
||||
return ($this->top ? BlockLegacyMetadata::DOUBLE_PLANT_FLAG_TOP : 0);
|
||||
public function getRequiredStateDataBits() : int{ return 1; }
|
||||
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->top = $r->readBool();
|
||||
}
|
||||
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->top = ($stateMeta & BlockLegacyMetadata::DOUBLE_PLANT_FLAG_TOP) !== 0;
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b1000;
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeBool($this->top);
|
||||
}
|
||||
|
||||
public function isTop() : bool{ return $this->top; }
|
||||
@ -54,8 +53,8 @@ class DoublePlant extends Flowable{
|
||||
}
|
||||
|
||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
$id = $blockReplace->getSide(Facing::DOWN)->getId();
|
||||
if(($id === BlockLegacyIds::GRASS || $id === BlockLegacyIds::DIRT) && $blockReplace->getSide(Facing::UP)->canBeReplaced()){
|
||||
$id = $blockReplace->getSide(Facing::DOWN)->getTypeId();
|
||||
if(($id === BlockTypeIds::GRASS || $id === BlockTypeIds::DIRT) && $blockReplace->getSide(Facing::UP)->canBeReplaced()){
|
||||
$top = clone $this;
|
||||
$top->top = true;
|
||||
$tx->addBlock($blockReplace->position, $this)->addBlock($blockReplace->position->getSide(Facing::UP), $top);
|
||||
|
36
src/block/DyedCandle.php
Normal file
36
src/block/DyedCandle.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\ColoredTrait;
|
||||
|
||||
class DyedCandle extends Candle{
|
||||
use ColoredTrait;
|
||||
|
||||
protected function getCandleIfCompatibleType(Block $block) : ?Candle{
|
||||
$result = parent::getCandleIfCompatibleType($block);
|
||||
//different coloured candles can't be combined in the same block
|
||||
return $result instanceof DyedCandle && $result->color->equals($this->color) ? $result : null;
|
||||
}
|
||||
}
|
@ -23,11 +23,11 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\ColorInMetadataTrait;
|
||||
use pocketmine\block\utils\ColoredTrait;
|
||||
use pocketmine\block\utils\DyeColor;
|
||||
|
||||
final class DyedShulkerBox extends ShulkerBox{
|
||||
use ColorInMetadataTrait;
|
||||
use ColoredTrait;
|
||||
|
||||
public function __construct(BlockIdentifier $idInfo, string $name, BlockBreakInfo $breakInfo){
|
||||
$this->color = DyeColor::WHITE();
|
||||
|
@ -23,9 +23,10 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\BlockDataSerializer;
|
||||
use pocketmine\block\utils\FacesOppositePlacingPlayerTrait;
|
||||
use pocketmine\block\utils\HorizontalFacingTrait;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Facing;
|
||||
|
||||
@ -35,17 +36,16 @@ class EndPortalFrame extends Opaque{
|
||||
|
||||
protected bool $eye = false;
|
||||
|
||||
protected function writeStateToMeta() : int{
|
||||
return BlockDataSerializer::writeLegacyHorizontalFacing($this->facing) | ($this->eye ? BlockLegacyMetadata::END_PORTAL_FRAME_FLAG_EYE : 0);
|
||||
public function getRequiredStateDataBits() : int{ return 3; }
|
||||
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->facing = $r->readHorizontalFacing();
|
||||
$this->eye = $r->readBool();
|
||||
}
|
||||
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->facing = BlockDataSerializer::readLegacyHorizontalFacing($stateMeta & 0x03);
|
||||
$this->eye = ($stateMeta & BlockLegacyMetadata::END_PORTAL_FRAME_FLAG_EYE) !== 0;
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b111;
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeHorizontalFacing($this->facing);
|
||||
$w->writeBool($this->eye);
|
||||
}
|
||||
|
||||
public function hasEye() : bool{ return $this->eye; }
|
||||
|
@ -24,7 +24,6 @@ declare(strict_types=1);
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\AnyFacingTrait;
|
||||
use pocketmine\block\utils\BlockDataSerializer;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Axis;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
@ -36,27 +35,6 @@ use pocketmine\world\BlockTransaction;
|
||||
class EndRod extends Flowable{
|
||||
use AnyFacingTrait;
|
||||
|
||||
protected function writeStateToMeta() : int{
|
||||
$result = BlockDataSerializer::writeFacing($this->facing);
|
||||
if(Facing::axis($this->facing) !== Axis::Y){
|
||||
$result ^= 1; //TODO: in PC this is always the same as facing, just PE is stupid
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
if($stateMeta !== 0 && $stateMeta !== 1){
|
||||
$stateMeta ^= 1;
|
||||
}
|
||||
|
||||
$this->facing = BlockDataSerializer::readFacing($stateMeta);
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b111;
|
||||
}
|
||||
|
||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
$this->facing = $face;
|
||||
if($blockClicked instanceof EndRod && $blockClicked->facing === $this->facing){
|
||||
|
@ -26,7 +26,7 @@ namespace pocketmine\block;
|
||||
use pocketmine\block\inventory\EnderChestInventory;
|
||||
use pocketmine\block\tile\EnderChest as TileEnderChest;
|
||||
use pocketmine\block\utils\FacesOppositePlacingPlayerTrait;
|
||||
use pocketmine\block\utils\NormalHorizontalFacingInMetadataTrait;
|
||||
use pocketmine\block\utils\HorizontalFacingTrait;
|
||||
use pocketmine\block\utils\SupportType;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
@ -36,7 +36,7 @@ use pocketmine\player\Player;
|
||||
|
||||
class EnderChest extends Transparent{
|
||||
use FacesOppositePlacingPlayerTrait;
|
||||
use NormalHorizontalFacingInMetadataTrait;
|
||||
use HorizontalFacingTrait;
|
||||
|
||||
public function getLightLevel() : int{
|
||||
return 7;
|
||||
|
@ -23,7 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\BlockDataSerializer;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\entity\Entity;
|
||||
use pocketmine\entity\Living;
|
||||
use pocketmine\event\entity\EntityTrampleFarmlandEvent;
|
||||
@ -37,16 +38,14 @@ class Farmland extends Transparent{
|
||||
|
||||
protected int $wetness = 0; //"moisture" blockstate property in PC
|
||||
|
||||
protected function writeStateToMeta() : int{
|
||||
return $this->wetness;
|
||||
public function getRequiredStateDataBits() : int{ return 3; }
|
||||
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->wetness = $r->readBoundedInt(3, 0, self::MAX_WETNESS);
|
||||
}
|
||||
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->wetness = BlockDataSerializer::readBoundedInt("wetness", $stateMeta, 0, self::MAX_WETNESS);
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b111;
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeBoundedInt(3, 0, self::MAX_WETNESS, $this->wetness);
|
||||
}
|
||||
|
||||
public function getWetness() : int{ return $this->wetness; }
|
||||
|
@ -23,9 +23,11 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\BlockDataSerializer;
|
||||
use pocketmine\block\utils\HorizontalFacingTrait;
|
||||
use pocketmine\block\utils\SupportType;
|
||||
use pocketmine\block\utils\WoodTypeTrait;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Facing;
|
||||
@ -35,25 +37,24 @@ use pocketmine\world\BlockTransaction;
|
||||
use pocketmine\world\sound\DoorSound;
|
||||
|
||||
class FenceGate extends Transparent{
|
||||
use WoodTypeTrait;
|
||||
use HorizontalFacingTrait;
|
||||
|
||||
protected bool $open = false;
|
||||
protected bool $inWall = false;
|
||||
|
||||
protected function writeStateToMeta() : int{
|
||||
return BlockDataSerializer::writeLegacyHorizontalFacing($this->facing) |
|
||||
($this->open ? BlockLegacyMetadata::FENCE_GATE_FLAG_OPEN : 0) |
|
||||
($this->inWall ? BlockLegacyMetadata::FENCE_GATE_FLAG_IN_WALL : 0);
|
||||
public function getRequiredStateDataBits() : int{ return 4; }
|
||||
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->facing = $r->readHorizontalFacing();
|
||||
$this->open = $r->readBool();
|
||||
$this->inWall = $r->readBool();
|
||||
}
|
||||
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->facing = BlockDataSerializer::readLegacyHorizontalFacing($stateMeta & 0x03);
|
||||
$this->open = ($stateMeta & BlockLegacyMetadata::FENCE_GATE_FLAG_OPEN) !== 0;
|
||||
$this->inWall = ($stateMeta & BlockLegacyMetadata::FENCE_GATE_FLAG_IN_WALL) !== 0;
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b1111;
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeHorizontalFacing($this->facing);
|
||||
$w->writeBool($this->open);
|
||||
$w->writeBool($this->inWall);
|
||||
}
|
||||
|
||||
public function isOpen() : bool{ return $this->open; }
|
||||
@ -127,10 +128,10 @@ class FenceGate extends Transparent{
|
||||
}
|
||||
|
||||
public function getFlameEncouragement() : int{
|
||||
return 5;
|
||||
return $this->woodType->isFlammable() ? 5 : 0;
|
||||
}
|
||||
|
||||
public function getFlammability() : int{
|
||||
return 20;
|
||||
return $this->woodType->isFlammable() ? 20 : 0;
|
||||
}
|
||||
}
|
||||
|
@ -23,15 +23,10 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\BlockDataSerializer;
|
||||
use pocketmine\entity\Entity;
|
||||
use pocketmine\entity\projectile\Arrow;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\event\block\BlockBurnEvent;
|
||||
use pocketmine\event\block\BlockSpreadEvent;
|
||||
use pocketmine\event\entity\EntityCombustByBlockEvent;
|
||||
use pocketmine\event\entity\EntityDamageByBlockEvent;
|
||||
use pocketmine\event\entity\EntityDamageEvent;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\world\format\Chunk;
|
||||
use pocketmine\world\World;
|
||||
@ -40,21 +35,19 @@ use function max;
|
||||
use function min;
|
||||
use function mt_rand;
|
||||
|
||||
class Fire extends Flowable{
|
||||
class Fire extends BaseFire{
|
||||
public const MAX_AGE = 15;
|
||||
|
||||
protected int $age = 0;
|
||||
|
||||
protected function writeStateToMeta() : int{
|
||||
return $this->age;
|
||||
public function getRequiredStateDataBits() : int{ return 4; }
|
||||
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->age = $r->readBoundedInt(4, 0, self::MAX_AGE);
|
||||
}
|
||||
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->age = BlockDataSerializer::readBoundedInt("age", $stateMeta, 0, self::MAX_AGE);
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b1111;
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeBoundedInt(4, 0, self::MAX_AGE, $this->age);
|
||||
}
|
||||
|
||||
public function getAge() : int{ return $this->age; }
|
||||
@ -68,39 +61,15 @@ class Fire extends Flowable{
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function hasEntityCollision() : bool{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getLightLevel() : int{
|
||||
return 15;
|
||||
}
|
||||
|
||||
public function canBeReplaced() : bool{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function onEntityInside(Entity $entity) : bool{
|
||||
$ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_FIRE, 1);
|
||||
$entity->attack($ev);
|
||||
|
||||
$ev = new EntityCombustByBlockEvent($this, $entity, 8);
|
||||
if($entity instanceof Arrow){
|
||||
$ev->cancel();
|
||||
}
|
||||
$ev->call();
|
||||
if(!$ev->isCancelled()){
|
||||
$entity->setOnFire($ev->getDuration());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
return [];
|
||||
protected function getFireDamage() : int{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
if($this->getSide(Facing::DOWN)->isTransparent() && !$this->hasAdjacentFlammableBlocks()){
|
||||
$down = $this->getSide(Facing::DOWN);
|
||||
if(SoulFire::canBeSupportedBy($down)){
|
||||
$this->position->getWorld()->setBlock($this->position, VanillaBlocks::SOUL_FIRE());
|
||||
}elseif($down->isTransparent() && !$this->hasAdjacentFlammableBlocks()){
|
||||
$this->position->getWorld()->setBlock($this->position, VanillaBlocks::AIR());
|
||||
}else{
|
||||
$this->position->getWorld()->scheduleDelayedBlockUpdate($this->position, mt_rand(30, 40));
|
||||
@ -224,7 +193,7 @@ class Fire extends Flowable{
|
||||
continue;
|
||||
}
|
||||
$block = $world->getBlockAt($targetX, $targetY, $targetZ);
|
||||
if($block->getId() !== BlockLegacyIds::AIR){
|
||||
if($block->getTypeId() !== BlockTypeIds::AIR){
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -33,18 +33,6 @@ use pocketmine\world\BlockTransaction;
|
||||
final class FloorBanner extends BaseBanner{
|
||||
use SignLikeRotationTrait;
|
||||
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->rotation = $stateMeta;
|
||||
}
|
||||
|
||||
protected function writeStateToMeta() : int{
|
||||
return $this->rotation;
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b1111;
|
||||
}
|
||||
|
||||
protected function getSupportingFace() : int{
|
||||
return Facing::DOWN;
|
||||
}
|
||||
|
@ -23,11 +23,10 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\InvalidBlockStateException;
|
||||
use pocketmine\data\bedrock\CoralTypeIdMap;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\ItemFactory;
|
||||
use pocketmine\item\ItemIds;
|
||||
use pocketmine\item\VanillaItems;
|
||||
use pocketmine\math\Axis;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\math\Vector3;
|
||||
@ -37,49 +36,16 @@ use function atan2;
|
||||
use function rad2deg;
|
||||
|
||||
final class FloorCoralFan extends BaseCoral{
|
||||
|
||||
protected BlockIdentifierFlattened $idInfoFlattened;
|
||||
|
||||
private int $axis = Axis::X;
|
||||
|
||||
public function __construct(BlockIdentifierFlattened $idInfo, string $name, BlockBreakInfo $breakInfo){
|
||||
$this->idInfoFlattened = $idInfo;
|
||||
parent::__construct($idInfo, $name, $breakInfo);
|
||||
public function getRequiredStateDataBits() : int{ return parent::getRequiredStateDataBits() + 1; }
|
||||
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->axis = $r->readHorizontalAxis();
|
||||
}
|
||||
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->dead = $id === $this->idInfoFlattened->getSecondId();
|
||||
$this->axis = ($stateMeta >> 3) === BlockLegacyMetadata::CORAL_FAN_EAST_WEST ? Axis::X : Axis::Z;
|
||||
$coralType = CoralTypeIdMap::getInstance()->fromId($stateMeta & BlockLegacyMetadata::CORAL_FAN_TYPE_MASK);
|
||||
if($coralType === null){
|
||||
throw new InvalidBlockStateException("No such coral type");
|
||||
}
|
||||
$this->coralType = $coralType;
|
||||
}
|
||||
|
||||
public function getId() : int{
|
||||
return $this->dead ? $this->idInfoFlattened->getSecondId() : parent::getId();
|
||||
}
|
||||
|
||||
public function asItem() : Item{
|
||||
//TODO: HACK! workaround dead flag being lost when broken / blockpicked (original impl only uses first ID)
|
||||
return ItemFactory::getInstance()->get(
|
||||
$this->dead ? ItemIds::CORAL_FAN_DEAD : ItemIds::CORAL_FAN,
|
||||
$this->writeStateToItemMeta()
|
||||
);
|
||||
}
|
||||
|
||||
protected function writeStateToMeta() : int{
|
||||
return (($this->axis === Axis::X ? BlockLegacyMetadata::CORAL_FAN_EAST_WEST : BlockLegacyMetadata::CORAL_FAN_NORTH_SOUTH) << 3) |
|
||||
CoralTypeIdMap::getInstance()->toId($this->coralType);
|
||||
}
|
||||
|
||||
protected function writeStateToItemMeta() : int{
|
||||
return CoralTypeIdMap::getInstance()->toId($this->coralType);
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b1111;
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeHorizontalAxis($this->axis);
|
||||
}
|
||||
|
||||
public function getAxis() : int{ return $this->axis; }
|
||||
@ -124,4 +90,7 @@ final class FloorCoralFan extends BaseCoral{
|
||||
return $block->getSupportType(Facing::UP)->hasCenterSupport();
|
||||
}
|
||||
|
||||
public function asItem() : Item{
|
||||
return VanillaItems::CORAL_FAN()->setCoralType($this->coralType)->setDead($this->dead);
|
||||
}
|
||||
}
|
||||
|
@ -33,18 +33,6 @@ use pocketmine\world\BlockTransaction;
|
||||
final class FloorSign extends BaseSign{
|
||||
use SignLikeRotationTrait;
|
||||
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->rotation = $stateMeta;
|
||||
}
|
||||
|
||||
protected function writeStateToMeta() : int{
|
||||
return $this->rotation;
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b1111;
|
||||
}
|
||||
|
||||
protected function getSupportingFace() : int{
|
||||
return Facing::DOWN;
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ class Flower extends Flowable{
|
||||
|
||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
$down = $this->getSide(Facing::DOWN);
|
||||
if($down->getId() === BlockLegacyIds::GRASS || $down->getId() === BlockLegacyIds::DIRT || $down->getId() === BlockLegacyIds::FARMLAND){
|
||||
if($down->getTypeId() === BlockTypeIds::GRASS || $down->getTypeId() === BlockTypeIds::DIRT || $down->getTypeId() === BlockTypeIds::FARMLAND){
|
||||
return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
||||
}
|
||||
|
||||
|
@ -36,15 +36,6 @@ class FlowerPot extends Flowable{
|
||||
|
||||
protected ?Block $plant = null;
|
||||
|
||||
protected function writeStateToMeta() : int{
|
||||
//TODO: HACK! this is just to make the client actually render the plant - we purposely don't read the flag back
|
||||
return $this->plant !== null ? BlockLegacyMetadata::FLOWER_POT_FLAG_OCCUPIED : 0;
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b1;
|
||||
}
|
||||
|
||||
public function readStateFromWorld() : void{
|
||||
parent::readStateFromWorld();
|
||||
$tile = $this->position->getWorld()->getTile($this->position);
|
||||
@ -92,7 +83,7 @@ class FlowerPot extends Flowable{
|
||||
$block instanceof Flower ||
|
||||
$block instanceof RedMushroom ||
|
||||
$block instanceof Sapling ||
|
||||
($block instanceof TallGrass && $block->getIdInfo()->getVariant() === BlockLegacyMetadata::TALLGRASS_FERN); //TODO: clean up
|
||||
($block instanceof TallGrass && $block->getTypeId() === BlockTypeIds::LARGE_FERN);
|
||||
//TODO: bamboo
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\BlockDataSerializer;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\event\block\BlockMeltEvent;
|
||||
use function mt_rand;
|
||||
|
||||
@ -32,16 +33,14 @@ class FrostedIce extends Ice{
|
||||
|
||||
protected int $age = 0;
|
||||
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->age = BlockDataSerializer::readBoundedInt("age", $stateMeta, 0, self::MAX_AGE);
|
||||
public function getRequiredStateDataBits() : int{ return 2; }
|
||||
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->age = $r->readBoundedInt(2, 0, self::MAX_AGE);
|
||||
}
|
||||
|
||||
protected function writeStateToMeta() : int{
|
||||
return $this->age;
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b11;
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeBoundedInt(2, 0, self::MAX_AGE, $this->age);
|
||||
}
|
||||
|
||||
public function getAge() : int{ return $this->age; }
|
||||
|
@ -25,7 +25,9 @@ namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\tile\Furnace as TileFurnace;
|
||||
use pocketmine\block\utils\FacesOppositePlacingPlayerTrait;
|
||||
use pocketmine\block\utils\NormalHorizontalFacingInMetadataTrait;
|
||||
use pocketmine\block\utils\HorizontalFacingTrait;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\player\Player;
|
||||
@ -33,26 +35,20 @@ use function mt_rand;
|
||||
|
||||
class Furnace extends Opaque{
|
||||
use FacesOppositePlacingPlayerTrait;
|
||||
use NormalHorizontalFacingInMetadataTrait {
|
||||
readStateFromData as readFacingStateFromData;
|
||||
use HorizontalFacingTrait;
|
||||
|
||||
protected bool $lit = false;
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 3; }
|
||||
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->facing = $r->readHorizontalFacing();
|
||||
$this->lit = $r->readBool();
|
||||
}
|
||||
|
||||
protected BlockIdentifierFlattened $idInfoFlattened;
|
||||
|
||||
protected bool $lit = false; //this is set based on the blockID
|
||||
|
||||
public function __construct(BlockIdentifierFlattened $idInfo, string $name, BlockBreakInfo $breakInfo){
|
||||
$this->idInfoFlattened = $idInfo;
|
||||
parent::__construct($idInfo, $name, $breakInfo);
|
||||
}
|
||||
|
||||
public function getId() : int{
|
||||
return $this->lit ? $this->idInfoFlattened->getSecondId() : parent::getId();
|
||||
}
|
||||
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->readFacingStateFromData($id, $stateMeta);
|
||||
$this->lit = $id === $this->idInfoFlattened->getSecondId();
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeHorizontalFacing($this->facing);
|
||||
$w->writeBool($this->lit);
|
||||
}
|
||||
|
||||
public function getLightLevel() : int{
|
||||
|
41
src/block/GildedBlackstone.php
Normal file
41
src/block/GildedBlackstone.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\VanillaItems;
|
||||
use function mt_rand;
|
||||
|
||||
final class GildedBlackstone extends Opaque{
|
||||
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
if(mt_rand(1, 10) === 1){
|
||||
return [VanillaItems::GOLD_NUGGET()->setCount(mt_rand(2, 5))];
|
||||
}
|
||||
|
||||
return parent::getDropsForCompatibleTool($item);
|
||||
}
|
||||
|
||||
public function isAffectedBySilkTouch() : bool{ return true; }
|
||||
}
|
@ -23,10 +23,18 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\ColoredTrait;
|
||||
use pocketmine\block\utils\DyeColor;
|
||||
use pocketmine\block\utils\FacesOppositePlacingPlayerTrait;
|
||||
use pocketmine\block\utils\NormalHorizontalFacingInMetadataTrait;
|
||||
use pocketmine\block\utils\HorizontalFacingTrait;
|
||||
|
||||
class GlazedTerracotta extends Opaque{
|
||||
use ColoredTrait;
|
||||
use FacesOppositePlacingPlayerTrait;
|
||||
use NormalHorizontalFacingInMetadataTrait;
|
||||
use HorizontalFacingTrait;
|
||||
|
||||
public function __construct(BlockIdentifier $idInfo, string $name, BlockBreakInfo $breakInfo){
|
||||
$this->color = DyeColor::BLACK();
|
||||
parent::__construct($idInfo, $name, $breakInfo);
|
||||
}
|
||||
}
|
||||
|
36
src/block/GoldOre.php
Normal file
36
src/block/GoldOre.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\VanillaItems;
|
||||
|
||||
final class GoldOre extends Opaque{
|
||||
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
return [VanillaItems::RAW_GOLD()];
|
||||
}
|
||||
|
||||
public function isAffectedBySilkTouch() : bool{ return true; }
|
||||
}
|
@ -103,7 +103,7 @@ class Grass extends Opaque{
|
||||
$this->position->getWorld()->setBlock($this->position, $newBlock);
|
||||
|
||||
return true;
|
||||
}elseif($item instanceof Shovel && $this->getSide(Facing::UP)->getId() === BlockLegacyIds::AIR){
|
||||
}elseif($item instanceof Shovel && $this->getSide(Facing::UP)->getTypeId() === BlockTypeIds::AIR){
|
||||
$item->applyDamage(1);
|
||||
$newBlock = VanillaBlocks::GRASS_PATH();
|
||||
$this->position->getWorld()->addSound($this->position->add(0.5, 0.5, 0.5), new ItemUseOnBlockSound($newBlock));
|
||||
|
58
src/block/HangingRoots.php
Normal file
58
src/block/HangingRoots.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\enchantment\VanillaEnchantments;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\player\Player;
|
||||
use pocketmine\world\BlockTransaction;
|
||||
|
||||
final class HangingRoots extends Flowable{
|
||||
|
||||
private function canBeSupportedBy(Block $block) : bool{
|
||||
return $block->isSolid(); //TODO: not sure if this is the correct logic
|
||||
}
|
||||
|
||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
if(!$blockReplace->getSide(Facing::UP)->isSolid()){
|
||||
return false;
|
||||
}
|
||||
return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
||||
}
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
if(!$this->canBeSupportedBy($this->getSide(Facing::UP))){
|
||||
$this->position->getWorld()->useBreakOn($this->position);
|
||||
}
|
||||
}
|
||||
|
||||
public function getDropsForIncompatibleTool(Item $item) : array{
|
||||
if($item->hasEnchantment(VanillaEnchantments::SILK_TOUCH())){
|
||||
return $this->getDropsForCompatibleTool($item);
|
||||
}
|
||||
return [];
|
||||
}
|
||||
}
|
@ -23,11 +23,11 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\PillarRotationInMetadataTrait;
|
||||
use pocketmine\block\utils\PillarRotationTrait;
|
||||
use pocketmine\entity\Entity;
|
||||
|
||||
class HayBale extends Opaque{
|
||||
use PillarRotationInMetadataTrait;
|
||||
use PillarRotationTrait;
|
||||
|
||||
public function getFlameEncouragement() : int{
|
||||
return 60;
|
||||
|
@ -24,10 +24,11 @@ declare(strict_types=1);
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\tile\Hopper as TileHopper;
|
||||
use pocketmine\block\utils\BlockDataSerializer;
|
||||
use pocketmine\block\utils\InvalidBlockStateException;
|
||||
use pocketmine\block\utils\PoweredByRedstoneTrait;
|
||||
use pocketmine\block\utils\SupportType;
|
||||
use pocketmine\data\runtime\InvalidSerializedRuntimeDataException;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Facing;
|
||||
@ -40,21 +41,20 @@ class Hopper extends Transparent{
|
||||
|
||||
private int $facing = Facing::DOWN;
|
||||
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$facing = BlockDataSerializer::readFacing($stateMeta & 0x07);
|
||||
public function getRequiredStateDataBits() : int{ return 4; }
|
||||
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$facing = $r->readFacing();
|
||||
if($facing === Facing::UP){
|
||||
throw new InvalidBlockStateException("Hopper may not face upward");
|
||||
throw new InvalidSerializedRuntimeDataException("Hopper may not face upward");
|
||||
}
|
||||
$this->facing = $facing;
|
||||
$this->powered = ($stateMeta & BlockLegacyMetadata::HOPPER_FLAG_POWERED) !== 0;
|
||||
$this->powered = $r->readBool();
|
||||
}
|
||||
|
||||
protected function writeStateToMeta() : int{
|
||||
return BlockDataSerializer::writeFacing($this->facing) | ($this->powered ? BlockLegacyMetadata::HOPPER_FLAG_POWERED : 0);
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b1111;
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeFacing($this->facing);
|
||||
$w->writeBool($this->powered);
|
||||
}
|
||||
|
||||
public function getFacing() : int{ return $this->facing; }
|
||||
|
@ -31,11 +31,11 @@ final class InfestedStone extends Opaque{
|
||||
|
||||
public function __construct(BlockIdentifier $idInfo, string $name, BlockBreakInfo $breakInfo, Block $imitated){
|
||||
parent::__construct($idInfo, $name, $breakInfo);
|
||||
$this->imitated = $imitated->getFullId();
|
||||
$this->imitated = $imitated->getStateId();
|
||||
}
|
||||
|
||||
public function getImitatedBlock() : Block{
|
||||
return BlockFactory::getInstance()->fromFullBlock($this->imitated);
|
||||
return BlockFactory::getInstance()->fromStateId($this->imitated);
|
||||
}
|
||||
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
|
36
src/block/IronOre.php
Normal file
36
src/block/IronOre.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\VanillaItems;
|
||||
|
||||
final class IronOre extends Opaque{
|
||||
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
return [VanillaItems::RAW_IRON()];
|
||||
}
|
||||
|
||||
public function isAffectedBySilkTouch() : bool{ return true; }
|
||||
}
|
@ -24,8 +24,9 @@ declare(strict_types=1);
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\tile\ItemFrame as TileItemFrame;
|
||||
use pocketmine\block\utils\BlockDataSerializer;
|
||||
use pocketmine\block\utils\HorizontalFacingTrait;
|
||||
use pocketmine\block\utils\AnyFacingTrait;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\math\Vector3;
|
||||
@ -36,23 +37,38 @@ use function is_nan;
|
||||
use function lcg_value;
|
||||
|
||||
class ItemFrame extends Flowable{
|
||||
use HorizontalFacingTrait;
|
||||
use AnyFacingTrait;
|
||||
|
||||
public const ROTATIONS = 8;
|
||||
|
||||
protected bool $glowing = false;
|
||||
|
||||
protected bool $hasMap = false; //makes frame appear large if set
|
||||
|
||||
protected ?Item $framedItem = null;
|
||||
protected int $itemRotation = 0;
|
||||
protected float $itemDropChance = 1.0;
|
||||
|
||||
protected function writeStateToMeta() : int{
|
||||
return BlockDataSerializer::write5MinusHorizontalFacing($this->facing) | ($this->hasMap ? BlockLegacyMetadata::ITEM_FRAME_FLAG_HAS_MAP : 0);
|
||||
public function getRequiredTypeDataBits() : int{ return 1; }
|
||||
|
||||
protected function decodeType(RuntimeDataReader $r) : void{
|
||||
$this->glowing = $r->readBool();
|
||||
}
|
||||
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->facing = BlockDataSerializer::read5MinusHorizontalFacing($stateMeta);
|
||||
$this->hasMap = ($stateMeta & BlockLegacyMetadata::ITEM_FRAME_FLAG_HAS_MAP) !== 0;
|
||||
protected function encodeType(RuntimeDataWriter $w) : void{
|
||||
$w->writeBool($this->glowing);
|
||||
}
|
||||
|
||||
public function getRequiredStateDataBits() : int{ return 4; }
|
||||
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->facing = $r->readFacing();
|
||||
$this->hasMap = $r->readBool();
|
||||
}
|
||||
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeFacing($this->facing);
|
||||
$w->writeBool($this->hasMap);
|
||||
}
|
||||
|
||||
public function readStateFromWorld() : void{
|
||||
@ -78,10 +94,6 @@ class ItemFrame extends Flowable{
|
||||
}
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b111;
|
||||
}
|
||||
|
||||
public function getFramedItem() : ?Item{
|
||||
return $this->framedItem !== null ? clone $this->framedItem : null;
|
||||
}
|
||||
@ -133,6 +145,14 @@ class ItemFrame extends Flowable{
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isGlowing() : bool{ return $this->glowing; }
|
||||
|
||||
/** @return $this */
|
||||
public function setGlowing(bool $glowing) : self{
|
||||
$this->glowing = $glowing;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
if($this->framedItem !== null){
|
||||
$this->itemRotation = ($this->itemRotation + 1) % self::ROTATIONS;
|
||||
@ -166,7 +186,7 @@ class ItemFrame extends Flowable{
|
||||
}
|
||||
|
||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
if($face === Facing::DOWN || $face === Facing::UP || !$blockClicked->isSolid()){
|
||||
if(!$blockClicked->isSolid()){
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\NormalHorizontalFacingInMetadataTrait;
|
||||
use pocketmine\block\utils\HorizontalFacingTrait;
|
||||
use pocketmine\block\utils\SupportType;
|
||||
use pocketmine\entity\Entity;
|
||||
use pocketmine\entity\Living;
|
||||
@ -36,7 +36,7 @@ use pocketmine\player\Player;
|
||||
use pocketmine\world\BlockTransaction;
|
||||
|
||||
class Ladder extends Transparent{
|
||||
use NormalHorizontalFacingInMetadataTrait;
|
||||
use HorizontalFacingTrait;
|
||||
|
||||
public function hasEntityCollision() : bool{
|
||||
return true;
|
||||
|
@ -24,6 +24,8 @@ declare(strict_types=1);
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\SupportType;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Axis;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
@ -33,19 +35,23 @@ use pocketmine\player\Player;
|
||||
use pocketmine\world\BlockTransaction;
|
||||
|
||||
class Lantern extends Transparent{
|
||||
private int $lightLevel; //readonly
|
||||
|
||||
protected bool $hanging = false;
|
||||
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->hanging = ($stateMeta & BlockLegacyMetadata::LANTERN_FLAG_HANGING) !== 0;
|
||||
public function __construct(BlockIdentifier $idInfo, string $name, BlockBreakInfo $breakInfo, int $lightLevel){
|
||||
$this->lightLevel = $lightLevel;
|
||||
parent::__construct($idInfo, $name, $breakInfo);
|
||||
}
|
||||
|
||||
protected function writeStateToMeta() : int{
|
||||
return $this->hanging ? BlockLegacyMetadata::LANTERN_FLAG_HANGING : 0;
|
||||
public function getRequiredStateDataBits() : int{ return 1; }
|
||||
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->hanging = $r->readBool();
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b1;
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeBool($this->hanging);
|
||||
}
|
||||
|
||||
public function isHanging() : bool{ return $this->hanging; }
|
||||
@ -57,7 +63,7 @@ class Lantern extends Transparent{
|
||||
}
|
||||
|
||||
public function getLightLevel() : int{
|
||||
return 15;
|
||||
return $this->lightLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -54,31 +54,43 @@ class Lava extends Liquid{
|
||||
return 2; //TODO: this is 1 in the nether
|
||||
}
|
||||
|
||||
protected function checkForHarden() : bool{
|
||||
if($this->falling){
|
||||
return false;
|
||||
}
|
||||
$colliding = null;
|
||||
/**
|
||||
* @phpstan-return \Generator<int, Block, void, void>
|
||||
*/
|
||||
private function getAdjacentBlocksExceptDown() : \Generator{
|
||||
foreach(Facing::ALL as $side){
|
||||
if($side === Facing::DOWN){
|
||||
continue;
|
||||
}
|
||||
$blockSide = $this->getSide($side);
|
||||
if($blockSide instanceof Water){
|
||||
$colliding = $blockSide;
|
||||
break;
|
||||
yield $this->getSide($side);
|
||||
}
|
||||
}
|
||||
|
||||
protected function checkForHarden() : bool{
|
||||
if($this->falling){
|
||||
return false;
|
||||
}
|
||||
foreach($this->getAdjacentBlocksExceptDown() as $colliding){
|
||||
if($colliding instanceof Water){
|
||||
if($this->decay === 0){
|
||||
$this->liquidCollide($colliding, VanillaBlocks::OBSIDIAN());
|
||||
return true;
|
||||
}elseif($this->decay <= 4){
|
||||
$this->liquidCollide($colliding, VanillaBlocks::COBBLESTONE());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($colliding !== null){
|
||||
if($this->decay === 0){
|
||||
$this->liquidCollide($colliding, VanillaBlocks::OBSIDIAN());
|
||||
return true;
|
||||
}elseif($this->decay <= 4){
|
||||
$this->liquidCollide($colliding, VanillaBlocks::COBBLESTONE());
|
||||
return true;
|
||||
if($this->getSide(Facing::DOWN)->getTypeId() === BlockTypeIds::SOUL_SOIL){
|
||||
foreach($this->getAdjacentBlocksExceptDown() as $colliding){
|
||||
if($colliding->getTypeId() === BlockTypeIds::BLUE_ICE){
|
||||
$this->liquidCollide($colliding, VanillaBlocks::BASALT());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -25,20 +25,20 @@ namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\SupportType;
|
||||
use pocketmine\block\utils\TreeType;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\event\block\LeavesDecayEvent;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\ItemFactory;
|
||||
use pocketmine\item\ItemIds;
|
||||
use pocketmine\item\VanillaItems;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\player\Player;
|
||||
use pocketmine\utils\AssumptionFailedError;
|
||||
use pocketmine\world\BlockTransaction;
|
||||
use pocketmine\world\World;
|
||||
use function mt_rand;
|
||||
|
||||
class Leaves extends Transparent{
|
||||
|
||||
protected TreeType $treeType;
|
||||
protected bool $noDecay = false;
|
||||
protected bool $checkDecay = false;
|
||||
@ -48,17 +48,16 @@ class Leaves extends Transparent{
|
||||
$this->treeType = $treeType;
|
||||
}
|
||||
|
||||
protected function writeStateToMeta() : int{
|
||||
return ($this->noDecay ? BlockLegacyMetadata::LEAVES_FLAG_NO_DECAY : 0) | ($this->checkDecay ? BlockLegacyMetadata::LEAVES_FLAG_CHECK_DECAY : 0);
|
||||
public function getRequiredStateDataBits() : int{ return 2; }
|
||||
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->noDecay = $r->readBool();
|
||||
$this->checkDecay = $r->readBool();
|
||||
}
|
||||
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->noDecay = ($stateMeta & BlockLegacyMetadata::LEAVES_FLAG_NO_DECAY) !== 0;
|
||||
$this->checkDecay = ($stateMeta & BlockLegacyMetadata::LEAVES_FLAG_CHECK_DECAY) !== 0;
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b1100;
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeBool($this->noDecay);
|
||||
$w->writeBool($this->checkDecay);
|
||||
}
|
||||
|
||||
public function isNoDecay() : bool{ return $this->noDecay; }
|
||||
@ -97,7 +96,7 @@ class Leaves extends Transparent{
|
||||
return true;
|
||||
}
|
||||
|
||||
if($block->getId() === $this->getId() && $distance <= 4){
|
||||
if($block instanceof Leaves && $distance <= 4){
|
||||
foreach(Facing::ALL as $side){
|
||||
if($this->findLog($pos->getSide($side), $visited, $distance + 1)){
|
||||
return true;
|
||||
@ -144,7 +143,15 @@ class Leaves extends Transparent{
|
||||
|
||||
$drops = [];
|
||||
if(mt_rand(1, 20) === 1){ //Saplings
|
||||
$drops[] = ItemFactory::getInstance()->get(ItemIds::SAPLING, $this->treeType->getMagicNumber());
|
||||
$drops[] = (match($this->treeType){
|
||||
TreeType::ACACIA() => VanillaBlocks::ACACIA_SAPLING(),
|
||||
TreeType::BIRCH() => VanillaBlocks::BIRCH_SAPLING(),
|
||||
TreeType::DARK_OAK() => VanillaBlocks::DARK_OAK_SAPLING(),
|
||||
TreeType::JUNGLE() => VanillaBlocks::JUNGLE_SAPLING(),
|
||||
TreeType::OAK() => VanillaBlocks::OAK_SAPLING(),
|
||||
TreeType::SPRUCE() => VanillaBlocks::SPRUCE_SAPLING(),
|
||||
default => throw new AssumptionFailedError("Unreachable")
|
||||
})->asItem();
|
||||
}
|
||||
if(($this->treeType->equals(TreeType::OAK()) || $this->treeType->equals(TreeType::DARK_OAK())) && mt_rand(1, 200) === 1){ //Apples
|
||||
$drops[] = VanillaItems::APPLE();
|
||||
|
@ -24,10 +24,11 @@ declare(strict_types=1);
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\tile\Lectern as TileLectern;
|
||||
use pocketmine\block\utils\BlockDataSerializer;
|
||||
use pocketmine\block\utils\FacesOppositePlacingPlayerTrait;
|
||||
use pocketmine\block\utils\HorizontalFacingTrait;
|
||||
use pocketmine\block\utils\SupportType;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\WritableBookBase;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
@ -43,15 +44,19 @@ class Lectern extends Transparent{
|
||||
|
||||
protected int $viewedPage = 0;
|
||||
protected ?WritableBookBase $book = null;
|
||||
|
||||
protected bool $producingSignal = false;
|
||||
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->facing = BlockDataSerializer::readLegacyHorizontalFacing($stateMeta & 0x03);
|
||||
$this->producingSignal = ($stateMeta & BlockLegacyMetadata::LECTERN_FLAG_POWERED) !== 0;
|
||||
public function getRequiredStateDataBits() : int{ return 3; }
|
||||
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->facing = $r->readHorizontalFacing();
|
||||
$this->producingSignal = $r->readBool();
|
||||
}
|
||||
|
||||
public function writeStateToMeta() : int{
|
||||
return BlockDataSerializer::writeLegacyHorizontalFacing($this->facing) | ($this->producingSignal ? BlockLegacyMetadata::LECTERN_FLAG_POWERED : 0);
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeHorizontalFacing($this->facing);
|
||||
$w->writeBool($this->producingSignal);
|
||||
}
|
||||
|
||||
public function readStateFromWorld() : void{
|
||||
@ -72,10 +77,6 @@ class Lectern extends Transparent{
|
||||
}
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b111;
|
||||
}
|
||||
|
||||
public function getFlammability() : int{
|
||||
return 30;
|
||||
}
|
||||
|
@ -24,6 +24,10 @@ declare(strict_types=1);
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\LeverFacing;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\data\runtime\RuntimeEnumDeserializer;
|
||||
use pocketmine\data\runtime\RuntimeEnumSerializer;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Axis;
|
||||
use pocketmine\math\Facing;
|
||||
@ -43,36 +47,16 @@ class Lever extends Flowable{
|
||||
parent::__construct($idInfo, $name, $breakInfo);
|
||||
}
|
||||
|
||||
protected function writeStateToMeta() : int{
|
||||
$rotationMeta = match($this->facing->id()){
|
||||
LeverFacing::DOWN_AXIS_X()->id() => 0,
|
||||
LeverFacing::EAST()->id() => 1,
|
||||
LeverFacing::WEST()->id() => 2,
|
||||
LeverFacing::SOUTH()->id() => 3,
|
||||
LeverFacing::NORTH()->id() => 4,
|
||||
LeverFacing::UP_AXIS_Z()->id() => 5,
|
||||
LeverFacing::UP_AXIS_X()->id() => 6,
|
||||
LeverFacing::DOWN_AXIS_Z()->id() => 7,
|
||||
default => throw new AssumptionFailedError(),
|
||||
};
|
||||
return $rotationMeta | ($this->activated ? BlockLegacyMetadata::LEVER_FLAG_POWERED : 0);
|
||||
public function getRequiredStateDataBits() : int{ return 4; }
|
||||
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->facing = RuntimeEnumDeserializer::readLeverFacing($r);
|
||||
$this->activated = $r->readBool();
|
||||
}
|
||||
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$rotationMeta = $stateMeta & 0x07;
|
||||
$this->facing = match($rotationMeta){
|
||||
0 => LeverFacing::DOWN_AXIS_X(),
|
||||
1 => LeverFacing::EAST(),
|
||||
2 => LeverFacing::WEST(),
|
||||
3 => LeverFacing::SOUTH(),
|
||||
4 => LeverFacing::NORTH(),
|
||||
5 => LeverFacing::UP_AXIS_Z(),
|
||||
6 => LeverFacing::UP_AXIS_X(),
|
||||
7 => LeverFacing::DOWN_AXIS_Z(),
|
||||
default => throw new AssumptionFailedError("0x07 mask should make this impossible"), //phpstan doesn't understand :(
|
||||
};
|
||||
|
||||
$this->activated = ($stateMeta & BlockLegacyMetadata::LEVER_FLAG_POWERED) !== 0;
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
RuntimeEnumSerializer::writeLeverFacing($w, $this->facing);
|
||||
$w->writeBool($this->activated);
|
||||
}
|
||||
|
||||
public function getFacing() : LeverFacing{ return $this->facing; }
|
||||
@ -91,10 +75,6 @@ class Lever extends Flowable{
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b1111;
|
||||
}
|
||||
|
||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
if(!$this->canBeSupportedBy($blockClicked, $face)){
|
||||
return false;
|
||||
|
75
src/block/Light.php
Normal file
75
src/block/Light.php
Normal file
@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\player\Player;
|
||||
|
||||
final class Light extends Flowable{
|
||||
public const MIN_LIGHT_LEVEL = 0;
|
||||
public const MAX_LIGHT_LEVEL = 15;
|
||||
|
||||
private int $level = self::MAX_LIGHT_LEVEL;
|
||||
|
||||
public function getRequiredTypeDataBits() : int{ return 4; }
|
||||
|
||||
protected function decodeType(RuntimeDataReader $r) : void{
|
||||
$this->level = $r->readBoundedInt(4, self::MIN_LIGHT_LEVEL, self::MAX_LIGHT_LEVEL);
|
||||
}
|
||||
|
||||
protected function encodeType(RuntimeDataWriter $w) : void{
|
||||
$w->writeBoundedInt(4, self::MIN_LIGHT_LEVEL, self::MAX_LIGHT_LEVEL, $this->level);
|
||||
}
|
||||
|
||||
public function getLightLevel() : int{ return $this->level; }
|
||||
|
||||
/** @return $this */
|
||||
public function setLightLevel(int $level) : self{
|
||||
if($level < self::MIN_LIGHT_LEVEL || $level > self::MAX_LIGHT_LEVEL){
|
||||
throw new \InvalidArgumentException("Light level must be in the range " . self::MIN_LIGHT_LEVEL . " ... " . self::MAX_LIGHT_LEVEL);
|
||||
}
|
||||
$this->level = $level;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function canBeReplaced() : bool{ return true; }
|
||||
|
||||
public function canBePlacedAt(Block $blockReplace, Vector3 $clickVector, int $face, bool $isClickedBlock) : bool{
|
||||
//light blocks behave like solid blocks when placing them on another light block
|
||||
return $blockReplace->canBeReplaced() && $blockReplace->getTypeId() !== $this->getTypeId();
|
||||
}
|
||||
|
||||
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
$this->level = $this->level === self::MAX_LIGHT_LEVEL ?
|
||||
self::MIN_LIGHT_LEVEL :
|
||||
$this->level + 1;
|
||||
|
||||
$this->position->getWorld()->setBlock($this->position, $this);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
55
src/block/LightningRod.php
Normal file
55
src/block/LightningRod.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\AnyFacingTrait;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Axis;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\player\Player;
|
||||
use pocketmine\world\BlockTransaction;
|
||||
|
||||
final class LightningRod extends Transparent{
|
||||
use AnyFacingTrait;
|
||||
|
||||
protected function recalculateCollisionBoxes() : array{
|
||||
$myAxis = Facing::axis($this->facing);
|
||||
|
||||
$result = AxisAlignedBB::one();
|
||||
foreach([Axis::X, Axis::Y, Axis::Z] as $axis){
|
||||
if($axis !== $myAxis){
|
||||
$result->squash($axis, 6 / 16);
|
||||
}
|
||||
}
|
||||
|
||||
return [$result];
|
||||
}
|
||||
|
||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
$this->facing = $face;
|
||||
return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
||||
}
|
||||
}
|
@ -23,9 +23,10 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\BlockDataSerializer;
|
||||
use pocketmine\block\utils\MinimumCostFlowCalculator;
|
||||
use pocketmine\block\utils\SupportType;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\entity\Entity;
|
||||
use pocketmine\event\block\BlockFormEvent;
|
||||
use pocketmine\event\block\BlockSpreadEvent;
|
||||
@ -40,8 +41,6 @@ use function lcg_value;
|
||||
abstract class Liquid extends Transparent{
|
||||
public const MAX_DECAY = 7;
|
||||
|
||||
protected BlockIdentifierFlattened $idInfoFlattened;
|
||||
|
||||
public int $adjacentSources = 0;
|
||||
|
||||
protected ?Vector3 $flowVector = null;
|
||||
@ -50,27 +49,18 @@ abstract class Liquid extends Transparent{
|
||||
protected int $decay = 0; //PC "level" property
|
||||
protected bool $still = false;
|
||||
|
||||
public function __construct(BlockIdentifierFlattened $idInfo, string $name, BlockBreakInfo $breakInfo){
|
||||
$this->idInfoFlattened = $idInfo;
|
||||
parent::__construct($idInfo, $name, $breakInfo);
|
||||
public function getRequiredStateDataBits() : int{ return 5; }
|
||||
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->decay = $r->readBoundedInt(3, 0, self::MAX_DECAY);
|
||||
$this->falling = $r->readBool();
|
||||
$this->still = $r->readBool();
|
||||
}
|
||||
|
||||
public function getId() : int{
|
||||
return $this->still ? $this->idInfoFlattened->getSecondId() : parent::getId();
|
||||
}
|
||||
|
||||
protected function writeStateToMeta() : int{
|
||||
return $this->decay | ($this->falling ? BlockLegacyMetadata::LIQUID_FLAG_FALLING : 0);
|
||||
}
|
||||
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->decay = BlockDataSerializer::readBoundedInt("decay", $stateMeta & 0x07, 0, self::MAX_DECAY);
|
||||
$this->falling = ($stateMeta & BlockLegacyMetadata::LIQUID_FLAG_FALLING) !== 0;
|
||||
$this->still = $id === $this->idInfoFlattened->getSecondId();
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b1111;
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeBoundedInt(3, 0, self::MAX_DECAY, $this->decay);
|
||||
$w->writeBool($this->falling);
|
||||
$w->writeBool($this->still);
|
||||
}
|
||||
|
||||
public function isFalling() : bool{ return $this->falling; }
|
||||
@ -348,7 +338,7 @@ abstract class Liquid extends Transparent{
|
||||
$ev = new BlockSpreadEvent($block, $this, $new);
|
||||
$ev->call();
|
||||
if(!$ev->isCancelled()){
|
||||
if($block->getId() !== BlockLegacyIds::AIR){
|
||||
if($block->getTypeId() !== BlockTypeIds::AIR){
|
||||
$this->position->getWorld()->useBreakOn($block->position);
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,6 @@ declare(strict_types=1);
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\inventory\LoomInventory;
|
||||
use pocketmine\block\utils\BlockDataSerializer;
|
||||
use pocketmine\block\utils\FacesOppositePlacingPlayerTrait;
|
||||
use pocketmine\block\utils\HorizontalFacingTrait;
|
||||
use pocketmine\item\Item;
|
||||
@ -35,18 +34,6 @@ final class Loom extends Opaque{
|
||||
use FacesOppositePlacingPlayerTrait;
|
||||
use HorizontalFacingTrait;
|
||||
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->facing = BlockDataSerializer::readLegacyHorizontalFacing($stateMeta & 0x3);
|
||||
}
|
||||
|
||||
protected function writeStateToMeta() : int{
|
||||
return BlockDataSerializer::writeLegacyHorizontalFacing($this->facing);
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b11;
|
||||
}
|
||||
|
||||
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
if($player !== null){
|
||||
$player->setCurrentWindow(new LoomInventory($this->position));
|
||||
|
@ -23,9 +23,16 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\VanillaItems;
|
||||
|
||||
class MelonStem extends Stem{
|
||||
|
||||
protected function getPlant() : Block{
|
||||
return VanillaBlocks::MELON();
|
||||
}
|
||||
|
||||
public function asItem() : Item{
|
||||
return VanillaItems::MELON_SEEDS();
|
||||
}
|
||||
}
|
||||
|
37
src/block/NetherGoldOre.php
Normal file
37
src/block/NetherGoldOre.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\VanillaItems;
|
||||
use function mt_rand;
|
||||
|
||||
final class NetherGoldOre extends Opaque{
|
||||
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
return [VanillaItems::GOLD_NUGGET()->setCount(mt_rand(2, 6))];
|
||||
}
|
||||
|
||||
public function isAffectedBySilkTouch() : bool{ return true; }
|
||||
}
|
@ -24,6 +24,8 @@ declare(strict_types=1);
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\SupportType;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\entity\Entity;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Axis;
|
||||
@ -33,16 +35,14 @@ class NetherPortal extends Transparent{
|
||||
|
||||
protected int $axis = Axis::X;
|
||||
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->axis = $stateMeta === BlockLegacyMetadata::NETHER_PORTAL_AXIS_Z ? Axis::Z : Axis::X; //mojang u dumb
|
||||
public function getRequiredStateDataBits() : int{ return 1; }
|
||||
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->axis = $r->readHorizontalAxis();
|
||||
}
|
||||
|
||||
protected function writeStateToMeta() : int{
|
||||
return $this->axis === Axis::Z ? BlockLegacyMetadata::NETHER_PORTAL_AXIS_Z : BlockLegacyMetadata::NETHER_PORTAL_AXIS_X;
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b11;
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeHorizontalAxis($this->axis);
|
||||
}
|
||||
|
||||
public function getAxis() : int{
|
||||
|
@ -23,26 +23,11 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\BlockDataSerializer;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\VanillaItems;
|
||||
|
||||
class NetherReactor extends Opaque{
|
||||
|
||||
protected int $state = BlockLegacyMetadata::NETHER_REACTOR_INACTIVE;
|
||||
|
||||
protected function writeStateToMeta() : int{
|
||||
return $this->state;
|
||||
}
|
||||
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->state = BlockDataSerializer::readBoundedInt("state", $stateMeta, 0, 2);
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b11;
|
||||
}
|
||||
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
return [
|
||||
VanillaItems::IRON_INGOT()->setCount(6),
|
||||
|
@ -23,7 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\BlockDataSerializer;
|
||||
use pocketmine\data\runtime\RuntimeDataReader;
|
||||
use pocketmine\data\runtime\RuntimeDataWriter;
|
||||
use pocketmine\event\block\BlockGrowEvent;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Facing;
|
||||
@ -37,16 +38,14 @@ class NetherWartPlant extends Flowable{
|
||||
|
||||
protected int $age = 0;
|
||||
|
||||
protected function writeStateToMeta() : int{
|
||||
return $this->age;
|
||||
public function getRequiredStateDataBits() : int{ return 2; }
|
||||
|
||||
protected function decodeState(RuntimeDataReader $r) : void{
|
||||
$this->age = $r->readBoundedInt(2, 0, self::MAX_AGE);
|
||||
}
|
||||
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->age = BlockDataSerializer::readBoundedInt("age", $stateMeta, 0, self::MAX_AGE);
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b11;
|
||||
protected function encodeState(RuntimeDataWriter $w) : void{
|
||||
$w->writeBoundedInt(2, 0, self::MAX_AGE, $this->age);
|
||||
}
|
||||
|
||||
public function getAge() : int{ return $this->age; }
|
||||
@ -62,7 +61,7 @@ class NetherWartPlant extends Flowable{
|
||||
|
||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
$down = $this->getSide(Facing::DOWN);
|
||||
if($down->getId() === BlockLegacyIds::SOUL_SAND){
|
||||
if($down->getTypeId() === BlockTypeIds::SOUL_SAND){
|
||||
return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
||||
}
|
||||
|
||||
@ -70,7 +69,7 @@ class NetherWartPlant extends Flowable{
|
||||
}
|
||||
|
||||
public function onNearbyBlockChange() : void{
|
||||
if($this->getSide(Facing::DOWN)->getId() !== BlockLegacyIds::SOUL_SAND){
|
||||
if($this->getSide(Facing::DOWN)->getTypeId() !== BlockTypeIds::SOUL_SAND){
|
||||
$this->position->getWorld()->useBreakOn($this->position);
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user