Compare commits

..

106 Commits

Author SHA1 Message Date
9a67fbf27a Release 5.0.0-ALPHA9 2023-02-21 16:44:27 +00:00
94ffef1a99 ItemIdMetaUpgrader: consistency of API method naming 2023-02-21 16:14:31 +00:00
2feb9ca903 ItemIdMetaUpgrader: consistency of API method naming 2023-02-21 16:12:44 +00:00
50b8d39aba Merge branch 'next-minor' into next-major 2023-02-21 15:41:57 +00:00
c4ecb3d128 Merge branch 'stable' into next-minor 2023-02-21 15:37:06 +00:00
b574d49d36 4.15.2 is next 2023-02-21 15:23:25 +00:00
47e9ecd257 Release 4.15.1 2023-02-21 15:23:25 +00:00
799739fe86 Updated build/php submodule to pmmp/PHP-Binaries@b2207cf70d 2023-02-21 15:22:38 +00:00
59a04c971f Getter and setter for gravity (#5584)
closes #5525
2023-02-21 15:01:22 +00:00
168af31fd7 Bump phpstan/phpstan from 1.9.17 to 1.9.18 (#5585)
Bumps [phpstan/phpstan](https://github.com/phpstan/phpstan) from 1.9.17 to 1.9.18.
- [Release notes](https://github.com/phpstan/phpstan/releases)
- [Changelog](https://github.com/phpstan/phpstan/blob/1.10.x/CHANGELOG.md)
- [Commits](https://github.com/phpstan/phpstan/compare/1.9.17...1.9.18)

---
updated-dependencies:
- dependency-name: phpstan/phpstan
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-20 18:39:29 +00:00
871bd169a8 Timings: remove unnecessary code 2023-02-19 17:58:12 +00:00
4dbcd714bd NetworkSession: fixed some segments of recv/send logic not being covered by their respective network timings 2023-02-19 17:21:10 +00:00
d5e92b4ae6 ... 2023-02-19 16:53:04 +00:00
2a3288c4f9 Avoid useless throwaway PacketBatch objects 2023-02-19 16:50:03 +00:00
9cdb641936 Added encode packet timings
these changes required some new APIs in BedrockProtocol.
2023-02-19 16:47:20 +00:00
42df1a5c70 Fixed merge error 2023-02-17 20:19:32 +00:00
b56b35b10d ItemEntity: fixed a bunch of suspicious logic in entityBaseTick()
closes #5580
2023-02-17 20:14:38 +00:00
0e0f5e85eb Merge branch 'next-minor' into next-major 2023-02-17 20:00:51 +00:00
324bc27b5a Merge branch 'stable' into next-minor 2023-02-17 19:59:28 +00:00
71aad310c6 stfu 2023-02-17 16:39:46 +00:00
38828e2b42 4.15.1 is next 2023-02-17 16:37:34 +00:00
9a6d7b505c Release 4.15.0 2023-02-17 16:37:34 +00:00
1e3b025916 1.19.62 2023-02-17 16:36:32 +00:00
55a48e0c84 Block: specifying required type/state data bits is no longer required
RuntimeDataSizeCalculator allows calculating the number of required bits from describeType directly, which considerably reduces boilerplate code.
2023-02-16 16:45:19 +00:00
c2f6d8139a Added interface RuntimeDataDescriber 2023-02-16 16:23:32 +00:00
ceff230d73 Simplify generation of enum serializers code 2023-02-16 15:57:54 +00:00
e6f1cb69d1 RuntimeBlockStateRegistry: throw a hard error on blockstates that return different state data than they were given
this suggests improper validation of state data.
2023-02-16 15:44:58 +00:00
4c3892b2d6 RuntimeBlockStateRegistry: separate permutation expansion from register() 2023-02-16 15:41:43 +00:00
396d64c60b 4.14.2 is next 2023-02-15 15:19:39 +00:00
d7a0f5362e Release 4.14.1 2023-02-15 15:19:38 +00:00
75f74454c6 Implemented reinforced deepslate (#5553) 2023-02-15 15:15:04 +00:00
7611155ff9 CS 2023-02-15 15:13:12 +00:00
c0f3dbdd70 Regenerate constants for block and item data handling 2023-02-15 15:12:53 +00:00
c5dcd268ad CS 2023-02-15 15:04:41 +00:00
910c4c4b24 Updated BedrockProtocol 2023-02-15 15:02:00 +00:00
2fd6e769e6 NetworkSession: Improved packet budgeting
this fixes players getting kicked during server lag spikes.

closes #5532
2023-02-15 14:59:05 +00:00
aacd92bf08 Command: fix setPermissions docblock 2023-02-13 14:46:37 +00:00
caebe14dab Use an array for command permissions
it doesn't make sense to have to parse the string every time we want to verify permissions, nor to expect that people will somehow know to use ; to separate them without it being documented anywhere...
2023-02-13 14:44:55 +00:00
cb10360c20 SimpleCommandMap: require commands to have a permission
fixes #5305
2023-02-13 14:24:30 +00:00
082f9e1647 Deny permission to use a command if no permission is set
Having no permission is almost always a bug. We already have behaviour elsewhere in the core that assumes undefined permission = permission denied.

This behaviour might confuse some people, but I think it's much less dangerous than accidentally allowing everyone to use your command.
2023-02-13 14:22:36 +00:00
d891646d0a Fix CS 2023-02-13 14:10:42 +00:00
886b40a455 ÂLocalize disconnect reasons for RakLib disconnects 2023-02-13 14:10:25 +00:00
525f62e1e4 ÂRakLib 0.15 2023-02-13 14:00:16 +00:00
69155015c9 Double quote array expansions to avoid re-splitting elements. (#5570)
See: https://github.com/koalaman/shellcheck/wiki/SC2068
2023-02-13 12:24:47 +00:00
6854830b6e start.sh: Use -n instead of ! -z (#5567)
See https://github.com/koalaman/shellcheck/wiki/SC2236
2023-02-13 12:21:35 +00:00
2d56aa50b9 A bunch of mostly inseparable changes to PlayerPreLoginEvent
including support for separated disconnect reasons and disconnect screen messages (closes #4512)

While the refactoring of kick reason -> kick flag wasn't exactly in my agenda, I realized that these changes would become pretty confusing and inconsistent with other events if they weren't refactored.
Hopefully I don't have to break this API again for a while...
2023-02-13 11:32:32 +00:00
5d0388e747 PlayerPreLoginEvent no longer implements Cancellable
please see #5516 for motivation on this, but I don't think anyone will be complaining - this behaviour made no sense and caused a lot of confusion for people who were trying to set custom ban messages.
2023-02-13 11:10:29 +00:00
074e7586cb Merge branch 'next-minor' into next-major 2023-02-11 17:17:08 +00:00
2c413768a5 Merge branch 'stable' into next-minor 2023-02-11 17:15:12 +00:00
fbaf8e3fc8 Update composer dependencies 2023-02-11 17:13:12 +00:00
c62845e92a 4.14.1 is next 2023-02-08 20:21:43 +00:00
c7930ce9ec Release 4.14.0 2023-02-08 20:21:42 +00:00
475888b031 InGamePacketHandler: do not process repeated skin change requests for the same full skin ID
this fixes a feedback loop with persona skins in 1.19.60.
2023-02-08 20:16:41 +00:00
40b90bb722 InGamePacketHandler: log a debug when processing skin change requests 2023-02-08 19:47:12 +00:00
5a4550a4fc CS 2023-02-08 18:55:49 +00:00
7bbc04e6de Silence PlayerSkinPacket debug messages during spawn response stage
the client sends its skin here in 1.19.60 for some reason, which makes no sense - I can only assume it's a bug
2023-02-08 18:55:38 +00:00
3ba662f64f 1.19.60 2023-02-08 18:46:37 +00:00
5d7b99daf4 Bump phpstan/phpstan from 1.9.15 to 1.9.16 (#5560)
Bumps [phpstan/phpstan](https://github.com/phpstan/phpstan) from 1.9.15 to 1.9.16.
- [Release notes](https://github.com/phpstan/phpstan/releases)
- [Changelog](https://github.com/phpstan/phpstan/blob/1.10.x/CHANGELOG.md)
- [Commits](https://github.com/phpstan/phpstan/compare/1.9.15...1.9.16)

---
updated-dependencies:
- dependency-name: phpstan/phpstan
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-08 10:55:09 +00:00
e47627f565 Bump build/php from f51e954 to fb297eb (#5558)
Bumps [build/php](https://github.com/pmmp/php-build-scripts) from `f51e954` to `fb297eb`.
- [Release notes](https://github.com/pmmp/php-build-scripts/releases)
- [Commits](f51e954743...fb297eb511)

---
updated-dependencies:
- dependency-name: build/php
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-08 10:09:15 +00:00
39207c7992 Bump phpstan/phpstan from 1.9.14 to 1.9.15 (#5557)
Bumps [phpstan/phpstan](https://github.com/phpstan/phpstan) from 1.9.14 to 1.9.15.
- [Release notes](https://github.com/phpstan/phpstan/releases)
- [Changelog](https://github.com/phpstan/phpstan/blob/1.10.x/CHANGELOG.md)
- [Commits](https://github.com/phpstan/phpstan/compare/1.9.14...1.9.15)

---
updated-dependencies:
- dependency-name: phpstan/phpstan
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-07 12:39:49 +00:00
2f12bb9943 Merge branch 'next-minor' into next-major 2023-02-06 12:34:57 +00:00
41ab698f93 wrong filename 2023-02-06 12:29:54 +00:00
e45a6d8311 Merge branch 'stable' into next-minor 2023-02-06 12:27:09 +00:00
8912a97be7 Update Composer dependencies 2023-02-06 12:11:42 +00:00
8d2a9ce67c Clean PHPStan baselines 2023-02-06 12:09:19 +00:00
811352e2ef Bump build/php from c658506 to f51e954 (#5555)
Bumps [build/php](https://github.com/pmmp/php-build-scripts) from `c658506` to `f51e954`.
- [Release notes](https://github.com/pmmp/php-build-scripts/releases)
- [Commits](c6585061ca...f51e954743)

---
updated-dependencies:
- dependency-name: build/php
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-06 11:50:10 +00:00
981385cf4a GeneratorManager: Removed redundant Closure wrapping (#5551) 2023-02-04 14:04:31 +00:00
433b0ca6cc Fix PHPStan 2023-02-02 16:23:21 +00:00
da5302ca86 BlockStateData: introduce and use current() 2023-02-02 16:21:50 +00:00
6b7a4e2c41 Split up ItemDataUpgrader (preparing for code backport) 2023-02-02 16:08:49 +00:00
e9b994cbc3 Allow limiting max schema ID loaded for item ID upgrading 2023-02-02 15:29:45 +00:00
cfa1e7486a Move legacy recipes and creative items in-house
having them here allows BedrockData to represent latest versions freely, without being limited by technical limitations of PM4.
2023-02-02 15:25:03 +00:00
3c46bf01c6 Begin removing dependence on obsolete files from BedrockData
these files were only kept for backwards compatibility, and aren't actively maintained. They are only needed for legacy conversions in the modern day era.
2023-02-02 14:47:38 +00:00
0e15a8698a BlockStateUpgrader: do not use blockstate version to manage internal schemas
these are no longer reliable.
2023-02-01 22:35:59 +00:00
d3fff4e0b2 Updated to newer BedrockBlockUpgradeSchema 2023-02-01 21:21:55 +00:00
aeb26141b2 Merge branch 'next-minor' into next-major 2023-01-30 22:19:24 +00:00
4562cfb85b 4.13.1 is next 2023-01-30 21:55:26 +00:00
cb1aac3cd4 Release 4.13.0 2023-01-30 21:55:26 +00:00
3dd1a14fb7 Merge branch 'next-minor' into stable 2023-01-30 21:52:41 +00:00
63c3127248 Scrub PHPStan baselines 2023-01-30 21:52:31 +00:00
2f283678c7 Merge branch 'next-minor' into next-major 2023-01-30 13:26:29 +00:00
96c32d24ba Update composer dependencies 2023-01-30 13:23:40 +00:00
d64a9d8b52 Merge branch 'stable' into next-minor 2023-01-30 12:58:50 +00:00
92c29b8172 Update transitive composer dependencies 2023-01-30 12:53:06 +00:00
0ac9584bbb Bump shivammathur/setup-php from 2.23.0 to 2.24.0 (#5543)
Bumps [shivammathur/setup-php](https://github.com/shivammathur/setup-php) from 2.23.0 to 2.24.0.
- [Release notes](https://github.com/shivammathur/setup-php/releases)
- [Commits](https://github.com/shivammathur/setup-php/compare/2.23.0...2.24.0)

---
updated-dependencies:
- dependency-name: shivammathur/setup-php
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-30 12:49:42 +00:00
fe12e8d944 Bump build/php from 1c44c61 to c658506 (#5542)
Bumps [build/php](https://github.com/pmmp/php-build-scripts) from `1c44c61` to `c658506`.
- [Release notes](https://github.com/pmmp/php-build-scripts/releases)
- [Commits](1c44c615c3...c6585061ca)

---
updated-dependencies:
- dependency-name: build/php
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-30 12:39:14 +00:00
7529953f0a Bump phpstan/phpstan from 1.9.13 to 1.9.14 (#5523)
Bumps [phpstan/phpstan](https://github.com/phpstan/phpstan) from 1.9.13 to 1.9.14.
- [Release notes](https://github.com/phpstan/phpstan/releases)
- [Changelog](https://github.com/phpstan/phpstan/blob/1.10.x/CHANGELOG.md)
- [Commits](https://github.com/phpstan/phpstan/compare/1.9.13...1.9.14)

---
updated-dependencies:
- dependency-name: phpstan/phpstan
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-27 23:08:36 +00:00
00dbb6855a Bump build/php from 83bec42 to 1c44c61 (#5539)
Bumps [build/php](https://github.com/pmmp/php-build-scripts) from `83bec42` to `1c44c61`.
- [Release notes](https://github.com/pmmp/php-build-scripts/releases)
- [Commits](83bec42c3c...1c44c615c3)

---
updated-dependencies:
- dependency-name: build/php
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-27 23:08:08 +00:00
5226300b99 Ring bell when hit by a projectile (#5505) 2023-01-27 23:07:41 +00:00
0f81b7be15 Fixed deepslate drops (#5535)
Co-authored-by: Dylan T <dktapps@pmmp.io>
2023-01-26 15:08:15 +00:00
2b987b450b always the CS... 2023-01-26 14:58:32 +00:00
7eca3e8081 Fix typo
closes #5533
2023-01-26 14:52:50 +00:00
0975da57d6 Removed obsolete pthreads-related ignoreErrors 2023-01-26 14:51:18 +00:00
f56339c306 Fix build 2023-01-26 14:48:43 +00:00
b58d7fc82a Bump build/php from af250d7 to 83bec42 (#5534)
Bumps [build/php](https://github.com/pmmp/php-build-scripts) from `af250d7` to `83bec42`.
- [Release notes](https://github.com/pmmp/php-build-scripts/releases)
- [Commits](af250d7e06...83bec42c3c)

---
updated-dependencies:
- dependency-name: build/php
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-26 13:00:07 +00:00
2cd8e4d270 ... 2023-01-25 19:02:42 +00:00
0a3ecfdae9 Clean up terminology around block state IDs and their handling 2023-01-25 19:01:15 +00:00
2f469ef4a0 Added mangrove, azalea and flowering azalea leaves 2023-01-25 18:50:14 +00:00
ceea8220a9 Bump symfony/filesystem from 5.4.13 to 5.4.19 (#5530)
Bumps [symfony/filesystem](https://github.com/symfony/filesystem) from 5.4.13 to 5.4.19.
- [Release notes](https://github.com/symfony/filesystem/releases)
- [Changelog](https://github.com/symfony/filesystem/blob/6.2/CHANGELOG.md)
- [Commits](https://github.com/symfony/filesystem/compare/v5.4.13...v5.4.19)

---
updated-dependencies:
- dependency-name: symfony/filesystem
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-25 13:23:48 +00:00
cbaff1caec BlockPlaceEvent: use BlockTransaction, closes #1760
BlockPlaceEvent no longer extends BlockEvent, since it's now a multi-block event
getBlockReplaced() is removed
getTransaction() is added

to be honest, BlockPlaceEvent should be something like PlayerBlockPlaceEvent...
2023-01-24 15:49:42 +00:00
18013e9551 Bump build/php from b479ec4 to af250d7 (#5527)
Bumps [build/php](https://github.com/pmmp/php-build-scripts) from `b479ec4` to `af250d7`.
- [Release notes](https://github.com/pmmp/php-build-scripts/releases)
- [Commits](b479ec438f...af250d7e06)

---
updated-dependencies:
- dependency-name: build/php
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-24 13:51:50 +00:00
92896c78da 5.0.0-ALPHA9 is next 2023-01-23 20:38:35 +00:00
bd3e9e1cad Do not allow more than 1 run to compile PHP at a time
this causes cache collisions and build failures
2023-01-23 20:13:29 +00:00
6173471cca Merge branch 'stable' of github.com:pmmp/PocketMine-MP into stable 2023-01-23 19:40:14 +00:00
608fcd6cd7 4.12.12 is next 2023-01-22 20:44:31 +00:00
ce9b25e97a Release 4.12.11 2023-01-22 20:44:26 +00:00
197 changed files with 2035 additions and 1288 deletions

View File

@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v3
- name: Setup PHP and tools
uses: shivammathur/setup-php@2.23.0
uses: shivammathur/setup-php@2.24.0
with:
php-version: 8.0

View File

@ -18,7 +18,7 @@ jobs:
submodules: true
- name: Setup PHP
uses: shivammathur/setup-php@2.23.0
uses: shivammathur/setup-php@2.24.0
with:
php-version: 8.0

View File

@ -9,6 +9,7 @@ jobs:
build-php:
name: Prepare PHP
runs-on: ${{ matrix.image }}
concurrency: php-build-${{ matrix.php }}
strategy:
matrix:
@ -203,7 +204,7 @@ jobs:
- uses: actions/checkout@v3
- name: Setup PHP and tools
uses: shivammathur/setup-php@2.23.0
uses: shivammathur/setup-php@2.24.0
with:
php-version: 8.0
tools: php-cs-fixer:3.11

View File

@ -60,13 +60,12 @@ require dirname(__DIR__) . '/vendor/autoload.php';
* @return string[]
* @phpstan-return list<string>
*/
function buildWriterFunc(string $virtualTypeName, string $nativeTypeName, array $memberNames, string &$functionName) : array{
function buildWriterFunc(string $virtualTypeName, string $nativeTypeName, array $memberNames, string $functionName) : array{
$bits = getBitsRequired($memberNames);
$lines = [];
$functionName = lcfirst($virtualTypeName);
$lines[] = "public function $functionName(\\$nativeTypeName \$value) : void{";
$lines[] = "\t\$this->int($bits, match(\$value){";
$lines[] = "public function $functionName(\\$nativeTypeName &\$value) : void{";
$lines[] = "\t\$this->writeInt($bits, match(\$value){";
foreach($memberNames as $key => $memberName){
$lines[] = "\t\t$memberName => $key,";
@ -85,11 +84,10 @@ function buildWriterFunc(string $virtualTypeName, string $nativeTypeName, array
* @return string[]
* @phpstan-return list<string>
*/
function buildReaderFunc(string $virtualTypeName, string $nativeTypeName, array $memberNames, string &$functionName) : array{
function buildReaderFunc(string $virtualTypeName, string $nativeTypeName, array $memberNames, string $functionName) : array{
$bits = getBitsRequired($memberNames);
$lines = [];
$functionName = lcfirst($virtualTypeName);
$lines[] = "public function $functionName(\\$nativeTypeName &\$value) : void{";
$lines[] = "\t\$value = match(\$this->readInt($bits)){";
@ -103,6 +101,26 @@ function buildReaderFunc(string $virtualTypeName, string $nativeTypeName, array
return $lines;
}
function buildInterfaceFunc(string $nativeTypeName, string $functionName) : string{
return "public function $functionName(\\$nativeTypeName &\$value) : void;";
}
/**
* @param string[] $memberNames
* @phpstan-param list<string> $memberNames
*
* @return string[]
* @phpstan-return list<string>
*/
function buildSizeCalculationFunc(string $nativeTypeName, string $functionName, array $memberNames) : array{
$lines = [];
$lines[] = "public function $functionName(\\$nativeTypeName &\$value) : void{";
$lines[] = "\t\$this->addBits(" . getBitsRequired($memberNames) . ");";
$lines[] = "}";
return $lines;
}
/**
* @param mixed[] $members
*/
@ -122,43 +140,6 @@ function stringifyEnumMembers(array $members, string $enumClass) : array{
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(),
@ -182,25 +163,54 @@ $readerFuncs = [
];
$writerFuncs = [
"" => [
"abstract public function int(int \$bits, int \$value) : void;"
"abstract protected function writeInt(int \$bits, int \$value) : void;"
]
];
$interfaceFuncs = [];
$sizeCalculationFuncs = [
"" => [
"abstract protected function addBits(int \$bits) : void;"
]
];
$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;
if(count($enumMembers) === 0){
throw new \InvalidArgumentException("Enum members cannot be empty");
}
$reflect = new \ReflectionClass($enumMembers[array_key_first($enumMembers)]);
$virtualTypeName = $reflect->getShortName();
$nativeTypeName = $reflect->getName();
$functionName = lcfirst($virtualTypeName);
$stringifiedMembers = stringifyEnumMembers($enumMembers, $nativeTypeName);
$writerFuncs[$functionName] = buildWriterFunc(
$virtualTypeName,
$nativeTypeName,
$stringifiedMembers,
$functionName
);
$readerFuncs[$functionName] = buildReaderFunc(
$virtualTypeName,
$nativeTypeName,
$stringifiedMembers,
$functionName
);
$interfaceFuncs[$functionName] = [buildInterfaceFunc(
$nativeTypeName,
$functionName
)];
$sizeCalculationFuncs[$functionName] = buildSizeCalculationFunc(
$nativeTypeName,
$functionName,
$stringifiedMembers
);
}
/**
* @param string[][] $functions
* @phpstan-param array<string, list<string>> $functions
*/
function printFunctions(array $functions, string $className) : void{
function printFunctions(array $functions, string $className, string $classType) : void{
ksort($functions, SORT_STRING);
ob_start();
@ -238,14 +248,16 @@ namespace pocketmine\data\runtime;
HEADER;
echo "trait $className{\n\n";
echo "$classType $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, "RuntimeEnumSerializerTrait");
printFunctions($readerFuncs, "RuntimeEnumDeserializerTrait");
printFunctions($writerFuncs, "RuntimeEnumSerializerTrait", "trait");
printFunctions($readerFuncs, "RuntimeEnumDeserializerTrait", "trait");
printFunctions($interfaceFuncs, "RuntimeEnumDescriber", "interface");
printFunctions($sizeCalculationFuncs, "RuntimeEnumSizeCalculatorTrait", "trait");
echo "Done. Don't forget to run CS fixup after generating code.\n";

View File

@ -104,3 +104,16 @@ Released 18th January 2023.
## Note about server load & performance
This version will report higher apparent server load than previous versions. The actual performance of the server is unchanged; the previous reported load was inaccurate.
These bugs have been present for nearly 5 years (ever since the first introduction of Snooze in 3.0.0).
# 4.12.11
Released 22nd January 2023.
## General
- Code is now tested and analysed using PHP 8.2 in addition to 8.1 and 8.0.
## Fixes
- Fixed pthreads 5.0.0 incorrectly being treated as compatible.
- Fixed deprecation errors on PHP 8.2.
## Documentation
- Updated documentation in `PlayerPreLoginEvent`.

94
changelogs/4.13.md Normal file
View File

@ -0,0 +1,94 @@
**For Minecraft: Bedrock Edition 1.19.50**
This is a minor feature release for PocketMine-MP, introducing some new features and improvements.
### Note about API versions
Plugins which don't touch the protocol and compatible with any previous 4.x.y version will also run on these releases and do not need API bumps.
Plugin developers should **only** update their required API to this version if you need the changes in this build.
**WARNING: If your plugin uses the protocol, you're not shielded by API change constraints.** You should consider using the `mcpe-protocol` directive in `plugin.yml` as a constraint if you do.
# 4.13.0
Released 30th January 2023.
## Gameplay
- Death message is now shown on the death screen when a player dies.
- Armour damage is now only increased if the armour reduced the damage taken.
- Implemented Swift Sneak enchantment.
- Fixed incorrect collision box calculation of walls and glass/bars when connected. Note: Client-side, wall connections are still broken; this only fixes projectile flight server-side.
## Performance
- Improved performance of chunk selection for chunk random ticking using a cache. This improves performance of chunk random ticking by 10-20%.
## Localization
- Added localized description for the `/dumpmemory` command.
## Permissions
- Added the following new core permissions:
- `pocketmine.command.effect.other` - allows the player to use the `/effect` command on other players (default operator only)
- `pocketmine.command.effect.self` - allows the player to use the `/effect` command on themselves (default operator only)
- `pocketmine.command.enchant.other` - allows the player to use the `/enchant` command on other players (default operator only)
- `pocketmine.command.enchant.self` - allows the player to use the `/enchant` command on themselves (default operator only)
- `pocketmine.command.gamemode.other` - allows the player to use the `/gamemode` command on other players (default operator only)
- `pocketmine.command.gamemode.self` - allows the player to use the `/gamemode` command on themselves (default operator only)
- `pocketmine.command.give.other` - allows the player to use the `/give` command on other players (default operator only)
- `pocketmine.command.give.self` - allows the player to use the `/give` command on themselves (default operator only)
- `pocketmine.command.spawnpoint.other` - allows the player to use the `/spawnpoint` command on other players (default operator only)
- `pocketmine.command.spawnpoint.self` - allows the player to use the `/spawnpoint` command on themselves (default operator only)
- `pocketmine.command.teleport.other` - allows the player to use the `/teleport` command on other players (default operator only)
- `pocketmine.command.teleport.self` - allows the player to use the `/teleport` command on themselves (default operator only)
- `pocketmine.command.title.other` - allows the player to use the `/title` command on other players (default operator only)
- `pocketmine.command.title.self` - allows the player to use the `/title` command on themselves (default operator only)
## Internals
- Decoupled `Player->sendMessage()` and `Player->sendTranslation()`.
- Refactored resource pack loading in `ResourcePackManager` to make it easier to understand.
- Client-aware translation processing has been moved to `NetworkSession` due to being client-specific.
- Replaced hardcoded strings with constants in various places.
- `NetworkSession` destructive cleanup is now deferred to the next session tick. This fixes various `InventoryManager` crashes when kicking players during events.
- Updated code using `strpos()` to use `str_starts_with()`, `str_ends_with()` and `str_contains()` where appropriate.
- Added documentation for some internal methods.
## API
### `pocketmine\command`
- The following new API methods have been added:
- `protected VanillaCommand->fetchPermittedPlayerTarget(...) : ?Player` - fetches a player target according to the given sender permissions, or null if not found or not permitted
### `pocketmine\entity`
- The following new API methods have been added:
- `public Living->getDisplayName() : string` - the name of the entity to be shown in death messages, commands etc.
### `pocketmine\event\world`
- The following new classes have been added:
- `WorldSoundEvent` - called when a sound is played in a world
- `WorldParticleEvent` - called when a particle is spawned in a world
### `pocketmine\item`
- The following new API methods have been added:
- `public Item->onInteractEntity(Player $player, Entity $entity, Vector3 $clickVector) : bool` - called when a player interacts with an entity with this item in hand
### `pocketmine\lang`
- `Language->translate()` and `Language->translateString()` no longer parse nested translation in the "base text". This was never intended behaviour, and didn't work beyond the first level anyway.
### `pocketmine\player`
- The following new interfaces have been added:
- `PlayerDataProvider` - implemented by classes which want to offer storage for player data
- The following new classes have been added:
- `DatFilePlayerDataProvider` - the default player data provider, which stores `.dat` files in the `players` folder
- `PlayerDataLoadException` - thrown when an error occurs while loading player data
- `PlayerDataSaveException` - thrown when an error occurs while saving player data
- The following API methods have been deprecated:
- `Player->sendTranslation()` - use `Player->sendMessage()` instead with a `Translatable` message
### `pocketmine\resourcepacks`
- The following new API methods have been added:
- `public ResourcePackManager->setResourceStack(list<ResourcePack> $resourceStack) : void` - sets the list of resource packs to be applied by players
- `public ResourcePackManager->setPackEncryptionKey(string $id, ?string $key) : void` - sets the encryption key to be used for a resource pack
### `pocketmine\utils`
- The following new API methods have been added:
- `public static Filesystem::fileGetContents(...) : string` - a wrapper around `file_get_contents()` which throws an exception on failure
### `pocketmine\world`
- The following new API methods have been added:
- `public World->requestSafeSpawn(?Vector3 $spawn = null) : Promise<Position>` - an async version of `getSafeSpawn()` which generates all the needed chunks before returning

21
changelogs/4.14.md Normal file
View File

@ -0,0 +1,21 @@
**For Minecraft: Bedrock Edition 1.19.60**
### Note about API versions
Plugins which don't touch the protocol and compatible with any previous 4.x.y version will also run on these releases and do not need API bumps.
Plugin developers should **only** update their required API to this version if you need the changes in this build.
**WARNING: If your plugin uses the protocol, you're not shielded by API change constraints.** You should consider using the `mcpe-protocol` directive in `plugin.yml` as a constraint if you do.
# 4.14.0
Released 8th February 2023.
## General
- Added support for Minecraft: Bedrock Edition 1.19.60.
- Removed support for older versions.
# 4.14.1
Released 15th February 2023.
## Fixes
- Fixed all players getting kicked with `Receiving packets too fast` if a server tick takes longer than 5 seconds (e.g. because of autosave or GC).
- Fixed players getting kicked when linking with entities.

22
changelogs/4.15.md Normal file
View File

@ -0,0 +1,22 @@
**For Minecraft: Bedrock Edition 1.19.62**
### Note about API versions
Plugins which don't touch the protocol and compatible with any previous 4.x.y version will also run on these releases and do not need API bumps.
Plugin developers should **only** update their required API to this version if you need the changes in this build.
**WARNING: If your plugin uses the protocol, you're not shielded by API change constraints.** You should consider using the `mcpe-protocol` directive in `plugin.yml` as a constraint if you do.
# 4.15.0
Released 17th February 2023.
## General
- Added support for Minecraft: Bedrock Edition 1.19.62.
- Removed support for older versions.
# 4.15.1
Released 21st February 2023.
## Fixes
- Fixed dropped items not despawning when in non-ticking chunks.
- Fixed dropped items not despawning if an infinite pickup delay is set.
- Fixed infinite despawn delay (never despawn) being ignored for dropped items.

View File

@ -908,4 +908,131 @@ Released 23rd January 2023.
- `Player->disconnect()` now accepts an additional `Translatable|string|null $disconnectScreenMessage` parameter, which is the message to be displayed on the disconnect screen (the message in `$reason` is used if null is passed)
## Internals
- `NetworkSession` disconnect methods have been altered to allow specifying a different disconnect reason and disconnection screen message.
- `NetworkSession` disconnect methods have been altered to allow specifying a different disconnect reason and disconnection screen message.
# 5.0.0-ALPHA9
Released 21st February 2023.
## Core
- Introduced timings for individual packet encoding.
- Network timings now cover more parts of the network system which weren't previously accounted for.
## API
### `pocketmine\block`
- Blocks are no longer required to explicitly specify how many type or state data bits they require. This is now automatically calculated using `RuntimeDataSizeCalculator`.
- The following API methods have changed signatures:
- `Block->describeState()` now accepts `RuntimeDataDescriber` instead of `RuntimeDataReader|RuntimeDataWriter`
- `Block->describeType()` now accepts `RuntimeDataDescriber` instead of `RuntimeDataReader|RuntimeDataWriter`
- `Block->getRequiredStateDataBits()` is now `final`.
- `Block->getRequiredTypeDataBits()` is now `final`.
- `Leaves->__construct()` now `LeavesType $leavesType` instead of `TreeType $treeType`
- The following API methods have been added:
- `public Leaves->getLeavesType() : LeavesType` - returns the type of leaves
- The following classes have been added:
- `LeavesType` - an enum of all the different types of leaves
- The following classes have been renamed:
- `BlockFactory` -> `RuntimeBlockStateRegistry` - this more accurately describes the purpose of the class
- The following API methods have changed behaviour:
- `RuntimeBlockStateRegistry->register()` now throws a `LogicException` if a block does not properly reject invalid state data.
### `pocketmine\command`
- `SimpleCommandMap` now requires all commands to have a permission set when registered.
- If you actually want to allow everyone to use your command (not advised), you can add a new permission to the `pocketmine.group.user` group, or use `default: true` for `plugin.yml` permissions.
- The following API methods have changed behaviour:
- `Command->testPermissionSilent()` now returns `false` if there are no permissions associated with the command. This is to prevent commands with no permissions being usable by everyone, which has previously been a source of security issues.
- The following API methods have been added:
- `public Command->getPermissions() : list<string>` - returns a list of permissions which grant usage access to this command. A user with one or more of these permissions will be able to invoke the command's `execute()` method
- `public Command->setPermissions(list<string> $permissions) : void` - sets the permissions which grant usage access to this command. This should be used instead of `setPermission()` with `;` separators (which is now deprecated)
### `pocketmine\data\bedrock\block`
- The following API methods have been added:
- `public static BlockStateData::current(string $name, array<string, Tag> $states) : BlockStateData` - creates a new `BlockStateData` instance with the current blockstate version
### `pocketmine\data\bedrock\block\upgrade`
- Blockstate upgrade schemas are now indexed by schema ID instead of Minecraft version. This is because the Minecraft blockstate version isn't consistently bumped when changes are made.
- `BlockStateUpgrader` now requires that every schema added must have a unique schema ID.
- The following API methods have been removed:
- `BlockStateUpgradeSchema->getPriority()`
- The following API methods have been added:
- `public BlockStateUpgradeSchema->getSchemaId() : int` - returns the schema ID of this upgrade schema, usually the number at the start of the JSON filename
- The following API methods have changed signatures:
- `BlockStateUpgradeSchemaUtils::fromJsonModel()` now accepts `int $schemaId` instead of `int $priority`
- `BlockStateUpgradeSchemaUtils::loadSchemaFromString()` now accepts `int $schemaId` instead of `int $priority`
- `BlockStateUpgradeSchemaUtils::loadSchemas()` now accepts `int $maxSchemaId` instead of `int $currentVersion`
### `pocketmine\data\bedrock\item\upgrade`
- The following API methods have changed signatures:
- `ItemUpgradeSchemaUtils::loadSchemas()` now accepts `int $maxSchemaId`
- The following API methods have been renamed:
- `ItemIdMetaUpgradeSchema->getPriority()` -> `ItemIdMetaUpgradeSchema->getSchemaId()`
- The following classes have been added:
- `ItemIdMetaUpgrader` - encapsulates handling for upgrading item string IDs and meta to newer versions
- The following API methods have been moved:
- `ItemDataUpgrader->addIdMetaUpgradeSchema()` -> `ItemIdMetaUpgrader->addSchema()`
- `ItemDataUpgrader->upgradeItemStringIdMeta()` -> `ItemIdMetaUpgrader->upgrade()`
### `pocketmine\data\runtime`
- The following interfaces have been added:
- `RuntimeDataDescriber` - contract for symmetric APIs exposed by `RuntimeDataReader`, `RuntimeDataWriter` and `RuntimeDataSizeCalculator`
### `pocketmine\event\player`
- `PlayerPreLoginEvent` now supports setting separate log reasons (disconnect reason) and disconnect screen messages.
- The following classes have inheritance changes:
- `PlayerPreLoginEvent` no longer implements `Cancellable`. This caused unexpected behaviour for most plugin devs due to default-ignoring cancelled events, forcing people to usually have to use `@handleCancelled` to handle the event when they wanted to use it.
- The following API methods have been added:
- `public PlayerPreLoginEvent->getDisconnectScreenMessage(int $flag) : Translatable|string|null` - returns the message to be displayed on the disconnect screen for the specified kick flag, if set
- `public PlayerPreLoginEvent->getFinalDisconnectScreenMessage() : Translatable|string|null` - returns the message to be displayed on the disconnect screen, taking into account the kick flags set
- The following API constants have been renamed:
- `PlayerPreLoginEvent::KICK_REASON_BANNED` -> `PlayerPreLoginEvent::KICK_FLAG_BANNED`
- `PlayerPreLoginEvent::KICK_REASON_PLUGIN` -> `PlayerPreLoginEvent::KICK_FLAG_PLUGIN`
- `PlayerPreLoginEvent::KICK_REASON_PRIORITY` -> `PlayerPreLoginEvent::KICK_FLAG_PRIORITY`
- `PlayerPreLoginEvent::KICK_REASON_SERVER_FULL` -> `PlayerPreLoginEvent::KICK_FLAG_SERVER_FULL`
- `PlayerPreLoginEvent::KICK_REASON_SERVER_WHITELISTED` -> `PlayerPreLoginEvent::KICK_FLAG_SERVER_WHITELISTED`
- The following API methods have been renamed:
- `PlayerPreLoginEvent->clearAllKickReasons()` -> `PlayerPreLoginEvent->clearAllKickFlags()`
- `PlayerPreLoginEvent->clearKickReason()` -> `PlayerPreLoginEvent->clearKickFlag()`
- `PlayerPreLoginEvent->getFinalKickMessage()` -> `PlayerPreLoginEvent->getFinalDisconnectReason()` (now used for logs only, if a disconnect screen message is set for the highest priority flag)
- `PlayerPreLoginEvent->getKickMessage()` -> `PlayerPreLoginEvent->getDisconnectReason()` (now used for logs only, if a disconnect screen message is set for the flag)
- `PlayerPreLoginEvent->getKickReasons()` -> `PlayerPreLoginEvent->getKickFlags()`
- `PlayerPreLoginEvent->isKickReasonSet()` -> `PlayerPreLoginEvent->isKickFlagSet()`
- `PlayerPreLoginEvent->setKickReason()` -> `PlayerPreLoginEvent->setKickFlag()`
- The following API methods have changed signatures:
- `PlayerPreLoginEvent->setKickFlag()` (previously `setKickReason()`) now accepts `Translatable|string $disconnectReason, Translatable|string|null $disconnectScreenMessage = null` instead of `Translatable|string $message`
### `pocketmine\event\block`
- The following classes have inheritance changes:
- `BlockPlaceEvent` no longer extends `BlockEvent`, and therefore no longer has `getBlock()`.
- The following API methods have been removed:
- `BlockPlaceEvent->getBlockReplaced()` - this information is now provided in the `BlockTransaction` object returned by `BlockPlaceEvent->getTransaction()`
- The following API methods have been added:
- `public BlockPlaceEvent->getTransaction() : BlockTransaction` - returns the transaction containing a list of changed block positions and the blockstates they will be changed to
- The following API methods have changed signatures:
- `BlockPlaceEvent->__construct()` now accepts `BlockTransaction $transaction` instead of `Block $blockPlace, Block $blockReplace`
### `pocketmine\item`
- The following API methods have signature changes:
- `Item->describeType()` now accepts `RuntimeDataDescriber` instead of `RuntimeDataReader|RuntimeDataWriter`
### `pocketmine\world\format`
- The following API methods have been renamed:
- `Chunk->getFullBlock()` -> `Chunk->getBlockStateId()`
- `Chunk->setFullBlock()` -> `Chunk->setBlockStateId()`
- `SubChunk->getFullBlock()` -> `SubChunk->getBlockStateId()`
- `SubChunk->setFullBlock()` -> `SubChunk->setBlockStateId()`
## Gameplay
### Blocks
- The following new blocks have been added:
- Mangrove Leaves
- Azalea Leaves
- Flowering Azalea Leaves
- Reinforced Deepslate
- Fixed incorrect drops of deepslate when mined without a Silk Touch tool.
- Bells now ring when hit by a projectile.
## Internals
- `build/generate-runtime-enum-serializers.php` now generates the following additional classes:
- `interface RuntimeEnumDescriber`
- `trait RuntimeEnumSizeCalculatorTrait`
- Block type/state data required bits are now calculated from `Block->describeType()` using `RuntimeDataSizeCalculator`.
- Commands now use an array for permissions internally, instead of a string separated by `;`.

View File

@ -34,28 +34,28 @@
"adhocore/json-comment": "^1.1",
"fgrosse/phpasn1": "^2.3",
"netresearch/jsonmapper": "^4.0",
"pocketmine/bedrock-block-upgrade-schema": "dev-master@dev",
"pocketmine/bedrock-block-upgrade-schema": "^1.0.0",
"pocketmine/bedrock-data": "dev-modern-world-support@dev",
"pocketmine/bedrock-item-upgrade-schema": "dev-master",
"pocketmine/bedrock-protocol": "~18.0.0+bedrock-1.19.50",
"pocketmine/bedrock-item-upgrade-schema": "^1.0.0",
"pocketmine/bedrock-protocol": "~19.3.0+bedrock-1.19.62",
"pocketmine/binaryutils": "^0.2.1",
"pocketmine/callback-validator": "^1.0.2",
"pocketmine/classloader": "^0.3.0",
"pocketmine/color": "^0.3.0",
"pocketmine/errorhandler": "^0.6.0",
"pocketmine/locale-data": "~2.18.0",
"pocketmine/locale-data": "~2.19.0",
"pocketmine/log": "^0.4.0",
"pocketmine/log-pthreads": "^0.5.0",
"pocketmine/math": "^0.4.0",
"pocketmine/nbt": "^0.3.2",
"pocketmine/raklib": "^0.14.2",
"pocketmine/raklib-ipc": "^0.1.0",
"pocketmine/raklib": "^0.15.0",
"pocketmine/raklib-ipc": "^0.2.0",
"pocketmine/snooze": "^0.4.0",
"ramsey/uuid": "^4.1",
"symfony/filesystem": "^5.4"
},
"require-dev": {
"phpstan/phpstan": "1.9.13",
"phpstan/phpstan": "1.9.18",
"phpstan/phpstan-phpunit": "^1.1.0",
"phpstan/phpstan-strict-rules": "^1.2.0",
"phpunit/phpunit": "^9.2"

200
composer.lock generated
View File

@ -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": "17ca826af1a32c9768cd162e75d10ad5",
"content-hash": "ea992cf9b9be39c9d5251b7769f9d044",
"packages": [
{
"name": "adhocore/json-comment",
@ -250,19 +250,18 @@
},
{
"name": "pocketmine/bedrock-block-upgrade-schema",
"version": "dev-master",
"version": "1.0.0",
"source": {
"type": "git",
"url": "https://github.com/pmmp/BedrockBlockUpgradeSchema.git",
"reference": "63f5f5e02e952ffa196a4c0671d7fcf8b8cdd9a4"
"reference": "a05ce434eb7f8c11058d26833bc975fe635b23b4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pmmp/BedrockBlockUpgradeSchema/zipball/63f5f5e02e952ffa196a4c0671d7fcf8b8cdd9a4",
"reference": "63f5f5e02e952ffa196a4c0671d7fcf8b8cdd9a4",
"url": "https://api.github.com/repos/pmmp/BedrockBlockUpgradeSchema/zipball/a05ce434eb7f8c11058d26833bc975fe635b23b4",
"reference": "a05ce434eb7f8c11058d26833bc975fe635b23b4",
"shasum": ""
},
"default-branch": true,
"type": "library",
"notification-url": "https://packagist.org/downloads/",
"license": [
@ -271,9 +270,9 @@
"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"
"source": "https://github.com/pmmp/BedrockBlockUpgradeSchema/tree/1.0.0"
},
"time": "2022-08-07T19:29:31+00:00"
"time": "2023-02-01T21:09:54+00:00"
},
{
"name": "pocketmine/bedrock-data",
@ -281,12 +280,12 @@
"source": {
"type": "git",
"url": "https://github.com/pmmp/BedrockData.git",
"reference": "d64617faab77300d828debcd1e3597b3403b63b7"
"reference": "27cb4d5133d6cbe30018b759eb97e3fdc7036c3b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pmmp/BedrockData/zipball/d64617faab77300d828debcd1e3597b3403b63b7",
"reference": "d64617faab77300d828debcd1e3597b3403b63b7",
"url": "https://api.github.com/repos/pmmp/BedrockData/zipball/27cb4d5133d6cbe30018b759eb97e3fdc7036c3b",
"reference": "27cb4d5133d6cbe30018b759eb97e3fdc7036c3b",
"shasum": ""
},
"type": "library",
@ -299,23 +298,22 @@
"issues": "https://github.com/pmmp/BedrockData/issues",
"source": "https://github.com/pmmp/BedrockData/tree/modern-world-support"
},
"time": "2022-12-02T13:01:28+00:00"
"time": "2023-02-08T18:33:49+00:00"
},
{
"name": "pocketmine/bedrock-item-upgrade-schema",
"version": "dev-master",
"version": "1.0.0",
"source": {
"type": "git",
"url": "https://github.com/pmmp/BedrockItemUpgradeSchema.git",
"reference": "d984d2ee7283bc52e8733e7c7da1d0f6b6dc501f"
"reference": "7e53f77ea34ba30b1f94d3c24e64e19d3c4296e7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pmmp/BedrockItemUpgradeSchema/zipball/d984d2ee7283bc52e8733e7c7da1d0f6b6dc501f",
"reference": "d984d2ee7283bc52e8733e7c7da1d0f6b6dc501f",
"url": "https://api.github.com/repos/pmmp/BedrockItemUpgradeSchema/zipball/7e53f77ea34ba30b1f94d3c24e64e19d3c4296e7",
"reference": "7e53f77ea34ba30b1f94d3c24e64e19d3c4296e7",
"shasum": ""
},
"default-branch": true,
"type": "library",
"notification-url": "https://packagist.org/downloads/",
"license": [
@ -324,22 +322,22 @@
"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"
"source": "https://github.com/pmmp/BedrockItemUpgradeSchema/tree/1.0.0"
},
"time": "2022-06-08T13:47:48+00:00"
"time": "2023-02-01T22:50:02+00:00"
},
{
"name": "pocketmine/bedrock-protocol",
"version": "18.0.0+bedrock-1.19.50",
"version": "19.3.0+bedrock-1.19.62",
"source": {
"type": "git",
"url": "https://github.com/pmmp/BedrockProtocol.git",
"reference": "b558ec883bd967dd3339f513cba62d2fbcd63349"
"reference": "a5bf4753c7f30f781c4541918e238f5bb637e7ad"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pmmp/BedrockProtocol/zipball/b558ec883bd967dd3339f513cba62d2fbcd63349",
"reference": "b558ec883bd967dd3339f513cba62d2fbcd63349",
"url": "https://api.github.com/repos/pmmp/BedrockProtocol/zipball/a5bf4753c7f30f781c4541918e238f5bb637e7ad",
"reference": "a5bf4753c7f30f781c4541918e238f5bb637e7ad",
"shasum": ""
},
"require": {
@ -353,7 +351,7 @@
"ramsey/uuid": "^4.1"
},
"require-dev": {
"phpstan/phpstan": "1.9.4",
"phpstan/phpstan": "1.9.13",
"phpstan/phpstan-phpunit": "^1.0.0",
"phpstan/phpstan-strict-rules": "^1.0.0",
"phpunit/phpunit": "^9.5"
@ -371,9 +369,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/18.0.0+bedrock-1.19.50"
"source": "https://github.com/pmmp/BedrockProtocol/tree/19.3.0+bedrock-1.19.62"
},
"time": "2023-01-06T21:47:35+00:00"
"time": "2023-02-19T16:11:03+00:00"
},
{
"name": "pocketmine/binaryutils",
@ -591,16 +589,16 @@
},
{
"name": "pocketmine/locale-data",
"version": "2.18.3",
"version": "2.19.0",
"source": {
"type": "git",
"url": "https://github.com/pmmp/Language.git",
"reference": "da25bfe9ee4822a84feb9b7e620c56ad4000aed0"
"reference": "f47d1687f21f09d2858f040873184a11746b1cf7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pmmp/Language/zipball/da25bfe9ee4822a84feb9b7e620c56ad4000aed0",
"reference": "da25bfe9ee4822a84feb9b7e620c56ad4000aed0",
"url": "https://api.github.com/repos/pmmp/Language/zipball/f47d1687f21f09d2858f040873184a11746b1cf7",
"reference": "f47d1687f21f09d2858f040873184a11746b1cf7",
"shasum": ""
},
"type": "library",
@ -608,9 +606,9 @@
"description": "Language resources used by PocketMine-MP",
"support": {
"issues": "https://github.com/pmmp/Language/issues",
"source": "https://github.com/pmmp/Language/tree/2.18.3"
"source": "https://github.com/pmmp/Language/tree/2.19.0"
},
"time": "2023-01-17T21:43:36+00:00"
"time": "2023-02-13T13:55:22+00:00"
},
{
"name": "pocketmine/log",
@ -782,16 +780,16 @@
},
{
"name": "pocketmine/raklib",
"version": "0.14.5",
"version": "0.15.0",
"source": {
"type": "git",
"url": "https://github.com/pmmp/RakLib.git",
"reference": "85b4e5cb7117d37e010eeadb3ff53b21276c6f48"
"reference": "1f490cff6bf5e9eb46ebdbf7a7994d62be2bd2c1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pmmp/RakLib/zipball/85b4e5cb7117d37e010eeadb3ff53b21276c6f48",
"reference": "85b4e5cb7117d37e010eeadb3ff53b21276c6f48",
"url": "https://api.github.com/repos/pmmp/RakLib/zipball/1f490cff6bf5e9eb46ebdbf7a7994d62be2bd2c1",
"reference": "1f490cff6bf5e9eb46ebdbf7a7994d62be2bd2c1",
"shasum": ""
},
"require": {
@ -803,7 +801,7 @@
"pocketmine/log": "^0.3.0 || ^0.4.0"
},
"require-dev": {
"phpstan/phpstan": "1.7.7",
"phpstan/phpstan": "1.9.17",
"phpstan/phpstan-strict-rules": "^1.0"
},
"type": "library",
@ -819,33 +817,33 @@
"description": "A RakNet server implementation written in PHP",
"support": {
"issues": "https://github.com/pmmp/RakLib/issues",
"source": "https://github.com/pmmp/RakLib/tree/0.14.5"
"source": "https://github.com/pmmp/RakLib/tree/0.15.0"
},
"time": "2022-08-25T16:16:44+00:00"
"time": "2023-02-13T12:56:35+00:00"
},
{
"name": "pocketmine/raklib-ipc",
"version": "0.1.1",
"version": "0.2.0",
"source": {
"type": "git",
"url": "https://github.com/pmmp/RakLibIpc.git",
"reference": "922a6444b0c6c7daaa5aa5a832107e1ec4738aed"
"reference": "26ed56fa9db06e4ca6e8920c0ede2e01e219bb9c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pmmp/RakLibIpc/zipball/922a6444b0c6c7daaa5aa5a832107e1ec4738aed",
"reference": "922a6444b0c6c7daaa5aa5a832107e1ec4738aed",
"url": "https://api.github.com/repos/pmmp/RakLibIpc/zipball/26ed56fa9db06e4ca6e8920c0ede2e01e219bb9c",
"reference": "26ed56fa9db06e4ca6e8920c0ede2e01e219bb9c",
"shasum": ""
},
"require": {
"php": "^7.4 || ^8.0",
"php": "^8.0",
"php-64bit": "*",
"pocketmine/binaryutils": "^0.2.0",
"pocketmine/raklib": "^0.13.1 || ^0.14.0"
"pocketmine/raklib": "^0.15.0"
},
"require-dev": {
"phpstan/phpstan": "0.12.81",
"phpstan/phpstan-strict-rules": "^0.12.2"
"phpstan/phpstan": "1.9.17",
"phpstan/phpstan-strict-rules": "^1.0.0"
},
"type": "library",
"autoload": {
@ -860,9 +858,9 @@
"description": "Channel-based protocols for inter-thread/inter-process communication with RakLib",
"support": {
"issues": "https://github.com/pmmp/RakLibIpc/issues",
"source": "https://github.com/pmmp/RakLibIpc/tree/0.1.1"
"source": "https://github.com/pmmp/RakLibIpc/tree/0.2.0"
},
"time": "2021-09-22T17:01:12+00:00"
"time": "2023-02-13T13:40:40+00:00"
},
{
"name": "pocketmine/snooze",
@ -1088,16 +1086,16 @@
},
{
"name": "symfony/filesystem",
"version": "v5.4.13",
"version": "v5.4.19",
"source": {
"type": "git",
"url": "https://github.com/symfony/filesystem.git",
"reference": "ac09569844a9109a5966b9438fc29113ce77cf51"
"reference": "648bfaca6a494f3e22378123bcee2894045dc9d8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/filesystem/zipball/ac09569844a9109a5966b9438fc29113ce77cf51",
"reference": "ac09569844a9109a5966b9438fc29113ce77cf51",
"url": "https://api.github.com/repos/symfony/filesystem/zipball/648bfaca6a494f3e22378123bcee2894045dc9d8",
"reference": "648bfaca6a494f3e22378123bcee2894045dc9d8",
"shasum": ""
},
"require": {
@ -1132,7 +1130,7 @@
"description": "Provides basic utilities for the filesystem",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/filesystem/tree/v5.4.13"
"source": "https://github.com/symfony/filesystem/tree/v5.4.19"
},
"funding": [
{
@ -1148,7 +1146,7 @@
"type": "tidelift"
}
],
"time": "2022-09-21T19:53:16+00:00"
"time": "2023-01-14T19:14:44+00:00"
},
{
"name": "symfony/polyfill-ctype",
@ -1777,16 +1775,16 @@
},
{
"name": "phpstan/phpstan",
"version": "1.9.13",
"version": "1.9.18",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan.git",
"reference": "a0922426da3a7d0d9334e99a363f7f9f6e23e84f"
"reference": "f2d5cf71be91172a57c649770b73c20ebcffb0bf"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/a0922426da3a7d0d9334e99a363f7f9f6e23e84f",
"reference": "a0922426da3a7d0d9334e99a363f7f9f6e23e84f",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/f2d5cf71be91172a57c649770b73c20ebcffb0bf",
"reference": "f2d5cf71be91172a57c649770b73c20ebcffb0bf",
"shasum": ""
},
"require": {
@ -1816,7 +1814,7 @@
],
"support": {
"issues": "https://github.com/phpstan/phpstan/issues",
"source": "https://github.com/phpstan/phpstan/tree/1.9.13"
"source": "https://github.com/phpstan/phpstan/tree/1.9.18"
},
"funding": [
{
@ -1832,20 +1830,20 @@
"type": "tidelift"
}
],
"time": "2023-01-18T15:26:53+00:00"
"time": "2023-02-17T15:01:27+00:00"
},
{
"name": "phpstan/phpstan-phpunit",
"version": "1.3.3",
"version": "1.3.4",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan-phpunit.git",
"reference": "54a24bd23e9e80ee918cdc24f909d376c2e273f7"
"reference": "d77af96c1aaec28f7c0293677132eaaad079e01b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/54a24bd23e9e80ee918cdc24f909d376c2e273f7",
"reference": "54a24bd23e9e80ee918cdc24f909d376c2e273f7",
"url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/d77af96c1aaec28f7c0293677132eaaad079e01b",
"reference": "d77af96c1aaec28f7c0293677132eaaad079e01b",
"shasum": ""
},
"require": {
@ -1882,9 +1880,9 @@
"description": "PHPUnit extensions and rules for PHPStan",
"support": {
"issues": "https://github.com/phpstan/phpstan-phpunit/issues",
"source": "https://github.com/phpstan/phpstan-phpunit/tree/1.3.3"
"source": "https://github.com/phpstan/phpstan-phpunit/tree/1.3.4"
},
"time": "2022-12-21T15:25:00+00:00"
"time": "2023-02-09T08:05:29+00:00"
},
{
"name": "phpstan/phpstan-strict-rules",
@ -1936,16 +1934,16 @@
},
{
"name": "phpunit/php-code-coverage",
"version": "9.2.23",
"version": "9.2.24",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
"reference": "9f1f0f9a2fbb680b26d1cf9b61b6eac43a6e4e9c"
"reference": "2cf940ebc6355a9d430462811b5aaa308b174bed"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/9f1f0f9a2fbb680b26d1cf9b61b6eac43a6e4e9c",
"reference": "9f1f0f9a2fbb680b26d1cf9b61b6eac43a6e4e9c",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/2cf940ebc6355a9d430462811b5aaa308b174bed",
"reference": "2cf940ebc6355a9d430462811b5aaa308b174bed",
"shasum": ""
},
"require": {
@ -2001,7 +1999,7 @@
],
"support": {
"issues": "https://github.com/sebastianbergmann/php-code-coverage/issues",
"source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.23"
"source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.24"
},
"funding": [
{
@ -2009,7 +2007,7 @@
"type": "github"
}
],
"time": "2022-12-28T12:41:10+00:00"
"time": "2023-01-26T08:26:55+00:00"
},
{
"name": "phpunit/php-file-iterator",
@ -2254,16 +2252,16 @@
},
{
"name": "phpunit/phpunit",
"version": "9.5.28",
"version": "9.6.3",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "954ca3113a03bf780d22f07bf055d883ee04b65e"
"reference": "e7b1615e3e887d6c719121c6d4a44b0ab9645555"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/954ca3113a03bf780d22f07bf055d883ee04b65e",
"reference": "954ca3113a03bf780d22f07bf055d883ee04b65e",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/e7b1615e3e887d6c719121c6d4a44b0ab9645555",
"reference": "e7b1615e3e887d6c719121c6d4a44b0ab9645555",
"shasum": ""
},
"require": {
@ -2305,7 +2303,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "9.5-dev"
"dev-master": "9.6-dev"
}
},
"autoload": {
@ -2336,7 +2334,7 @@
],
"support": {
"issues": "https://github.com/sebastianbergmann/phpunit/issues",
"source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.28"
"source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.3"
},
"funding": [
{
@ -2352,7 +2350,7 @@
"type": "tidelift"
}
],
"time": "2023-01-14T12:32:24+00:00"
"time": "2023-02-04T13:37:15+00:00"
},
{
"name": "sebastian/cli-parser",
@ -2720,16 +2718,16 @@
},
{
"name": "sebastian/environment",
"version": "5.1.4",
"version": "5.1.5",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/environment.git",
"reference": "1b5dff7bb151a4db11d49d90e5408e4e938270f7"
"reference": "830c43a844f1f8d5b7a1f6d6076b784454d8b7ed"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/1b5dff7bb151a4db11d49d90e5408e4e938270f7",
"reference": "1b5dff7bb151a4db11d49d90e5408e4e938270f7",
"url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/830c43a844f1f8d5b7a1f6d6076b784454d8b7ed",
"reference": "830c43a844f1f8d5b7a1f6d6076b784454d8b7ed",
"shasum": ""
},
"require": {
@ -2771,7 +2769,7 @@
],
"support": {
"issues": "https://github.com/sebastianbergmann/environment/issues",
"source": "https://github.com/sebastianbergmann/environment/tree/5.1.4"
"source": "https://github.com/sebastianbergmann/environment/tree/5.1.5"
},
"funding": [
{
@ -2779,7 +2777,7 @@
"type": "github"
}
],
"time": "2022-04-03T09:37:03+00:00"
"time": "2023-02-03T06:03:51+00:00"
},
{
"name": "sebastian/exporter",
@ -3093,16 +3091,16 @@
},
{
"name": "sebastian/recursion-context",
"version": "4.0.4",
"version": "4.0.5",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/recursion-context.git",
"reference": "cd9d8cf3c5804de4341c283ed787f099f5506172"
"reference": "e75bd0f07204fec2a0af9b0f3cfe97d05f92efc1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/cd9d8cf3c5804de4341c283ed787f099f5506172",
"reference": "cd9d8cf3c5804de4341c283ed787f099f5506172",
"url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/e75bd0f07204fec2a0af9b0f3cfe97d05f92efc1",
"reference": "e75bd0f07204fec2a0af9b0f3cfe97d05f92efc1",
"shasum": ""
},
"require": {
@ -3141,10 +3139,10 @@
}
],
"description": "Provides functionality to recursively process PHP variables",
"homepage": "http://www.github.com/sebastianbergmann/recursion-context",
"homepage": "https://github.com/sebastianbergmann/recursion-context",
"support": {
"issues": "https://github.com/sebastianbergmann/recursion-context/issues",
"source": "https://github.com/sebastianbergmann/recursion-context/tree/4.0.4"
"source": "https://github.com/sebastianbergmann/recursion-context/tree/4.0.5"
},
"funding": [
{
@ -3152,7 +3150,7 @@
"type": "github"
}
],
"time": "2020-10-26T13:17:30+00:00"
"time": "2023-02-03T06:07:39+00:00"
},
{
"name": "sebastian/resource-operations",
@ -3211,16 +3209,16 @@
},
{
"name": "sebastian/type",
"version": "3.2.0",
"version": "3.2.1",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/type.git",
"reference": "fb3fe09c5f0bae6bc27ef3ce933a1e0ed9464b6e"
"reference": "75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/type/zipball/fb3fe09c5f0bae6bc27ef3ce933a1e0ed9464b6e",
"reference": "fb3fe09c5f0bae6bc27ef3ce933a1e0ed9464b6e",
"url": "https://api.github.com/repos/sebastianbergmann/type/zipball/75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7",
"reference": "75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7",
"shasum": ""
},
"require": {
@ -3255,7 +3253,7 @@
"homepage": "https://github.com/sebastianbergmann/type",
"support": {
"issues": "https://github.com/sebastianbergmann/type/issues",
"source": "https://github.com/sebastianbergmann/type/tree/3.2.0"
"source": "https://github.com/sebastianbergmann/type/tree/3.2.1"
},
"funding": [
{
@ -3263,7 +3261,7 @@
"type": "github"
}
],
"time": "2022-09-12T14:47:03+00:00"
"time": "2023-02-03T06:13:03+00:00"
},
{
"name": "sebastian/version",
@ -3372,9 +3370,7 @@
"aliases": [],
"minimum-stability": "stable",
"stability-flags": {
"pocketmine/bedrock-block-upgrade-schema": 20,
"pocketmine/bedrock-data": 20,
"pocketmine/bedrock-item-upgrade-schema": 20
"pocketmine/bedrock-data": 20
},
"prefer-stable": false,
"prefer-lowest": false,

View File

@ -71,7 +71,7 @@ use const SORT_NUMERIC;
class MemoryManager{
private const DEFAULT_CHECK_RATE = Server::TARGET_TICKS_PER_SECOND;
private const DEFAULT_CONTINUOUS_TRIGGER_RATE = Server::TARGET_TICKS_PER_SECOND * 2;
private const DEEFAULT_TICKS_PER_GC = 30 * 60 * Server::TARGET_TICKS_PER_SECOND;
private const DEFAULT_TICKS_PER_GC = 30 * 60 * Server::TARGET_TICKS_PER_SECOND;
private int $memoryLimit;
private int $globalMemoryLimit;
@ -139,7 +139,7 @@ class MemoryManager{
$this->continuousTrigger = $config->getPropertyBool("memory.continuous-trigger", true);
$this->continuousTriggerRate = $config->getPropertyInt("memory.continuous-trigger-rate", self::DEFAULT_CONTINUOUS_TRIGGER_RATE);
$this->garbageCollectionPeriod = $config->getPropertyInt("memory.garbage-collection.period", self::DEEFAULT_TICKS_PER_GC);
$this->garbageCollectionPeriod = $config->getPropertyInt("memory.garbage-collection.period", self::DEFAULT_TICKS_PER_GC);
$this->garbageCollectionTrigger = $config->getPropertyBool("memory.garbage-collection.low-memory-trigger", true);
$this->garbageCollectionAsync = $config->getPropertyBool("memory.garbage-collection.collect-async-worker", true);

View File

@ -31,7 +31,7 @@ use function str_repeat;
final class VersionInfo{
public const NAME = "PocketMine-MP";
public const BASE_VERSION = "5.0.0-ALPHA8";
public const BASE_VERSION = "5.0.0-ALPHA9";
public const IS_DEVELOPMENT_BUILD = false;
public const BUILD_CHANNEL = "alpha";

View File

@ -28,8 +28,7 @@ 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\data\runtime\RuntimeDataDescriber;
use pocketmine\entity\object\FallingBlock;
use pocketmine\item\Item;
use pocketmine\math\AxisAlignedBB;
@ -52,15 +51,11 @@ class Anvil extends Transparent implements Fallable{
private int $damage = self::UNDAMAGED;
public function getRequiredTypeDataBits() : int{ return 2; }
protected function describeType(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeType(RuntimeDataDescriber $w) : void{
$w->boundedInt(2, self::UNDAMAGED, self::VERY_DAMAGED, $this->damage);
}
public function getRequiredStateDataBits() : int{ return 2; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->horizontalFacing($this->facing);
}

View File

@ -24,8 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\block\utils\SupportType;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\event\block\StructureGrowEvent;
use pocketmine\item\Bamboo as ItemBamboo;
use pocketmine\item\Fertilizer;
@ -56,9 +55,7 @@ class Bamboo extends Transparent{
protected bool $ready = false;
protected int $leafSize = self::NO_LEAVES;
public function getRequiredStateDataBits() : int{ return 4; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->boundedInt(2, self::NO_LEAVES, self::LARGE_LEAVES, $this->leafSize);
$w->bool($this->thick);
$w->bool($this->ready);

View File

@ -23,8 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\event\block\StructureGrowEvent;
use pocketmine\item\Bamboo as ItemBamboo;
use pocketmine\item\Fertilizer;
@ -37,9 +36,7 @@ use pocketmine\world\BlockTransaction;
final class BambooSapling extends Flowable{
private bool $ready = false;
public function getRequiredStateDataBits() : int{ return 1; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->bool($this->ready);
}

View File

@ -25,8 +25,7 @@ namespace pocketmine\block;
use pocketmine\block\tile\Barrel as TileBarrel;
use pocketmine\block\utils\AnyFacingTrait;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\item\Item;
use pocketmine\math\Facing;
use pocketmine\math\Vector3;
@ -39,9 +38,7 @@ class Barrel extends Opaque{
protected bool $open = false;
public function getRequiredStateDataBits() : int{ return 4; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->facing($this->facing);
$w->bool($this->open);
}

View File

@ -28,8 +28,7 @@ use pocketmine\block\utils\ColoredTrait;
use pocketmine\block\utils\DyeColor;
use pocketmine\block\utils\HorizontalFacingTrait;
use pocketmine\block\utils\SupportType;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\entity\Entity;
use pocketmine\entity\Living;
use pocketmine\item\Item;
@ -54,9 +53,7 @@ class Bed extends Transparent{
parent::__construct($idInfo, $name, $typeInfo);
}
public function getRequiredStateDataBits() : int{ return 4; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->horizontalFacing($this->facing);
$w->bool($this->occupied);
$w->bool($this->head);

View File

@ -23,15 +23,12 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
class Bedrock extends Opaque{
private bool $burnsForever = false;
public function getRequiredStateDataBits() : int{ return 1; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->bool($this->burnsForever);
}

View File

@ -27,11 +27,12 @@ use pocketmine\block\tile\Bell as TileBell;
use pocketmine\block\utils\BellAttachmentType;
use pocketmine\block\utils\HorizontalFacingTrait;
use pocketmine\block\utils\SupportType;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\entity\projectile\Projectile;
use pocketmine\item\Item;
use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Facing;
use pocketmine\math\RayTraceResult;
use pocketmine\math\Vector3;
use pocketmine\player\Player;
use pocketmine\world\BlockTransaction;
@ -47,9 +48,7 @@ final class Bell extends Transparent{
parent::__construct($idInfo, $name, $typeInfo);
}
public function getRequiredStateDataBits() : int{ return 4; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->bellAttachmentType($this->attachmentType);
$w->horizontalFacing($this->facing);
}
@ -134,14 +133,7 @@ final class Bell extends Transparent{
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null, array &$returnedItems = []) : bool{
if($player !== null){
$faceHit = Facing::opposite($player->getHorizontalFacing());
if(
$this->attachmentType->equals(BellAttachmentType::CEILING()) ||
($this->attachmentType->equals(BellAttachmentType::FLOOR()) && Facing::axis($faceHit) === Facing::axis($this->facing)) ||
(
($this->attachmentType->equals(BellAttachmentType::ONE_WALL()) || $this->attachmentType->equals(BellAttachmentType::TWO_WALLS())) &&
($faceHit === Facing::rotateY($this->facing, false) || $faceHit === Facing::rotateY($this->facing, true))
)
){
if($this->isValidFaceToRing($faceHit)){
$this->ring($faceHit);
return true;
}
@ -150,6 +142,13 @@ final class Bell extends Transparent{
return false;
}
public function onProjectileHit(Projectile $projectile, RayTraceResult $hitResult) : void{
$faceHit = Facing::opposite($projectile->getHorizontalFacing());
if($this->isValidFaceToRing($faceHit)){
$this->ring($faceHit);
}
}
public function ring(int $faceHit) : void{
$world = $this->position->getWorld();
$world->addSound($this->position, new BellRingSound());
@ -158,4 +157,15 @@ final class Bell extends Transparent{
$world->broadcastPacketToViewers($this->position, $tile->createFakeUpdatePacket($faceHit));
}
}
private function isValidFaceToRing(int $faceHit) : bool{
return (
$this->attachmentType->equals(BellAttachmentType::CEILING()) ||
($this->attachmentType->equals(BellAttachmentType::FLOOR()) && Facing::axis($faceHit) === Facing::axis($this->facing)) ||
(
($this->attachmentType->equals(BellAttachmentType::ONE_WALL()) || $this->attachmentType->equals(BellAttachmentType::TWO_WALLS())) &&
($faceHit === Facing::rotateY($this->facing, false) || $faceHit === Facing::rotateY($this->facing, true))
)
);
}
}

View File

@ -29,7 +29,9 @@ namespace pocketmine\block;
use pocketmine\block\tile\Spawnable;
use pocketmine\block\tile\Tile;
use pocketmine\block\utils\SupportType;
use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataSizeCalculator;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\entity\Entity;
use pocketmine\entity\projectile\Projectile;
@ -42,6 +44,7 @@ use pocketmine\math\RayTraceResult;
use pocketmine\math\Vector3;
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\player\Player;
use pocketmine\utils\AssumptionFailedError;
use pocketmine\world\BlockTransaction;
use pocketmine\world\format\Chunk;
use pocketmine\world\Position;
@ -62,6 +65,17 @@ class Block{
/** @var AxisAlignedBB[]|null */
protected ?array $collisionBoxes = null;
/**
* @var int[]
* @phpstan-var array<string, int>
*/
private static array $typeDataBits = [];
/**
* @var int[]
* @phpstan-var array<string, int>
*/
private static array $stateDataBits = [];
/**
* @param string $name English name of the block type (TODO: implement translations)
*/
@ -97,7 +111,7 @@ class Block{
* Returns the full blockstate ID of this block. This is a compact way of representing a blockstate used to store
* blocks in chunks at runtime.
*
* This ID can be used to later obtain a copy of this block using {@link BlockFactory::fromStateId()}.
* This ID can be used to later obtain a copy of this block using {@link RuntimeBlockStateRegistry::fromStateId()}.
*/
public function getStateId() : int{
return ($this->getTypeId() << self::INTERNAL_STATE_DATA_BITS) | $this->computeStateData();
@ -112,9 +126,25 @@ class Block{
return new ItemBlock($this);
}
public function getRequiredTypeDataBits() : int{ return 0; }
final public function getRequiredTypeDataBits() : int{
$class = get_class($this);
if(isset(self::$typeDataBits[$class])){
return self::$typeDataBits[$class];
}
$calculator = new RuntimeDataSizeCalculator();
$this->describeType($calculator);
return self::$typeDataBits[$class] = $calculator->getBitsUsed();
}
public function getRequiredStateDataBits() : int{ return 0; }
final public function getRequiredStateDataBits() : int{
$class = get_class($this);
if(isset(self::$stateDataBits[$class])){
return self::$stateDataBits[$class];
}
$calculator = new RuntimeDataSizeCalculator();
$this->describeState($calculator);
return self::$stateDataBits[$class] = $calculator->getBitsUsed();
}
/**
* @internal
@ -173,7 +203,7 @@ class Block{
$stateBits = $this->getRequiredStateDataBits();
$requiredBits = $typeBits + $stateBits;
$writer = new RuntimeDataWriter($requiredBits);
$writer->int($typeBits, $this->computeTypeData());
$writer->writeInt($typeBits, $this->computeTypeData());
$this->describeState($writer);
$writtenBits = $writer->getOffset() - $typeBits;
@ -184,11 +214,11 @@ class Block{
return $writer->getValue();
}
protected function describeType(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeType(RuntimeDataDescriber $w) : void{
//NOOP
}
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
//NOOP
}
@ -216,7 +246,11 @@ class Block{
*/
public function writeStateToWorld() : void{
$world = $this->position->getWorld();
$world->getOrLoadChunkAtPosition($this->position)->setFullBlock($this->position->x & Chunk::COORD_MASK, $this->position->y, $this->position->z & Chunk::COORD_MASK, $this->getStateId());
$chunk = $world->getOrLoadChunkAtPosition($this->position);
if($chunk === null){
throw new AssumptionFailedError("World::setBlock() should have loaded the chunk before calling this method");
}
$chunk->setBlockStateId($this->position->x & Chunk::COORD_MASK, $this->position->y, $this->position->z & Chunk::COORD_MASK, $this->getStateId());
$tileType = $this->idInfo->getTileClass();
$oldTile = $world->getTile($this->position);

View File

@ -26,6 +26,7 @@ namespace pocketmine\block;
use pocketmine\block\BlockIdentifier as BID;
use pocketmine\block\BlockTypeIds as Ids;
use pocketmine\block\tile\Sign as TileSign;
use pocketmine\block\utils\LeavesType;
use pocketmine\block\utils\TreeType;
use pocketmine\block\utils\WoodType;
use pocketmine\item\VanillaItems;
@ -108,15 +109,18 @@ final class BlockLegacyIdHelper{
});
}
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 getLeavesIdentifier(LeavesType $leavesType) : BID{
return new BID(match($leavesType->id()){
LeavesType::OAK()->id() => Ids::OAK_LEAVES,
LeavesType::SPRUCE()->id() => Ids::SPRUCE_LEAVES,
LeavesType::BIRCH()->id() => Ids::BIRCH_LEAVES,
LeavesType::JUNGLE()->id() => Ids::JUNGLE_LEAVES,
LeavesType::ACACIA()->id() => Ids::ACACIA_LEAVES,
LeavesType::DARK_OAK()->id() => Ids::DARK_OAK_LEAVES,
LeavesType::MANGROVE()->id() => Ids::MANGROVE_LEAVES,
LeavesType::AZALEA()->id() => Ids::AZALEA_LEAVES,
LeavesType::FLOWERING_AZALEA()->id() => Ids::FLOWERING_AZALEA_LEAVES,
default => throw new AssumptionFailedError("All leaves types should be covered")
});
}

View File

@ -709,8 +709,12 @@ final class BlockTypeIds{
public const CHAIN = 10682;
public const SCULK = 10683;
public const GLOWING_ITEM_FRAME = 10684;
public const MANGROVE_LEAVES = 10685;
public const AZALEA_LEAVES = 10686;
public const FLOWERING_AZALEA_LEAVES = 10687;
public const REINFORCED_DEEPSLATE = 10688;
public const FIRST_UNUSED_BLOCK_ID = 10685;
public const FIRST_UNUSED_BLOCK_ID = 10689;
private static int $nextDynamicId = self::FIRST_UNUSED_BLOCK_ID;

View File

@ -26,8 +26,7 @@ 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\data\runtime\RuntimeDataDescriber;
use pocketmine\item\Item;
use pocketmine\math\Axis;
use pocketmine\math\AxisAlignedBB;
@ -44,9 +43,7 @@ class BrewingStand extends Transparent{
*/
protected array $slots = [];
public function getRequiredStateDataBits() : int{ return 3; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->brewingStandSlots($this->slots);
}

View File

@ -24,8 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\block\utils\AnyFacingTrait;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\item\Item;
use pocketmine\math\Facing;
use pocketmine\math\Vector3;
@ -39,9 +38,7 @@ abstract class Button extends Flowable{
protected bool $pressed = false;
public function getRequiredStateDataBits() : int{ return 4; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->facing($this->facing);
$w->bool($this->pressed);
}

View File

@ -24,8 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\block\utils\SupportType;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\entity\Entity;
use pocketmine\event\block\BlockGrowEvent;
use pocketmine\event\entity\EntityDamageByBlockEvent;
@ -42,9 +41,7 @@ class Cactus extends Transparent{
protected int $age = 0;
public function getRequiredStateDataBits() : int{ return 4; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->boundedInt(4, 0, self::MAX_AGE, $this->age);
}

View File

@ -23,8 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\item\Item;
use pocketmine\item\ItemBlock;
use pocketmine\math\AxisAlignedBB;
@ -37,9 +36,7 @@ class Cake extends BaseCake{
protected int $bites = 0;
public function getRequiredStateDataBits() : int{ return 3; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->boundedInt(3, 0, self::MAX_BITES, $this->bites);
}

View File

@ -25,8 +25,7 @@ namespace pocketmine\block;
use pocketmine\block\utils\CandleTrait;
use pocketmine\block\utils\SupportType;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\item\Item;
use pocketmine\math\Axis;
use pocketmine\math\AxisAlignedBB;
@ -47,11 +46,7 @@ class Candle extends Transparent{
private int $count = self::MIN_COUNT;
public function getRequiredStateDataBits() : int{
return 3;
}
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$this->encodeLitState($w);
$w->boundedInt(2, self::MIN_COUNT, self::MAX_COUNT, $this->count);
}

View File

@ -23,8 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\entity\projectile\Projectile;
use pocketmine\event\block\StructureGrowEvent;
use pocketmine\item\Item;
@ -50,9 +49,7 @@ final class ChorusFlower extends Flowable{
private int $age = self::MIN_AGE;
public function getRequiredStateDataBits() : int{ return 3; }
protected function describeState(RuntimeDataWriter|RuntimeDataReader $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->boundedInt(3, self::MIN_AGE, self::MAX_AGE, $this->age);
}

View File

@ -26,8 +26,7 @@ namespace pocketmine\block;
use pocketmine\block\utils\HorizontalFacingTrait;
use pocketmine\block\utils\SupportType;
use pocketmine\block\utils\WoodType;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\event\block\BlockGrowEvent;
use pocketmine\item\Fertilizer;
use pocketmine\item\Item;
@ -47,9 +46,7 @@ class CocoaBlock extends Transparent{
protected int $age = 0;
public function getRequiredStateDataBits() : int{ return 4; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->horizontalFacing($this->facing);
$w->boundedInt(2, 0, self::MAX_AGE, $this->age);
}

View File

@ -23,8 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\event\block\BlockGrowEvent;
use pocketmine\item\Fertilizer;
use pocketmine\item\Item;
@ -39,9 +38,7 @@ abstract class Crops extends Flowable{
protected int $age = 0;
public function getRequiredStateDataBits() : int{ return 3; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->boundedInt(3, 0, self::MAX_AGE, $this->age);
}

View File

@ -25,8 +25,7 @@ namespace pocketmine\block;
use pocketmine\block\utils\AnalogRedstoneSignalEmitterTrait;
use pocketmine\block\utils\SupportType;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\item\Item;
use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Facing;
@ -42,9 +41,7 @@ class DaylightSensor extends Transparent{
protected bool $inverted = false;
public function getRequiredStateDataBits() : int{ return 5; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->boundedInt(4, 0, 15, $this->signalStrength);
$w->bool($this->inverted);
}

View File

@ -23,15 +23,12 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
class DetectorRail extends StraightOnlyRail{
protected bool $activated = false;
public function getRequiredStateDataBits() : int{ return 4; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
parent::describeState($w);
$w->bool($this->activated);
}

View File

@ -24,8 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\block\utils\DirtType;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\item\Fertilizer;
use pocketmine\item\Hoe;
use pocketmine\item\Item;
@ -46,9 +45,7 @@ class Dirt extends Opaque{
parent::__construct($idInfo, $name, $typeInfo);
}
public function getRequiredTypeDataBits() : int{ return 2; }
protected function describeType(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeType(RuntimeDataDescriber $w) : void{
$w->dirtType($this->dirtType);
}

View File

@ -25,8 +25,7 @@ namespace pocketmine\block;
use pocketmine\block\utils\HorizontalFacingTrait;
use pocketmine\block\utils\SupportType;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\item\Item;
use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Facing;
@ -42,9 +41,7 @@ class Door extends Transparent{
protected bool $hingeRight = false;
protected bool $open = false;
public function getRequiredStateDataBits() : int{ return 5; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->horizontalFacing($this->facing);
$w->bool($this->top);
$w->bool($this->hingeRight);

View File

@ -23,8 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\item\Item;
use pocketmine\math\Facing;
use pocketmine\math\Vector3;
@ -34,9 +33,7 @@ use pocketmine\world\BlockTransaction;
class DoublePlant extends Flowable{
protected bool $top = false;
public function getRequiredStateDataBits() : int{ return 1; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->bool($this->top);
}

View File

@ -25,8 +25,7 @@ namespace pocketmine\block;
use pocketmine\block\utils\FacesOppositePlacingPlayerTrait;
use pocketmine\block\utils\HorizontalFacingTrait;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Facing;
@ -36,9 +35,7 @@ class EndPortalFrame extends Opaque{
protected bool $eye = false;
public function getRequiredStateDataBits() : int{ return 3; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->horizontalFacing($this->facing);
$w->bool($this->eye);
}

View File

@ -23,8 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\entity\Entity;
use pocketmine\entity\Living;
use pocketmine\event\entity\EntityTrampleFarmlandEvent;
@ -38,9 +37,7 @@ class Farmland extends Transparent{
protected int $wetness = 0; //"moisture" blockstate property in PC
public function getRequiredStateDataBits() : int{ return 3; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->boundedInt(3, 0, self::MAX_WETNESS, $this->wetness);
}

View File

@ -26,8 +26,7 @@ namespace pocketmine\block;
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\data\runtime\RuntimeDataDescriber;
use pocketmine\item\Item;
use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Facing;
@ -43,9 +42,7 @@ class FenceGate extends Transparent{
protected bool $open = false;
protected bool $inWall = false;
public function getRequiredStateDataBits() : int{ return 4; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->horizontalFacing($this->facing);
$w->bool($this->open);
$w->bool($this->inWall);

View File

@ -24,8 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\block\utils\SupportType;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\item\Item;
use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Facing;
@ -38,11 +37,7 @@ abstract class FillableCauldron extends Transparent{
private int $fillLevel = self::MIN_FILL_LEVEL;
public function getRequiredStateDataBits() : int{
return 3;
}
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->boundedInt(3, self::MIN_FILL_LEVEL, self::MAX_FILL_LEVEL, $this->fillLevel);
}

View File

@ -23,8 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\event\block\BlockBurnEvent;
use pocketmine\event\block\BlockSpreadEvent;
use pocketmine\math\Facing;
@ -40,9 +39,7 @@ class Fire extends BaseFire{
protected int $age = 0;
public function getRequiredStateDataBits() : int{ return 4; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->boundedInt(4, 0, self::MAX_AGE, $this->age);
}

View File

@ -23,8 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\item\Item;
use pocketmine\item\VanillaItems;
use pocketmine\math\Axis;
@ -38,9 +37,7 @@ use function rad2deg;
final class FloorCoralFan extends BaseCoral{
private int $axis = Axis::X;
public function getRequiredStateDataBits() : int{ return parent::getRequiredStateDataBits() + 1; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->horizontalAxis($this->axis);
}

View File

@ -24,8 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\block\utils\FroglightType;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
final class Froglight extends SimplePillar{
@ -36,9 +35,7 @@ final class Froglight extends SimplePillar{
parent::__construct($idInfo, $name, $typeInfo);
}
public function getRequiredTypeDataBits() : int{ return 2; }
protected function describeType(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeType(RuntimeDataDescriber $w) : void{
$w->froglightType($this->froglightType);
}

View File

@ -23,8 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\event\block\BlockMeltEvent;
use function mt_rand;
@ -33,9 +32,7 @@ class FrostedIce extends Ice{
protected int $age = 0;
public function getRequiredStateDataBits() : int{ return 2; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->boundedInt(2, 0, self::MAX_AGE, $this->age);
}

View File

@ -27,8 +27,7 @@ use pocketmine\block\tile\Furnace as TileFurnace;
use pocketmine\block\utils\FacesOppositePlacingPlayerTrait;
use pocketmine\block\utils\HorizontalFacingTrait;
use pocketmine\crafting\FurnaceType;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\item\Item;
use pocketmine\math\Vector3;
use pocketmine\player\Player;
@ -47,9 +46,7 @@ class Furnace extends Opaque{
parent::__construct($idInfo, $name, $typeInfo);
}
public function getRequiredStateDataBits() : int{ return 3; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->horizontalFacing($this->facing);
$w->bool($this->lit);
}

View File

@ -26,8 +26,7 @@ namespace pocketmine\block;
use pocketmine\block\tile\Hopper as TileHopper;
use pocketmine\block\utils\PoweredByRedstoneTrait;
use pocketmine\block\utils\SupportType;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\item\Item;
use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Facing;
@ -40,9 +39,7 @@ class Hopper extends Transparent{
private int $facing = Facing::DOWN;
public function getRequiredStateDataBits() : int{ return 4; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->facingExcept($this->facing, Facing::UP);
$w->bool($this->powered);
}

View File

@ -35,7 +35,7 @@ final class InfestedStone extends Opaque{
}
public function getImitatedBlock() : Block{
return BlockFactory::getInstance()->fromStateId($this->imitated);
return RuntimeBlockStateRegistry::getInstance()->fromStateId($this->imitated);
}
public function getDropsForCompatibleTool(Item $item) : array{

View File

@ -26,8 +26,7 @@ namespace pocketmine\block;
use pocketmine\block\tile\ItemFrame as TileItemFrame;
use pocketmine\block\utils\AnyFacingTrait;
use pocketmine\block\utils\SupportType;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\item\Item;
use pocketmine\math\Facing;
use pocketmine\math\Vector3;
@ -51,9 +50,7 @@ class ItemFrame extends Flowable{
protected int $itemRotation = 0;
protected float $itemDropChance = 1.0;
public function getRequiredStateDataBits() : int{ return 4; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->facing($this->facing);
$w->bool($this->hasMap);
}

View File

@ -24,8 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\block\utils\SupportType;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\item\Item;
use pocketmine\math\Axis;
use pocketmine\math\AxisAlignedBB;
@ -44,9 +43,7 @@ class Lantern extends Transparent{
parent::__construct($idInfo, $name, $typeInfo);
}
public function getRequiredStateDataBits() : int{ return 1; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->bool($this->hanging);
}

View File

@ -23,10 +23,9 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\block\utils\LeavesType;
use pocketmine\block\utils\SupportType;
use pocketmine\block\utils\TreeType;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\event\block\LeavesDecayEvent;
use pocketmine\item\Item;
use pocketmine\item\VanillaItems;
@ -39,22 +38,22 @@ use pocketmine\world\World;
use function mt_rand;
class Leaves extends Transparent{
protected TreeType $treeType;
protected LeavesType $leavesType; //immutable for now
protected bool $noDecay = false;
protected bool $checkDecay = false;
public function __construct(BlockIdentifier $idInfo, string $name, BlockTypeInfo $typeInfo, TreeType $treeType){
public function __construct(BlockIdentifier $idInfo, string $name, BlockTypeInfo $typeInfo, LeavesType $leavesType){
parent::__construct($idInfo, $name, $typeInfo);
$this->treeType = $treeType;
$this->leavesType = $leavesType;
}
public function getRequiredStateDataBits() : int{ return 2; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->bool($this->noDecay);
$w->bool($this->checkDecay);
}
public function getLeavesType() : LeavesType{ return $this->leavesType; }
public function isNoDecay() : bool{ return $this->noDecay; }
/** @return $this */
@ -140,17 +139,22 @@ class Leaves extends Transparent{
$drops = [];
if(mt_rand(1, 20) === 1){ //Saplings
$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(),
$sapling = (match($this->leavesType){
LeavesType::ACACIA() => VanillaBlocks::ACACIA_SAPLING(),
LeavesType::BIRCH() => VanillaBlocks::BIRCH_SAPLING(),
LeavesType::DARK_OAK() => VanillaBlocks::DARK_OAK_SAPLING(),
LeavesType::JUNGLE() => VanillaBlocks::JUNGLE_SAPLING(),
LeavesType::OAK() => VanillaBlocks::OAK_SAPLING(),
LeavesType::SPRUCE() => VanillaBlocks::SPRUCE_SAPLING(),
LeavesType::MANGROVE(), //TODO: mangrove propagule
LeavesType::AZALEA(), LeavesType::FLOWERING_AZALEA() => null, //TODO: azalea
default => throw new AssumptionFailedError("Unreachable")
})->asItem();
})?->asItem();
if($sapling !== null){
$drops[] = $sapling;
}
}
if(($this->treeType->equals(TreeType::OAK()) || $this->treeType->equals(TreeType::DARK_OAK())) && mt_rand(1, 200) === 1){ //Apples
if(($this->leavesType->equals(LeavesType::OAK()) || $this->leavesType->equals(LeavesType::DARK_OAK())) && mt_rand(1, 200) === 1){ //Apples
$drops[] = VanillaItems::APPLE();
}
if(mt_rand(1, 50) === 1){

View File

@ -27,8 +27,7 @@ use pocketmine\block\tile\Lectern as TileLectern;
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\data\runtime\RuntimeDataDescriber;
use pocketmine\item\Item;
use pocketmine\item\WritableBookBase;
use pocketmine\math\AxisAlignedBB;
@ -47,9 +46,7 @@ class Lectern extends Transparent{
protected bool $producingSignal = false;
public function getRequiredStateDataBits() : int{ return 3; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->horizontalFacing($this->facing);
$w->bool($this->producingSignal);
}

View File

@ -24,8 +24,7 @@ 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\RuntimeDataDescriber;
use pocketmine\item\Item;
use pocketmine\math\Axis;
use pocketmine\math\Facing;
@ -45,9 +44,7 @@ class Lever extends Flowable{
parent::__construct($idInfo, $name, $typeInfo);
}
public function getRequiredStateDataBits() : int{ return 4; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->leverFacing($this->facing);
$w->bool($this->activated);
}

View File

@ -23,8 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\item\Item;
use pocketmine\math\Vector3;
use pocketmine\player\Player;
@ -35,9 +34,7 @@ final class Light extends Flowable{
private int $level = self::MAX_LIGHT_LEVEL;
public function getRequiredTypeDataBits() : int{ return 4; }
protected function describeType(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeType(RuntimeDataDescriber $w) : void{
$w->boundedInt(4, self::MIN_LIGHT_LEVEL, self::MAX_LIGHT_LEVEL, $this->level);
}

View File

@ -25,8 +25,7 @@ namespace pocketmine\block;
use pocketmine\block\utils\MinimumCostFlowCalculator;
use pocketmine\block\utils\SupportType;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\entity\Entity;
use pocketmine\event\block\BlockFormEvent;
use pocketmine\event\block\BlockSpreadEvent;
@ -49,9 +48,7 @@ abstract class Liquid extends Transparent{
protected int $decay = 0; //PC "level" property
protected bool $still = false;
public function getRequiredStateDataBits() : int{ return 5; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->boundedInt(3, 0, self::MAX_DECAY, $this->decay);
$w->bool($this->falling);
$w->bool($this->still);

View File

@ -24,8 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\block\utils\SupportType;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\entity\Entity;
use pocketmine\item\Item;
use pocketmine\math\Axis;
@ -35,9 +34,7 @@ class NetherPortal extends Transparent{
protected int $axis = Axis::X;
public function getRequiredStateDataBits() : int{ return 1; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->horizontalAxis($this->axis);
}

View File

@ -24,8 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\block\utils\SupportType;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\entity\Entity;
use pocketmine\event\block\StructureGrowEvent;
use pocketmine\item\Fertilizer;
@ -53,11 +52,7 @@ class NetherVines extends Flowable{
parent::__construct($idInfo, $name, $typeInfo);
}
public function getRequiredStateDataBits() : int{
return 5;
}
public function describeState(RuntimeDataWriter|RuntimeDataReader $w) : void{
public function describeState(RuntimeDataDescriber $w) : void{
$w->boundedInt(5, 0, self::MAX_AGE, $this->age);
}

View File

@ -23,8 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\event\block\BlockGrowEvent;
use pocketmine\item\Item;
use pocketmine\math\Facing;
@ -38,9 +37,7 @@ class NetherWartPlant extends Flowable{
protected int $age = 0;
public function getRequiredStateDataBits() : int{ return 2; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->boundedInt(2, 0, self::MAX_AGE, $this->age);
}

View File

@ -25,8 +25,7 @@ namespace pocketmine\block;
use pocketmine\block\utils\RailConnectionInfo;
use pocketmine\data\bedrock\block\BlockLegacyMetadata;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\math\Facing;
use function array_keys;
use function implode;
@ -35,9 +34,7 @@ class Rail extends BaseRail{
private int $railShape = BlockLegacyMetadata::RAIL_STRAIGHT_NORTH_SOUTH;
public function getRequiredStateDataBits() : int{ return 4; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->railShape($this->railShape);
}

View File

@ -24,8 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\block\utils\MushroomBlockType;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\item\Item;
use function mt_rand;
@ -37,9 +36,7 @@ class RedMushroomBlock extends Opaque{
parent::__construct($idInfo, $name, $typeInfo);
}
public function getRequiredStateDataBits() : int{ return 4; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->mushroomBlockType($this->mushroomBlockType);
}

View File

@ -28,8 +28,7 @@ use pocketmine\block\utils\AnalogRedstoneSignalEmitterTrait;
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\data\runtime\RuntimeDataDescriber;
use pocketmine\item\Item;
use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Facing;
@ -45,9 +44,7 @@ class RedstoneComparator extends Flowable{
protected bool $isSubtractMode = false;
public function getRequiredStateDataBits() : int{ return 4; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->horizontalFacing($this->facing);
$w->bool($this->isSubtractMode);
$w->bool($this->powered);

View File

@ -24,15 +24,12 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\block\utils\PoweredByRedstoneTrait;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
class RedstoneLamp extends Opaque{
use PoweredByRedstoneTrait;
public function getRequiredStateDataBits() : int{ return 1; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->bool($this->powered);
}

View File

@ -23,8 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\item\Item;
use pocketmine\item\VanillaItems;
use pocketmine\math\Vector3;
@ -34,9 +33,7 @@ use function mt_rand;
class RedstoneOre extends Opaque{
protected bool $lit = false;
public function getRequiredStateDataBits() : int{ return 1; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->bool($this->lit);
}

View File

@ -26,8 +26,7 @@ namespace pocketmine\block;
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\data\runtime\RuntimeDataDescriber;
use pocketmine\item\Item;
use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Facing;
@ -44,9 +43,7 @@ class RedstoneRepeater extends Flowable{
protected int $delay = self::MIN_DELAY;
public function getRequiredStateDataBits() : int{ return 5; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->horizontalFacing($this->facing);
$w->boundedInt(2, self::MIN_DELAY, self::MAX_DELAY, $this->delay);
$w->bool($this->powered);

View File

@ -23,15 +23,12 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
class RedstoneTorch extends Torch{
protected bool $lit = true;
public function getRequiredStateDataBits() : int{ return parent::getRequiredStateDataBits() + 1; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
parent::describeState($w);
$w->bool($this->lit);
}

View File

@ -29,13 +29,17 @@ use pocketmine\data\runtime\InvalidSerializedRuntimeDataException;
use pocketmine\utils\AssumptionFailedError;
use pocketmine\utils\SingletonTrait;
use pocketmine\world\light\LightUpdate;
use function get_class;
use function min;
/**
* Manages deserializing block types from their legacy blockIDs and metadata.
* This is primarily needed for loading chunks from disk.
* Blocks are stored as state IDs in chunks at runtime (it would waste far too much memory to represent every block as
* an object). This class maps block state IDs to their corresponding block objects when reading blocks from chunks at
* runtime.
*
* @internal Plugin devs shouldn't need to interact with this class at all, unless registering a new block type.
*/
class BlockFactory{
class RuntimeBlockStateRegistry{
use SingletonTrait;
/**
@ -78,6 +82,34 @@ class BlockFactory{
}
}
/**
* Generates all the possible valid blockstates for a given block type.
*
* @phpstan-return \Generator<int, Block, void, void>
*/
private static function generateAllStatesForType(Block $block) : \Generator{
//TODO: this bruteforce approach to discovering all valid states is very inefficient for larger state data sizes
//at some point we'll need to find a better way to do this
$bits = $block->getRequiredTypeDataBits() + $block->getRequiredStateDataBits();
if($bits > Block::INTERNAL_STATE_DATA_BITS){
throw new \InvalidArgumentException("Block state data cannot use more than " . Block::INTERNAL_STATE_DATA_BITS . " bits");
}
for($stateData = 0; $stateData < (1 << $bits); ++$stateData){
$v = clone $block;
try{
$v->decodeStateData($stateData);
if($v->computeStateData() !== $stateData){
//TODO: this should probably be a hard error
throw new \LogicException(get_class($block) . "::decodeStateData() accepts invalid state data (returned " . $v->computeStateData() . " for input $stateData)");
}
}catch(InvalidSerializedRuntimeDataException){ //invalid property combination, leave it
continue;
}
yield $v;
}
}
/**
* Maps a block type to its corresponding type ID. This is necessary for the block to be recognized when loading
* from disk, and also when being read at runtime.
@ -99,24 +131,7 @@ class BlockFactory{
$this->typeIndex[$typeId] = clone $block;
//TODO: this bruteforce approach to discovering all valid states is very inefficient for larger state data sizes
//at some point we'll need to find a better way to do this
$bits = $block->getRequiredTypeDataBits() + $block->getRequiredStateDataBits();
if($bits > Block::INTERNAL_STATE_DATA_BITS){
throw new \InvalidArgumentException("Block state data cannot use more than " . Block::INTERNAL_STATE_DATA_BITS . " bits");
}
for($stateData = 0; $stateData < (1 << $bits); ++$stateData){
$v = clone $block;
try{
$v->decodeStateData($stateData);
if($v->computeStateData() !== $stateData){
//if the fullID comes back different, this is a broken state that we can't rely on; map it to default
throw new InvalidSerializedRuntimeDataException("Corrupted state");
}
}catch(InvalidSerializedRuntimeDataException $e){ //invalid property combination, leave it
continue;
}
foreach(self::generateAllStatesForType($block) as $v){
$this->fillStaticArrays($v->getStateId(), $v);
}
}

View File

@ -24,8 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\block\utils\TreeType;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\event\block\StructureGrowEvent;
use pocketmine\item\Fertilizer;
use pocketmine\item\Item;
@ -47,9 +46,7 @@ class Sapling extends Flowable{
$this->treeType = $treeType;
}
public function getRequiredStateDataBits() : int{ return 1; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->bool($this->ready);
}

View File

@ -24,8 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\block\utils\SupportType;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\item\Item;
use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Vector3;
@ -39,9 +38,7 @@ class SeaPickle extends Transparent{
protected int $count = self::MIN_COUNT;
protected bool $underwater = false;
public function getRequiredStateDataBits() : int{ return 3; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->boundedInt(2, self::MIN_COUNT, self::MAX_COUNT, $this->count);
$w->bool($this->underwater);
}

View File

@ -25,8 +25,7 @@ namespace pocketmine\block;
use pocketmine\block\tile\ShulkerBox as TileShulkerBox;
use pocketmine\block\utils\AnyFacingTrait;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\item\Item;
use pocketmine\math\Vector3;
use pocketmine\player\Player;
@ -35,9 +34,7 @@ use pocketmine\world\BlockTransaction;
class ShulkerBox extends Opaque{
use AnyFacingTrait;
public function getRequiredStateDataBits() : int{ return 0; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
//NOOP - we don't read or write facing here, because the tile persists it
}

View File

@ -23,15 +23,12 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
abstract class SimplePressurePlate extends PressurePlate{
protected bool $pressed = false;
public function getRequiredStateDataBits() : int{ return 1; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->bool($this->pressed);
}

View File

@ -25,8 +25,7 @@ namespace pocketmine\block;
use pocketmine\block\tile\Skull as TileSkull;
use pocketmine\block\utils\SkullType;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\item\Item;
use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Facing;
@ -50,15 +49,11 @@ class Skull extends Flowable{
parent::__construct($idInfo, $name, $typeInfo);
}
public function getRequiredTypeDataBits() : int{ return 3; }
protected function describeType(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeType(RuntimeDataDescriber $w) : void{
$w->skullType($this->skullType);
}
public function getRequiredStateDataBits() : int{ return 3; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->facingExcept($this->facing, Facing::DOWN);
}

View File

@ -25,8 +25,7 @@ namespace pocketmine\block;
use pocketmine\block\utils\SlabType;
use pocketmine\block\utils\SupportType;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\item\Item;
use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Facing;
@ -42,9 +41,7 @@ class Slab extends Transparent{
$this->slabType = SlabType::BOTTOM();
}
public function getRequiredStateDataBits() : int{ return 2; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->slabType($this->slabType);
}

View File

@ -26,8 +26,7 @@ namespace pocketmine\block;
use pocketmine\block\utils\Fallable;
use pocketmine\block\utils\FallableTrait;
use pocketmine\block\utils\SupportType;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\event\block\BlockMeltEvent;
use pocketmine\item\Item;
use pocketmine\item\VanillaItems;
@ -47,9 +46,7 @@ class SnowLayer extends Flowable implements Fallable{
protected int $layers = self::MIN_LAYERS;
public function getRequiredStateDataBits() : int{ return 3; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->boundedInt(3, self::MIN_LAYERS, self::MAX_LAYERS, $this->layers);
}

View File

@ -23,15 +23,12 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
class Sponge extends Opaque{
protected bool $wet = false;
public function getRequiredTypeDataBits() : int{ return 1; }
protected function describeType(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeType(RuntimeDataDescriber $w) : void{
$w->bool($this->wet);
}

View File

@ -26,8 +26,7 @@ namespace pocketmine\block;
use pocketmine\block\utils\HorizontalFacingTrait;
use pocketmine\block\utils\StairShape;
use pocketmine\block\utils\SupportType;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\item\Item;
use pocketmine\math\Axis;
use pocketmine\math\AxisAlignedBB;
@ -47,9 +46,7 @@ class Stair extends Transparent{
parent::__construct($idInfo, $name, $typeInfo);
}
public function getRequiredStateDataBits() : int{ return 3; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->horizontalFacing($this->facing);
$w->bool($this->upsideDown);
}

View File

@ -25,8 +25,7 @@ namespace pocketmine\block;
use pocketmine\block\utils\RailConnectionInfo;
use pocketmine\data\bedrock\block\BlockLegacyMetadata;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
use function array_keys;
use function implode;
@ -37,9 +36,7 @@ class StraightOnlyRail extends BaseRail{
private int $railShape = BlockLegacyMetadata::RAIL_STRAIGHT_NORTH_SOUTH;
public function getRequiredStateDataBits() : int{ return 3; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->straightOnlyRailShape($this->railShape);
}

View File

@ -23,8 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\event\block\BlockGrowEvent;
use pocketmine\item\Fertilizer;
use pocketmine\item\Item;
@ -39,9 +38,7 @@ class Sugarcane extends Flowable{
protected int $age = 0;
public function getRequiredStateDataBits() : int{ return 4; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->boundedInt(4, 0, self::MAX_AGE, $this->age);
}

View File

@ -23,8 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\entity\Entity;
use pocketmine\entity\Living;
use pocketmine\event\block\BlockGrowEvent;
@ -46,9 +45,7 @@ class SweetBerryBush extends Flowable{
protected int $age = self::STAGE_SAPLING;
public function getRequiredStateDataBits() : int{ return 3; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->boundedInt(3, self::STAGE_SAPLING, self::STAGE_MATURE, $this->age);
}

View File

@ -23,8 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\entity\Location;
use pocketmine\entity\object\PrimedTNT;
use pocketmine\entity\projectile\Projectile;
@ -46,15 +45,11 @@ class TNT extends Opaque{
protected bool $unstable = false; //TODO: Usage unclear, seems to be a weird hack in vanilla
protected bool $worksUnderwater = false;
public function getRequiredTypeDataBits() : int{ return 1; }
protected function describeType(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeType(RuntimeDataDescriber $w) : void{
$w->bool($this->worksUnderwater);
}
public function getRequiredStateDataBits() : int{ return 1; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->bool($this->unstable);
}

View File

@ -24,8 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\block\utils\SupportType;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\item\Item;
use pocketmine\math\Axis;
use pocketmine\math\Facing;
@ -37,9 +36,7 @@ class Torch extends Flowable{
protected int $facing = Facing::UP;
public function getRequiredStateDataBits() : int{ return 3; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->facingExcept($this->facing, Facing::DOWN);
}

View File

@ -25,8 +25,7 @@ namespace pocketmine\block;
use pocketmine\block\utils\HorizontalFacingTrait;
use pocketmine\block\utils\SupportType;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\item\Item;
use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Facing;
@ -41,9 +40,7 @@ class Trapdoor extends Transparent{
protected bool $open = false;
protected bool $top = false;
public function getRequiredStateDataBits() : int{ return 4; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->horizontalFacing($this->facing);
$w->bool($this->top);
$w->bool($this->open);

View File

@ -23,8 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\item\Item;
use pocketmine\item\VanillaItems;
@ -34,9 +33,7 @@ class Tripwire extends Flowable{
protected bool $connected = false;
protected bool $disarmed = false;
public function getRequiredStateDataBits() : int{ return 4; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->bool($this->triggered);
$w->bool($this->suspended);
$w->bool($this->connected);

View File

@ -24,8 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\block\utils\HorizontalFacingTrait;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\item\Item;
use pocketmine\math\Axis;
use pocketmine\math\Facing;
@ -39,9 +38,7 @@ class TripwireHook extends Flowable{
protected bool $connected = false;
protected bool $powered = false;
public function getRequiredStateDataBits() : int{ return 4; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->horizontalFacing($this->facing);
$w->bool($this->connected);
$w->bool($this->powered);

View File

@ -23,8 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\item\Item;
/**
@ -39,9 +38,7 @@ class UnknownBlock extends Transparent{
$this->stateData = $stateData;
}
public function getRequiredTypeDataBits() : int{ return Block::INTERNAL_STATE_DATA_BITS; }
protected function describeType(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeType(RuntimeDataDescriber $w) : void{
//use type instead of state, so we don't lose any information like colour
//this might be an improperly registered plugin block
$w->int(Block::INTERNAL_STATE_DATA_BITS, $this->stateData);

View File

@ -54,6 +54,7 @@ use pocketmine\block\tile\Note as TileNote;
use pocketmine\block\tile\ShulkerBox as TileShulkerBox;
use pocketmine\block\tile\Skull as TileSkull;
use pocketmine\block\tile\Smoker as TileSmoker;
use pocketmine\block\utils\LeavesType;
use pocketmine\block\utils\TreeType;
use pocketmine\block\utils\WoodType;
use pocketmine\crafting\FurnaceType;
@ -99,6 +100,7 @@ use function mb_strtolower;
* @method static Stair ANDESITE_STAIRS()
* @method static Wall ANDESITE_WALL()
* @method static Anvil ANVIL()
* @method static Leaves AZALEA_LEAVES()
* @method static Flower AZURE_BLUET()
* @method static Bamboo BAMBOO()
* @method static BambooSapling BAMBOO_SAPLING()
@ -402,6 +404,7 @@ use function mb_strtolower;
* @method static TallGrass FERN()
* @method static Fire FIRE()
* @method static FletchingTable FLETCHING_TABLE()
* @method static Leaves FLOWERING_AZALEA_LEAVES()
* @method static FlowerPot FLOWER_POT()
* @method static Froglight FROGLIGHT()
* @method static FrostedIce FROSTED_ICE()
@ -485,6 +488,7 @@ use function mb_strtolower;
* @method static WoodenDoor MANGROVE_DOOR()
* @method static WoodenFence MANGROVE_FENCE()
* @method static FenceGate MANGROVE_FENCE_GATE()
* @method static Leaves MANGROVE_LEAVES()
* @method static Wood MANGROVE_LOG()
* @method static Planks MANGROVE_PLANKS()
* @method static WoodenPressurePlate MANGROVE_PRESSURE_PLATE()
@ -624,6 +628,7 @@ use function mb_strtolower;
* @method static Wall RED_SANDSTONE_WALL()
* @method static Torch RED_TORCH()
* @method static Flower RED_TULIP()
* @method static Opaque REINFORCED_DEEPSLATE()
* @method static Reserved6 RESERVED6()
* @method static DoublePlant ROSE_BUSH()
* @method static Sand SAND()
@ -1106,7 +1111,10 @@ final class VanillaBlocks{
foreach(TreeType::getAll() as $treeType){
$name = $treeType->getDisplayName();
self::register($treeType->name() . "_sapling", new Sapling(BlockLegacyIdHelper::getSaplingIdentifier($treeType), $name . " Sapling", $saplingTypeInfo, $treeType));
self::register($treeType->name() . "_leaves", new Leaves(BlockLegacyIdHelper::getLeavesIdentifier($treeType), $name . " Leaves", $leavesBreakInfo, $treeType));
}
foreach(LeavesType::getAll() as $leavesType){
$name = $leavesType->getDisplayName();
self::register($leavesType->name() . "_leaves", new Leaves(BlockLegacyIdHelper::getLeavesIdentifier($leavesType), $name . " Leaves", $leavesBreakInfo, $leavesType));
}
$sandstoneBreakInfo = new Info(BreakInfo::pickaxe(0.8, ToolTier::WOOD()));
@ -1194,6 +1202,11 @@ final class VanillaBlocks{
self::register("muddy_mangrove_roots", new SimplePillar(new BID(Ids::MUDDY_MANGROVE_ROOTS), "Muddy Mangrove Roots", new Info(BreakInfo::shovel(0.7), [Tags::MUD])));
self::register("froglight", new Froglight(new BID(Ids::FROGLIGHT), "Froglight", new Info(new BreakInfo(0.3))));
self::register("sculk", new Sculk(new BID(Ids::SCULK), "Sculk", new Info(new BreakInfo(0.6, ToolType::HOE))));
self::register("reinforced_deepslate", new class(new BID(Ids::REINFORCED_DEEPSLATE), "Reinforced Deepslate", new Info(new BreakInfo(55.0, ToolType::NONE, 0, 3600.0))) extends Opaque{
public function getDropsForCompatibleTool(Item $item) : array{
return [];
}
});
self::registerBlocksR13();
self::registerBlocksR14();
@ -1503,7 +1516,15 @@ final class VanillaBlocks{
self::register("raw_iron", new Opaque(new BID(Ids::RAW_IRON), "Raw Iron Block", new Info(BreakInfo::pickaxe(5, ToolTier::STONE(), 30.0))));
$deepslateBreakInfo = new Info(BreakInfo::pickaxe(3, ToolTier::WOOD(), 18.0));
self::register("deepslate", new SimplePillar(new BID(Ids::DEEPSLATE), "Deepslate", $deepslateBreakInfo));
self::register("deepslate", new class(new BID(Ids::DEEPSLATE), "Deepslate", $deepslateBreakInfo) extends SimplePillar{
public function getDropsForCompatibleTool(Item $item) : array{
return [VanillaBlocks::COBBLED_DEEPSLATE()->asItem()];
}
public function isAffectedBySilkTouch() : bool{
return true;
}
});
//TODO: parity issue here - in Java this has a hardness of 3.0, but in bedrock it's 3.5
self::register("chiseled_deepslate", new Opaque(new BID(Ids::CHISELED_DEEPSLATE), "Chiseled Deepslate", new Info(BreakInfo::pickaxe(3.5, ToolTier::WOOD(), 18.0))));

View File

@ -23,8 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\entity\Entity;
use pocketmine\item\Item;
use pocketmine\math\Axis;
@ -40,9 +39,7 @@ class Vine extends Flowable{
/** @var int[] */
protected array $faces = [];
public function getRequiredStateDataBits() : int{ return 4; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->horizontalFacingFlags($this->faces);
}

View File

@ -25,8 +25,7 @@ namespace pocketmine\block;
use pocketmine\block\utils\SupportType;
use pocketmine\block\utils\WallConnectionType;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\math\Axis;
use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Facing;
@ -43,9 +42,7 @@ class Wall extends Transparent{
protected array $connections = [];
protected bool $post = false;
public function getRequiredStateDataBits() : int{ return 9; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->wallConnections($this->connections);
$w->bool($this->post);
}

View File

@ -24,8 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\block\utils\HorizontalFacingTrait;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\item\Item;
use pocketmine\item\VanillaItems;
use pocketmine\math\Axis;
@ -37,9 +36,7 @@ use pocketmine\world\BlockTransaction;
final class WallCoralFan extends BaseCoral{
use HorizontalFacingTrait;
public function getRequiredStateDataBits() : int{ return parent::getRequiredStateDataBits() + 2; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->horizontalFacing($this->facing);
}

View File

@ -25,8 +25,7 @@ namespace pocketmine\block;
use pocketmine\block\utils\PillarRotationTrait;
use pocketmine\block\utils\WoodTypeTrait;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\item\Axe;
use pocketmine\item\Item;
use pocketmine\math\Vector3;
@ -39,9 +38,7 @@ class Wood extends Opaque{
private bool $stripped = false;
public function getRequiredTypeDataBits() : int{ return 1; }
protected function describeType(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeType(RuntimeDataDescriber $w) : void{
$w->bool($this->stripped);
}

View File

@ -25,7 +25,7 @@ namespace pocketmine\block\tile;
use pocketmine\block\Air;
use pocketmine\block\Block;
use pocketmine\block\BlockFactory;
use pocketmine\block\RuntimeBlockStateRegistry;
use pocketmine\data\bedrock\block\BlockStateDeserializeException;
use pocketmine\data\bedrock\block\BlockStateNames;
use pocketmine\data\SavedDataLoadingException;
@ -67,7 +67,7 @@ class FlowerPot extends Spawnable{
}catch(BlockStateDeserializeException $e){
throw new SavedDataLoadingException("Error deserializing plant for flower pot: " . $e->getMessage(), 0, $e);
}
$this->setPlant(BlockFactory::getInstance()->fromStateId($blockStateId));
$this->setPlant(RuntimeBlockStateRegistry::getInstance()->fromStateId($blockStateId));
}
}

View File

@ -23,15 +23,12 @@ declare(strict_types=1);
namespace pocketmine\block\utils;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
trait AnalogRedstoneSignalEmitterTrait{
protected int $signalStrength = 0;
public function getRequiredStateDataBits() : int{ return 4; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->boundedInt(4, 0, 15, $this->signalStrength);
}

View File

@ -23,16 +23,13 @@ declare(strict_types=1);
namespace pocketmine\block\utils;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\math\Facing;
trait AnyFacingTrait{
protected int $facing = Facing::DOWN;
public function getRequiredStateDataBits() : int{ return 3; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->facing($this->facing);
}

View File

@ -24,8 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block\utils;
use pocketmine\block\Block;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\entity\projectile\Projectile;
use pocketmine\item\Durable;
use pocketmine\item\enchantment\VanillaEnchantments;
@ -40,9 +39,7 @@ use pocketmine\world\sound\FlintSteelSound;
trait CandleTrait{
private bool $lit = false;
public function getRequiredStateDataBits() : int{ return 1; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->bool($this->lit);
}

View File

@ -24,17 +24,14 @@ declare(strict_types=1);
namespace pocketmine\block\utils;
use pocketmine\block\Block;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
trait ColoredTrait{
/** @var DyeColor */
private $color;
public function getRequiredTypeDataBits() : int{ return 4; }
/** @see Block::describeType() */
protected function describeType(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeType(RuntimeDataDescriber $w) : void{
$w->dyeColor($this->color);
}

View File

@ -25,8 +25,7 @@ namespace pocketmine\block\utils;
use pocketmine\block\BlockIdentifier;
use pocketmine\block\BlockTypeInfo;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\item\Axe;
use pocketmine\item\Item;
use pocketmine\item\ItemTypeIds;
@ -45,9 +44,7 @@ trait CopperTrait{
parent::__construct($identifier, $name, $typeInfo);
}
public function getRequiredTypeDataBits() : int{ return 3; }
protected function describeType(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeType(RuntimeDataDescriber $w) : void{
$w->copperOxidation($this->oxidation);
$w->bool($this->waxed);
}

View File

@ -24,17 +24,14 @@ declare(strict_types=1);
namespace pocketmine\block\utils;
use pocketmine\block\Block;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
trait CoralTypeTrait{
protected CoralType $coralType;
protected bool $dead = false;
public function getRequiredTypeDataBits() : int{ return 4; }
/** @see Block::describeType() */
protected function describeType(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeType(RuntimeDataDescriber $w) : void{
$w->coralType($this->coralType);
$w->bool($this->dead);
}

View File

@ -23,17 +23,14 @@ declare(strict_types=1);
namespace pocketmine\block\utils;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\math\Axis;
use pocketmine\math\Facing;
trait HorizontalFacingTrait{
protected int $facing = Facing::NORTH;
public function getRequiredStateDataBits() : int{ return 2; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->horizontalFacing($this->facing);
}

View File

@ -0,0 +1,74 @@
<?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\utils;
use pocketmine\utils\EnumTrait;
/**
* This doc-block is generated automatically, do not modify it manually.
* This must be regenerated whenever registry members are added, removed or changed.
* @see build/generate-registry-annotations.php
* @generate-registry-docblock
*
* @method static LeavesType ACACIA()
* @method static LeavesType AZALEA()
* @method static LeavesType BIRCH()
* @method static LeavesType DARK_OAK()
* @method static LeavesType FLOWERING_AZALEA()
* @method static LeavesType JUNGLE()
* @method static LeavesType MANGROVE()
* @method static LeavesType OAK()
* @method static LeavesType SPRUCE()
*/
final class LeavesType{
use EnumTrait {
register as Enum_register;
__construct as Enum___construct;
}
protected static function setup() : void{
self::registerAll(
new self("oak", "Oak"),
new self("spruce", "Spruce"),
new self("birch", "Birch"),
new self("jungle", "Jungle"),
new self("acacia", "Acacia"),
new self("dark_oak", "Dark Oak"),
new self("mangrove", "Mangrove"),
new self("azalea", "Azalea"),
new self("flowering_azalea", "Flowering Azalea")
);
}
private function __construct(
string $enumName,
private string $displayName
){
$this->Enum___construct($enumName);
}
public function getDisplayName() : string{
return $this->displayName;
}
}

View File

@ -24,8 +24,7 @@ declare(strict_types=1);
namespace pocketmine\block\utils;
use pocketmine\block\Block;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
use pocketmine\item\Item;
use pocketmine\math\Axis;
use pocketmine\math\Facing;
@ -36,9 +35,7 @@ use pocketmine\world\BlockTransaction;
trait PillarRotationTrait{
protected int $axis = Axis::Y;
public function getRequiredStateDataBits() : int{ return 2; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
$w->axis($this->axis);
}

View File

@ -23,15 +23,12 @@ declare(strict_types=1);
namespace pocketmine\block\utils;
use pocketmine\data\runtime\RuntimeDataReader;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\data\runtime\RuntimeDataDescriber;
trait RailPoweredByRedstoneTrait{
use PoweredByRedstoneTrait;
public function getRequiredStateDataBits() : int{ return parent::getRequiredStateDataBits() + 1; }
protected function describeState(RuntimeDataReader|RuntimeDataWriter $w) : void{
protected function describeState(RuntimeDataDescriber $w) : void{
parent::describeState($w);
$w->bool($this->powered);
}

Some files were not shown because too many files have changed in this diff Show More