mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-09 11:16:57 +00:00
Compare commits
73 Commits
5.27.1
...
translatab
Author | SHA1 | Date | |
---|---|---|---|
c4fb8832fe | |||
48b80ecf78 | |||
4c3a2ef46e | |||
d053e9e168 | |||
5ebbcd5d33 | |||
a4ac28592c | |||
e99665fb12 | |||
b4b6bbe29f | |||
0910a219d4 | |||
56da492e48 | |||
035d2dec23 | |||
b40b99fe72 | |||
baafaed362 | |||
bf33a625c9 | |||
059f4ee7bf | |||
dd17adeaaf | |||
98f28f8b6d | |||
a554d2acf5 | |||
5527a0c6bf | |||
eee2e62d81 | |||
4d5c27a734 | |||
e1af2a4af1 | |||
f656d7d3d7 | |||
3636173d75 | |||
9606c0e0bb | |||
55123b36e1 | |||
94fb5d95b9 | |||
b5f236c019 | |||
7169f8e553 | |||
657e6c8130 | |||
647c2587a8 | |||
81d3017ad5 | |||
a37353c060 | |||
280911ec59 | |||
abb004fbc5 | |||
e0864e7ee8 | |||
dca37d5842 | |||
67f3bb9c52 | |||
acf4341d71 | |||
84bb9d2ab4 | |||
50f3fe2578 | |||
04de72e85e | |||
4bcef443f7 | |||
d90fc3415c | |||
e2e16a4ec5 | |||
134c7309c5 | |||
5e830c7320 | |||
c1cee1fc24 | |||
d789c75c00 | |||
6196b9c995 | |||
f2e7473629 | |||
6bf9a305de | |||
f8abcd5102 | |||
6f3506360e | |||
efaf9311b3 | |||
fe70b31881 | |||
cfafb584a8 | |||
ad6f7dfedb | |||
1ea5c060fd | |||
4a5c1e7540 | |||
2548422973 | |||
028815490e | |||
a74168953c | |||
f661443ec7 | |||
1073f372f8 | |||
835c383d4e | |||
d3f6c22996 | |||
071c15d7de | |||
673b39e2a1 | |||
17faa19743 | |||
644c04bee4 | |||
d954772a20 | |||
6b04bb504f |
32
.github/workflows/branch-sync-cron-trigger.yml
vendored
Normal file
32
.github/workflows/branch-sync-cron-trigger.yml
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
#Since GitHub automatically disables cron actions after 60 days of repo inactivity, we need the active repo (PM)
|
||||
#to trigger the branch merge workflow explicitly. This avoids the need for TOS-violating actions which we previously
|
||||
#used to keep the restricted action active, as the workflow depends on the activity of this repo anyway.
|
||||
|
||||
name: Trigger branch sync
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: "0 0 * * *" #once per day so we don't spam merge commits on busy days
|
||||
workflow_dispatch: #for testing
|
||||
|
||||
jobs:
|
||||
trigger:
|
||||
name: Trigger branch sync RestrictedActions workflow
|
||||
runs-on: ubuntu-22.04
|
||||
|
||||
steps:
|
||||
- name: Generate access token
|
||||
id: generate-token
|
||||
uses: actions/create-github-app-token@v2
|
||||
with:
|
||||
app-id: ${{ vars.RESTRICTED_ACTIONS_DISPATCH_ID }}
|
||||
private-key: ${{ secrets.RESTRICTED_ACTIONS_DISPATCH_KEY }}
|
||||
owner: ${{ github.repository_owner }}
|
||||
repositories: RestrictedActions
|
||||
|
||||
- name: Dispatch branch sync restricted action
|
||||
uses: peter-evans/repository-dispatch@v3
|
||||
with:
|
||||
token: ${{ steps.generate-token.outputs.token }}
|
||||
repository: ${{ github.repository_owner }}/RestrictedActions
|
||||
event-type: pocketmine_mp_branch_sync
|
10
.github/workflows/build-docker-image.yml
vendored
10
.github/workflows/build-docker-image.yml
vendored
@ -8,7 +8,7 @@ on:
|
||||
jobs:
|
||||
build:
|
||||
name: Update Docker Hub images
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
|
||||
steps:
|
||||
- name: Set up Docker Buildx
|
||||
@ -53,7 +53,7 @@ jobs:
|
||||
run: echo NAME=$(echo "${GITHUB_REPOSITORY,,}") >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Build image for tag
|
||||
uses: docker/build-push-action@v6.15.0
|
||||
uses: docker/build-push-action@v6.18.0
|
||||
with:
|
||||
push: true
|
||||
context: ./pocketmine-mp
|
||||
@ -66,7 +66,7 @@ jobs:
|
||||
|
||||
- name: Build image for major tag
|
||||
if: steps.channel.outputs.CHANNEL == 'stable'
|
||||
uses: docker/build-push-action@v6.15.0
|
||||
uses: docker/build-push-action@v6.18.0
|
||||
with:
|
||||
push: true
|
||||
context: ./pocketmine-mp
|
||||
@ -79,7 +79,7 @@ jobs:
|
||||
|
||||
- name: Build image for minor tag
|
||||
if: steps.channel.outputs.CHANNEL == 'stable'
|
||||
uses: docker/build-push-action@v6.15.0
|
||||
uses: docker/build-push-action@v6.18.0
|
||||
with:
|
||||
push: true
|
||||
context: ./pocketmine-mp
|
||||
@ -92,7 +92,7 @@ jobs:
|
||||
|
||||
- name: Build image for latest tag
|
||||
if: steps.channel.outputs.CHANNEL == 'stable'
|
||||
uses: docker/build-push-action@v6.15.0
|
||||
uses: docker/build-push-action@v6.18.0
|
||||
with:
|
||||
push: true
|
||||
context: ./pocketmine-mp
|
||||
|
2
.github/workflows/discord-release-notify.yml
vendored
2
.github/workflows/discord-release-notify.yml
vendored
@ -13,7 +13,7 @@ jobs:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup PHP and tools
|
||||
uses: shivammathur/setup-php@2.32.0
|
||||
uses: shivammathur/setup-php@2.33.0
|
||||
with:
|
||||
php-version: 8.2
|
||||
|
||||
|
6
.github/workflows/draft-release-pr-check.yml
vendored
6
.github/workflows/draft-release-pr-check.yml
vendored
@ -24,7 +24,7 @@ permissions:
|
||||
jobs:
|
||||
check-intent:
|
||||
name: Check release trigger
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
|
||||
outputs:
|
||||
valid: ${{ steps.validate.outputs.DEV_BUILD == 'false' }}
|
||||
@ -43,13 +43,13 @@ jobs:
|
||||
#don't do these checks if this isn't a release - we don't want to generate unnecessary failed statuses
|
||||
if: needs.check-intent.outputs.valid == 'true'
|
||||
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@2.32.0
|
||||
uses: shivammathur/setup-php@2.33.0
|
||||
with:
|
||||
php-version: 8.2
|
||||
|
||||
|
10
.github/workflows/draft-release.yml
vendored
10
.github/workflows/draft-release.yml
vendored
@ -23,7 +23,7 @@ env:
|
||||
jobs:
|
||||
skip:
|
||||
name: Check whether to ignore this tag
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
|
||||
outputs:
|
||||
skip: ${{ steps.exists.outputs.exists == 'true' }}
|
||||
@ -54,12 +54,12 @@ jobs:
|
||||
needs: [check]
|
||||
if: needs.check.outputs.valid == 'true' && github.ref_type != 'tag' #can't do post-commit for a tag
|
||||
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
|
||||
steps:
|
||||
- name: Generate access token
|
||||
id: generate-token
|
||||
uses: actions/create-github-app-token@v1
|
||||
uses: actions/create-github-app-token@v2
|
||||
with:
|
||||
app-id: ${{ vars.RESTRICTED_ACTIONS_DISPATCH_ID }}
|
||||
private-key: ${{ secrets.RESTRICTED_ACTIONS_DISPATCH_KEY }}
|
||||
@ -79,7 +79,7 @@ jobs:
|
||||
needs: [check]
|
||||
if: needs.check.outputs.valid == 'true' || github.ref_type == 'tag' #ignore validity check for tags
|
||||
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
@ -87,7 +87,7 @@ jobs:
|
||||
submodules: true
|
||||
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@2.32.0
|
||||
uses: shivammathur/setup-php@2.33.0
|
||||
with:
|
||||
php-version: ${{ env.PHP_VERSION }}
|
||||
|
||||
|
2
.github/workflows/main-php-matrix.yml
vendored
2
.github/workflows/main-php-matrix.yml
vendored
@ -15,7 +15,7 @@ on:
|
||||
type: number
|
||||
image:
|
||||
description: 'Runner image to use'
|
||||
default: 'ubuntu-20.04'
|
||||
default: 'ubuntu-22.04'
|
||||
type: string
|
||||
|
||||
jobs:
|
||||
|
10
.github/workflows/main.yml
vendored
10
.github/workflows/main.yml
vendored
@ -20,7 +20,7 @@ jobs:
|
||||
|
||||
codestyle:
|
||||
name: Code Style checks
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
strategy:
|
||||
fail-fast: false
|
||||
|
||||
@ -28,10 +28,10 @@ jobs:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup PHP and tools
|
||||
uses: shivammathur/setup-php@2.32.0
|
||||
uses: shivammathur/setup-php@2.33.0
|
||||
with:
|
||||
php-version: 8.2
|
||||
tools: php-cs-fixer:3.49
|
||||
php-version: 8.3
|
||||
tools: php-cs-fixer:3.75
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
@ -40,7 +40,7 @@ jobs:
|
||||
|
||||
shellcheck:
|
||||
name: ShellCheck
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
strategy:
|
||||
fail-fast: false
|
||||
|
||||
|
32
.github/workflows/pr-remove-waiting-label.yml
vendored
32
.github/workflows/pr-remove-waiting-label.yml
vendored
@ -15,19 +15,23 @@ jobs:
|
||||
with:
|
||||
github-token: ${{ github.token }}
|
||||
script: |
|
||||
const [owner, repo] = context.payload.repository.full_name.split('/');
|
||||
try {
|
||||
await github.rest.issues.removeLabel({
|
||||
owner: owner,
|
||||
repo: repo,
|
||||
issue_number: context.payload.number,
|
||||
name: "Status: Waiting on Author",
|
||||
});
|
||||
} catch (error) {
|
||||
if (error.status === 404) {
|
||||
//probably label wasn't set on the issue
|
||||
console.log('Failed to remove label (probably label isn\'t on the PR): ' + error.message);
|
||||
} else {
|
||||
throw error;
|
||||
async function removeLabel(owner, repo, issue_number, name) {
|
||||
try {
|
||||
await github.rest.issues.removeLabel({
|
||||
owner: owner,
|
||||
repo: repo,
|
||||
issue_number: issue_number,
|
||||
name: name,
|
||||
});
|
||||
} catch (error) {
|
||||
if (error.status === 404) {
|
||||
//probably label wasn't set on the issue
|
||||
console.log('Failed to remove label ' + name + ' (probably label isn\'t on the PR): ' + error.message);
|
||||
} else {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
const [owner, repo] = context.payload.repository.full_name.split('/');
|
||||
removeLabel(owner, repo, context.payload.number, "Status: Waiting on Author");
|
||||
removeLabel(owner, repo, context.payload.number, "Stale");
|
||||
|
2
.github/workflows/team-pr-auto-approve.yml
vendored
2
.github/workflows/team-pr-auto-approve.yml
vendored
@ -22,7 +22,7 @@ jobs:
|
||||
steps:
|
||||
- name: Generate access token
|
||||
id: generate-token
|
||||
uses: actions/create-github-app-token@v1
|
||||
uses: actions/create-github-app-token@v2
|
||||
with:
|
||||
app-id: ${{ vars.RESTRICTED_ACTIONS_DISPATCH_ID }}
|
||||
private-key: ${{ secrets.RESTRICTED_ACTIONS_DISPATCH_KEY }}
|
||||
|
@ -6,6 +6,12 @@ $finder = PhpCsFixer\Finder::create()
|
||||
->in(__DIR__ . '/tests')
|
||||
->in(__DIR__ . '/tools')
|
||||
->notPath('plugins/DevTools')
|
||||
//JsonMapper will break if the FQNs in the doc comments for these are shortened :(
|
||||
->notPath('crafting/json')
|
||||
->notPath('inventory/json')
|
||||
->notPath('data/bedrock/block/upgrade/model')
|
||||
->notPath('data/bedrock/item/upgrade/model')
|
||||
|
||||
->notName('PocketMine.php');
|
||||
|
||||
return (new PhpCsFixer\Config)
|
||||
|
@ -31,8 +31,8 @@ require dirname(__DIR__) . '/vendor/autoload.php';
|
||||
*/
|
||||
|
||||
/**
|
||||
* @var string[]|\Closure[] $options
|
||||
* @phpstan-var array<string, string|\Closure() : string> $options
|
||||
* @var string[]|Closure[] $options
|
||||
* @phpstan-var array<string, string|Closure() : string> $options
|
||||
*/
|
||||
$options = [
|
||||
"base_version" => VersionInfo::BASE_VERSION,
|
||||
|
34
changelogs/5.28.md
Normal file
34
changelogs/5.28.md
Normal file
@ -0,0 +1,34 @@
|
||||
# 5.28.0
|
||||
Released 9th May 2025.
|
||||
|
||||
This is a support release for Minecraft: Bedrock Edition 1.21.80.
|
||||
|
||||
**Plugin compatibility:** Plugins for previous 5.x versions will run unchanged on this release, unless they use internal APIs, reflection, or packages like the `pocketmine\network\mcpe` or `pocketmine\data` namespace.
|
||||
Do not update plugin minimum API versions unless you need new features added in this release.
|
||||
|
||||
**WARNING: If your plugin uses the `pocketmine\network\mcpe` namespace, you're not shielded by API change constraints.**
|
||||
Consider using the `mcpe-protocol` directive in `plugin.yml` as a constraint if you're using packets directly.
|
||||
|
||||
## General
|
||||
- Added support for Minecraft: Bedrock Edition 1.21.80.
|
||||
- Removed support for earlier versions.
|
||||
|
||||
## Fixes
|
||||
- `AvailableEnchantmentRegistry` now requires provided tags to always be `string`. Previously, this wasn't enforced, leading to random crashes in core code related to enchanting.
|
||||
- `Entity->setFireTicks()` and `Entity->setOnFire()` now truncate the fire time to the max value instead of throwing exceptions.
|
||||
|
||||
## Internals
|
||||
- Improved PHPStan error reporting for unsafe foreaches. Foreach on an array with implicit keys now generates different errors than foreach on an array with string keys.
|
||||
|
||||
# 5.28.1
|
||||
Released 17th May 2025.
|
||||
|
||||
## Fixes
|
||||
- Fixed errors when PlayStation players attempt to join due to null `TitleID`.
|
||||
|
||||
# 5.28.2
|
||||
Released 17th May 2025.
|
||||
|
||||
## Fixes
|
||||
- Fixed version constraints which were incorrectly updated during the 1.21.80 update. This led to an unnoticed failure to update BedrockProtocol in the previous patch release.
|
||||
- Actually fixed PlayStation issues this time
|
@ -34,29 +34,33 @@
|
||||
"adhocore/json-comment": "~1.2.0",
|
||||
"netresearch/jsonmapper": "~v5.0.0",
|
||||
"pocketmine/bedrock-block-upgrade-schema": "~5.1.0+bedrock-1.21.60",
|
||||
"pocketmine/bedrock-data": "~4.1.0+bedrock-1.21.70",
|
||||
"pocketmine/bedrock-data": "~5.0.0+bedrock-1.21.80",
|
||||
"pocketmine/bedrock-item-upgrade-schema": "~1.14.0+bedrock-1.21.50",
|
||||
"pocketmine/bedrock-protocol": "~37.0.0+bedrock-1.21.70",
|
||||
"pocketmine/bedrock-protocol": "~38.1.0+bedrock-1.21.80",
|
||||
"pocketmine/binaryutils": "^0.2.1",
|
||||
"pocketmine/callback-validator": "^1.0.2",
|
||||
"pocketmine/color": "^0.3.0",
|
||||
"pocketmine/errorhandler": "^0.7.0",
|
||||
"pocketmine/locale-data": "~2.24.0",
|
||||
"pocketmine/locale-data": "~2.25.0",
|
||||
"pocketmine/log": "^0.4.0",
|
||||
"pocketmine/math": "~1.0.0",
|
||||
"pocketmine/nbt": "~1.1.0",
|
||||
"pocketmine/raklib": "~1.1.2",
|
||||
"pocketmine/raklib": "~1.2.0",
|
||||
"pocketmine/raklib-ipc": "~1.0.0",
|
||||
"pocketmine/snooze": "^0.5.0",
|
||||
"ramsey/uuid": "~4.7.0",
|
||||
"ramsey/uuid": "~4.8.0",
|
||||
"symfony/filesystem": "~6.4.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpstan/phpstan": "2.1.8",
|
||||
"phpstan/phpstan": "2.1.17",
|
||||
"phpstan/phpstan-phpunit": "^2.0.0",
|
||||
"phpstan/phpstan-strict-rules": "^2.0.0",
|
||||
"phpunit/phpunit": "^10.5.24"
|
||||
},
|
||||
"replace": {
|
||||
"symfony/polyfill-ctype": "*",
|
||||
"symfony/polyfill-mbstring": "*"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"pocketmine\\": "src/"
|
||||
|
364
composer.lock
generated
364
composer.lock
generated
@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "8d3061c5cc77e5b1dfa1fcf77f5146c6",
|
||||
"content-hash": "7c3052613e98e566d8b00ae3c9119057",
|
||||
"packages": [
|
||||
{
|
||||
"name": "adhocore/json-comment",
|
||||
@ -67,16 +67,16 @@
|
||||
},
|
||||
{
|
||||
"name": "brick/math",
|
||||
"version": "0.12.3",
|
||||
"version": "0.13.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/brick/math.git",
|
||||
"reference": "866551da34e9a618e64a819ee1e01c20d8a588ba"
|
||||
"reference": "fc7ed316430118cc7836bf45faff18d5dfc8de04"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/brick/math/zipball/866551da34e9a618e64a819ee1e01c20d8a588ba",
|
||||
"reference": "866551da34e9a618e64a819ee1e01c20d8a588ba",
|
||||
"url": "https://api.github.com/repos/brick/math/zipball/fc7ed316430118cc7836bf45faff18d5dfc8de04",
|
||||
"reference": "fc7ed316430118cc7836bf45faff18d5dfc8de04",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -115,7 +115,7 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/brick/math/issues",
|
||||
"source": "https://github.com/brick/math/tree/0.12.3"
|
||||
"source": "https://github.com/brick/math/tree/0.13.1"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@ -123,7 +123,7 @@
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2025-02-28T13:11:00+00:00"
|
||||
"time": "2025-03-29T13:50:30+00:00"
|
||||
},
|
||||
{
|
||||
"name": "netresearch/jsonmapper",
|
||||
@ -204,16 +204,16 @@
|
||||
},
|
||||
{
|
||||
"name": "pocketmine/bedrock-data",
|
||||
"version": "4.1.0+bedrock-1.21.70",
|
||||
"version": "5.0.0+bedrock-1.21.80",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/pmmp/BedrockData.git",
|
||||
"reference": "d53fe98cb3b596ac016e275df5bd5e89b04a4817"
|
||||
"reference": "e38d5ea19f794ec5216e5f96742237e8c4e7f080"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/pmmp/BedrockData/zipball/d53fe98cb3b596ac016e275df5bd5e89b04a4817",
|
||||
"reference": "d53fe98cb3b596ac016e275df5bd5e89b04a4817",
|
||||
"url": "https://api.github.com/repos/pmmp/BedrockData/zipball/e38d5ea19f794ec5216e5f96742237e8c4e7f080",
|
||||
"reference": "e38d5ea19f794ec5216e5f96742237e8c4e7f080",
|
||||
"shasum": ""
|
||||
},
|
||||
"type": "library",
|
||||
@ -224,9 +224,9 @@
|
||||
"description": "Blobs of data generated from Minecraft: Bedrock Edition, used by PocketMine-MP",
|
||||
"support": {
|
||||
"issues": "https://github.com/pmmp/BedrockData/issues",
|
||||
"source": "https://github.com/pmmp/BedrockData/tree/bedrock-1.21.70"
|
||||
"source": "https://github.com/pmmp/BedrockData/tree/bedrock-1.21.80"
|
||||
},
|
||||
"time": "2025-03-25T19:43:31+00:00"
|
||||
"time": "2025-05-09T14:15:18+00:00"
|
||||
},
|
||||
{
|
||||
"name": "pocketmine/bedrock-item-upgrade-schema",
|
||||
@ -256,16 +256,16 @@
|
||||
},
|
||||
{
|
||||
"name": "pocketmine/bedrock-protocol",
|
||||
"version": "37.0.0+bedrock-1.21.70",
|
||||
"version": "38.1.0+bedrock-1.21.80",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/pmmp/BedrockProtocol.git",
|
||||
"reference": "7091dad2c12ed4a4106432df21fc698960c6be9e"
|
||||
"reference": "a1fa215563517050045309bb779a67f75843b867"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/pmmp/BedrockProtocol/zipball/7091dad2c12ed4a4106432df21fc698960c6be9e",
|
||||
"reference": "7091dad2c12ed4a4106432df21fc698960c6be9e",
|
||||
"url": "https://api.github.com/repos/pmmp/BedrockProtocol/zipball/a1fa215563517050045309bb779a67f75843b867",
|
||||
"reference": "a1fa215563517050045309bb779a67f75843b867",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -296,9 +296,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/37.0.0+bedrock-1.21.70"
|
||||
"source": "https://github.com/pmmp/BedrockProtocol/tree/38.1.0+bedrock-1.21.80"
|
||||
},
|
||||
"time": "2025-03-27T15:19:36+00:00"
|
||||
"time": "2025-05-28T22:19:59+00:00"
|
||||
},
|
||||
{
|
||||
"name": "pocketmine/binaryutils",
|
||||
@ -471,16 +471,16 @@
|
||||
},
|
||||
{
|
||||
"name": "pocketmine/locale-data",
|
||||
"version": "2.24.1",
|
||||
"version": "2.25.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/pmmp/Language.git",
|
||||
"reference": "8f48cbe1fb5835a8bb573bed00ef04c65c26c7e5"
|
||||
"reference": "8e6514f5a9638e69cdc2219c775fc7d3bb4c9fdd"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/pmmp/Language/zipball/8f48cbe1fb5835a8bb573bed00ef04c65c26c7e5",
|
||||
"reference": "8f48cbe1fb5835a8bb573bed00ef04c65c26c7e5",
|
||||
"url": "https://api.github.com/repos/pmmp/Language/zipball/8e6514f5a9638e69cdc2219c775fc7d3bb4c9fdd",
|
||||
"reference": "8e6514f5a9638e69cdc2219c775fc7d3bb4c9fdd",
|
||||
"shasum": ""
|
||||
},
|
||||
"type": "library",
|
||||
@ -488,9 +488,9 @@
|
||||
"description": "Language resources used by PocketMine-MP",
|
||||
"support": {
|
||||
"issues": "https://github.com/pmmp/Language/issues",
|
||||
"source": "https://github.com/pmmp/Language/tree/2.24.1"
|
||||
"source": "https://github.com/pmmp/Language/tree/2.25.1"
|
||||
},
|
||||
"time": "2025-03-16T19:04:15+00:00"
|
||||
"time": "2025-04-16T11:15:32+00:00"
|
||||
},
|
||||
{
|
||||
"name": "pocketmine/log",
|
||||
@ -618,16 +618,16 @@
|
||||
},
|
||||
{
|
||||
"name": "pocketmine/raklib",
|
||||
"version": "1.1.2",
|
||||
"version": "1.2.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/pmmp/RakLib.git",
|
||||
"reference": "4145a31cd812fe8931c3c9c691fcd2ded2f47e7f"
|
||||
"reference": "a28d05216d34dbd00e8aed827a58df6b4c11510b"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/pmmp/RakLib/zipball/4145a31cd812fe8931c3c9c691fcd2ded2f47e7f",
|
||||
"reference": "4145a31cd812fe8931c3c9c691fcd2ded2f47e7f",
|
||||
"url": "https://api.github.com/repos/pmmp/RakLib/zipball/a28d05216d34dbd00e8aed827a58df6b4c11510b",
|
||||
"reference": "a28d05216d34dbd00e8aed827a58df6b4c11510b",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -655,9 +655,9 @@
|
||||
"description": "A RakNet server implementation written in PHP",
|
||||
"support": {
|
||||
"issues": "https://github.com/pmmp/RakLib/issues",
|
||||
"source": "https://github.com/pmmp/RakLib/tree/1.1.2"
|
||||
"source": "https://github.com/pmmp/RakLib/tree/1.2.0"
|
||||
},
|
||||
"time": "2025-04-06T03:38:21+00:00"
|
||||
"time": "2025-06-08T17:36:06+00:00"
|
||||
},
|
||||
{
|
||||
"name": "pocketmine/raklib-ipc",
|
||||
@ -742,16 +742,16 @@
|
||||
},
|
||||
{
|
||||
"name": "ramsey/collection",
|
||||
"version": "2.1.0",
|
||||
"version": "2.1.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/ramsey/collection.git",
|
||||
"reference": "3c5990b8a5e0b79cd1cf11c2dc1229e58e93f109"
|
||||
"reference": "344572933ad0181accbf4ba763e85a0306a8c5e2"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/ramsey/collection/zipball/3c5990b8a5e0b79cd1cf11c2dc1229e58e93f109",
|
||||
"reference": "3c5990b8a5e0b79cd1cf11c2dc1229e58e93f109",
|
||||
"url": "https://api.github.com/repos/ramsey/collection/zipball/344572933ad0181accbf4ba763e85a0306a8c5e2",
|
||||
"reference": "344572933ad0181accbf4ba763e85a0306a8c5e2",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -812,26 +812,26 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/ramsey/collection/issues",
|
||||
"source": "https://github.com/ramsey/collection/tree/2.1.0"
|
||||
"source": "https://github.com/ramsey/collection/tree/2.1.1"
|
||||
},
|
||||
"time": "2025-03-02T04:48:29+00:00"
|
||||
"time": "2025-03-22T05:38:12+00:00"
|
||||
},
|
||||
{
|
||||
"name": "ramsey/uuid",
|
||||
"version": "4.7.6",
|
||||
"version": "4.8.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/ramsey/uuid.git",
|
||||
"reference": "91039bc1faa45ba123c4328958e620d382ec7088"
|
||||
"reference": "fdf4dd4e2ff1813111bd0ad58d7a1ddbb5b56c28"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/ramsey/uuid/zipball/91039bc1faa45ba123c4328958e620d382ec7088",
|
||||
"reference": "91039bc1faa45ba123c4328958e620d382ec7088",
|
||||
"url": "https://api.github.com/repos/ramsey/uuid/zipball/fdf4dd4e2ff1813111bd0ad58d7a1ddbb5b56c28",
|
||||
"reference": "fdf4dd4e2ff1813111bd0ad58d7a1ddbb5b56c28",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"brick/math": "^0.8.8 || ^0.9 || ^0.10 || ^0.11 || ^0.12",
|
||||
"brick/math": "^0.8.8 || ^0.9 || ^0.10 || ^0.11 || ^0.12 || ^0.13",
|
||||
"ext-json": "*",
|
||||
"php": "^8.0",
|
||||
"ramsey/collection": "^1.2 || ^2.0"
|
||||
@ -840,26 +840,23 @@
|
||||
"rhumsaa/uuid": "self.version"
|
||||
},
|
||||
"require-dev": {
|
||||
"captainhook/captainhook": "^5.10",
|
||||
"captainhook/captainhook": "^5.25",
|
||||
"captainhook/plugin-composer": "^5.3",
|
||||
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
|
||||
"doctrine/annotations": "^1.8",
|
||||
"ergebnis/composer-normalize": "^2.15",
|
||||
"mockery/mockery": "^1.3",
|
||||
"dealerdirect/phpcodesniffer-composer-installer": "^1.0",
|
||||
"ergebnis/composer-normalize": "^2.47",
|
||||
"mockery/mockery": "^1.6",
|
||||
"paragonie/random-lib": "^2",
|
||||
"php-mock/php-mock": "^2.2",
|
||||
"php-mock/php-mock-mockery": "^1.3",
|
||||
"php-parallel-lint/php-parallel-lint": "^1.1",
|
||||
"phpbench/phpbench": "^1.0",
|
||||
"phpstan/extension-installer": "^1.1",
|
||||
"phpstan/phpstan": "^1.8",
|
||||
"phpstan/phpstan-mockery": "^1.1",
|
||||
"phpstan/phpstan-phpunit": "^1.1",
|
||||
"phpunit/phpunit": "^8.5 || ^9",
|
||||
"ramsey/composer-repl": "^1.4",
|
||||
"slevomat/coding-standard": "^8.4",
|
||||
"squizlabs/php_codesniffer": "^3.5",
|
||||
"vimeo/psalm": "^4.9"
|
||||
"php-mock/php-mock": "^2.6",
|
||||
"php-mock/php-mock-mockery": "^1.5",
|
||||
"php-parallel-lint/php-parallel-lint": "^1.4.0",
|
||||
"phpbench/phpbench": "^1.2.14",
|
||||
"phpstan/extension-installer": "^1.4",
|
||||
"phpstan/phpstan": "^2.1",
|
||||
"phpstan/phpstan-mockery": "^2.0",
|
||||
"phpstan/phpstan-phpunit": "^2.0",
|
||||
"phpunit/phpunit": "^9.6",
|
||||
"slevomat/coding-standard": "^8.18",
|
||||
"squizlabs/php_codesniffer": "^3.13"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-bcmath": "Enables faster math with arbitrary-precision integers using BCMath.",
|
||||
@ -894,19 +891,9 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/ramsey/uuid/issues",
|
||||
"source": "https://github.com/ramsey/uuid/tree/4.7.6"
|
||||
"source": "https://github.com/ramsey/uuid/tree/4.8.1"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://github.com/ramsey",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://tidelift.com/funding/github/packagist/ramsey/uuid",
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2024-04-27T21:32:50+00:00"
|
||||
"time": "2025-06-01T06:28:46+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/filesystem",
|
||||
@ -973,180 +960,21 @@
|
||||
}
|
||||
],
|
||||
"time": "2024-10-25T15:07:50+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/polyfill-ctype",
|
||||
"version": "v1.31.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/polyfill-ctype.git",
|
||||
"reference": "a3cc8b044a6ea513310cbd48ef7333b384945638"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/a3cc8b044a6ea513310cbd48ef7333b384945638",
|
||||
"reference": "a3cc8b044a6ea513310cbd48ef7333b384945638",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=7.2"
|
||||
},
|
||||
"provide": {
|
||||
"ext-ctype": "*"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-ctype": "For best performance"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"thanks": {
|
||||
"url": "https://github.com/symfony/polyfill",
|
||||
"name": "symfony/polyfill"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"files": [
|
||||
"bootstrap.php"
|
||||
],
|
||||
"psr-4": {
|
||||
"Symfony\\Polyfill\\Ctype\\": ""
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Gert de Pagter",
|
||||
"email": "BackEndTea@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony polyfill for ctype functions",
|
||||
"homepage": "https://symfony.com",
|
||||
"keywords": [
|
||||
"compatibility",
|
||||
"ctype",
|
||||
"polyfill",
|
||||
"portable"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/polyfill-ctype/tree/v1.31.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://symfony.com/sponsor",
|
||||
"type": "custom"
|
||||
},
|
||||
{
|
||||
"url": "https://github.com/fabpot",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2024-09-09T11:45:10+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/polyfill-mbstring",
|
||||
"version": "v1.31.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/polyfill-mbstring.git",
|
||||
"reference": "85181ba99b2345b0ef10ce42ecac37612d9fd341"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/85181ba99b2345b0ef10ce42ecac37612d9fd341",
|
||||
"reference": "85181ba99b2345b0ef10ce42ecac37612d9fd341",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=7.2"
|
||||
},
|
||||
"provide": {
|
||||
"ext-mbstring": "*"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-mbstring": "For best performance"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"thanks": {
|
||||
"url": "https://github.com/symfony/polyfill",
|
||||
"name": "symfony/polyfill"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"files": [
|
||||
"bootstrap.php"
|
||||
],
|
||||
"psr-4": {
|
||||
"Symfony\\Polyfill\\Mbstring\\": ""
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Nicolas Grekas",
|
||||
"email": "p@tchwork.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony polyfill for the Mbstring extension",
|
||||
"homepage": "https://symfony.com",
|
||||
"keywords": [
|
||||
"compatibility",
|
||||
"mbstring",
|
||||
"polyfill",
|
||||
"portable",
|
||||
"shim"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/polyfill-mbstring/tree/v1.31.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://symfony.com/sponsor",
|
||||
"type": "custom"
|
||||
},
|
||||
{
|
||||
"url": "https://github.com/fabpot",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2024-09-09T11:45:10+00:00"
|
||||
}
|
||||
],
|
||||
"packages-dev": [
|
||||
{
|
||||
"name": "myclabs/deep-copy",
|
||||
"version": "1.13.0",
|
||||
"version": "1.13.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/myclabs/DeepCopy.git",
|
||||
"reference": "024473a478be9df5fdaca2c793f2232fe788e414"
|
||||
"reference": "1720ddd719e16cf0db4eb1c6eca108031636d46c"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/024473a478be9df5fdaca2c793f2232fe788e414",
|
||||
"reference": "024473a478be9df5fdaca2c793f2232fe788e414",
|
||||
"url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/1720ddd719e16cf0db4eb1c6eca108031636d46c",
|
||||
"reference": "1720ddd719e16cf0db4eb1c6eca108031636d46c",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -1185,7 +1013,7 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/myclabs/DeepCopy/issues",
|
||||
"source": "https://github.com/myclabs/DeepCopy/tree/1.13.0"
|
||||
"source": "https://github.com/myclabs/DeepCopy/tree/1.13.1"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@ -1193,20 +1021,20 @@
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2025-02-12T12:17:51+00:00"
|
||||
"time": "2025-04-29T12:36:36+00:00"
|
||||
},
|
||||
{
|
||||
"name": "nikic/php-parser",
|
||||
"version": "v5.4.0",
|
||||
"version": "v5.5.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/nikic/PHP-Parser.git",
|
||||
"reference": "447a020a1f875a434d62f2a401f53b82a396e494"
|
||||
"reference": "ae59794362fe85e051a58ad36b289443f57be7a9"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/447a020a1f875a434d62f2a401f53b82a396e494",
|
||||
"reference": "447a020a1f875a434d62f2a401f53b82a396e494",
|
||||
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/ae59794362fe85e051a58ad36b289443f57be7a9",
|
||||
"reference": "ae59794362fe85e051a58ad36b289443f57be7a9",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -1249,9 +1077,9 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/nikic/PHP-Parser/issues",
|
||||
"source": "https://github.com/nikic/PHP-Parser/tree/v5.4.0"
|
||||
"source": "https://github.com/nikic/PHP-Parser/tree/v5.5.0"
|
||||
},
|
||||
"time": "2024-12-30T11:07:19+00:00"
|
||||
"time": "2025-05-31T08:24:38+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phar-io/manifest",
|
||||
@ -1373,16 +1201,16 @@
|
||||
},
|
||||
{
|
||||
"name": "phpstan/phpstan",
|
||||
"version": "2.1.8",
|
||||
"version": "2.1.17",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/phpstan/phpstan.git",
|
||||
"reference": "f9adff3b87c03b12cc7e46a30a524648e497758f"
|
||||
"reference": "89b5ef665716fa2a52ecd2633f21007a6a349053"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/f9adff3b87c03b12cc7e46a30a524648e497758f",
|
||||
"reference": "f9adff3b87c03b12cc7e46a30a524648e497758f",
|
||||
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/89b5ef665716fa2a52ecd2633f21007a6a349053",
|
||||
"reference": "89b5ef665716fa2a52ecd2633f21007a6a349053",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -1427,20 +1255,20 @@
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2025-03-09T09:30:48+00:00"
|
||||
"time": "2025-05-21T20:55:28+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpstan/phpstan-phpunit",
|
||||
"version": "2.0.4",
|
||||
"version": "2.0.6",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/phpstan/phpstan-phpunit.git",
|
||||
"reference": "d09e152f403c843998d7a52b5d87040c937525dd"
|
||||
"reference": "6b92469f8a7995e626da3aa487099617b8dfa260"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/d09e152f403c843998d7a52b5d87040c937525dd",
|
||||
"reference": "d09e152f403c843998d7a52b5d87040c937525dd",
|
||||
"url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/6b92469f8a7995e626da3aa487099617b8dfa260",
|
||||
"reference": "6b92469f8a7995e626da3aa487099617b8dfa260",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -1451,7 +1279,9 @@
|
||||
"phpunit/phpunit": "<7.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"nikic/php-parser": "^5",
|
||||
"php-parallel-lint/php-parallel-lint": "^1.2",
|
||||
"phpstan/phpstan-deprecation-rules": "^2.0",
|
||||
"phpstan/phpstan-strict-rules": "^2.0",
|
||||
"phpunit/phpunit": "^9.6"
|
||||
},
|
||||
@ -1476,9 +1306,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/2.0.4"
|
||||
"source": "https://github.com/phpstan/phpstan-phpunit/tree/2.0.6"
|
||||
},
|
||||
"time": "2025-01-22T13:07:38+00:00"
|
||||
"time": "2025-03-26T12:47:06+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpstan/phpstan-strict-rules",
|
||||
@ -1851,16 +1681,16 @@
|
||||
},
|
||||
{
|
||||
"name": "phpunit/phpunit",
|
||||
"version": "10.5.45",
|
||||
"version": "10.5.46",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/phpunit.git",
|
||||
"reference": "bd68a781d8e30348bc297449f5234b3458267ae8"
|
||||
"reference": "8080be387a5be380dda48c6f41cee4a13aadab3d"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/bd68a781d8e30348bc297449f5234b3458267ae8",
|
||||
"reference": "bd68a781d8e30348bc297449f5234b3458267ae8",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/8080be387a5be380dda48c6f41cee4a13aadab3d",
|
||||
"reference": "8080be387a5be380dda48c6f41cee4a13aadab3d",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -1870,7 +1700,7 @@
|
||||
"ext-mbstring": "*",
|
||||
"ext-xml": "*",
|
||||
"ext-xmlwriter": "*",
|
||||
"myclabs/deep-copy": "^1.12.1",
|
||||
"myclabs/deep-copy": "^1.13.1",
|
||||
"phar-io/manifest": "^2.0.4",
|
||||
"phar-io/version": "^3.2.1",
|
||||
"php": ">=8.1",
|
||||
@ -1932,7 +1762,7 @@
|
||||
"support": {
|
||||
"issues": "https://github.com/sebastianbergmann/phpunit/issues",
|
||||
"security": "https://github.com/sebastianbergmann/phpunit/security/policy",
|
||||
"source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.45"
|
||||
"source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.46"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@ -1943,12 +1773,20 @@
|
||||
"url": "https://github.com/sebastianbergmann",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://liberapay.com/sebastianbergmann",
|
||||
"type": "liberapay"
|
||||
},
|
||||
{
|
||||
"url": "https://thanks.dev/u/gh/sebastianbergmann",
|
||||
"type": "thanks_dev"
|
||||
},
|
||||
{
|
||||
"url": "https://tidelift.com/funding/github/packagist/phpunit/phpunit",
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2025-02-06T16:08:12+00:00"
|
||||
"time": "2025-05-02T06:46:24+00:00"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/cli-parser",
|
||||
@ -2919,7 +2757,7 @@
|
||||
],
|
||||
"aliases": [],
|
||||
"minimum-stability": "stable",
|
||||
"stability-flags": [],
|
||||
"stability-flags": {},
|
||||
"prefer-stable": false,
|
||||
"prefer-lowest": false,
|
||||
"platform": {
|
||||
@ -2950,7 +2788,7 @@
|
||||
"ext-zlib": ">=1.2.11",
|
||||
"composer-runtime-api": "^2.0"
|
||||
},
|
||||
"platform-dev": [],
|
||||
"platform-dev": {},
|
||||
"platform-overrides": {
|
||||
"php": "8.1.0"
|
||||
},
|
||||
|
@ -15,7 +15,7 @@ rules:
|
||||
- pocketmine\phpstan\rules\DisallowEnumComparisonRule
|
||||
- pocketmine\phpstan\rules\DisallowForeachByReferenceRule
|
||||
- pocketmine\phpstan\rules\ExplodeLimitRule
|
||||
- pocketmine\phpstan\rules\UnsafeForeachArrayOfStringRule
|
||||
- pocketmine\phpstan\rules\UnsafeForeachRule
|
||||
# - pocketmine\phpstan\rules\ThreadedSupportedTypesRule
|
||||
|
||||
parameters:
|
||||
|
@ -1618,7 +1618,7 @@ class Server{
|
||||
if(!is_dir($crashFolder)){
|
||||
mkdir($crashFolder);
|
||||
}
|
||||
$crashDumpPath = Path::join($crashFolder, date("D_M_j-H.i.s-T_Y", (int) $dump->getData()->time) . ".log");
|
||||
$crashDumpPath = Path::join($crashFolder, date("Y-m-d_H.i.s_T", (int) $dump->getData()->time) . ".log");
|
||||
|
||||
$fp = @fopen($crashDumpPath, "wb");
|
||||
if(!is_resource($fp)){
|
||||
|
@ -31,8 +31,8 @@ use function str_repeat;
|
||||
|
||||
final class VersionInfo{
|
||||
public const NAME = "PocketMine-MP";
|
||||
public const BASE_VERSION = "5.27.1";
|
||||
public const IS_DEVELOPMENT_BUILD = false;
|
||||
public const BASE_VERSION = "5.28.3";
|
||||
public const IS_DEVELOPMENT_BUILD = true;
|
||||
public const BUILD_CHANNEL = "stable";
|
||||
|
||||
/**
|
||||
|
@ -73,7 +73,7 @@ class BlockBreakInfo{
|
||||
return new self(0.0, $toolType, $toolHarvestLevel, 0.0);
|
||||
}
|
||||
|
||||
public static function indestructible(float $blastResistance = 18000000.0) : self{
|
||||
public static function indestructible(float $blastResistance = 18000003.75) : self{
|
||||
return new self(-1.0, BlockToolType::NONE, 0, $blastResistance);
|
||||
}
|
||||
|
||||
|
@ -786,8 +786,9 @@ final class BlockTypeIds{
|
||||
public const RESIN_BRICKS = 10756;
|
||||
public const RESIN_CLUMP = 10757;
|
||||
public const CHISELED_RESIN_BRICKS = 10758;
|
||||
public const RESPAWN_ANCHOR = 10759;
|
||||
|
||||
public const FIRST_UNUSED_BLOCK_ID = 10759;
|
||||
public const FIRST_UNUSED_BLOCK_ID = 10760;
|
||||
|
||||
private static int $nextDynamicId = self::FIRST_UNUSED_BLOCK_ID;
|
||||
|
||||
|
123
src/block/RespawnAnchor.php
Normal file
123
src/block/RespawnAnchor.php
Normal file
@ -0,0 +1,123 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\data\runtime\RuntimeDataDescriber;
|
||||
use pocketmine\event\block\BlockPreExplodeEvent;
|
||||
use pocketmine\event\player\PlayerRespawnAnchorUseEvent;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\ItemTypeIds;
|
||||
use pocketmine\lang\KnownTranslationFactory;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\player\Player;
|
||||
use pocketmine\utils\TextFormat;
|
||||
use pocketmine\world\Explosion;
|
||||
use pocketmine\world\Position;
|
||||
use pocketmine\world\sound\RespawnAnchorChargeSound;
|
||||
use pocketmine\world\sound\RespawnAnchorSetSpawnSound;
|
||||
|
||||
final class RespawnAnchor extends Opaque{
|
||||
private const MIN_CHARGES = 0;
|
||||
private const MAX_CHARGES = 4;
|
||||
|
||||
private int $charges = self::MIN_CHARGES;
|
||||
|
||||
protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{
|
||||
$w->boundedIntAuto(self::MIN_CHARGES, self::MAX_CHARGES, $this->charges);
|
||||
}
|
||||
|
||||
public function getCharges() : int{
|
||||
return $this->charges;
|
||||
}
|
||||
|
||||
/** @return $this */
|
||||
public function setCharges(int $charges) : self{
|
||||
if($charges < self::MIN_CHARGES || $charges > self::MAX_CHARGES){
|
||||
throw new \InvalidArgumentException("Charges must be between " . self::MIN_CHARGES . " and " . self::MAX_CHARGES . ", given: $charges");
|
||||
}
|
||||
$this->charges = $charges;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getLightLevel() : int{
|
||||
return $this->charges > 0 ? ($this->charges * 4) - 1 : 0;
|
||||
}
|
||||
|
||||
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null, array &$returnedItems = []) : bool{
|
||||
if($item->getTypeId() === ItemTypeIds::fromBlockTypeId(BlockTypeIds::GLOWSTONE) && $this->charges < self::MAX_CHARGES){
|
||||
$this->position->getWorld()->setBlock($this->position, $this->setCharges($this->charges + 1));
|
||||
$this->position->getWorld()->addSound($this->position, new RespawnAnchorChargeSound());
|
||||
return true;
|
||||
}
|
||||
|
||||
if($this->charges > self::MIN_CHARGES){
|
||||
if($player === null){
|
||||
return false;
|
||||
}
|
||||
|
||||
$ev = new PlayerRespawnAnchorUseEvent($player, $this, PlayerRespawnAnchorUseEvent::ACTION_EXPLODE);
|
||||
$ev->call();
|
||||
if($ev->isCancelled()){
|
||||
return false;
|
||||
}
|
||||
|
||||
switch($ev->getAction()){
|
||||
case PlayerRespawnAnchorUseEvent::ACTION_EXPLODE:
|
||||
$this->explode($player);
|
||||
return false;
|
||||
|
||||
case PlayerRespawnAnchorUseEvent::ACTION_SET_SPAWN:
|
||||
if($player->getSpawn() !== null && $player->getSpawn()->equals($this->position)){
|
||||
return true;
|
||||
}
|
||||
|
||||
$player->setSpawn($this->position);
|
||||
$this->position->getWorld()->addSound($this->position, new RespawnAnchorSetSpawnSound());
|
||||
$player->sendMessage(KnownTranslationFactory::tile_respawn_anchor_respawnSet()->prefix(TextFormat::GRAY));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private function explode(?Player $player) : void{
|
||||
$ev = new BlockPreExplodeEvent($this, 5, $player);
|
||||
$ev->setIncendiary(true);
|
||||
|
||||
$ev->call();
|
||||
if($ev->isCancelled()){
|
||||
return;
|
||||
}
|
||||
|
||||
$this->position->getWorld()->setBlock($this->position, VanillaBlocks::AIR());
|
||||
|
||||
$explosion = new Explosion(Position::fromObject($this->position->add(0.5, 0.5, 0.5), $this->position->getWorld()), $ev->getRadius(), $this);
|
||||
$explosion->setFireChance($ev->getFireChance());
|
||||
|
||||
if($ev->isBlockBreaking()){
|
||||
$explosion->explodeA();
|
||||
}
|
||||
$explosion->explodeB();
|
||||
}
|
||||
}
|
@ -25,11 +25,12 @@ namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\BlockEventHelper;
|
||||
use pocketmine\block\utils\CropGrowthHelper;
|
||||
use pocketmine\block\utils\FortuneDropHelper;
|
||||
use pocketmine\data\runtime\RuntimeDataDescriber;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\VanillaItems;
|
||||
use pocketmine\math\Facing;
|
||||
use function array_rand;
|
||||
use function mt_rand;
|
||||
|
||||
abstract class Stem extends Crops{
|
||||
protected int $facing = Facing::UP;
|
||||
@ -90,8 +91,10 @@ abstract class Stem extends Crops{
|
||||
}
|
||||
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
//TODO: bit annoying we have to pass an Item instance here
|
||||
//this should not be affected by Fortune, but still follows a binomial distribution
|
||||
return [
|
||||
$this->asItem()->setCount(mt_rand(0, 2))
|
||||
$this->asItem()->setCount(FortuneDropHelper::binomial(VanillaItems::AIR(), 0, chance: ($this->age + 1) / 15))
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -694,6 +694,7 @@ use function strtolower;
|
||||
* @method static Stair RESIN_BRICK_STAIRS()
|
||||
* @method static Wall RESIN_BRICK_WALL()
|
||||
* @method static ResinClump RESIN_CLUMP()
|
||||
* @method static RespawnAnchor RESPAWN_ANCHOR()
|
||||
* @method static DoublePlant ROSE_BUSH()
|
||||
* @method static Sand SAND()
|
||||
* @method static Opaque SANDSTONE()
|
||||
@ -859,7 +860,7 @@ final class VanillaBlocks{
|
||||
$railBreakInfo = new Info(new BreakInfo(0.7));
|
||||
self::register("activator_rail", fn(BID $id) => new ActivatorRail($id, "Activator Rail", $railBreakInfo));
|
||||
self::register("anvil", fn(BID $id) => new Anvil($id, "Anvil", new Info(BreakInfo::pickaxe(5.0, ToolTier::WOOD, 6000.0))));
|
||||
self::register("bamboo", fn(BID $id) => new Bamboo($id, "Bamboo", new Info(new class(2.0 /* 1.0 in PC */, ToolType::AXE) extends BreakInfo{
|
||||
self::register("bamboo", fn(BID $id) => new Bamboo($id, "Bamboo", new Info(new class(1.0, ToolType::AXE) extends BreakInfo{
|
||||
public function getBreakTime(Item $item) : float{
|
||||
if($item->getBlockToolType() === ToolType::SWORD){
|
||||
return 0.0;
|
||||
@ -867,7 +868,7 @@ final class VanillaBlocks{
|
||||
return parent::getBreakTime($item);
|
||||
}
|
||||
}, [Tags::POTTABLE_PLANTS])));
|
||||
self::register("bamboo_sapling", fn(BID $id) => new BambooSapling($id, "Bamboo Sapling", new Info(BreakInfo::instant())));
|
||||
self::register("bamboo_sapling", fn(BID $id) => new BambooSapling($id, "Bamboo Sapling", new Info(new BreakInfo(1.0))));
|
||||
|
||||
$bannerBreakInfo = new Info(BreakInfo::axe(1.0));
|
||||
self::register("banner", fn(BID $id) => new FloorBanner($id, "Banner", $bannerBreakInfo), TileBanner::class);
|
||||
@ -876,7 +877,7 @@ final class VanillaBlocks{
|
||||
self::register("barrier", fn(BID $id) => new Transparent($id, "Barrier", new Info(BreakInfo::indestructible())));
|
||||
self::register("beacon", fn(BID $id) => new Beacon($id, "Beacon", new Info(new BreakInfo(3.0))), TileBeacon::class);
|
||||
self::register("bed", fn(BID $id) => new Bed($id, "Bed Block", new Info(new BreakInfo(0.2))), TileBed::class);
|
||||
self::register("bedrock", fn(BID $id) => new Bedrock($id, "Bedrock", new Info(BreakInfo::indestructible())));
|
||||
self::register("bedrock", fn(BID $id) => new Bedrock($id, "Bedrock", new Info(BreakInfo::indestructible(18000000.0))));
|
||||
|
||||
self::register("beetroots", fn(BID $id) => new Beetroot($id, "Beetroot Block", new Info(BreakInfo::instant())));
|
||||
self::register("bell", fn(BID $id) => new Bell($id, "Bell", new Info(BreakInfo::pickaxe(5.0))), TileBell::class);
|
||||
@ -913,7 +914,7 @@ final class VanillaBlocks{
|
||||
|
||||
self::register("cobweb", fn(BID $id) => new Cobweb($id, "Cobweb", new Info(new BreakInfo(4.0, ToolType::SWORD | ToolType::SHEARS, 1))));
|
||||
self::register("cocoa_pod", fn(BID $id) => new CocoaBlock($id, "Cocoa Block", new Info(BreakInfo::axe(0.2, null, 15.0))));
|
||||
self::register("coral_block", fn(BID $id) => new CoralBlock($id, "Coral Block", new Info(BreakInfo::pickaxe(7.0, ToolTier::WOOD))));
|
||||
self::register("coral_block", fn(BID $id) => new CoralBlock($id, "Coral Block", new Info(BreakInfo::pickaxe(1.5, ToolTier::WOOD, 30.0))));
|
||||
self::register("daylight_sensor", fn(BID $id) => new DaylightSensor($id, "Daylight Sensor", new Info(BreakInfo::axe(0.2))), TileDaylightSensor::class);
|
||||
self::register("dead_bush", fn(BID $id) => new DeadBush($id, "Dead Bush", new Info(BreakInfo::instant(ToolType::SHEARS, 1), [Tags::POTTABLE_PLANTS])));
|
||||
self::register("detector_rail", fn(BID $id) => new DetectorRail($id, "Detector Rail", $railBreakInfo));
|
||||
@ -930,15 +931,15 @@ final class VanillaBlocks{
|
||||
self::register("pitcher_plant", fn(BID $id) => new DoublePlant($id, "Pitcher Plant", new Info(BreakInfo::instant())));
|
||||
self::register("pitcher_crop", fn(BID $id) => new PitcherCrop($id, "Pitcher Crop", new Info(BreakInfo::instant())));
|
||||
self::register("double_pitcher_crop", fn(BID $id) => new DoublePitcherCrop($id, "Double Pitcher Crop", new Info(BreakInfo::instant())));
|
||||
self::register("dragon_egg", fn(BID $id) => new DragonEgg($id, "Dragon Egg", new Info(BreakInfo::pickaxe(3.0, ToolTier::WOOD))));
|
||||
self::register("dragon_egg", fn(BID $id) => new DragonEgg($id, "Dragon Egg", new Info(BreakInfo::pickaxe(3.0, ToolTier::WOOD, blastResistance: 45.0))));
|
||||
self::register("dried_kelp", fn(BID $id) => new DriedKelp($id, "Dried Kelp Block", new Info(new BreakInfo(0.5, ToolType::NONE, 0, 12.5))));
|
||||
self::register("emerald", fn(BID $id) => new Opaque($id, "Emerald Block", new Info(BreakInfo::pickaxe(5.0, ToolTier::IRON, 30.0))));
|
||||
self::register("enchanting_table", fn(BID $id) => new EnchantingTable($id, "Enchanting Table", new Info(BreakInfo::pickaxe(5.0, ToolTier::WOOD, 6000.0))), TileEnchantingTable::class);
|
||||
self::register("end_portal_frame", fn(BID $id) => new EndPortalFrame($id, "End Portal Frame", new Info(BreakInfo::indestructible())));
|
||||
self::register("end_portal_frame", fn(BID $id) => new EndPortalFrame($id, "End Portal Frame", new Info(BreakInfo::indestructible(18000000.0))));
|
||||
self::register("end_rod", fn(BID $id) => new EndRod($id, "End Rod", new Info(BreakInfo::instant())));
|
||||
self::register("end_stone", fn(BID $id) => new Opaque($id, "End Stone", new Info(BreakInfo::pickaxe(3.0, ToolTier::WOOD, 45.0))));
|
||||
|
||||
$endBrickBreakInfo = new Info(BreakInfo::pickaxe(0.8, ToolTier::WOOD, 4.0));
|
||||
$endBrickBreakInfo = new Info(BreakInfo::pickaxe(3.0, ToolTier::WOOD, 45.0));
|
||||
self::register("end_stone_bricks", fn(BID $id) => new Opaque($id, "End Stone Bricks", $endBrickBreakInfo));
|
||||
self::register("end_stone_brick_stairs", fn(BID $id) => new Stair($id, "End Stone Brick Stairs", $endBrickBreakInfo));
|
||||
|
||||
@ -962,7 +963,7 @@ final class VanillaBlocks{
|
||||
self::register("torchflower", fn(BID $id) => new Flower($id, "Torchflower", $flowerTypeInfo));
|
||||
self::register("torchflower_crop", fn(BID $id) => new TorchflowerCrop($id, "Torchflower Crop", new Info(BreakInfo::instant())));
|
||||
self::register("flower_pot", fn(BID $id) => new FlowerPot($id, "Flower Pot", new Info(BreakInfo::instant())), TileFlowerPot::class);
|
||||
self::register("frosted_ice", fn(BID $id) => new FrostedIce($id, "Frosted Ice", new Info(BreakInfo::pickaxe(2.5))));
|
||||
self::register("frosted_ice", fn(BID $id) => new FrostedIce($id, "Frosted Ice", new Info(BreakInfo::pickaxe(0.5))));
|
||||
self::register("furnace", fn(BID $id) => new Furnace($id, "Furnace", new Info(BreakInfo::pickaxe(3.5, ToolTier::WOOD)), FurnaceType::FURNACE), TileNormalFurnace::class);
|
||||
self::register("blast_furnace", fn(BID $id) => new Furnace($id, "Blast Furnace", new Info(BreakInfo::pickaxe(3.5, ToolTier::WOOD)), FurnaceType::BLAST_FURNACE), TileBlastFurnace::class);
|
||||
self::register("smoker", fn(BID $id) => new Furnace($id, "Smoker", new Info(BreakInfo::pickaxe(3.5, ToolTier::WOOD)), FurnaceType::SMOKER), TileSmoker::class);
|
||||
@ -970,30 +971,28 @@ final class VanillaBlocks{
|
||||
$glassBreakInfo = new Info(new BreakInfo(0.3));
|
||||
self::register("glass", fn(BID $id) => new Glass($id, "Glass", $glassBreakInfo));
|
||||
self::register("glass_pane", fn(BID $id) => new GlassPane($id, "Glass Pane", $glassBreakInfo));
|
||||
self::register("glowing_obsidian", fn(BID $id) => new GlowingObsidian($id, "Glowing Obsidian", new Info(BreakInfo::pickaxe(10.0, ToolTier::DIAMOND, 50.0))));
|
||||
self::register("glowing_obsidian", fn(BID $id) => new GlowingObsidian($id, "Glowing Obsidian", new Info(BreakInfo::pickaxe(35.0, ToolTier::DIAMOND, 6000.0))));
|
||||
self::register("glowstone", fn(BID $id) => new Glowstone($id, "Glowstone", new Info(BreakInfo::pickaxe(0.3))));
|
||||
self::register("glow_lichen", fn(BID $id) => new GlowLichen($id, "Glow Lichen", new Info(BreakInfo::axe(0.2, null, 0.2))));
|
||||
self::register("glow_lichen", fn(BID $id) => new GlowLichen($id, "Glow Lichen", new Info(BreakInfo::axe(0.2))));
|
||||
self::register("gold", fn(BID $id) => new Opaque($id, "Gold Block", new Info(BreakInfo::pickaxe(3.0, ToolTier::IRON, 30.0))));
|
||||
|
||||
$grassBreakInfo = BreakInfo::shovel(0.6);
|
||||
self::register("grass", fn(BID $id) => new Grass($id, "Grass", new Info($grassBreakInfo, [Tags::DIRT])));
|
||||
self::register("grass_path", fn(BID $id) => new GrassPath($id, "Grass Path", new Info($grassBreakInfo)));
|
||||
self::register("grass", fn(BID $id) => new Grass($id, "Grass", new Info(BreakInfo::shovel(0.6), [Tags::DIRT])));
|
||||
self::register("grass_path", fn(BID $id) => new GrassPath($id, "Grass Path", new Info(BreakInfo::shovel(0.65))));
|
||||
self::register("gravel", fn(BID $id) => new Gravel($id, "Gravel", new Info(BreakInfo::shovel(0.6))));
|
||||
|
||||
$hardenedClayBreakInfo = new Info(BreakInfo::pickaxe(1.25, ToolTier::WOOD, 21.0));
|
||||
self::register("hardened_clay", fn(BID $id) => new HardenedClay($id, "Hardened Clay", $hardenedClayBreakInfo));
|
||||
self::register("hardened_clay", fn(BID $id) => new HardenedClay($id, "Hardened Clay", new Info(BreakInfo::pickaxe(1.25, ToolTier::WOOD, 21.0))));
|
||||
|
||||
$hardenedGlassBreakInfo = new Info(new BreakInfo(10.0));
|
||||
self::register("hardened_glass", fn(BID $id) => new HardenedGlass($id, "Hardened Glass", $hardenedGlassBreakInfo));
|
||||
self::register("hardened_glass_pane", fn(BID $id) => new HardenedGlassPane($id, "Hardened Glass Pane", $hardenedGlassBreakInfo));
|
||||
self::register("hay_bale", fn(BID $id) => new HayBale($id, "Hay Bale", new Info(new BreakInfo(0.5))));
|
||||
self::register("hopper", fn(BID $id) => new Hopper($id, "Hopper", new Info(BreakInfo::pickaxe(3.0, ToolTier::WOOD, 15.0))), TileHopper::class);
|
||||
self::register("hopper", fn(BID $id) => new Hopper($id, "Hopper", new Info(BreakInfo::pickaxe(3.0, ToolTier::WOOD, 24.0))), TileHopper::class);
|
||||
self::register("ice", fn(BID $id) => new Ice($id, "Ice", new Info(BreakInfo::pickaxe(0.5))));
|
||||
|
||||
$updateBlockBreakInfo = new Info(new BreakInfo(1.0));
|
||||
self::register("info_update", fn(BID $id) => new Opaque($id, "update!", $updateBlockBreakInfo));
|
||||
self::register("info_update2", fn(BID $id) => new Opaque($id, "ate!upd", $updateBlockBreakInfo));
|
||||
self::register("invisible_bedrock", fn(BID $id) => new Transparent($id, "Invisible Bedrock", new Info(BreakInfo::indestructible())));
|
||||
self::register("invisible_bedrock", fn(BID $id) => new Transparent($id, "Invisible Bedrock", new Info(BreakInfo::indestructible(18000000.0))));
|
||||
|
||||
$ironBreakInfo = new Info(BreakInfo::pickaxe(5.0, ToolTier::STONE, 30.0));
|
||||
self::register("iron", fn(BID $id) => new Opaque($id, "Iron Block", $ironBreakInfo));
|
||||
@ -1006,16 +1005,16 @@ final class VanillaBlocks{
|
||||
self::register("item_frame", fn(BID $id) => new ItemFrame($id, "Item Frame", $itemFrameInfo), TileItemFrame::class);
|
||||
self::register("glowing_item_frame", fn(BID $id) => new ItemFrame($id, "Glow Item Frame", $itemFrameInfo), TileGlowingItemFrame::class);
|
||||
|
||||
self::register("jukebox", fn(BID $id) => new Jukebox($id, "Jukebox", new Info(BreakInfo::axe(0.8))), TileJukebox::class); //TODO: in PC the hardness is 2.0, not 0.8, unsure if this is a MCPE bug or not
|
||||
self::register("jukebox", fn(BID $id) => new Jukebox($id, "Jukebox", new Info(BreakInfo::axe(2.0, blastResistance: 30.0))), TileJukebox::class);
|
||||
self::register("ladder", fn(BID $id) => new Ladder($id, "Ladder", new Info(BreakInfo::axe(0.4))));
|
||||
|
||||
$lanternBreakInfo = new Info(BreakInfo::pickaxe(5.0));
|
||||
$lanternBreakInfo = new Info(BreakInfo::pickaxe(3.5));
|
||||
self::register("lantern", fn(BID $id) => new Lantern($id, "Lantern", $lanternBreakInfo, 15));
|
||||
self::register("soul_lantern", fn(BID $id) => new Lantern($id, "Soul Lantern", $lanternBreakInfo, 10));
|
||||
|
||||
self::register("lapis_lazuli", fn(BID $id) => new Opaque($id, "Lapis Lazuli Block", new Info(BreakInfo::pickaxe(3.0, ToolTier::STONE))));
|
||||
self::register("lava", fn(BID $id) => new Lava($id, "Lava", new Info(BreakInfo::indestructible(500.0))));
|
||||
self::register("lectern", fn(BID $id) => new Lectern($id, "Lectern", new Info(BreakInfo::axe(2.0))), TileLectern::class);
|
||||
self::register("lectern", fn(BID $id) => new Lectern($id, "Lectern", new Info(BreakInfo::axe(2.5))), TileLectern::class);
|
||||
self::register("lever", fn(BID $id) => new Lever($id, "Lever", new Info(new BreakInfo(0.5))));
|
||||
self::register("magma", fn(BID $id) => new Magma($id, "Magma Block", new Info(BreakInfo::pickaxe(0.5, ToolTier::WOOD))));
|
||||
self::register("melon", fn(BID $id) => new Melon($id, "Melon Block", new Info(BreakInfo::axe(1.0))));
|
||||
@ -1065,14 +1064,15 @@ final class VanillaBlocks{
|
||||
self::register("purpur_stairs", fn(BID $id) => new Stair($id, "Purpur Stairs", $purpurBreakInfo));
|
||||
|
||||
$quartzBreakInfo = new Info(BreakInfo::pickaxe(0.8, ToolTier::WOOD));
|
||||
$smoothQuartzBreakInfo = new Info(BreakInfo::pickaxe(2.0, ToolTier::WOOD, 30.0));
|
||||
self::register("quartz", fn(BID $id) => new Opaque($id, "Quartz Block", $quartzBreakInfo));
|
||||
self::register("chiseled_quartz", fn(BID $id) => new SimplePillar($id, "Chiseled Quartz Block", $quartzBreakInfo));
|
||||
self::register("quartz_pillar", fn(BID $id) => new SimplePillar($id, "Quartz Pillar", $quartzBreakInfo));
|
||||
self::register("smooth_quartz", fn(BID $id) => new Opaque($id, "Smooth Quartz Block", $quartzBreakInfo));
|
||||
self::register("smooth_quartz", fn(BID $id) => new Opaque($id, "Smooth Quartz Block", $smoothQuartzBreakInfo));
|
||||
self::register("quartz_bricks", fn(BID $id) => new Opaque($id, "Quartz Bricks", $quartzBreakInfo));
|
||||
|
||||
self::register("quartz_stairs", fn(BID $id) => new Stair($id, "Quartz Stairs", $quartzBreakInfo));
|
||||
self::register("smooth_quartz_stairs", fn(BID $id) => new Stair($id, "Smooth Quartz Stairs", $quartzBreakInfo));
|
||||
self::register("smooth_quartz_stairs", fn(BID $id) => new Stair($id, "Smooth Quartz Stairs", $smoothQuartzBreakInfo));
|
||||
|
||||
self::register("rail", fn(BID $id) => new Rail($id, "Rail", $railBreakInfo));
|
||||
self::register("red_mushroom", fn(BID $id) => new RedMushroom($id, "Red Mushroom", new Info(BreakInfo::instant(), [Tags::POTTABLE_PLANTS])));
|
||||
@ -1127,13 +1127,13 @@ final class VanillaBlocks{
|
||||
$infestedStoneBreakInfo = new Info(BreakInfo::pickaxe(0.75));
|
||||
self::register("infested_stone", fn(BID $id) => new InfestedStone($id, "Infested Stone", $infestedStoneBreakInfo, $stone));
|
||||
self::register("infested_stone_brick", fn(BID $id) => new InfestedStone($id, "Infested Stone Brick", $infestedStoneBreakInfo, $stoneBrick));
|
||||
self::register("infested_cobblestone", fn(BID $id) => new InfestedStone($id, "Infested Cobblestone", $infestedStoneBreakInfo, $cobblestone));
|
||||
self::register("infested_cobblestone", fn(BID $id) => new InfestedStone($id, "Infested Cobblestone", new Info(BreakInfo::pickaxe(1.0, blastResistance: 3.75)), $cobblestone));
|
||||
self::register("infested_mossy_stone_brick", fn(BID $id) => new InfestedStone($id, "Infested Mossy Stone Brick", $infestedStoneBreakInfo, $mossyStoneBrick));
|
||||
self::register("infested_cracked_stone_brick", fn(BID $id) => new InfestedStone($id, "Infested Cracked Stone Brick", $infestedStoneBreakInfo, $crackedStoneBrick));
|
||||
self::register("infested_chiseled_stone_brick", fn(BID $id) => new InfestedStone($id, "Infested Chiseled Stone Brick", $infestedStoneBreakInfo, $chiseledStoneBrick));
|
||||
|
||||
self::register("stone_stairs", fn(BID $id) => new Stair($id, "Stone Stairs", $stoneBreakInfo));
|
||||
self::register("smooth_stone", fn(BID $id) => new Opaque($id, "Smooth Stone", $stoneBreakInfo));
|
||||
self::register("smooth_stone", fn(BID $id) => new Opaque($id, "Smooth Stone", new Info(BreakInfo::pickaxe(2.0, ToolTier::WOOD, 30.0))));
|
||||
self::register("andesite_stairs", fn(BID $id) => new Stair($id, "Andesite Stairs", $stoneBreakInfo));
|
||||
self::register("diorite_stairs", fn(BID $id) => new Stair($id, "Diorite Stairs", $stoneBreakInfo));
|
||||
self::register("granite_stairs", fn(BID $id) => new Stair($id, "Granite Stairs", $stoneBreakInfo));
|
||||
@ -1146,7 +1146,6 @@ final class VanillaBlocks{
|
||||
self::register("stonecutter", fn(BID $id) => new Stonecutter($id, "Stonecutter", new Info(BreakInfo::pickaxe(3.5))));
|
||||
self::register("stone_pressure_plate", fn(BID $id) => new StonePressurePlate($id, "Stone Pressure Plate", new Info(BreakInfo::pickaxe(0.5))));
|
||||
|
||||
//TODO: in the future this won't be the same for all the types
|
||||
$stoneSlabBreakInfo = new Info(BreakInfo::pickaxe(2.0, ToolTier::WOOD, 30.0));
|
||||
|
||||
self::register("brick_slab", fn(BID $id) => new Slab($id, "Brick", $stoneSlabBreakInfo));
|
||||
@ -1157,28 +1156,31 @@ final class VanillaBlocks{
|
||||
self::register("sandstone_slab", fn(BID $id) => new Slab($id, "Sandstone", $stoneSlabBreakInfo));
|
||||
self::register("smooth_stone_slab", fn(BID $id) => new Slab($id, "Smooth Stone", $stoneSlabBreakInfo));
|
||||
self::register("stone_brick_slab", fn(BID $id) => new Slab($id, "Stone Brick", $stoneSlabBreakInfo));
|
||||
self::register("dark_prismarine_slab", fn(BID $id) => new Slab($id, "Dark Prismarine", $stoneSlabBreakInfo));
|
||||
self::register("mossy_cobblestone_slab", fn(BID $id) => new Slab($id, "Mossy Cobblestone", $stoneSlabBreakInfo));
|
||||
self::register("prismarine_slab", fn(BID $id) => new Slab($id, "Prismarine", $stoneSlabBreakInfo));
|
||||
self::register("prismarine_bricks_slab", fn(BID $id) => new Slab($id, "Prismarine Bricks", $stoneSlabBreakInfo));
|
||||
self::register("purpur_slab", fn(BID $id) => new Slab($id, "Purpur", $stoneSlabBreakInfo));
|
||||
self::register("red_nether_brick_slab", fn(BID $id) => new Slab($id, "Red Nether Brick", $stoneSlabBreakInfo));
|
||||
self::register("red_sandstone_slab", fn(BID $id) => new Slab($id, "Red Sandstone", $stoneSlabBreakInfo));
|
||||
self::register("smooth_sandstone_slab", fn(BID $id) => new Slab($id, "Smooth Sandstone", $stoneSlabBreakInfo));
|
||||
self::register("andesite_slab", fn(BID $id) => new Slab($id, "Andesite", $stoneSlabBreakInfo));
|
||||
self::register("diorite_slab", fn(BID $id) => new Slab($id, "Diorite", $stoneSlabBreakInfo));
|
||||
self::register("end_stone_brick_slab", fn(BID $id) => new Slab($id, "End Stone Brick", $stoneSlabBreakInfo));
|
||||
self::register("granite_slab", fn(BID $id) => new Slab($id, "Granite", $stoneSlabBreakInfo));
|
||||
self::register("polished_andesite_slab", fn(BID $id) => new Slab($id, "Polished Andesite", $stoneSlabBreakInfo));
|
||||
self::register("polished_diorite_slab", fn(BID $id) => new Slab($id, "Polished Diorite", $stoneSlabBreakInfo));
|
||||
self::register("polished_granite_slab", fn(BID $id) => new Slab($id, "Polished Granite", $stoneSlabBreakInfo));
|
||||
self::register("smooth_red_sandstone_slab", fn(BID $id) => new Slab($id, "Smooth Red Sandstone", $stoneSlabBreakInfo));
|
||||
self::register("cut_red_sandstone_slab", fn(BID $id) => new Slab($id, "Cut Red Sandstone", $stoneSlabBreakInfo));
|
||||
self::register("cut_sandstone_slab", fn(BID $id) => new Slab($id, "Cut Sandstone", $stoneSlabBreakInfo));
|
||||
self::register("mossy_stone_brick_slab", fn(BID $id) => new Slab($id, "Mossy Stone Brick", $stoneSlabBreakInfo));
|
||||
self::register("mossy_cobblestone_slab", fn(BID $id) => new Slab($id, "Mossy Cobblestone", $stoneSlabBreakInfo));
|
||||
self::register("purpur_slab", fn(BID $id) => new Slab($id, "Purpur", $stoneSlabBreakInfo));
|
||||
self::register("smooth_red_sandstone_slab", fn(BID $id) => new Slab($id, "Smooth Red Sandstone", $stoneSlabBreakInfo));
|
||||
self::register("smooth_quartz_slab", fn(BID $id) => new Slab($id, "Smooth Quartz", $stoneSlabBreakInfo));
|
||||
self::register("stone_slab", fn(BID $id) => new Slab($id, "Stone", $stoneSlabBreakInfo));
|
||||
|
||||
self::register("end_stone_brick_slab", fn(BID $id) => new Slab($id, "End Stone Brick", new Info(BreakInfo::pickaxe(3.0, ToolTier::WOOD, 30.0))));
|
||||
|
||||
$lightStoneSlabBreakInfo = new Info(BreakInfo::pickaxe(1.5, ToolTier::WOOD, 30.0));
|
||||
self::register("dark_prismarine_slab", fn(BID $id) => new Slab($id, "Dark Prismarine", $lightStoneSlabBreakInfo));
|
||||
self::register("prismarine_slab", fn(BID $id) => new Slab($id, "Prismarine", $lightStoneSlabBreakInfo));
|
||||
self::register("prismarine_bricks_slab", fn(BID $id) => new Slab($id, "Prismarine Bricks", $lightStoneSlabBreakInfo));
|
||||
self::register("andesite_slab", fn(BID $id) => new Slab($id, "Andesite", $lightStoneSlabBreakInfo));
|
||||
self::register("diorite_slab", fn(BID $id) => new Slab($id, "Diorite", $lightStoneSlabBreakInfo));
|
||||
self::register("granite_slab", fn(BID $id) => new Slab($id, "Granite", $lightStoneSlabBreakInfo));
|
||||
self::register("polished_andesite_slab", fn(BID $id) => new Slab($id, "Polished Andesite", $lightStoneSlabBreakInfo));
|
||||
self::register("polished_diorite_slab", fn(BID $id) => new Slab($id, "Polished Diorite", $lightStoneSlabBreakInfo));
|
||||
self::register("polished_granite_slab", fn(BID $id) => new Slab($id, "Polished Granite", $lightStoneSlabBreakInfo));
|
||||
self::register("mossy_stone_brick_slab", fn(BID $id) => new Slab($id, "Mossy Stone Brick", $lightStoneSlabBreakInfo));
|
||||
|
||||
self::register("legacy_stonecutter", fn(BID $id) => new Opaque($id, "Legacy Stonecutter", new Info(BreakInfo::pickaxe(3.5, ToolTier::WOOD))));
|
||||
self::register("sugarcane", fn(BID $id) => new Sugarcane($id, "Sugarcane", new Info(BreakInfo::instant())));
|
||||
self::register("sweet_berry_bush", fn(BID $id) => new SweetBerryBush($id, "Sweet Berry Bush", new Info(BreakInfo::instant())));
|
||||
@ -1237,25 +1239,26 @@ final class VanillaBlocks{
|
||||
}
|
||||
|
||||
$sandstoneBreakInfo = new Info(BreakInfo::pickaxe(0.8, ToolTier::WOOD));
|
||||
$smoothSandstoneBreakInfo = new Info(BreakInfo::pickaxe(2.0, ToolTier::WOOD, 30.0));
|
||||
self::register("red_sandstone_stairs", fn(BID $id) => new Stair($id, "Red Sandstone Stairs", $sandstoneBreakInfo));
|
||||
self::register("smooth_red_sandstone_stairs", fn(BID $id) => new Stair($id, "Smooth Red Sandstone Stairs", $sandstoneBreakInfo));
|
||||
self::register("smooth_red_sandstone_stairs", fn(BID $id) => new Stair($id, "Smooth Red Sandstone Stairs", $smoothSandstoneBreakInfo));
|
||||
self::register("red_sandstone", fn(BID $id) => new Opaque($id, "Red Sandstone", $sandstoneBreakInfo));
|
||||
self::register("chiseled_red_sandstone", fn(BID $id) => new Opaque($id, "Chiseled Red Sandstone", $sandstoneBreakInfo));
|
||||
self::register("cut_red_sandstone", fn(BID $id) => new Opaque($id, "Cut Red Sandstone", $sandstoneBreakInfo));
|
||||
self::register("smooth_red_sandstone", fn(BID $id) => new Opaque($id, "Smooth Red Sandstone", $sandstoneBreakInfo));
|
||||
self::register("smooth_red_sandstone", fn(BID $id) => new Opaque($id, "Smooth Red Sandstone", $smoothSandstoneBreakInfo));
|
||||
|
||||
self::register("sandstone_stairs", fn(BID $id) => new Stair($id, "Sandstone Stairs", $sandstoneBreakInfo));
|
||||
self::register("smooth_sandstone_stairs", fn(BID $id) => new Stair($id, "Smooth Sandstone Stairs", $sandstoneBreakInfo));
|
||||
self::register("smooth_sandstone_stairs", fn(BID $id) => new Stair($id, "Smooth Sandstone Stairs", $smoothSandstoneBreakInfo));
|
||||
self::register("sandstone", fn(BID $id) => new Opaque($id, "Sandstone", $sandstoneBreakInfo));
|
||||
self::register("chiseled_sandstone", fn(BID $id) => new Opaque($id, "Chiseled Sandstone", $sandstoneBreakInfo));
|
||||
self::register("cut_sandstone", fn(BID $id) => new Opaque($id, "Cut Sandstone", $sandstoneBreakInfo));
|
||||
self::register("smooth_sandstone", fn(BID $id) => new Opaque($id, "Smooth Sandstone", $sandstoneBreakInfo));
|
||||
self::register("smooth_sandstone", fn(BID $id) => new Opaque($id, "Smooth Sandstone", $smoothSandstoneBreakInfo));
|
||||
|
||||
self::register("glazed_terracotta", fn(BID $id) => new GlazedTerracotta($id, "Glazed Terracotta", new Info(BreakInfo::pickaxe(1.4, ToolTier::WOOD))));
|
||||
self::register("dyed_shulker_box", fn(BID $id) => new DyedShulkerBox($id, "Dyed Shulker Box", $shulkerBoxBreakInfo), TileShulkerBox::class);
|
||||
self::register("stained_glass", fn(BID $id) => new StainedGlass($id, "Stained Glass", $glassBreakInfo));
|
||||
self::register("stained_glass_pane", fn(BID $id) => new StainedGlassPane($id, "Stained Glass Pane", $glassBreakInfo));
|
||||
self::register("stained_clay", fn(BID $id) => new StainedHardenedClay($id, "Stained Clay", $hardenedClayBreakInfo));
|
||||
self::register("stained_clay", fn(BID $id) => new StainedHardenedClay($id, "Stained Clay", new Info(BreakInfo::pickaxe(1.25, ToolTier::WOOD, 6.25))));
|
||||
self::register("stained_hardened_glass", fn(BID $id) => new StainedHardenedGlass($id, "Stained Hardened Glass", $hardenedGlassBreakInfo));
|
||||
self::register("stained_hardened_glass_pane", fn(BID $id) => new StainedHardenedGlassPane($id, "Stained Hardened Glass Pane", $hardenedGlassBreakInfo));
|
||||
self::register("carpet", fn(BID $id) => new Carpet($id, "Carpet", new Info(new BreakInfo(0.1))));
|
||||
@ -1272,22 +1275,26 @@ final class VanillaBlocks{
|
||||
}
|
||||
})));
|
||||
|
||||
//TODO: in the future these won't all have the same hardness; they only do now because of the old metadata crap
|
||||
$wallBreakInfo = new Info(BreakInfo::pickaxe(2.0, ToolTier::WOOD, 30.0));
|
||||
self::register("cobblestone_wall", fn(BID $id) => new Wall($id, "Cobblestone Wall", $wallBreakInfo));
|
||||
self::register("andesite_wall", fn(BID $id) => new Wall($id, "Andesite Wall", $wallBreakInfo));
|
||||
self::register("brick_wall", fn(BID $id) => new Wall($id, "Brick Wall", $wallBreakInfo));
|
||||
self::register("diorite_wall", fn(BID $id) => new Wall($id, "Diorite Wall", $wallBreakInfo));
|
||||
self::register("end_stone_brick_wall", fn(BID $id) => new Wall($id, "End Stone Brick Wall", $wallBreakInfo));
|
||||
self::register("granite_wall", fn(BID $id) => new Wall($id, "Granite Wall", $wallBreakInfo));
|
||||
self::register("mossy_stone_brick_wall", fn(BID $id) => new Wall($id, "Mossy Stone Brick Wall", $wallBreakInfo));
|
||||
self::register("mossy_cobblestone_wall", fn(BID $id) => new Wall($id, "Mossy Cobblestone Wall", $wallBreakInfo));
|
||||
self::register("nether_brick_wall", fn(BID $id) => new Wall($id, "Nether Brick Wall", $wallBreakInfo));
|
||||
self::register("prismarine_wall", fn(BID $id) => new Wall($id, "Prismarine Wall", $wallBreakInfo));
|
||||
self::register("red_nether_brick_wall", fn(BID $id) => new Wall($id, "Red Nether Brick Wall", $wallBreakInfo));
|
||||
self::register("red_sandstone_wall", fn(BID $id) => new Wall($id, "Red Sandstone Wall", $wallBreakInfo));
|
||||
self::register("sandstone_wall", fn(BID $id) => new Wall($id, "Sandstone Wall", $wallBreakInfo));
|
||||
self::register("stone_brick_wall", fn(BID $id) => new Wall($id, "Stone Brick Wall", $wallBreakInfo));
|
||||
self::register("end_stone_brick_wall", fn(BID $id) => new Wall($id, "End Stone Brick Wall", new Info(BreakInfo::pickaxe(3.0, ToolTier::WOOD, 45.0))));
|
||||
|
||||
$brickWallBreakInfo = new Info(BreakInfo::pickaxe(2.0, ToolTier::WOOD, 30.0));
|
||||
self::register("cobblestone_wall", fn(BID $id) => new Wall($id, "Cobblestone Wall", $brickWallBreakInfo));
|
||||
self::register("brick_wall", fn(BID $id) => new Wall($id, "Brick Wall", $brickWallBreakInfo));
|
||||
self::register("mossy_cobblestone_wall", fn(BID $id) => new Wall($id, "Mossy Cobblestone Wall", $brickWallBreakInfo));
|
||||
self::register("nether_brick_wall", fn(BID $id) => new Wall($id, "Nether Brick Wall", $brickWallBreakInfo));
|
||||
self::register("red_nether_brick_wall", fn(BID $id) => new Wall($id, "Red Nether Brick Wall", $brickWallBreakInfo));
|
||||
|
||||
$stoneWallBreakInfo = new Info(BreakInfo::pickaxe(1.5, ToolTier::WOOD, 30.0));
|
||||
self::register("stone_brick_wall", fn(BID $id) => new Wall($id, "Stone Brick Wall", $stoneWallBreakInfo));
|
||||
self::register("mossy_stone_brick_wall", fn(BID $id) => new Wall($id, "Mossy Stone Brick Wall", $stoneWallBreakInfo));
|
||||
self::register("granite_wall", fn(BID $id) => new Wall($id, "Granite Wall", $stoneWallBreakInfo));
|
||||
self::register("diorite_wall", fn(BID $id) => new Wall($id, "Diorite Wall", $stoneWallBreakInfo));
|
||||
self::register("andesite_wall", fn(BID $id) => new Wall($id, "Andesite Wall", $stoneWallBreakInfo));
|
||||
self::register("prismarine_wall", fn(BID $id) => new Wall($id, "Prismarine Wall", $stoneWallBreakInfo));
|
||||
|
||||
$sandstoneWallBreakInfo = new Info(BreakInfo::pickaxe(0.8, ToolTier::WOOD, 4.0));
|
||||
self::register("red_sandstone_wall", fn(BID $id) => new Wall($id, "Red Sandstone Wall", $sandstoneWallBreakInfo));
|
||||
self::register("sandstone_wall", fn(BID $id) => new Wall($id, "Sandstone Wall", $sandstoneWallBreakInfo));
|
||||
|
||||
self::registerElements();
|
||||
|
||||
@ -1320,8 +1327,8 @@ final class VanillaBlocks{
|
||||
self::register("mangrove_roots", fn(BID $id) => new MangroveRoots($id, "Mangrove Roots", new Info(BreakInfo::axe(0.7))));
|
||||
self::register("muddy_mangrove_roots", fn(BID $id) => new SimplePillar($id, "Muddy Mangrove Roots", new Info(BreakInfo::shovel(0.7), [Tags::MUD])));
|
||||
self::register("froglight", fn(BID $id) => new Froglight($id, "Froglight", new Info(new BreakInfo(0.3))));
|
||||
self::register("sculk", fn(BID $id) => new Sculk($id, "Sculk", new Info(new BreakInfo(0.6, ToolType::HOE))));
|
||||
self::register("reinforced_deepslate", fn(BID $id) => new class($id, "Reinforced Deepslate", new Info(new BreakInfo(55.0, ToolType::NONE, 0, 3600.0))) extends Opaque{
|
||||
self::register("sculk", fn(BID $id) => new Sculk($id, "Sculk", new Info(new BreakInfo(0.2, ToolType::HOE))));
|
||||
self::register("reinforced_deepslate", fn(BID $id) => new class($id, "Reinforced Deepslate", new Info(new BreakInfo(55.0, ToolType::NONE, 0, 6000.0))) extends Opaque{
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
return [];
|
||||
}
|
||||
@ -1537,7 +1544,7 @@ final class VanillaBlocks{
|
||||
self::register("lapis_lazuli_ore", fn(BID $id) => new LapisOre($id, "Lapis Lazuli Ore", $stoneOreBreakInfo(ToolTier::STONE)));
|
||||
self::register("redstone_ore", fn(BID $id) => new RedstoneOre($id, "Redstone Ore", $stoneOreBreakInfo(ToolTier::IRON)));
|
||||
|
||||
$deepslateOreBreakInfo = fn(ToolTier $toolTier) => new Info(BreakInfo::pickaxe(4.5, $toolTier));
|
||||
$deepslateOreBreakInfo = fn(ToolTier $toolTier) => new Info(BreakInfo::pickaxe(4.5, $toolTier, 15.0));
|
||||
self::register("deepslate_coal_ore", fn(BID $id) => new CoalOre($id, "Deepslate Coal Ore", $deepslateOreBreakInfo(ToolTier::WOOD)));
|
||||
self::register("deepslate_copper_ore", fn(BID $id) => new CopperOre($id, "Deepslate Copper Ore", $deepslateOreBreakInfo(ToolTier::STONE)));
|
||||
self::register("deepslate_diamond_ore", fn(BID $id) => new DiamondOre($id, "Deepslate Diamond Ore", $deepslateOreBreakInfo(ToolTier::IRON)));
|
||||
@ -1581,10 +1588,10 @@ final class VanillaBlocks{
|
||||
//for some reason, slabs have weird hardness like the legacy ones
|
||||
$slabBreakInfo = new Info(BreakInfo::pickaxe(2.0, ToolTier::WOOD, 30.0));
|
||||
|
||||
self::register("ancient_debris", fn(BID $id) => new class($id, "Ancient Debris", new Info(BreakInfo::pickaxe(30, ToolTier::DIAMOND, 3600.0))) extends Opaque{
|
||||
self::register("ancient_debris", fn(BID $id) => new class($id, "Ancient Debris", new Info(BreakInfo::pickaxe(30, ToolTier::DIAMOND, 6000.0))) extends Opaque{
|
||||
public function isFireProofAsItem() : bool{ return true; }
|
||||
});
|
||||
$netheriteBreakInfo = new Info(BreakInfo::pickaxe(50, ToolTier::DIAMOND, 3600.0));
|
||||
$netheriteBreakInfo = new Info(BreakInfo::pickaxe(50, ToolTier::DIAMOND, 6000.0));
|
||||
self::register("netherite", fn(BID $id) => new class($id, "Netherite Block", $netheriteBreakInfo) extends Opaque{
|
||||
public function isFireProofAsItem() : bool{ return true; }
|
||||
});
|
||||
@ -1602,14 +1609,14 @@ final class VanillaBlocks{
|
||||
|
||||
self::register("gilded_blackstone", fn(BID $id) => new GildedBlackstone($id, "Gilded Blackstone", $blackstoneBreakInfo));
|
||||
|
||||
//TODO: polished blackstone ought to have 2.0 hardness (as per java) but it's 1.5 in Bedrock (probably parity bug)
|
||||
$polishedBlackstoneBreakInfo = new Info(BreakInfo::pickaxe(2.0, ToolTier::WOOD, 30.0));
|
||||
$prefix = fn(string $thing) => "Polished Blackstone" . ($thing !== "" ? " $thing" : "");
|
||||
self::register("polished_blackstone", fn(BID $id) => new Opaque($id, $prefix(""), $blackstoneBreakInfo));
|
||||
self::register("polished_blackstone", fn(BID $id) => new Opaque($id, $prefix(""), $polishedBlackstoneBreakInfo));
|
||||
self::register("polished_blackstone_button", fn(BID $id) => new StoneButton($id, $prefix("Button"), new Info(BreakInfo::pickaxe(0.5))));
|
||||
self::register("polished_blackstone_pressure_plate", fn(BID $id) => new StonePressurePlate($id, $prefix("Pressure Plate"), new Info(BreakInfo::pickaxe(0.5)), 20));
|
||||
self::register("polished_blackstone_slab", fn(BID $id) => new Slab($id, $prefix(""), $slabBreakInfo));
|
||||
self::register("polished_blackstone_stairs", fn(BID $id) => new Stair($id, $prefix("Stairs"), $blackstoneBreakInfo));
|
||||
self::register("polished_blackstone_wall", fn(BID $id) => new Wall($id, $prefix("Wall"), $blackstoneBreakInfo));
|
||||
self::register("polished_blackstone_stairs", fn(BID $id) => new Stair($id, $prefix("Stairs"), $polishedBlackstoneBreakInfo));
|
||||
self::register("polished_blackstone_wall", fn(BID $id) => new Wall($id, $prefix("Wall"), $polishedBlackstoneBreakInfo));
|
||||
self::register("chiseled_polished_blackstone", fn(BID $id) => new Opaque($id, "Chiseled Polished Blackstone", $blackstoneBreakInfo));
|
||||
|
||||
$prefix = fn(string $thing) => "Polished Blackstone Brick" . ($thing !== "" ? " $thing" : "");
|
||||
@ -1622,8 +1629,7 @@ final class VanillaBlocks{
|
||||
self::register("soul_torch", fn(BID $id) => new Torch($id, "Soul Torch", new Info(BreakInfo::instant())));
|
||||
self::register("soul_fire", fn(BID $id) => new SoulFire($id, "Soul Fire", new Info(BreakInfo::instant(), [Tags::FIRE])));
|
||||
|
||||
//TODO: soul soul ought to have 0.5 hardness (as per java) but it's 1.0 in Bedrock (probably parity bug)
|
||||
self::register("soul_soil", fn(BID $id) => new Opaque($id, "Soul Soil", new Info(BreakInfo::shovel(1.0))));
|
||||
self::register("soul_soil", fn(BID $id) => new Opaque($id, "Soul Soil", new Info(BreakInfo::shovel(0.5))));
|
||||
|
||||
self::register("shroomlight", fn(BID $id) => new class($id, "Shroomlight", new Info(new BreakInfo(1.0, ToolType::HOE))) extends Opaque{
|
||||
public function getLightLevel() : int{ return 15; }
|
||||
@ -1641,7 +1647,9 @@ final class VanillaBlocks{
|
||||
self::register("crimson_roots", fn(BID $id) => new NetherRoots($id, "Crimson Roots", $netherRootsInfo));
|
||||
self::register("warped_roots", fn(BID $id) => new NetherRoots($id, "Warped Roots", $netherRootsInfo));
|
||||
|
||||
self::register("chain", fn(BID $id) => new Chain($id, "Chain", new Info(BreakInfo::pickaxe(5.0, ToolTier::WOOD))));
|
||||
self::register("chain", fn(BID $id) => new Chain($id, "Chain", new Info(BreakInfo::pickaxe(5.0, ToolTier::WOOD, 30.0))));
|
||||
|
||||
self::register("respawn_anchor", fn(BID $id) => new RespawnAnchor($id, "Respawn Anchor", new Info(BreakInfo::pickaxe(50.0, ToolTier::DIAMOND, 6000.0))));
|
||||
}
|
||||
|
||||
private static function registerBlocksR17() : void{
|
||||
@ -1659,7 +1667,7 @@ final class VanillaBlocks{
|
||||
self::register("raw_gold", fn(BID $id) => new Opaque($id, "Raw Gold Block", new Info(BreakInfo::pickaxe(5, ToolTier::IRON, 30.0))));
|
||||
self::register("raw_iron", fn(BID $id) => new Opaque($id, "Raw Iron Block", new Info(BreakInfo::pickaxe(5, ToolTier::STONE, 30.0))));
|
||||
|
||||
$deepslateBreakInfo = new Info(BreakInfo::pickaxe(3, ToolTier::WOOD, 18.0));
|
||||
$deepslateBreakInfo = new Info(BreakInfo::pickaxe(3, ToolTier::WOOD, 30.0));
|
||||
self::register("deepslate", fn(BID $id) => new class($id, "Deepslate", $deepslateBreakInfo) extends SimplePillar{
|
||||
public function getDropsForCompatibleTool(Item $item) : array{
|
||||
return [VanillaBlocks::COBBLED_DEEPSLATE()->asItem()];
|
||||
@ -1671,29 +1679,29 @@ final class VanillaBlocks{
|
||||
});
|
||||
|
||||
//TODO: parity issue here - in Java this has a hardness of 3.0, but in bedrock it's 3.5
|
||||
self::register("chiseled_deepslate", fn(BID $id) => new Opaque($id, "Chiseled Deepslate", new Info(BreakInfo::pickaxe(3.5, ToolTier::WOOD, 18.0))));
|
||||
self::register("chiseled_deepslate", fn(BID $id) => new Opaque($id, "Chiseled Deepslate", new Info(BreakInfo::pickaxe(3.5, ToolTier::WOOD, 30.0))));
|
||||
|
||||
$deepslateBrickBreakInfo = new Info(BreakInfo::pickaxe(3.5, ToolTier::WOOD, 18.0));
|
||||
$deepslateBrickBreakInfo = new Info(BreakInfo::pickaxe(3.5, ToolTier::WOOD, 30.0));
|
||||
self::register("deepslate_bricks", fn(BID $id) => new Opaque($id, "Deepslate Bricks", $deepslateBrickBreakInfo));
|
||||
self::register("deepslate_brick_slab", fn(BID $id) => new Slab($id, "Deepslate Brick", $deepslateBrickBreakInfo));
|
||||
self::register("deepslate_brick_stairs", fn(BID $id) => new Stair($id, "Deepslate Brick Stairs", $deepslateBrickBreakInfo));
|
||||
self::register("deepslate_brick_wall", fn(BID $id) => new Wall($id, "Deepslate Brick Wall", $deepslateBrickBreakInfo));
|
||||
self::register("cracked_deepslate_bricks", fn(BID $id) => new Opaque($id, "Cracked Deepslate Bricks", $deepslateBrickBreakInfo));
|
||||
|
||||
$deepslateTilesBreakInfo = new Info(BreakInfo::pickaxe(3.5, ToolTier::WOOD, 18.0));
|
||||
$deepslateTilesBreakInfo = new Info(BreakInfo::pickaxe(3.5, ToolTier::WOOD, 30.0));
|
||||
self::register("deepslate_tiles", fn(BID $id) => new Opaque($id, "Deepslate Tiles", $deepslateTilesBreakInfo));
|
||||
self::register("deepslate_tile_slab", fn(BID $id) => new Slab($id, "Deepslate Tile", $deepslateTilesBreakInfo));
|
||||
self::register("deepslate_tile_stairs", fn(BID $id) => new Stair($id, "Deepslate Tile Stairs", $deepslateTilesBreakInfo));
|
||||
self::register("deepslate_tile_wall", fn(BID $id) => new Wall($id, "Deepslate Tile Wall", $deepslateTilesBreakInfo));
|
||||
self::register("cracked_deepslate_tiles", fn(BID $id) => new Opaque($id, "Cracked Deepslate Tiles", $deepslateTilesBreakInfo));
|
||||
|
||||
$cobbledDeepslateBreakInfo = new Info(BreakInfo::pickaxe(3.5, ToolTier::WOOD, 18.0));
|
||||
$cobbledDeepslateBreakInfo = new Info(BreakInfo::pickaxe(3.5, ToolTier::WOOD, 30.0));
|
||||
self::register("cobbled_deepslate", fn(BID $id) => new Opaque($id, "Cobbled Deepslate", $cobbledDeepslateBreakInfo));
|
||||
self::register("cobbled_deepslate_slab", fn(BID $id) => new Slab($id, "Cobbled Deepslate", $cobbledDeepslateBreakInfo));
|
||||
self::register("cobbled_deepslate_stairs", fn(BID $id) => new Stair($id, "Cobbled Deepslate Stairs", $cobbledDeepslateBreakInfo));
|
||||
self::register("cobbled_deepslate_wall", fn(BID $id) => new Wall($id, "Cobbled Deepslate Wall", $cobbledDeepslateBreakInfo));
|
||||
|
||||
$polishedDeepslateBreakInfo = new Info(BreakInfo::pickaxe(3.5, ToolTier::WOOD, 18.0));
|
||||
$polishedDeepslateBreakInfo = new Info(BreakInfo::pickaxe(3.5, ToolTier::WOOD, 30.0));
|
||||
self::register("polished_deepslate", fn(BID $id) => new Opaque($id, "Polished Deepslate", $polishedDeepslateBreakInfo));
|
||||
self::register("polished_deepslate_slab", fn(BID $id) => new Slab($id, "Polished Deepslate", $polishedDeepslateBreakInfo));
|
||||
self::register("polished_deepslate_stairs", fn(BID $id) => new Stair($id, "Polished Deepslate Stairs", $polishedDeepslateBreakInfo));
|
||||
@ -1702,7 +1710,7 @@ final class VanillaBlocks{
|
||||
self::register("tinted_glass", fn(BID $id) => new TintedGlass($id, "Tinted Glass", new Info(new BreakInfo(0.3))));
|
||||
|
||||
//blast resistance should be 30 if we were matched with java :(
|
||||
$copperBreakInfo = new Info(BreakInfo::pickaxe(3.0, ToolTier::STONE, 18.0));
|
||||
$copperBreakInfo = new Info(BreakInfo::pickaxe(3.0, ToolTier::STONE, 30.0));
|
||||
self::register("lightning_rod", fn(BID $id) => new LightningRod($id, "Lightning Rod", $copperBreakInfo));
|
||||
|
||||
self::register("copper", fn(BID $id) => new Copper($id, "Copper Block", $copperBreakInfo));
|
||||
@ -1730,8 +1738,8 @@ final class VanillaBlocks{
|
||||
self::register("cave_vines", fn(BID $id) => new CaveVines($id, "Cave Vines", new Info(BreakInfo::instant())));
|
||||
|
||||
self::register("small_dripleaf", fn(BID $id) => new SmallDripleaf($id, "Small Dripleaf", new Info(BreakInfo::instant(ToolType::SHEARS, toolHarvestLevel: 1))));
|
||||
self::register("big_dripleaf_head", fn(BID $id) => new BigDripleafHead($id, "Big Dripleaf", new Info(BreakInfo::instant())));
|
||||
self::register("big_dripleaf_stem", fn(BID $id) => new BigDripleafStem($id, "Big Dripleaf Stem", new Info(BreakInfo::instant())));
|
||||
self::register("big_dripleaf_head", fn(BID $id) => new BigDripleafHead($id, "Big Dripleaf", new Info(new BreakInfo(0.1))));
|
||||
self::register("big_dripleaf_stem", fn(BID $id) => new BigDripleafStem($id, "Big Dripleaf Stem", new Info(new BreakInfo(0.1))));
|
||||
}
|
||||
|
||||
private static function registerBlocksR18() : void{
|
||||
@ -1742,7 +1750,7 @@ final class VanillaBlocks{
|
||||
self::register("mud", fn(BID $id) => new Opaque($id, "Mud", new Info(BreakInfo::shovel(0.5), [Tags::MUD])));
|
||||
self::register("packed_mud", fn(BID $id) => new Opaque($id, "Packed Mud", new Info(BreakInfo::pickaxe(1.0, null, 15.0))));
|
||||
|
||||
$mudBricksBreakInfo = new Info(BreakInfo::pickaxe(2.0, ToolTier::WOOD, 30.0));
|
||||
$mudBricksBreakInfo = new Info(BreakInfo::pickaxe(1.5, ToolTier::WOOD, 15.0));
|
||||
|
||||
self::register("mud_bricks", fn(BID $id) => new Opaque($id, "Mud Bricks", $mudBricksBreakInfo));
|
||||
self::register("mud_brick_slab", fn(BID $id) => new Slab($id, "Mud Brick", $mudBricksBreakInfo));
|
||||
@ -1754,7 +1762,7 @@ final class VanillaBlocks{
|
||||
self::register("resin", fn(BID $id) => new Opaque($id, "Block of Resin", new Info(BreakInfo::instant())));
|
||||
self::register("resin_clump", fn(BID $id) => new ResinClump($id, "Resin Clump", new Info(BreakInfo::instant())));
|
||||
|
||||
$resinBricksInfo = new Info(BreakInfo::pickaxe(1.5, ToolTier::WOOD));
|
||||
$resinBricksInfo = new Info(BreakInfo::pickaxe(1.5, ToolTier::WOOD, 30.0));
|
||||
self::register("resin_brick_slab", fn(BID $id) => new Slab($id, "Resin Brick", $resinBricksInfo));
|
||||
self::register("resin_brick_stairs", fn(BID $id) => new Stair($id, "Resin Brick Stairs", $resinBricksInfo));
|
||||
self::register("resin_brick_wall", fn(BID $id) => new Wall($id, "Resin Brick Wall", $resinBricksInfo));
|
||||
|
@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\entity\Entity;
|
||||
use pocketmine\event\entity\EntityExtinguishEvent;
|
||||
use pocketmine\world\sound\BucketEmptyWaterSound;
|
||||
use pocketmine\world\sound\BucketFillWaterSound;
|
||||
use pocketmine\world\sound\Sound;
|
||||
@ -53,7 +54,7 @@ class Water extends Liquid{
|
||||
public function onEntityInside(Entity $entity) : bool{
|
||||
$entity->resetFallDistance();
|
||||
if($entity->isOnFire()){
|
||||
$entity->extinguish();
|
||||
$entity->extinguish(EntityExtinguishEvent::CAUSE_WATER);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ use pocketmine\block\tile\Cauldron as TileCauldron;
|
||||
use pocketmine\block\utils\DyeColor;
|
||||
use pocketmine\color\Color;
|
||||
use pocketmine\entity\Entity;
|
||||
use pocketmine\event\entity\EntityExtinguishEvent;
|
||||
use pocketmine\item\Armor;
|
||||
use pocketmine\item\Banner;
|
||||
use pocketmine\item\Dye;
|
||||
@ -183,7 +184,7 @@ final class WaterCauldron extends FillableCauldron{
|
||||
|
||||
public function onEntityInside(Entity $entity) : bool{
|
||||
if($entity->isOnFire()){
|
||||
$entity->extinguish();
|
||||
$entity->extinguish(EntityExtinguishEvent::CAUSE_WATER_CAULDRON);
|
||||
//TODO: particles
|
||||
|
||||
$this->position->getWorld()->setBlock($this->position, $this->withFillLevel($this->getFillLevel() - self::ENTITY_EXTINGUISH_USE_AMOUNT));
|
||||
|
@ -32,7 +32,7 @@ use pocketmine\network\mcpe\protocol\types\CacheableNbt;
|
||||
use function get_class;
|
||||
|
||||
abstract class Spawnable extends Tile{
|
||||
/** @phpstan-var CacheableNbt<\pocketmine\nbt\tag\CompoundTag>|null */
|
||||
/** @phpstan-var CacheableNbt<CompoundTag>|null */
|
||||
private ?CacheableNbt $spawnCompoundCache = null;
|
||||
|
||||
/**
|
||||
@ -73,7 +73,7 @@ abstract class Spawnable extends Tile{
|
||||
* Returns encoded NBT (varint, little-endian) used to spawn this tile to clients. Uses cache where possible,
|
||||
* populates cache if it is null.
|
||||
*
|
||||
* @phpstan-return CacheableNbt<\pocketmine\nbt\tag\CompoundTag>
|
||||
* @phpstan-return CacheableNbt<CompoundTag>
|
||||
*/
|
||||
final public function getSerializedSpawnCompound() : CacheableNbt{
|
||||
if($this->spawnCompoundCache === null){
|
||||
|
@ -114,6 +114,13 @@ final class TileFactory{
|
||||
$this->saveNames[$className] = reset($saveNames);
|
||||
}
|
||||
|
||||
/**
|
||||
* @phpstan-param class-string<Tile> $class
|
||||
*/
|
||||
public function isRegistered(string $class) : bool{
|
||||
return isset($this->saveNames[$class]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @throws SavedDataLoadingException
|
||||
|
@ -123,7 +123,7 @@ abstract class Command{
|
||||
}
|
||||
|
||||
if($this->permissionMessage === null){
|
||||
$target->sendMessage(KnownTranslationFactory::pocketmine_command_error_permission($this->name)->prefix(TextFormat::RED));
|
||||
$target->sendMessage(KnownTranslationFactory::pocketmine_command_error_permission($this->name)->baseTextFormat(TextFormat::RED));
|
||||
}elseif($this->permissionMessage !== ""){
|
||||
$target->sendMessage(str_replace("<permission>", $permission ?? implode(";", $this->permission), $this->permissionMessage));
|
||||
}
|
||||
@ -237,7 +237,7 @@ abstract class Command{
|
||||
public static function broadcastCommandMessage(CommandSender $source, Translatable|string $message, bool $sendToSource = true) : void{
|
||||
$users = $source->getServer()->getBroadcastChannelSubscribers(Server::BROADCAST_CHANNEL_ADMINISTRATIVE);
|
||||
$result = KnownTranslationFactory::chat_type_admin($source->getName(), $message);
|
||||
$colored = $result->prefix(TextFormat::GRAY . TextFormat::ITALIC);
|
||||
$colored = $result->baseTextFormat(TextFormat::GRAY . TextFormat::ITALIC);
|
||||
|
||||
if($sendToSource){
|
||||
$source->sendMessage($message);
|
||||
|
@ -107,7 +107,7 @@ class FormattedCommandAlias extends Command{
|
||||
$timings->stopTiming();
|
||||
}
|
||||
}else{
|
||||
$sender->sendMessage($sender->getLanguage()->translate(KnownTranslationFactory::pocketmine_command_notFound($commandLabel, "/help")->prefix(TextFormat::RED)));
|
||||
$sender->sendMessage($sender->getLanguage()->translate(KnownTranslationFactory::pocketmine_command_notFound($commandLabel, "/help")->baseTextFormat(TextFormat::RED)));
|
||||
|
||||
//to match the behaviour of SimpleCommandMap::dispatch()
|
||||
//this shouldn't normally happen, but might happen if the command was unregistered or modified after
|
||||
|
@ -226,7 +226,7 @@ class SimpleCommandMap implements CommandMap{
|
||||
return true;
|
||||
}
|
||||
|
||||
$sender->sendMessage(KnownTranslationFactory::pocketmine_command_notFound($sentCommandLabel ?? "", "/help")->prefix(TextFormat::RED));
|
||||
$sender->sendMessage(KnownTranslationFactory::pocketmine_command_notFound($sentCommandLabel ?? "", "/help")->baseTextFormat(TextFormat::RED));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ class ClearCommand extends VanillaCommand{
|
||||
}
|
||||
}catch(LegacyStringToItemParserException $e){
|
||||
//vanilla checks this at argument parsing layer, can't come up with a better alternative
|
||||
$sender->sendMessage(KnownTranslationFactory::commands_give_item_notFound($args[1])->prefix(TextFormat::RED));
|
||||
$sender->sendMessage(KnownTranslationFactory::commands_give_item_notFound($args[1])->baseTextFormat(TextFormat::RED));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -90,7 +90,7 @@ class ClearCommand extends VanillaCommand{
|
||||
if($count > 0){
|
||||
$sender->sendMessage(KnownTranslationFactory::commands_clear_testing($target->getName(), (string) $count));
|
||||
}else{
|
||||
$sender->sendMessage(KnownTranslationFactory::commands_clear_failure_no_items($target->getName())->prefix(TextFormat::RED));
|
||||
$sender->sendMessage(KnownTranslationFactory::commands_clear_failure_no_items($target->getName())->baseTextFormat(TextFormat::RED));
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -132,7 +132,7 @@ class ClearCommand extends VanillaCommand{
|
||||
if($clearedCount > 0){
|
||||
Command::broadcastCommandMessage($sender, KnownTranslationFactory::commands_clear_success($target->getName(), (string) $clearedCount));
|
||||
}else{
|
||||
$sender->sendMessage(KnownTranslationFactory::commands_clear_failure_no_items($target->getName())->prefix(TextFormat::RED));
|
||||
$sender->sendMessage(KnownTranslationFactory::commands_clear_failure_no_items($target->getName())->baseTextFormat(TextFormat::RED));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -68,7 +68,7 @@ class EffectCommand extends VanillaCommand{
|
||||
|
||||
$effect = StringToEffectParser::getInstance()->parse($args[1]);
|
||||
if($effect === null){
|
||||
$sender->sendMessage(KnownTranslationFactory::commands_effect_notFound($args[1])->prefix(TextFormat::RED));
|
||||
$sender->sendMessage(KnownTranslationFactory::commands_effect_notFound($args[1])->baseTextFormat(TextFormat::RED));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ class GiveCommand extends VanillaCommand{
|
||||
try{
|
||||
$item = StringToItemParser::getInstance()->parse($args[1]) ?? LegacyStringToItemParser::getInstance()->parse($args[1]);
|
||||
}catch(LegacyStringToItemParserException $e){
|
||||
$sender->sendMessage(KnownTranslationFactory::commands_give_item_notFound($args[1])->prefix(TextFormat::RED));
|
||||
$sender->sendMessage(KnownTranslationFactory::commands_give_item_notFound($args[1])->baseTextFormat(TextFormat::RED));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -101,7 +101,7 @@ class GiveCommand extends VanillaCommand{
|
||||
$player->getInventory()->addItem($item);
|
||||
|
||||
Command::broadcastCommandMessage($sender, KnownTranslationFactory::commands_give_success(
|
||||
$item->getName() . " (" . $args[1] . ")",
|
||||
$item->getName() . TextFormat::RESET . " (" . $args[1] . ")",
|
||||
(string) $item->getCount(),
|
||||
$player->getName()
|
||||
));
|
||||
|
@ -105,22 +105,22 @@ class HelpCommand extends VanillaCommand{
|
||||
$sender->sendMessage(KnownTranslationFactory::pocketmine_command_help_specificCommand_header($cmd->getLabel())
|
||||
->format(TextFormat::YELLOW . "--------- " . TextFormat::RESET, TextFormat::YELLOW . " ---------"));
|
||||
$sender->sendMessage(KnownTranslationFactory::pocketmine_command_help_specificCommand_description(TextFormat::RESET . $descriptionString)
|
||||
->prefix(TextFormat::GOLD));
|
||||
->baseTextFormat(TextFormat::GOLD));
|
||||
|
||||
$usage = $cmd->getUsage();
|
||||
$usageString = $usage instanceof Translatable ? $lang->translate($usage) : $usage;
|
||||
$sender->sendMessage(KnownTranslationFactory::pocketmine_command_help_specificCommand_usage(TextFormat::RESET . implode("\n" . TextFormat::RESET, explode("\n", $usageString, limit: PHP_INT_MAX)))
|
||||
->prefix(TextFormat::GOLD));
|
||||
->baseTextFormat(TextFormat::GOLD));
|
||||
|
||||
$aliases = $cmd->getAliases();
|
||||
sort($aliases, SORT_NATURAL);
|
||||
$sender->sendMessage(KnownTranslationFactory::pocketmine_command_help_specificCommand_aliases(TextFormat::RESET . implode(", ", $aliases))
|
||||
->prefix(TextFormat::GOLD));
|
||||
->baseTextFormat(TextFormat::GOLD));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
$sender->sendMessage(KnownTranslationFactory::pocketmine_command_notFound($commandName, "/help")->prefix(TextFormat::RED));
|
||||
$sender->sendMessage(KnownTranslationFactory::pocketmine_command_notFound($commandName, "/help")->baseTextFormat(TextFormat::RED));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ class ParticleCommand extends VanillaCommand{
|
||||
$particle = $this->getParticle($name, $data);
|
||||
|
||||
if($particle === null){
|
||||
$sender->sendMessage(KnownTranslationFactory::commands_particle_notFound($name)->prefix(TextFormat::RED));
|
||||
$sender->sendMessage(KnownTranslationFactory::commands_particle_notFound($name)->baseTextFormat(TextFormat::RED));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ class SayCommand extends VanillaCommand{
|
||||
$sender->getServer()->broadcastMessage(KnownTranslationFactory::chat_type_announcement(
|
||||
$sender instanceof Player ? $sender->getDisplayName() : ($sender instanceof ConsoleCommandSender ? "Server" : $sender->getName()),
|
||||
implode(" ", $args)
|
||||
)->prefix(TextFormat::LIGHT_PURPLE));
|
||||
)->baseTextFormat(TextFormat::LIGHT_PURPLE));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -60,9 +60,9 @@ class TellCommand extends VanillaCommand{
|
||||
|
||||
if($player instanceof Player){
|
||||
$message = implode(" ", $args);
|
||||
$sender->sendMessage(KnownTranslationFactory::commands_message_display_outgoing($player->getDisplayName(), $message)->prefix(TextFormat::GRAY . TextFormat::ITALIC));
|
||||
$sender->sendMessage(KnownTranslationFactory::commands_message_display_outgoing($player->getDisplayName(), $message)->baseTextFormat(TextFormat::GRAY . TextFormat::ITALIC));
|
||||
$name = $sender instanceof Player ? $sender->getDisplayName() : $sender->getName();
|
||||
$player->sendMessage(KnownTranslationFactory::commands_message_display_incoming($name, $message)->prefix(TextFormat::GRAY . TextFormat::ITALIC));
|
||||
$player->sendMessage(KnownTranslationFactory::commands_message_display_incoming($name, $message)->baseTextFormat(TextFormat::GRAY . TextFormat::ITALIC));
|
||||
Command::broadcastCommandMessage($sender, KnownTranslationFactory::commands_message_display_outgoing($player->getDisplayName(), $message), false);
|
||||
}else{
|
||||
$sender->sendMessage(KnownTranslationFactory::commands_generic_player_notFound());
|
||||
|
@ -99,11 +99,11 @@ abstract class VanillaCommand extends Command{
|
||||
|
||||
$v = (int) $input;
|
||||
if($v > $max){
|
||||
$sender->sendMessage(KnownTranslationFactory::commands_generic_num_tooBig($input, (string) $max)->prefix(TextFormat::RED));
|
||||
$sender->sendMessage(KnownTranslationFactory::commands_generic_num_tooBig($input, (string) $max)->baseTextFormat(TextFormat::RED));
|
||||
return null;
|
||||
}
|
||||
if($v < $min){
|
||||
$sender->sendMessage(KnownTranslationFactory::commands_generic_num_tooSmall($input, (string) $min)->prefix(TextFormat::RED));
|
||||
$sender->sendMessage(KnownTranslationFactory::commands_generic_num_tooSmall($input, (string) $min)->baseTextFormat(TextFormat::RED));
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -31,8 +31,7 @@ final class BedrockDataFiles{
|
||||
}
|
||||
|
||||
public const BANNER_PATTERNS_JSON = BEDROCK_DATA_PATH . '/banner_patterns.json';
|
||||
public const BIOME_DEFINITIONS_NBT = BEDROCK_DATA_PATH . '/biome_definitions.nbt';
|
||||
public const BIOME_DEFINITIONS_FULL_NBT = BEDROCK_DATA_PATH . '/biome_definitions_full.nbt';
|
||||
public const BIOME_DEFINITIONS_JSON = BEDROCK_DATA_PATH . '/biome_definitions.json';
|
||||
public const BIOME_ID_MAP_JSON = BEDROCK_DATA_PATH . '/biome_id_map.json';
|
||||
public const BLOCK_ID_TO_ITEM_ID_MAP_JSON = BEDROCK_DATA_PATH . '/block_id_to_item_id_map.json';
|
||||
public const BLOCK_PROPERTIES_TABLE_JSON = BEDROCK_DATA_PATH . '/block_properties_table.json';
|
||||
|
66
src/data/bedrock/WorldDataVersions.php
Normal file
66
src/data/bedrock/WorldDataVersions.php
Normal file
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\data\bedrock;
|
||||
|
||||
use pocketmine\world\format\io\leveldb\ChunkVersion;
|
||||
use pocketmine\world\format\io\leveldb\SubChunkVersion;
|
||||
|
||||
/**
|
||||
* All version infos related to current Minecraft data version support
|
||||
* These are mostly related to world storage but may also influence network stuff
|
||||
*/
|
||||
final class WorldDataVersions{
|
||||
/**
|
||||
* Bedrock version of the most recent backwards-incompatible change to blockstates.
|
||||
*
|
||||
* This is *NOT* the same as current game version. It should match the numbers in the
|
||||
* newest blockstate upgrade schema used in BedrockBlockUpgradeSchema.
|
||||
*/
|
||||
public const BLOCK_STATES =
|
||||
(1 << 24) | //major
|
||||
(21 << 16) | //minor
|
||||
(60 << 8) | //patch
|
||||
(33); //revision
|
||||
|
||||
public const CHUNK = ChunkVersion::v1_21_40;
|
||||
public const SUBCHUNK = SubChunkVersion::PALETTED_MULTI;
|
||||
|
||||
public const STORAGE = 10;
|
||||
|
||||
/**
|
||||
* Highest NetworkVersion of Bedrock worlds currently supported by PocketMine-MP.
|
||||
*
|
||||
* This may be lower than the current protocol version if PocketMine-MP does not yet support features of the newer
|
||||
* version. This allows the protocol to be updated independently of world format support.
|
||||
*/
|
||||
public const NETWORK = 800;
|
||||
|
||||
public const LAST_OPENED_IN = [
|
||||
1, //major
|
||||
21, //minor
|
||||
80, //patch
|
||||
3, //revision
|
||||
0 //is beta
|
||||
];
|
||||
}
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\data\bedrock\block;
|
||||
|
||||
use pocketmine\data\bedrock\WorldDataVersions;
|
||||
use pocketmine\nbt\NbtException;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\nbt\tag\Tag;
|
||||
@ -36,17 +37,7 @@ use function implode;
|
||||
* Contains the common information found in a serialized blockstate.
|
||||
*/
|
||||
final class BlockStateData{
|
||||
/**
|
||||
* Bedrock version of the most recent backwards-incompatible change to blockstates.
|
||||
*
|
||||
* This is *not* the same as current game version. It should match the numbers in the
|
||||
* newest blockstate upgrade schema used in BedrockBlockUpgradeSchema.
|
||||
*/
|
||||
public const CURRENT_VERSION =
|
||||
(1 << 24) | //major
|
||||
(21 << 16) | //minor
|
||||
(70 << 8) | //patch
|
||||
(1); //revision
|
||||
public const CURRENT_VERSION = WorldDataVersions::BLOCK_STATES;
|
||||
|
||||
public const TAG_NAME = "name";
|
||||
public const TAG_STATES = "states";
|
||||
|
@ -113,6 +113,7 @@ final class BlockStateNames{
|
||||
public const RAIL_DATA_BIT = "rail_data_bit";
|
||||
public const RAIL_DIRECTION = "rail_direction";
|
||||
public const REDSTONE_SIGNAL = "redstone_signal";
|
||||
public const REHYDRATION_LEVEL = "rehydration_level";
|
||||
public const REPEATER_DELAY = "repeater_delay";
|
||||
public const RESPAWN_ANCHOR_CHARGE = "respawn_anchor_charge";
|
||||
public const ROTATION = "rotation";
|
||||
|
@ -392,6 +392,7 @@ final class BlockTypeNames{
|
||||
public const DOUBLE_CUT_COPPER_SLAB = "minecraft:double_cut_copper_slab";
|
||||
public const DRAGON_EGG = "minecraft:dragon_egg";
|
||||
public const DRAGON_HEAD = "minecraft:dragon_head";
|
||||
public const DRIED_GHAST = "minecraft:dried_ghast";
|
||||
public const DRIED_KELP_BLOCK = "minecraft:dried_kelp_block";
|
||||
public const DRIPSTONE_BLOCK = "minecraft:dripstone_block";
|
||||
public const DROPPER = "minecraft:dropper";
|
||||
|
@ -122,6 +122,7 @@ use pocketmine\block\RedstoneRepeater;
|
||||
use pocketmine\block\RedstoneTorch;
|
||||
use pocketmine\block\RedstoneWire;
|
||||
use pocketmine\block\ResinClump;
|
||||
use pocketmine\block\RespawnAnchor;
|
||||
use pocketmine\block\RuntimeBlockStateRegistry;
|
||||
use pocketmine\block\Sapling;
|
||||
use pocketmine\block\SeaPickle;
|
||||
@ -225,6 +226,10 @@ final class BlockObjectToStateSerializer implements BlockStateSerializer{
|
||||
return $this->cache[$stateId] ??= $this->serializeBlock(RuntimeBlockStateRegistry::getInstance()->fromStateId($stateId));
|
||||
}
|
||||
|
||||
public function isRegistered(Block $block) : bool{
|
||||
return isset($this->serializers[$block->getTypeId()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @phpstan-template TBlockType of Block
|
||||
* @phpstan-param TBlockType $block
|
||||
@ -1750,6 +1755,10 @@ final class BlockObjectToStateSerializer implements BlockStateSerializer{
|
||||
return Writer::create(Ids::RESIN_CLUMP)
|
||||
->writeFacingFlags($block->getFaces());
|
||||
});
|
||||
$this->map(Blocks::RESPAWN_ANCHOR(), function(RespawnAnchor $block) : Writer{
|
||||
return Writer::create(Ids::RESPAWN_ANCHOR)
|
||||
->writeInt(StateNames::RESPAWN_ANCHOR_CHARGE, $block->getCharges());
|
||||
});
|
||||
$this->map(Blocks::ROSE_BUSH(), fn(DoublePlant $block) => Helper::encodeDoublePlant($block, Writer::create(Ids::ROSE_BUSH)));
|
||||
$this->mapSlab(Blocks::SANDSTONE_SLAB(), Ids::SANDSTONE_SLAB, Ids::SANDSTONE_DOUBLE_SLAB);
|
||||
$this->mapStairs(Blocks::SANDSTONE_STAIRS(), Ids::SANDSTONE_STAIRS);
|
||||
|
@ -1717,6 +1717,10 @@ final class BlockStateToObjectDeserializer implements BlockStateDeserializer{
|
||||
$this->mapStairs(Ids::RESIN_BRICK_STAIRS, fn() => Blocks::RESIN_BRICK_STAIRS());
|
||||
$this->map(Ids::RESIN_BRICK_WALL, fn(Reader $in) => Helper::decodeWall(Blocks::RESIN_BRICK_WALL(), $in));
|
||||
$this->map(Ids::RESIN_CLUMP, fn(Reader $in) => Blocks::RESIN_CLUMP()->setFaces($in->readFacingFlags()));
|
||||
$this->map(Ids::RESPAWN_ANCHOR, function(Reader $in) : Block{
|
||||
return Blocks::RESPAWN_ANCHOR()
|
||||
->setCharges($in->readBoundedInt(StateNames::RESPAWN_ANCHOR_CHARGE, 0, 4));
|
||||
});
|
||||
$this->mapSlab(Ids::SANDSTONE_SLAB, Ids::SANDSTONE_DOUBLE_SLAB, fn() => Blocks::SANDSTONE_SLAB());
|
||||
$this->mapStairs(Ids::SANDSTONE_STAIRS, fn() => Blocks::SANDSTONE_STAIRS());
|
||||
$this->map(Ids::SANDSTONE_WALL, fn(Reader $in) => Helper::decodeWall(Blocks::SANDSTONE_WALL(), $in));
|
||||
|
@ -68,6 +68,7 @@ final class ItemTypeNames{
|
||||
public const BIRCH_SIGN = "minecraft:birch_sign";
|
||||
public const BLACK_BUNDLE = "minecraft:black_bundle";
|
||||
public const BLACK_DYE = "minecraft:black_dye";
|
||||
public const BLACK_HARNESS = "minecraft:black_harness";
|
||||
public const BLADE_POTTERY_SHERD = "minecraft:blade_pottery_sherd";
|
||||
public const BLAZE_POWDER = "minecraft:blaze_powder";
|
||||
public const BLAZE_ROD = "minecraft:blaze_rod";
|
||||
@ -76,6 +77,7 @@ final class ItemTypeNames{
|
||||
public const BLUE_BUNDLE = "minecraft:blue_bundle";
|
||||
public const BLUE_DYE = "minecraft:blue_dye";
|
||||
public const BLUE_EGG = "minecraft:blue_egg";
|
||||
public const BLUE_HARNESS = "minecraft:blue_harness";
|
||||
public const BOARD = "minecraft:board";
|
||||
public const BOAT = "minecraft:boat";
|
||||
public const BOGGED_SPAWN_EGG = "minecraft:bogged_spawn_egg";
|
||||
@ -95,6 +97,7 @@ final class ItemTypeNames{
|
||||
public const BROWN_BUNDLE = "minecraft:brown_bundle";
|
||||
public const BROWN_DYE = "minecraft:brown_dye";
|
||||
public const BROWN_EGG = "minecraft:brown_egg";
|
||||
public const BROWN_HARNESS = "minecraft:brown_harness";
|
||||
public const BRUSH = "minecraft:brush";
|
||||
public const BUCKET = "minecraft:bucket";
|
||||
public const BUNDLE = "minecraft:bundle";
|
||||
@ -166,6 +169,7 @@ final class ItemTypeNames{
|
||||
public const CROSSBOW = "minecraft:crossbow";
|
||||
public const CYAN_BUNDLE = "minecraft:cyan_bundle";
|
||||
public const CYAN_DYE = "minecraft:cyan_dye";
|
||||
public const CYAN_HARNESS = "minecraft:cyan_harness";
|
||||
public const DANGER_POTTERY_SHERD = "minecraft:danger_pottery_sherd";
|
||||
public const DARK_OAK_BOAT = "minecraft:dark_oak_boat";
|
||||
public const DARK_OAK_CHEST_BOAT = "minecraft:dark_oak_chest_boat";
|
||||
@ -265,12 +269,15 @@ final class ItemTypeNames{
|
||||
public const GOLDEN_SWORD = "minecraft:golden_sword";
|
||||
public const GRAY_BUNDLE = "minecraft:gray_bundle";
|
||||
public const GRAY_DYE = "minecraft:gray_dye";
|
||||
public const GRAY_HARNESS = "minecraft:gray_harness";
|
||||
public const GREEN_BUNDLE = "minecraft:green_bundle";
|
||||
public const GREEN_DYE = "minecraft:green_dye";
|
||||
public const GREEN_HARNESS = "minecraft:green_harness";
|
||||
public const GUARDIAN_SPAWN_EGG = "minecraft:guardian_spawn_egg";
|
||||
public const GUNPOWDER = "minecraft:gunpowder";
|
||||
public const GUSTER_BANNER_PATTERN = "minecraft:guster_banner_pattern";
|
||||
public const GUSTER_POTTERY_SHERD = "minecraft:guster_pottery_sherd";
|
||||
public const HAPPY_GHAST_SPAWN_EGG = "minecraft:happy_ghast_spawn_egg";
|
||||
public const HARD_STAINED_GLASS = "minecraft:hard_stained_glass";
|
||||
public const HARD_STAINED_GLASS_PANE = "minecraft:hard_stained_glass_pane";
|
||||
public const HEART_OF_THE_SEA = "minecraft:heart_of_the_sea";
|
||||
@ -321,10 +328,13 @@ final class ItemTypeNames{
|
||||
public const LIGHT_BLOCK = "minecraft:light_block";
|
||||
public const LIGHT_BLUE_BUNDLE = "minecraft:light_blue_bundle";
|
||||
public const LIGHT_BLUE_DYE = "minecraft:light_blue_dye";
|
||||
public const LIGHT_BLUE_HARNESS = "minecraft:light_blue_harness";
|
||||
public const LIGHT_GRAY_BUNDLE = "minecraft:light_gray_bundle";
|
||||
public const LIGHT_GRAY_DYE = "minecraft:light_gray_dye";
|
||||
public const LIGHT_GRAY_HARNESS = "minecraft:light_gray_harness";
|
||||
public const LIME_BUNDLE = "minecraft:lime_bundle";
|
||||
public const LIME_DYE = "minecraft:lime_dye";
|
||||
public const LIME_HARNESS = "minecraft:lime_harness";
|
||||
public const LINGERING_POTION = "minecraft:lingering_potion";
|
||||
public const LLAMA_SPAWN_EGG = "minecraft:llama_spawn_egg";
|
||||
public const LODESTONE_COMPASS = "minecraft:lodestone_compass";
|
||||
@ -333,6 +343,7 @@ final class ItemTypeNames{
|
||||
public const MACE = "minecraft:mace";
|
||||
public const MAGENTA_BUNDLE = "minecraft:magenta_bundle";
|
||||
public const MAGENTA_DYE = "minecraft:magenta_dye";
|
||||
public const MAGENTA_HARNESS = "minecraft:magenta_harness";
|
||||
public const MAGMA_CREAM = "minecraft:magma_cream";
|
||||
public const MAGMA_CUBE_SPAWN_EGG = "minecraft:magma_cube_spawn_egg";
|
||||
public const MANGROVE_BOAT = "minecraft:mangrove_boat";
|
||||
@ -400,6 +411,7 @@ final class ItemTypeNames{
|
||||
public const OMINOUS_TRIAL_KEY = "minecraft:ominous_trial_key";
|
||||
public const ORANGE_BUNDLE = "minecraft:orange_bundle";
|
||||
public const ORANGE_DYE = "minecraft:orange_dye";
|
||||
public const ORANGE_HARNESS = "minecraft:orange_harness";
|
||||
public const OXIDIZED_COPPER_DOOR = "minecraft:oxidized_copper_door";
|
||||
public const PAINTING = "minecraft:painting";
|
||||
public const PALE_OAK_BOAT = "minecraft:pale_oak_boat";
|
||||
@ -419,6 +431,7 @@ final class ItemTypeNames{
|
||||
public const PILLAGER_SPAWN_EGG = "minecraft:pillager_spawn_egg";
|
||||
public const PINK_BUNDLE = "minecraft:pink_bundle";
|
||||
public const PINK_DYE = "minecraft:pink_dye";
|
||||
public const PINK_HARNESS = "minecraft:pink_harness";
|
||||
public const PITCHER_POD = "minecraft:pitcher_pod";
|
||||
public const PLANKS = "minecraft:planks";
|
||||
public const PLENTY_POTTERY_SHERD = "minecraft:plenty_pottery_sherd";
|
||||
@ -439,6 +452,7 @@ final class ItemTypeNames{
|
||||
public const PUMPKIN_SEEDS = "minecraft:pumpkin_seeds";
|
||||
public const PURPLE_BUNDLE = "minecraft:purple_bundle";
|
||||
public const PURPLE_DYE = "minecraft:purple_dye";
|
||||
public const PURPLE_HARNESS = "minecraft:purple_harness";
|
||||
public const QUARTZ = "minecraft:quartz";
|
||||
public const RABBIT = "minecraft:rabbit";
|
||||
public const RABBIT_FOOT = "minecraft:rabbit_foot";
|
||||
@ -455,6 +469,7 @@ final class ItemTypeNames{
|
||||
public const RED_BUNDLE = "minecraft:red_bundle";
|
||||
public const RED_DYE = "minecraft:red_dye";
|
||||
public const RED_FLOWER = "minecraft:red_flower";
|
||||
public const RED_HARNESS = "minecraft:red_harness";
|
||||
public const REDSTONE = "minecraft:redstone";
|
||||
public const REPEATER = "minecraft:repeater";
|
||||
public const RESIN_BRICK = "minecraft:resin_brick";
|
||||
@ -563,6 +578,7 @@ final class ItemTypeNames{
|
||||
public const WHEAT_SEEDS = "minecraft:wheat_seeds";
|
||||
public const WHITE_BUNDLE = "minecraft:white_bundle";
|
||||
public const WHITE_DYE = "minecraft:white_dye";
|
||||
public const WHITE_HARNESS = "minecraft:white_harness";
|
||||
public const WILD_ARMOR_TRIM_SMITHING_TEMPLATE = "minecraft:wild_armor_trim_smithing_template";
|
||||
public const WIND_CHARGE = "minecraft:wind_charge";
|
||||
public const WITCH_SPAWN_EGG = "minecraft:witch_spawn_egg";
|
||||
@ -583,6 +599,7 @@ final class ItemTypeNames{
|
||||
public const WRITTEN_BOOK = "minecraft:written_book";
|
||||
public const YELLOW_BUNDLE = "minecraft:yellow_bundle";
|
||||
public const YELLOW_DYE = "minecraft:yellow_dye";
|
||||
public const YELLOW_HARNESS = "minecraft:yellow_harness";
|
||||
public const ZOGLIN_SPAWN_EGG = "minecraft:zoglin_spawn_egg";
|
||||
public const ZOMBIE_HORSE_SPAWN_EGG = "minecraft:zombie_horse_spawn_egg";
|
||||
public const ZOMBIE_PIGMAN_SPAWN_EGG = "minecraft:zombie_pigman_spawn_egg";
|
||||
|
@ -31,6 +31,7 @@ use pocketmine\block\Water;
|
||||
use pocketmine\entity\animation\Animation;
|
||||
use pocketmine\event\entity\EntityDamageEvent;
|
||||
use pocketmine\event\entity\EntityDespawnEvent;
|
||||
use pocketmine\event\entity\EntityExtinguishEvent;
|
||||
use pocketmine\event\entity\EntityMotionEvent;
|
||||
use pocketmine\event\entity\EntityRegainHealthEvent;
|
||||
use pocketmine\event\entity\EntitySpawnEvent;
|
||||
@ -60,6 +61,7 @@ use pocketmine\player\Player;
|
||||
use pocketmine\Server;
|
||||
use pocketmine\timings\Timings;
|
||||
use pocketmine\timings\TimingsHandler;
|
||||
use pocketmine\utils\Limits;
|
||||
use pocketmine\utils\Utils;
|
||||
use pocketmine\VersionInfo;
|
||||
use pocketmine\world\format\Chunk;
|
||||
@ -76,6 +78,7 @@ use function floatval;
|
||||
use function floor;
|
||||
use function fmod;
|
||||
use function get_class;
|
||||
use function min;
|
||||
use function sin;
|
||||
use function spl_object_id;
|
||||
use const M_PI_2;
|
||||
@ -700,16 +703,26 @@ abstract class Entity{
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function setFireTicks(int $fireTicks) : void{
|
||||
if($fireTicks < 0 || $fireTicks > 0x7fff){
|
||||
throw new \InvalidArgumentException("Fire ticks must be in range 0 ... " . 0x7fff . ", got $fireTicks");
|
||||
if($fireTicks < 0){
|
||||
throw new \InvalidArgumentException("Fire ticks cannot be negative");
|
||||
}
|
||||
|
||||
//Since the max value is not externally obvious or intuitive, many plugins use this without being aware that
|
||||
//reasonably large values are not accepted. We even have such usages within PM itself. It doesn't make sense
|
||||
//to force all those calls to be aware of this limitation, as it's not a functional limit but a limitation of
|
||||
//the Mojang save format. Truncating this to the max acceptable value is the next best thing we can do.
|
||||
$fireTicks = min($fireTicks, Limits::INT16_MAX);
|
||||
|
||||
if(!$this->isFireProof()){
|
||||
$this->fireTicks = $fireTicks;
|
||||
$this->networkPropertiesDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
public function extinguish() : void{
|
||||
public function extinguish(int $cause = EntityExtinguishEvent::CAUSE_CUSTOM) : void{
|
||||
$ev = new EntityExtinguishEvent($this, $cause);
|
||||
$ev->call();
|
||||
|
||||
$this->fireTicks = 0;
|
||||
$this->networkPropertiesDirty = true;
|
||||
}
|
||||
@ -720,7 +733,7 @@ abstract class Entity{
|
||||
|
||||
protected function doOnFireTick(int $tickDiff = 1) : bool{
|
||||
if($this->isFireProof() && $this->isOnFire()){
|
||||
$this->extinguish();
|
||||
$this->extinguish(EntityExtinguishEvent::CAUSE_FIRE_PROOF);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -731,7 +744,7 @@ abstract class Entity{
|
||||
}
|
||||
|
||||
if(!$this->isOnFire()){
|
||||
$this->extinguish();
|
||||
$this->extinguish(EntityExtinguishEvent::CAUSE_TICKING);
|
||||
}else{
|
||||
return true;
|
||||
}
|
||||
@ -1178,12 +1191,14 @@ abstract class Entity{
|
||||
|
||||
$moveBB->offset(0, 0, $dz);
|
||||
|
||||
if($this->stepHeight > 0 && $fallingFlag && ($wantedX !== $dx || $wantedZ !== $dz)){
|
||||
$stepHeight = $this->getStepHeight();
|
||||
|
||||
if($stepHeight > 0 && $fallingFlag && ($wantedX !== $dx || $wantedZ !== $dz)){
|
||||
$cx = $dx;
|
||||
$cy = $dy;
|
||||
$cz = $dz;
|
||||
$dx = $wantedX;
|
||||
$dy = $this->stepHeight;
|
||||
$dy = $stepHeight;
|
||||
$dz = $wantedZ;
|
||||
|
||||
$stepBB = clone $this->boundingBox;
|
||||
@ -1253,6 +1268,14 @@ abstract class Entity{
|
||||
Timings::$entityMove->stopTiming();
|
||||
}
|
||||
|
||||
public function setStepHeight(float $stepHeight) : void{
|
||||
$this->stepHeight = $stepHeight;
|
||||
}
|
||||
|
||||
public function getStepHeight() : float{
|
||||
return $this->stepHeight;
|
||||
}
|
||||
|
||||
protected function checkGroundState(float $wantedX, float $wantedY, float $wantedZ, float $dx, float $dy, float $dz) : void{
|
||||
$this->isCollidedVertically = $wantedY !== $dy;
|
||||
$this->isCollidedHorizontally = ($wantedX !== $dx || $wantedZ !== $dz);
|
||||
|
@ -219,6 +219,13 @@ final class EntityFactory{
|
||||
$this->saveNames[$className] = reset($saveNames);
|
||||
}
|
||||
|
||||
/**
|
||||
* @phpstan-param class-string<Entity> $class
|
||||
*/
|
||||
public function isRegistered(string $class) : bool{
|
||||
return isset($this->saveNames[$class]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an entity from data stored on a chunk.
|
||||
*
|
||||
|
@ -38,6 +38,7 @@ use pocketmine\event\entity\EntityDamageByChildEntityEvent;
|
||||
use pocketmine\event\entity\EntityDamageByEntityEvent;
|
||||
use pocketmine\event\entity\EntityDamageEvent;
|
||||
use pocketmine\event\entity\EntityDeathEvent;
|
||||
use pocketmine\event\entity\EntityFrostWalkerEvent;
|
||||
use pocketmine\inventory\ArmorInventory;
|
||||
use pocketmine\inventory\CallbackInventoryListener;
|
||||
use pocketmine\inventory\Inventory;
|
||||
@ -721,19 +722,30 @@ abstract class Living extends Entity{
|
||||
$y = $this->location->getFloorY() - 1;
|
||||
$baseZ = $this->location->getFloorZ();
|
||||
|
||||
$frostedIce = VanillaBlocks::FROSTED_ICE();
|
||||
$liquid = VanillaBlocks::WATER();
|
||||
$targetBlock = VanillaBlocks::FROSTED_ICE();
|
||||
if(EntityFrostWalkerEvent::hasHandlers()){
|
||||
$ev = new EntityFrostWalkerEvent($this, $radius, $liquid, $targetBlock);
|
||||
$ev->call();
|
||||
if($ev->isCancelled()){
|
||||
return;
|
||||
}
|
||||
$radius = $ev->getRadius();
|
||||
$liquid = $ev->getLiquid();
|
||||
$targetBlock = $ev->getTargetBlock();
|
||||
}
|
||||
|
||||
for($x = $baseX - $radius; $x <= $baseX + $radius; $x++){
|
||||
for($z = $baseZ - $radius; $z <= $baseZ + $radius; $z++){
|
||||
$block = $world->getBlockAt($x, $y, $z);
|
||||
if(
|
||||
!$block instanceof Water ||
|
||||
!$block->isSource() ||
|
||||
!$block->isSameState($liquid) ||
|
||||
$world->getBlockAt($x, $y + 1, $z)->getTypeId() !== BlockTypeIds::AIR ||
|
||||
count($world->getNearbyEntities(AxisAlignedBB::one()->offset($x, $y, $z))) !== 0
|
||||
){
|
||||
continue;
|
||||
}
|
||||
$world->setBlockAt($x, $y, $z, $frostedIce);
|
||||
$world->setBlockAt($x, $y, $z, $targetBlock);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ class EndCrystal extends Entity implements Explosive{
|
||||
$ev = new EntityPreExplodeEvent($this, 6);
|
||||
$ev->call();
|
||||
if(!$ev->isCancelled()){
|
||||
$explosion = new Explosion($this->getPosition(), $ev->getRadius(), $this);
|
||||
$explosion = new Explosion($this->getPosition(), $ev->getRadius(), $this, $ev->getFireChance());
|
||||
if($ev->isBlockBreaking()){
|
||||
$explosion->explodeA();
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ class PrimedTNT extends Entity implements Explosive{
|
||||
$ev->call();
|
||||
if(!$ev->isCancelled()){
|
||||
//TODO: deal with underwater TNT (underwater TNT treats water as if it has a blast resistance of 0)
|
||||
$explosion = new Explosion(Position::fromObject($this->location->add(0, $this->size->getHeight() / 2, 0), $this->getWorld()), $ev->getRadius(), $this);
|
||||
$explosion = new Explosion(Position::fromObject($this->location->add(0, $this->size->getHeight() / 2, 0), $this->getWorld()), $ev->getRadius(), $this, $ev->getFireChance());
|
||||
if($ev->isBlockBreaking()){
|
||||
$explosion->explodeA();
|
||||
}
|
||||
|
122
src/event/block/BlockExplodeEvent.php
Normal file
122
src/event/block/BlockExplodeEvent.php
Normal file
@ -0,0 +1,122 @@
|
||||
<?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\event\block;
|
||||
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\event\Cancellable;
|
||||
use pocketmine\event\CancellableTrait;
|
||||
use pocketmine\utils\Utils;
|
||||
use pocketmine\world\Position;
|
||||
|
||||
/**
|
||||
* Called when a block explodes, after explosion impact has been calculated.
|
||||
*
|
||||
* @see BlockPreExplodeEvent
|
||||
*/
|
||||
class BlockExplodeEvent extends BlockEvent implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
/**
|
||||
* @param Block[] $blocks
|
||||
* @param Block[] $ignitions
|
||||
*/
|
||||
public function __construct(
|
||||
Block $block,
|
||||
private Position $position,
|
||||
private array $blocks,
|
||||
private float $yield,
|
||||
private array $ignitions
|
||||
){
|
||||
parent::__construct($block);
|
||||
|
||||
Utils::checkFloatNotInfOrNaN("yield", $yield);
|
||||
if($yield < 0.0 || $yield > 100.0){
|
||||
throw new \InvalidArgumentException("Yield must be in range 0.0 - 100.0");
|
||||
}
|
||||
}
|
||||
|
||||
public function getPosition() : Position{
|
||||
return $this->position;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the percentage chance of drops from each block destroyed by the explosion.
|
||||
*
|
||||
* @return float 0-100
|
||||
*/
|
||||
public function getYield() : float{
|
||||
return $this->yield;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the percentage chance of drops from each block destroyed by the explosion.
|
||||
*
|
||||
* @param float $yield 0-100
|
||||
*/
|
||||
public function setYield(float $yield) : void{
|
||||
Utils::checkFloatNotInfOrNaN("yield", $yield);
|
||||
if($yield < 0.0 || $yield > 100.0){
|
||||
throw new \InvalidArgumentException("Yield must be in range 0.0 - 100.0");
|
||||
}
|
||||
$this->yield = $yield;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of blocks destroyed by the explosion.
|
||||
*
|
||||
* @return Block[]
|
||||
*/
|
||||
public function getAffectedBlocks() : array{
|
||||
return $this->blocks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the blocks destroyed by the explosion.
|
||||
*
|
||||
* @param Block[] $blocks
|
||||
*/
|
||||
public function setAffectedBlocks(array $blocks) : void{
|
||||
Utils::validateArrayValueType($blocks, fn(Block $block) => null);
|
||||
$this->blocks = $blocks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of affected blocks that will be replaced by fire.
|
||||
*
|
||||
* @return Block[]
|
||||
*/
|
||||
public function getIgnitions() : array{
|
||||
return $this->ignitions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the list of blocks that will be replaced by fire.
|
||||
*
|
||||
* @param Block[] $ignitions
|
||||
*/
|
||||
public function setIgnitions(array $ignitions) : void{
|
||||
Utils::validateArrayValueType($ignitions, fn(Block $block) => null);
|
||||
$this->ignitions = $ignitions;
|
||||
}
|
||||
}
|
129
src/event/block/BlockPreExplodeEvent.php
Normal file
129
src/event/block/BlockPreExplodeEvent.php
Normal file
@ -0,0 +1,129 @@
|
||||
<?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\event\block;
|
||||
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\event\Cancellable;
|
||||
use pocketmine\event\CancellableTrait;
|
||||
use pocketmine\player\Player;
|
||||
use pocketmine\utils\Utils;
|
||||
use pocketmine\world\Explosion;
|
||||
|
||||
/**
|
||||
* Called when a block wants to explode, before the explosion impact is calculated.
|
||||
* This allows changing the explosion force, fire chance and whether it will destroy blocks.
|
||||
*
|
||||
* @see BlockExplodeEvent
|
||||
*/
|
||||
class BlockPreExplodeEvent extends BlockEvent implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
private bool $blockBreaking = true;
|
||||
|
||||
public function __construct(
|
||||
Block $block,
|
||||
private float $radius,
|
||||
private readonly ?Player $player = null,
|
||||
private float $fireChance = 0.0
|
||||
){
|
||||
Utils::checkFloatNotInfOrNaN("radius", $radius);
|
||||
if($radius <= 0){
|
||||
throw new \InvalidArgumentException("Explosion radius must be positive");
|
||||
}
|
||||
Utils::checkFloatNotInfOrNaN("fireChance", $fireChance);
|
||||
if($fireChance < 0.0 || $fireChance > 1.0){
|
||||
throw new \InvalidArgumentException("Fire chance must be a number between 0 and 1.");
|
||||
}
|
||||
parent::__construct($block);
|
||||
}
|
||||
|
||||
public function getRadius() : float{
|
||||
return $this->radius;
|
||||
}
|
||||
|
||||
public function setRadius(float $radius) : void{
|
||||
Utils::checkFloatNotInfOrNaN("radius", $radius);
|
||||
if($radius <= 0){
|
||||
throw new \InvalidArgumentException("Explosion radius must be positive");
|
||||
}
|
||||
$this->radius = $radius;
|
||||
}
|
||||
|
||||
public function isBlockBreaking() : bool{
|
||||
return $this->blockBreaking;
|
||||
}
|
||||
|
||||
public function setBlockBreaking(bool $affectsBlocks) : void{
|
||||
$this->blockBreaking = $affectsBlocks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the explosion will create a fire.
|
||||
*/
|
||||
public function isIncendiary() : bool{
|
||||
return $this->fireChance > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether the explosion will create a fire by filling fireChance with default values.
|
||||
*
|
||||
* If $incendiary is true, the fire chance will be filled only if explosion isn't currently creating a fire (if fire chance is 0).
|
||||
*/
|
||||
public function setIncendiary(bool $incendiary) : void{
|
||||
if(!$incendiary){
|
||||
$this->fireChance = 0;
|
||||
}elseif($this->fireChance <= 0){
|
||||
$this->fireChance = Explosion::DEFAULT_FIRE_CHANCE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a chance between 0 and 1 of creating a fire.
|
||||
*/
|
||||
public function getFireChance() : float{
|
||||
return $this->fireChance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a chance between 0 and 1 of creating a fire.
|
||||
* For example, if the chance is 1/3, then that amount of affected blocks will be ignited.
|
||||
*
|
||||
* @param float $fireChance 0 ... 1
|
||||
*/
|
||||
public function setFireChance(float $fireChance) : void{
|
||||
Utils::checkFloatNotInfOrNaN("fireChance", $fireChance);
|
||||
if($fireChance < 0.0 || $fireChance > 1.0){
|
||||
throw new \InvalidArgumentException("Fire chance must be a number between 0 and 1.");
|
||||
}
|
||||
$this->fireChance = $fireChance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the player who triggered the block explosion.
|
||||
* Returns null if the block was exploded by other means.
|
||||
*/
|
||||
public function getPlayer() : ?Player{
|
||||
return $this->player;
|
||||
}
|
||||
}
|
@ -43,13 +43,15 @@ class EntityExplodeEvent extends EntityEvent implements Cancellable{
|
||||
|
||||
/**
|
||||
* @param Block[] $blocks
|
||||
* @param float $yield 0-100
|
||||
* @param float $yield 0-100
|
||||
* @param Block[] $ignitions
|
||||
*/
|
||||
public function __construct(
|
||||
Entity $entity,
|
||||
protected Position $position,
|
||||
protected array $blocks,
|
||||
protected float $yield
|
||||
protected float $yield,
|
||||
private array $ignitions
|
||||
){
|
||||
$this->entity = $entity;
|
||||
if($yield < 0.0 || $yield > 100.0){
|
||||
@ -98,4 +100,23 @@ class EntityExplodeEvent extends EntityEvent implements Cancellable{
|
||||
}
|
||||
$this->yield = $yield;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the list of blocks that will be replaced by fire.
|
||||
*
|
||||
* @param Block[] $ignitions
|
||||
*/
|
||||
public function setIgnitions(array $ignitions) : void{
|
||||
Utils::validateArrayValueType($ignitions, fn(Block $block) => null);
|
||||
$this->ignitions = $ignitions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of affected blocks that will be replaced by fire.
|
||||
*
|
||||
* @return Block[]
|
||||
*/
|
||||
public function getIgnitions() : array{
|
||||
return $this->ignitions;
|
||||
}
|
||||
}
|
||||
|
53
src/event/entity/EntityExtinguishEvent.php
Normal file
53
src/event/entity/EntityExtinguishEvent.php
Normal file
@ -0,0 +1,53 @@
|
||||
<?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\event\entity;
|
||||
|
||||
use pocketmine\entity\Entity;
|
||||
|
||||
/**
|
||||
* Called when an entity on fire gets extinguished.
|
||||
*
|
||||
* @phpstan-extends EntityEvent<Entity>
|
||||
*/
|
||||
class EntityExtinguishEvent extends EntityEvent{
|
||||
public const CAUSE_CUSTOM = 0;
|
||||
public const CAUSE_WATER = 1;
|
||||
public const CAUSE_WATER_CAULDRON = 2;
|
||||
public const CAUSE_RESPAWN = 3;
|
||||
public const CAUSE_FIRE_PROOF = 4;
|
||||
public const CAUSE_TICKING = 5;
|
||||
public const CAUSE_RAIN = 6;
|
||||
public const CAUSE_POWDER_SNOW = 7;
|
||||
|
||||
public function __construct(
|
||||
Entity $entity,
|
||||
private int $cause
|
||||
){
|
||||
$this->entity = $entity;
|
||||
}
|
||||
|
||||
public function getCause() : int{
|
||||
return $this->cause;
|
||||
}
|
||||
}
|
84
src/event/entity/EntityFrostWalkerEvent.php
Normal file
84
src/event/entity/EntityFrostWalkerEvent.php
Normal file
@ -0,0 +1,84 @@
|
||||
<?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\event\entity;
|
||||
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\block\Liquid;
|
||||
use pocketmine\entity\Living;
|
||||
use pocketmine\event\Cancellable;
|
||||
use pocketmine\event\CancellableTrait;
|
||||
|
||||
/**
|
||||
* Called when an entity moves horizontally while wearing boots enchanted with Frost Walker.
|
||||
*
|
||||
* @phpstan-extends EntityEvent<Living>
|
||||
*/
|
||||
class EntityFrostWalkerEvent extends EntityEvent implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
public function __construct(
|
||||
Living $entity,
|
||||
private int $radius,
|
||||
private Liquid $liquid,
|
||||
private Block $targetBlock
|
||||
){
|
||||
$this->entity = $entity;
|
||||
}
|
||||
|
||||
public function getRadius() : int{
|
||||
return $this->radius;
|
||||
}
|
||||
|
||||
public function setRadius(int $radius) : void{
|
||||
$this->radius = $radius;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the liquid that gets frozen
|
||||
*/
|
||||
public function getLiquid() : Liquid{
|
||||
return $this->liquid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the liquid that gets frozen
|
||||
*/
|
||||
public function setLiquid(Liquid $liquid) : void{
|
||||
$this->liquid = $liquid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the block that replaces the liquid
|
||||
*/
|
||||
public function getTargetBlock() : Block{
|
||||
return $this->targetBlock;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the block that replaces the liquid
|
||||
*/
|
||||
public function setTargetBlock(Block $targetBlock) : void{
|
||||
$this->targetBlock = $targetBlock;
|
||||
}
|
||||
}
|
@ -26,6 +26,8 @@ namespace pocketmine\event\entity;
|
||||
use pocketmine\entity\Entity;
|
||||
use pocketmine\event\Cancellable;
|
||||
use pocketmine\event\CancellableTrait;
|
||||
use pocketmine\utils\Utils;
|
||||
use pocketmine\world\Explosion;
|
||||
|
||||
/**
|
||||
* Called when an entity decides to explode, before the explosion's impact is calculated.
|
||||
@ -42,11 +44,16 @@ class EntityPreExplodeEvent extends EntityEvent implements Cancellable{
|
||||
|
||||
public function __construct(
|
||||
Entity $entity,
|
||||
protected float $radius
|
||||
protected float $radius,
|
||||
private float $fireChance = 0.0,
|
||||
){
|
||||
if($radius <= 0){
|
||||
throw new \InvalidArgumentException("Explosion radius must be positive");
|
||||
}
|
||||
Utils::checkFloatNotInfOrNaN("fireChance", $fireChance);
|
||||
if($fireChance < 0.0 || $fireChance > 1.0){
|
||||
throw new \InvalidArgumentException("Fire chance must be between 0 and 1.");
|
||||
}
|
||||
$this->entity = $entity;
|
||||
}
|
||||
|
||||
@ -61,6 +68,47 @@ class EntityPreExplodeEvent extends EntityEvent implements Cancellable{
|
||||
$this->radius = $radius;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the explosion will create a fire.
|
||||
*/
|
||||
public function isIncendiary() : bool{
|
||||
return $this->fireChance > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether the explosion will create a fire by filling fireChance with default values.
|
||||
*
|
||||
* If $incendiary is true, the fire chance will be filled only if explosion isn't currently creating a fire (if fire chance is 0).
|
||||
*/
|
||||
public function setIncendiary(bool $incendiary) : void{
|
||||
if(!$incendiary){
|
||||
$this->fireChance = 0;
|
||||
}elseif($this->fireChance <= 0){
|
||||
$this->fireChance = Explosion::DEFAULT_FIRE_CHANCE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a chance between 0 and 1 of creating a fire.
|
||||
*/
|
||||
public function getFireChance() : float{
|
||||
return $this->fireChance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a chance between 0 and 1 of creating a fire.
|
||||
* For example, if the chance is 1/3, then that amount of affected blocks will be ignited.
|
||||
*
|
||||
* @param float $fireChance 0 ... 1
|
||||
*/
|
||||
public function setFireChance(float $fireChance) : void{
|
||||
Utils::checkFloatNotInfOrNaN("fireChance", $fireChance);
|
||||
if($fireChance < 0.0 || $fireChance > 1.0){
|
||||
throw new \InvalidArgumentException("Fire chance must be between 0 and 1.");
|
||||
}
|
||||
$this->fireChance = $fireChance;
|
||||
}
|
||||
|
||||
public function isBlockBreaking() : bool{
|
||||
return $this->blockBreaking;
|
||||
}
|
||||
|
56
src/event/player/PlayerRespawnAnchorUseEvent.php
Normal file
56
src/event/player/PlayerRespawnAnchorUseEvent.php
Normal file
@ -0,0 +1,56 @@
|
||||
<?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\event\player;
|
||||
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\event\Cancellable;
|
||||
use pocketmine\event\CancellableTrait;
|
||||
use pocketmine\player\Player;
|
||||
|
||||
class PlayerRespawnAnchorUseEvent extends PlayerEvent implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
public const ACTION_EXPLODE = 0;
|
||||
public const ACTION_SET_SPAWN = 1;
|
||||
|
||||
public function __construct(
|
||||
Player $player,
|
||||
protected Block $block,
|
||||
private int $action = self::ACTION_EXPLODE
|
||||
){
|
||||
$this->player = $player;
|
||||
}
|
||||
|
||||
public function getBlock() : Block{
|
||||
return $this->block;
|
||||
}
|
||||
|
||||
public function getAction() : int{
|
||||
return $this->action;
|
||||
}
|
||||
|
||||
public function setAction(int $action) : void{
|
||||
$this->action = $action;
|
||||
}
|
||||
}
|
@ -256,7 +256,7 @@ abstract class BaseInventory implements Inventory, SlotValidatedInventory{
|
||||
$slotItem->setCount($slotItem->getCount() + $amount);
|
||||
$this->setItem($i, $slotItem);
|
||||
if($newItem->getCount() <= 0){
|
||||
break;
|
||||
return $newItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -270,7 +270,7 @@ abstract class BaseInventory implements Inventory, SlotValidatedInventory{
|
||||
$slotItem->setCount($amount);
|
||||
$this->setItem($slotIndex, $slotItem);
|
||||
if($newItem->getCount() <= 0){
|
||||
break;
|
||||
return $newItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -993,6 +993,7 @@ final class StringToItemParser extends StringToTParser{
|
||||
$result->registerBlock("resin_brick_wall", fn() => Blocks::RESIN_BRICK_WALL());
|
||||
$result->registerBlock("resin_bricks", fn() => Blocks::RESIN_BRICKS());
|
||||
$result->registerBlock("resin_clump", fn() => Blocks::RESIN_CLUMP());
|
||||
$result->registerBlock("respawn_anchor", fn() => Blocks::RESPAWN_ANCHOR());
|
||||
$result->registerBlock("rooted_dirt", fn() => Blocks::DIRT()->setDirtType(DirtType::ROOTED));
|
||||
$result->registerBlock("rose", fn() => Blocks::POPPY());
|
||||
$result->registerBlock("rose_bush", fn() => Blocks::ROSE_BUSH());
|
||||
|
@ -28,6 +28,7 @@ use pocketmine\item\enchantment\ItemEnchantmentTags as Tags;
|
||||
use pocketmine\item\enchantment\VanillaEnchantments as Enchantments;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\utils\SingletonTrait;
|
||||
use pocketmine\utils\Utils;
|
||||
use function array_filter;
|
||||
use function array_values;
|
||||
use function count;
|
||||
@ -129,6 +130,7 @@ final class AvailableEnchantmentRegistry{
|
||||
if(!$this->isRegistered($enchantment)){
|
||||
throw new \LogicException("Cannot set primary item tags for non-registered enchantment");
|
||||
}
|
||||
Utils::validateArrayValueType($tags, fn(string $v) => 1);
|
||||
$this->primaryItemTags[spl_object_id($enchantment)] = array_values($tags);
|
||||
}
|
||||
|
||||
@ -152,6 +154,7 @@ final class AvailableEnchantmentRegistry{
|
||||
if(!$this->isRegistered($enchantment)){
|
||||
throw new \LogicException("Cannot set secondary item tags for non-registered enchantment");
|
||||
}
|
||||
Utils::validateArrayValueType($tags, fn(string $v) => 1);
|
||||
$this->secondaryItemTags[spl_object_id($enchantment)] = array_values($tags);
|
||||
}
|
||||
|
||||
|
@ -3035,6 +3035,14 @@ final class KnownTranslationFactory{
|
||||
return new Translatable(KnownTranslationKeys::TILE_BED_TOOFAR, []);
|
||||
}
|
||||
|
||||
public static function tile_respawn_anchor_notValid() : Translatable{
|
||||
return new Translatable(KnownTranslationKeys::TILE_RESPAWN_ANCHOR_NOTVALID, []);
|
||||
}
|
||||
|
||||
public static function tile_respawn_anchor_respawnSet() : Translatable{
|
||||
return new Translatable(KnownTranslationKeys::TILE_RESPAWN_ANCHOR_RESPAWNSET, []);
|
||||
}
|
||||
|
||||
public static function view_distance() : Translatable{
|
||||
return new Translatable(KnownTranslationKeys::VIEW_DISTANCE, []);
|
||||
}
|
||||
|
@ -658,6 +658,8 @@ final class KnownTranslationKeys{
|
||||
public const TILE_BED_NOSLEEP = "tile.bed.noSleep";
|
||||
public const TILE_BED_OCCUPIED = "tile.bed.occupied";
|
||||
public const TILE_BED_TOOFAR = "tile.bed.tooFar";
|
||||
public const TILE_RESPAWN_ANCHOR_NOTVALID = "tile.respawn_anchor.notValid";
|
||||
public const TILE_RESPAWN_ANCHOR_RESPAWNSET = "tile.respawn_anchor.respawnSet";
|
||||
public const VIEW_DISTANCE = "view_distance";
|
||||
public const WELCOME_TO_POCKETMINE = "welcome_to_pocketmine";
|
||||
public const WHITELIST_ENABLE = "whitelist_enable";
|
||||
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\lang;
|
||||
|
||||
use pocketmine\utils\TextFormat;
|
||||
use pocketmine\utils\Utils;
|
||||
use Symfony\Component\Filesystem\Path;
|
||||
use function array_filter;
|
||||
@ -141,18 +142,26 @@ class Language{
|
||||
/**
|
||||
* @param (float|int|string|Translatable)[] $params
|
||||
*/
|
||||
public function translateString(string $str, array $params = [], ?string $onlyPrefix = null) : string{
|
||||
$baseText = ($onlyPrefix === null || str_starts_with($str, $onlyPrefix)) ? $this->internalGet($str) : null;
|
||||
if($baseText === null){ //key not found, embedded inside format string, or doesn't match prefix
|
||||
public function translateString(string $str, array $params = [], ?string $onlyPrefix = null, string $baseFormat = "") : string{
|
||||
if($onlyPrefix !== null && !str_starts_with($str, $onlyPrefix)){
|
||||
//plain key for client-side translation
|
||||
//% is added here if we add base format since this will turn into an embedded key
|
||||
return $baseFormat !== "" ? TextFormat::addBase($baseFormat, "%" . $str) : $str;
|
||||
}
|
||||
$baseText = $this->internalGet($str);
|
||||
if($baseText === null){ //key not found, embedded inside format string with %, or doesn't match prefix
|
||||
$baseText = $this->parseTranslation($str, $onlyPrefix);
|
||||
}
|
||||
|
||||
foreach(Utils::promoteKeys($params) as $i => $p){
|
||||
$replacement = $p instanceof Translatable ? $this->translate($p) : (string) $p;
|
||||
if($baseFormat !== ""){
|
||||
$replacement = TextFormat::addBase($baseFormat, $replacement) . TextFormat::RESET;
|
||||
}
|
||||
$baseText = str_replace("{%$i}", $replacement, $baseText);
|
||||
}
|
||||
|
||||
return $baseText;
|
||||
return $baseFormat !== "" ? TextFormat::addBase($baseFormat, $baseText) : $baseText;
|
||||
}
|
||||
|
||||
public function translate(Translatable $c) : string{
|
||||
@ -161,12 +170,17 @@ class Language{
|
||||
$baseText = $this->parseTranslation($c->getText());
|
||||
}
|
||||
|
||||
$baseFormat = $c->getBaseFormat();
|
||||
|
||||
foreach(Utils::promoteKeys($c->getParameters()) as $i => $p){
|
||||
$replacement = $p instanceof Translatable ? $this->translate($p) : $p;
|
||||
if($baseFormat !== ""){
|
||||
$replacement = TextFormat::addBase($baseFormat, $replacement) . TextFormat::RESET;
|
||||
}
|
||||
$baseText = str_replace("{%$i}", $replacement, $baseText);
|
||||
}
|
||||
|
||||
return $baseText;
|
||||
return $baseFormat !== "" ? TextFormat::addBase($baseFormat, $baseText) : $baseText;
|
||||
}
|
||||
|
||||
protected function internalGet(string $id) : ?string{
|
||||
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\lang;
|
||||
|
||||
use pocketmine\utils\TextFormat;
|
||||
use pocketmine\utils\Utils;
|
||||
|
||||
final class Translatable{
|
||||
@ -34,7 +35,8 @@ final class Translatable{
|
||||
*/
|
||||
public function __construct(
|
||||
protected string $text,
|
||||
array $params = []
|
||||
array $params = [],
|
||||
private string $baseFormat = ""
|
||||
){
|
||||
foreach(Utils::promoteKeys($params) as $k => $param){
|
||||
if(!($param instanceof Translatable)){
|
||||
@ -60,6 +62,8 @@ final class Translatable{
|
||||
return $this->params[$i] ?? null;
|
||||
}
|
||||
|
||||
public function getBaseFormat() : string{ return $this->baseFormat; }
|
||||
|
||||
public function format(string $before, string $after) : self{
|
||||
return new self("$before%$this->text$after", $this->params);
|
||||
}
|
||||
@ -71,4 +75,12 @@ final class Translatable{
|
||||
public function postfix(string $postfix) : self{
|
||||
return new self("%$this->text" . $postfix);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the base format to be applied to the translation result by {@link TextFormat::addBase()}.
|
||||
* Any existing base format is overwritten.
|
||||
*/
|
||||
public function baseTextFormat(string $baseFormat) : self{
|
||||
return new self($this->text, $this->params, $baseFormat);
|
||||
}
|
||||
}
|
||||
|
@ -41,6 +41,7 @@ use pocketmine\inventory\transaction\action\SlotChangeAction;
|
||||
use pocketmine\inventory\transaction\InventoryTransaction;
|
||||
use pocketmine\item\enchantment\EnchantingOption;
|
||||
use pocketmine\item\enchantment\EnchantmentInstance;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\network\mcpe\cache\CreativeInventoryCache;
|
||||
use pocketmine\network\mcpe\protocol\ClientboundPacket;
|
||||
use pocketmine\network\mcpe\protocol\ContainerClosePacket;
|
||||
@ -228,17 +229,25 @@ class InventoryManager{
|
||||
return null;
|
||||
}
|
||||
|
||||
private function addPredictedSlotChange(Inventory $inventory, int $slot, ItemStack $item) : void{
|
||||
private function addPredictedSlotChangeInternal(Inventory $inventory, int $slot, ItemStack $item) : void{
|
||||
$this->inventories[spl_object_id($inventory)]->predictions[$slot] = $item;
|
||||
}
|
||||
|
||||
public function addTransactionPredictedSlotChanges(InventoryTransaction $tx) : void{
|
||||
public function addPredictedSlotChange(Inventory $inventory, int $slot, Item $item) : void{
|
||||
$typeConverter = $this->session->getTypeConverter();
|
||||
$itemStack = $typeConverter->coreItemStackToNet($item);
|
||||
$this->addPredictedSlotChangeInternal($inventory, $slot, $itemStack);
|
||||
}
|
||||
|
||||
public function addTransactionPredictedSlotChanges(InventoryTransaction $tx) : void{
|
||||
foreach($tx->getActions() as $action){
|
||||
if($action instanceof SlotChangeAction){
|
||||
//TODO: ItemStackRequestExecutor can probably build these predictions with much lower overhead
|
||||
$itemStack = $typeConverter->coreItemStackToNet($action->getTargetItem());
|
||||
$this->addPredictedSlotChange($action->getInventory(), $action->getSlot(), $itemStack);
|
||||
$this->addPredictedSlotChange(
|
||||
$action->getInventory(),
|
||||
$action->getSlot(),
|
||||
$action->getTargetItem()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -267,7 +276,7 @@ class InventoryManager{
|
||||
}
|
||||
|
||||
[$inventory, $slot] = $info;
|
||||
$this->addPredictedSlotChange($inventory, $slot, $action->newItem->getItemStack());
|
||||
$this->addPredictedSlotChangeInternal($inventory, $slot, $action->newItem->getItemStack());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -174,7 +174,7 @@ class NetworkSession{
|
||||
*/
|
||||
private array $sendBufferAckPromises = [];
|
||||
|
||||
/** @phpstan-var \SplQueue<array{CompressBatchPromise|string, list<PromiseResolver<true>>}> */
|
||||
/** @phpstan-var \SplQueue<array{CompressBatchPromise|string, list<PromiseResolver<true>>, bool}> */
|
||||
private \SplQueue $compressedQueue;
|
||||
private bool $forceAsyncCompression = true;
|
||||
private bool $enableCompression = false; //disabled until handshake completed
|
||||
@ -235,7 +235,7 @@ class NetworkSession{
|
||||
|
||||
private function onSessionStartSuccess() : void{
|
||||
$this->logger->debug("Session start handshake completed, awaiting login packet");
|
||||
$this->flushSendBuffer(true);
|
||||
$this->flushGamePacketQueue();
|
||||
$this->enableCompression = true;
|
||||
$this->setHandler(new LoginPacketHandler(
|
||||
$this->server,
|
||||
@ -529,7 +529,7 @@ class NetworkSession{
|
||||
$this->addToSendBuffer(self::encodePacketTimed(PacketSerializer::encoder(), $evPacket));
|
||||
}
|
||||
if($immediate){
|
||||
$this->flushSendBuffer(true);
|
||||
$this->flushGamePacketQueue();
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -577,14 +577,12 @@ class NetworkSession{
|
||||
$this->sendBuffer[] = $buffer;
|
||||
}
|
||||
|
||||
private function flushSendBuffer(bool $immediate = false) : void{
|
||||
private function flushGamePacketQueue() : void{
|
||||
if(count($this->sendBuffer) > 0){
|
||||
Timings::$playerNetworkSend->startTiming();
|
||||
try{
|
||||
$syncMode = null; //automatic
|
||||
if($immediate){
|
||||
$syncMode = true;
|
||||
}elseif($this->forceAsyncCompression){
|
||||
if($this->forceAsyncCompression){
|
||||
$syncMode = false;
|
||||
}
|
||||
|
||||
@ -599,7 +597,9 @@ class NetworkSession{
|
||||
$this->sendBuffer = [];
|
||||
$ackPromises = $this->sendBufferAckPromises;
|
||||
$this->sendBufferAckPromises = [];
|
||||
$this->queueCompressedNoBufferFlush($batch, $immediate, $ackPromises);
|
||||
//these packets were already potentially buffered for up to 50ms - make sure the transport layer doesn't
|
||||
//delay them any longer
|
||||
$this->queueCompressedNoGamePacketFlush($batch, networkFlush: true, ackPromises: $ackPromises);
|
||||
}finally{
|
||||
Timings::$playerNetworkSend->stopTiming();
|
||||
}
|
||||
@ -619,8 +619,10 @@ class NetworkSession{
|
||||
public function queueCompressed(CompressBatchPromise|string $payload, bool $immediate = false) : void{
|
||||
Timings::$playerNetworkSend->startTiming();
|
||||
try{
|
||||
$this->flushSendBuffer($immediate); //Maintain ordering if possible
|
||||
$this->queueCompressedNoBufferFlush($payload, $immediate);
|
||||
//if the next packet causes a flush, avoid unnecessarily flushing twice
|
||||
//however, if the next packet does *not* cause a flush, game packets should be flushed to avoid delays
|
||||
$this->flushGamePacketQueue();
|
||||
$this->queueCompressedNoGamePacketFlush($payload, $immediate);
|
||||
}finally{
|
||||
Timings::$playerNetworkSend->stopTiming();
|
||||
}
|
||||
@ -631,22 +633,13 @@ class NetworkSession{
|
||||
*
|
||||
* @phpstan-param list<PromiseResolver<true>> $ackPromises
|
||||
*/
|
||||
private function queueCompressedNoBufferFlush(CompressBatchPromise|string $batch, bool $immediate = false, array $ackPromises = []) : void{
|
||||
private function queueCompressedNoGamePacketFlush(CompressBatchPromise|string $batch, bool $networkFlush = false, array $ackPromises = []) : void{
|
||||
Timings::$playerNetworkSend->startTiming();
|
||||
try{
|
||||
$this->compressedQueue->enqueue([$batch, $ackPromises, $networkFlush]);
|
||||
if(is_string($batch)){
|
||||
if($immediate){
|
||||
//Skips all queues
|
||||
$this->sendEncoded($batch, true, $ackPromises);
|
||||
}else{
|
||||
$this->compressedQueue->enqueue([$batch, $ackPromises]);
|
||||
$this->flushCompressedQueue();
|
||||
}
|
||||
}elseif($immediate){
|
||||
//Skips all queues
|
||||
$this->sendEncoded($batch->getResult(), true, $ackPromises);
|
||||
$this->flushCompressedQueue();
|
||||
}else{
|
||||
$this->compressedQueue->enqueue([$batch, $ackPromises]);
|
||||
$batch->onResolve(function() : void{
|
||||
if($this->connected){
|
||||
$this->flushCompressedQueue();
|
||||
@ -663,14 +656,14 @@ class NetworkSession{
|
||||
try{
|
||||
while(!$this->compressedQueue->isEmpty()){
|
||||
/** @var CompressBatchPromise|string $current */
|
||||
[$current, $ackPromises] = $this->compressedQueue->bottom();
|
||||
[$current, $ackPromises, $networkFlush] = $this->compressedQueue->bottom();
|
||||
if(is_string($current)){
|
||||
$this->compressedQueue->dequeue();
|
||||
$this->sendEncoded($current, false, $ackPromises);
|
||||
$this->sendEncoded($current, $networkFlush, $ackPromises);
|
||||
|
||||
}elseif($current->hasResult()){
|
||||
$this->compressedQueue->dequeue();
|
||||
$this->sendEncoded($current->getResult(), false, $ackPromises);
|
||||
$this->sendEncoded($current->getResult(), $networkFlush, $ackPromises);
|
||||
|
||||
}else{
|
||||
//can't send any more queued until this one is ready
|
||||
@ -710,7 +703,7 @@ class NetworkSession{
|
||||
$this->disconnectGuard = true;
|
||||
$func();
|
||||
$this->disconnectGuard = false;
|
||||
$this->flushSendBuffer(true);
|
||||
$this->flushGamePacketQueue();
|
||||
$this->sender->close("");
|
||||
foreach($this->disposeHooks as $callback){
|
||||
$callback();
|
||||
@ -774,7 +767,7 @@ class NetworkSession{
|
||||
$errorId = implode("-", str_split(bin2hex(random_bytes(6)), 4));
|
||||
|
||||
$this->disconnect(
|
||||
reason: KnownTranslationFactory::pocketmine_disconnect_error($reason, $errorId)->prefix(TextFormat::RED),
|
||||
reason: KnownTranslationFactory::pocketmine_disconnect_error($reason, $errorId)->baseTextFormat(TextFormat::RED),
|
||||
disconnectScreenMessage: KnownTranslationFactory::pocketmine_disconnect_error($disconnectScreenMessage ?? $reason, $errorId),
|
||||
);
|
||||
}
|
||||
@ -1137,8 +1130,12 @@ class NetworkSession{
|
||||
public function prepareClientTranslatableMessage(Translatable $message) : array{
|
||||
//we can't send nested translations to the client, so make sure they are always pre-translated by the server
|
||||
$language = $this->player->getLanguage();
|
||||
$parameters = array_map(fn(string|Translatable $p) => $p instanceof Translatable ? $language->translate($p) : $p, $message->getParameters());
|
||||
return [$language->translateString($message->getText(), $parameters, "pocketmine."), $parameters];
|
||||
$baseFormat = $message->getBaseFormat();
|
||||
$parameters = array_map(function(string|Translatable $p) use ($baseFormat, $language){
|
||||
$string = $p instanceof Translatable ? $language->translate($p) : $p;
|
||||
return $baseFormat !== "" ? TextFormat::addBase($baseFormat, $string) . TextFormat::RESET : $string;
|
||||
}, $message->getParameters());
|
||||
return [$language->translateString($message->getText(), $parameters, "pocketmine.", $baseFormat), $parameters];
|
||||
}
|
||||
|
||||
public function onChatMessage(Translatable|string $message) : void{
|
||||
@ -1345,6 +1342,6 @@ class NetworkSession{
|
||||
Timings::$playerNetworkSendInventorySync->stopTiming();
|
||||
}
|
||||
|
||||
$this->flushSendBuffer();
|
||||
$this->flushGamePacketQueue();
|
||||
}
|
||||
}
|
||||
|
63
src/network/mcpe/cache/StaticPacketCache.php
vendored
63
src/network/mcpe/cache/StaticPacketCache.php
vendored
@ -23,13 +23,22 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\network\mcpe\cache;
|
||||
|
||||
use pocketmine\color\Color;
|
||||
use pocketmine\data\bedrock\BedrockDataFiles;
|
||||
use pocketmine\data\SavedDataLoadingException;
|
||||
use pocketmine\network\mcpe\protocol\AvailableActorIdentifiersPacket;
|
||||
use pocketmine\network\mcpe\protocol\BiomeDefinitionListPacket;
|
||||
use pocketmine\network\mcpe\protocol\serializer\NetworkNbtSerializer;
|
||||
use pocketmine\network\mcpe\protocol\types\biome\BiomeDefinitionEntry;
|
||||
use pocketmine\network\mcpe\protocol\types\CacheableNbt;
|
||||
use pocketmine\utils\Filesystem;
|
||||
use pocketmine\utils\SingletonTrait;
|
||||
use pocketmine\utils\Utils;
|
||||
use pocketmine\world\biome\model\BiomeDefinitionEntryData;
|
||||
use function count;
|
||||
use function get_debug_type;
|
||||
use function is_array;
|
||||
use function json_decode;
|
||||
|
||||
class StaticPacketCache{
|
||||
use SingletonTrait;
|
||||
@ -41,9 +50,61 @@ class StaticPacketCache{
|
||||
return new CacheableNbt((new NetworkNbtSerializer())->read(Filesystem::fileGetContents($filePath))->mustGetCompoundTag());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<BiomeDefinitionEntry>
|
||||
*/
|
||||
private static function loadBiomeDefinitionModel(string $filePath) : array{
|
||||
$biomeEntries = json_decode(Filesystem::fileGetContents($filePath), associative: true);
|
||||
if(!is_array($biomeEntries)){
|
||||
throw new SavedDataLoadingException("$filePath root should be an array, got " . get_debug_type($biomeEntries));
|
||||
}
|
||||
|
||||
$jsonMapper = new \JsonMapper();
|
||||
$jsonMapper->bExceptionOnMissingData = true;
|
||||
$jsonMapper->bStrictObjectTypeChecking = true;
|
||||
$jsonMapper->bEnforceMapType = false;
|
||||
|
||||
$entries = [];
|
||||
foreach(Utils::promoteKeys($biomeEntries) as $biomeName => $entry){
|
||||
if(!is_array($entry)){
|
||||
throw new SavedDataLoadingException("$filePath should be an array of objects, got " . get_debug_type($entry));
|
||||
}
|
||||
|
||||
try{
|
||||
$biomeDefinition = $jsonMapper->map($entry, new BiomeDefinitionEntryData());
|
||||
|
||||
$mapWaterColour = $biomeDefinition->mapWaterColour;
|
||||
$entries[] = new BiomeDefinitionEntry(
|
||||
(string) $biomeName,
|
||||
$biomeDefinition->id,
|
||||
$biomeDefinition->temperature,
|
||||
$biomeDefinition->downfall,
|
||||
$biomeDefinition->redSporeDensity,
|
||||
$biomeDefinition->blueSporeDensity,
|
||||
$biomeDefinition->ashDensity,
|
||||
$biomeDefinition->whiteAshDensity,
|
||||
$biomeDefinition->depth,
|
||||
$biomeDefinition->scale,
|
||||
new Color(
|
||||
$mapWaterColour->r,
|
||||
$mapWaterColour->g,
|
||||
$mapWaterColour->b,
|
||||
$mapWaterColour->a
|
||||
),
|
||||
$biomeDefinition->rain,
|
||||
count($biomeDefinition->tags) > 0 ? $biomeDefinition->tags : null,
|
||||
);
|
||||
}catch(\JsonMapper_Exception $e){
|
||||
throw new \RuntimeException($e->getMessage(), 0, $e);
|
||||
}
|
||||
}
|
||||
|
||||
return $entries;
|
||||
}
|
||||
|
||||
private static function make() : self{
|
||||
return new self(
|
||||
BiomeDefinitionListPacket::create(self::loadCompoundFromFile(BedrockDataFiles::BIOME_DEFINITIONS_NBT)),
|
||||
BiomeDefinitionListPacket::fromDefinitions(self::loadBiomeDefinitionModel(BedrockDataFiles::BIOME_DEFINITIONS_JSON)),
|
||||
AvailableActorIdentifiersPacket::create(self::loadCompoundFromFile(BedrockDataFiles::ENTITY_IDENTIFIERS_NBT))
|
||||
);
|
||||
}
|
||||
|
@ -73,7 +73,6 @@ use pocketmine\network\mcpe\protocol\NetworkStackLatencyPacket;
|
||||
use pocketmine\network\mcpe\protocol\PlayerActionPacket;
|
||||
use pocketmine\network\mcpe\protocol\PlayerAuthInputPacket;
|
||||
use pocketmine\network\mcpe\protocol\PlayerHotbarPacket;
|
||||
use pocketmine\network\mcpe\protocol\PlayerInputPacket;
|
||||
use pocketmine\network\mcpe\protocol\PlayerSkinPacket;
|
||||
use pocketmine\network\mcpe\protocol\RequestChunkRadiusPacket;
|
||||
use pocketmine\network\mcpe\protocol\serializer\BitSet;
|
||||
@ -137,6 +136,8 @@ class InGamePacketHandler extends PacketHandler{
|
||||
protected ?float $lastPlayerAuthInputPitch = null;
|
||||
protected ?BitSet $lastPlayerAuthInputFlags = null;
|
||||
|
||||
protected ?BlockPosition $lastBlockAttacked = null;
|
||||
|
||||
public bool $forceMoveSync = false;
|
||||
|
||||
protected ?string $lastRequestedFullSkinId = null;
|
||||
@ -212,7 +213,7 @@ class InGamePacketHandler extends PacketHandler{
|
||||
}
|
||||
|
||||
$inputFlags = $packet->getInputFlags();
|
||||
if($inputFlags !== $this->lastPlayerAuthInputFlags){
|
||||
if($this->lastPlayerAuthInputFlags === null || !$inputFlags->equals($this->lastPlayerAuthInputFlags)){
|
||||
$this->lastPlayerAuthInputFlags = $inputFlags;
|
||||
|
||||
$sneaking = $inputFlags->get(PlayerAuthInputFlags::SNEAKING);
|
||||
@ -249,6 +250,28 @@ class InGamePacketHandler extends PacketHandler{
|
||||
|
||||
$packetHandled = true;
|
||||
|
||||
$useItemTransaction = $packet->getItemInteractionData();
|
||||
if($useItemTransaction !== null){
|
||||
if(count($useItemTransaction->getTransactionData()->getActions()) > 100){
|
||||
throw new PacketHandlingException("Too many actions in item use transaction");
|
||||
}
|
||||
|
||||
$this->inventoryManager->setCurrentItemStackRequestId($useItemTransaction->getRequestId());
|
||||
$this->inventoryManager->addRawPredictedSlotChanges($useItemTransaction->getTransactionData()->getActions());
|
||||
if(!$this->handleUseItemTransaction($useItemTransaction->getTransactionData())){
|
||||
$packetHandled = false;
|
||||
$this->session->getLogger()->debug("Unhandled transaction in PlayerAuthInputPacket (type " . $useItemTransaction->getTransactionData()->getActionType() . ")");
|
||||
}else{
|
||||
$this->inventoryManager->syncMismatchedPredictedSlotChanges();
|
||||
}
|
||||
$this->inventoryManager->setCurrentItemStackRequestId(null);
|
||||
}
|
||||
|
||||
$itemStackRequest = $packet->getItemStackRequest();
|
||||
$itemStackResponseBuilder = $itemStackRequest !== null ? $this->handleSingleItemStackRequest($itemStackRequest) : null;
|
||||
|
||||
//itemstack request or transaction may set predictions for the outcome of these actions, so these need to be
|
||||
//processed last
|
||||
$blockActions = $packet->getBlockActions();
|
||||
if($blockActions !== null){
|
||||
if(count($blockActions) > 100){
|
||||
@ -269,27 +292,9 @@ class InGamePacketHandler extends PacketHandler{
|
||||
}
|
||||
}
|
||||
|
||||
$useItemTransaction = $packet->getItemInteractionData();
|
||||
if($useItemTransaction !== null){
|
||||
if(count($useItemTransaction->getTransactionData()->getActions()) > 100){
|
||||
throw new PacketHandlingException("Too many actions in item use transaction");
|
||||
}
|
||||
|
||||
$this->inventoryManager->setCurrentItemStackRequestId($useItemTransaction->getRequestId());
|
||||
$this->inventoryManager->addRawPredictedSlotChanges($useItemTransaction->getTransactionData()->getActions());
|
||||
if(!$this->handleUseItemTransaction($useItemTransaction->getTransactionData())){
|
||||
$packetHandled = false;
|
||||
$this->session->getLogger()->debug("Unhandled transaction in PlayerAuthInputPacket (type " . $useItemTransaction->getTransactionData()->getActionType() . ")");
|
||||
}else{
|
||||
$this->inventoryManager->syncMismatchedPredictedSlotChanges();
|
||||
}
|
||||
$this->inventoryManager->setCurrentItemStackRequestId(null);
|
||||
}
|
||||
|
||||
$itemStackRequest = $packet->getItemStackRequest();
|
||||
if($itemStackRequest !== null){
|
||||
$result = $this->handleSingleItemStackRequest($itemStackRequest);
|
||||
$this->session->sendDataPacket(ItemStackResponsePacket::create([$result]));
|
||||
$itemStackResponse = $itemStackResponseBuilder?->build() ?? new ItemStackResponse(ItemStackResponse::RESULT_ERROR, $itemStackRequest->getRequestId());
|
||||
$this->session->sendDataPacket(ItemStackResponsePacket::create([$itemStackResponse]));
|
||||
}
|
||||
|
||||
return $packetHandled;
|
||||
@ -499,13 +504,6 @@ class InGamePacketHandler extends PacketHandler{
|
||||
//if only the client would tell us what blocks it thinks changed...
|
||||
$this->syncBlocksNearby($vBlockPos, $data->getFace());
|
||||
return true;
|
||||
case UseItemTransactionData::ACTION_BREAK_BLOCK:
|
||||
$blockPos = $data->getBlockPosition();
|
||||
$vBlockPos = new Vector3($blockPos->getX(), $blockPos->getY(), $blockPos->getZ());
|
||||
if(!$this->player->breakBlock($vBlockPos)){
|
||||
$this->syncBlocksNearby($vBlockPos, null);
|
||||
}
|
||||
return true;
|
||||
case UseItemTransactionData::ACTION_CLICK_AIR:
|
||||
if($this->player->isUsingItem()){
|
||||
if(!$this->player->consumeHeldItem()){
|
||||
@ -581,7 +579,7 @@ class InGamePacketHandler extends PacketHandler{
|
||||
return false;
|
||||
}
|
||||
|
||||
private function handleSingleItemStackRequest(ItemStackRequest $request) : ItemStackResponse{
|
||||
private function handleSingleItemStackRequest(ItemStackRequest $request) : ?ItemStackResponseBuilder{
|
||||
if(count($request->getActions()) > 60){
|
||||
//recipe book auto crafting can affect all slots of the inventory when consuming inputs or producing outputs
|
||||
//this means there could be as many as 50 CraftingConsumeInput actions or Place (taking the result) actions
|
||||
@ -598,7 +596,11 @@ class InGamePacketHandler extends PacketHandler{
|
||||
$executor = new ItemStackRequestExecutor($this->player, $this->inventoryManager, $request);
|
||||
try{
|
||||
$transaction = $executor->generateInventoryTransaction();
|
||||
$result = $this->executeInventoryTransaction($transaction, $request->getRequestId());
|
||||
if($transaction !== null){
|
||||
$result = $this->executeInventoryTransaction($transaction, $request->getRequestId());
|
||||
}else{
|
||||
$result = true; //predictions only, just send responses
|
||||
}
|
||||
}catch(ItemStackRequestProcessException $e){
|
||||
$result = false;
|
||||
$this->session->getLogger()->debug("ItemStackRequest #" . $request->getRequestId() . " failed: " . $e->getMessage());
|
||||
@ -606,10 +608,7 @@ class InGamePacketHandler extends PacketHandler{
|
||||
$this->inventoryManager->requestSyncAll();
|
||||
}
|
||||
|
||||
if(!$result){
|
||||
return new ItemStackResponse(ItemStackResponse::RESULT_ERROR, $request->getRequestId());
|
||||
}
|
||||
return $executor->buildItemStackResponse();
|
||||
return $result ? $executor->getItemStackResponseBuilder() : null;
|
||||
}
|
||||
|
||||
public function handleItemStackRequest(ItemStackRequestPacket $packet) : bool{
|
||||
@ -619,7 +618,7 @@ class InGamePacketHandler extends PacketHandler{
|
||||
throw new PacketHandlingException("Too many requests in ItemStackRequestPacket");
|
||||
}
|
||||
foreach($packet->getRequests() as $request){
|
||||
$responses[] = $this->handleSingleItemStackRequest($request);
|
||||
$responses[] = $this->handleSingleItemStackRequest($request)?->build() ?? new ItemStackResponse(ItemStackResponse::RESULT_ERROR, $request->getRequestId());
|
||||
}
|
||||
|
||||
$this->session->sendDataPacket(ItemStackResponsePacket::create($responses));
|
||||
@ -682,16 +681,27 @@ class InGamePacketHandler extends PacketHandler{
|
||||
|
||||
switch($action){
|
||||
case PlayerAction::START_BREAK:
|
||||
case PlayerAction::CONTINUE_DESTROY_BLOCK: //destroy the next block while holding down left click
|
||||
self::validateFacing($face);
|
||||
if($this->lastBlockAttacked !== null && $blockPosition->equals($this->lastBlockAttacked)){
|
||||
//the client will send CONTINUE_DESTROY_BLOCK for the currently targeted block directly before it
|
||||
//sends PREDICT_DESTROY_BLOCK, but also when it starts to break the block
|
||||
//this seems like a bug in the client and would cause spurious left-click events if we allowed it to
|
||||
//be delivered to the player
|
||||
$this->session->getLogger()->debug("Ignoring PlayerAction $action on $pos because we were already destroying this block");
|
||||
break;
|
||||
}
|
||||
if(!$this->player->attackBlock($pos, $face)){
|
||||
$this->syncBlocksNearby($pos, $face);
|
||||
}
|
||||
$this->lastBlockAttacked = $blockPosition;
|
||||
|
||||
break;
|
||||
|
||||
case PlayerAction::ABORT_BREAK:
|
||||
case PlayerAction::STOP_BREAK:
|
||||
$this->player->stopBreakBlock($pos);
|
||||
$this->lastBlockAttacked = null;
|
||||
break;
|
||||
case PlayerAction::START_SLEEPING:
|
||||
//unused
|
||||
@ -702,11 +712,17 @@ class InGamePacketHandler extends PacketHandler{
|
||||
case PlayerAction::CRACK_BREAK:
|
||||
self::validateFacing($face);
|
||||
$this->player->continueBreakBlock($pos, $face);
|
||||
$this->lastBlockAttacked = $blockPosition;
|
||||
break;
|
||||
case PlayerAction::INTERACT_BLOCK: //TODO: ignored (for now)
|
||||
break;
|
||||
case PlayerAction::CREATIVE_PLAYER_DESTROY_BLOCK:
|
||||
//TODO: do we need to handle this?
|
||||
case PlayerAction::PREDICT_DESTROY_BLOCK:
|
||||
if(!$this->player->breakBlock($pos)){
|
||||
$this->syncBlocksNearby($pos, $face);
|
||||
}
|
||||
$this->lastBlockAttacked = null;
|
||||
break;
|
||||
case PlayerAction::START_ITEM_USE_ON:
|
||||
case PlayerAction::STOP_ITEM_USE_ON:
|
||||
@ -781,10 +797,6 @@ class InGamePacketHandler extends PacketHandler{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handlePlayerInput(PlayerInputPacket $packet) : bool{
|
||||
return false; //TODO
|
||||
}
|
||||
|
||||
public function handleSetPlayerGameType(SetPlayerGameTypePacket $packet) : bool{
|
||||
$gameMode = $this->session->getTypeConverter()->protocolGameModeToCore($packet->gamemode);
|
||||
if($gameMode !== $this->player->getGamemode()){
|
||||
|
@ -33,9 +33,11 @@ use pocketmine\inventory\transaction\EnchantingTransaction;
|
||||
use pocketmine\inventory\transaction\InventoryTransaction;
|
||||
use pocketmine\inventory\transaction\TransactionBuilder;
|
||||
use pocketmine\inventory\transaction\TransactionBuilderInventory;
|
||||
use pocketmine\item\Durable;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\network\mcpe\InventoryManager;
|
||||
use pocketmine\network\mcpe\protocol\types\inventory\ContainerUIIds;
|
||||
use pocketmine\network\mcpe\protocol\types\inventory\FullContainerName;
|
||||
use pocketmine\network\mcpe\protocol\types\inventory\stackrequest\CraftingConsumeInputStackRequestAction;
|
||||
use pocketmine\network\mcpe\protocol\types\inventory\stackrequest\CraftingCreateSpecificResultStackRequestAction;
|
||||
use pocketmine\network\mcpe\protocol\types\inventory\stackrequest\CraftRecipeAutoStackRequestAction;
|
||||
@ -47,6 +49,7 @@ use pocketmine\network\mcpe\protocol\types\inventory\stackrequest\DropStackReque
|
||||
use pocketmine\network\mcpe\protocol\types\inventory\stackrequest\ItemStackRequest;
|
||||
use pocketmine\network\mcpe\protocol\types\inventory\stackrequest\ItemStackRequestAction;
|
||||
use pocketmine\network\mcpe\protocol\types\inventory\stackrequest\ItemStackRequestSlotInfo;
|
||||
use pocketmine\network\mcpe\protocol\types\inventory\stackrequest\MineBlockStackRequestAction;
|
||||
use pocketmine\network\mcpe\protocol\types\inventory\stackrequest\PlaceStackRequestAction;
|
||||
use pocketmine\network\mcpe\protocol\types\inventory\stackrequest\SwapStackRequestAction;
|
||||
use pocketmine\network\mcpe\protocol\types\inventory\stackrequest\TakeStackRequestAction;
|
||||
@ -362,6 +365,16 @@ class ItemStackRequestExecutor{
|
||||
$this->setNextCreatedItem($nextResultItem);
|
||||
}elseif($action instanceof DeprecatedCraftingResultsStackRequestAction){
|
||||
//no obvious use
|
||||
}elseif($action instanceof MineBlockStackRequestAction){
|
||||
$slot = $action->getHotbarSlot();
|
||||
$this->requestSlotInfos[] = new ItemStackRequestSlotInfo(new FullContainerName(ContainerUIIds::HOTBAR), $slot, $action->getStackId());
|
||||
$inventory = $this->player->getInventory();
|
||||
$usedItem = $inventory->slotExists($slot) ? $inventory->getItem($slot) : null;
|
||||
$predictedDamage = $action->getPredictedDurability();
|
||||
if($usedItem instanceof Durable && $predictedDamage >= 0 && $predictedDamage <= $usedItem->getMaxDurability()){
|
||||
$usedItem->setDamage($predictedDamage);
|
||||
$this->inventoryManager->addPredictedSlotChange($inventory, $slot, $usedItem);
|
||||
}
|
||||
}else{
|
||||
throw new ItemStackRequestProcessException("Unhandled item stack request action");
|
||||
}
|
||||
@ -370,7 +383,7 @@ class ItemStackRequestExecutor{
|
||||
/**
|
||||
* @throws ItemStackRequestProcessException
|
||||
*/
|
||||
public function generateInventoryTransaction() : InventoryTransaction{
|
||||
public function generateInventoryTransaction() : ?InventoryTransaction{
|
||||
foreach(Utils::promoteKeys($this->request->getActions()) as $k => $action){
|
||||
try{
|
||||
$this->processItemStackRequestAction($action);
|
||||
@ -380,6 +393,9 @@ class ItemStackRequestExecutor{
|
||||
}
|
||||
$this->setNextCreatedItem(null);
|
||||
$inventoryActions = $this->builder->generateActions();
|
||||
if(count($inventoryActions) === 0){
|
||||
return null;
|
||||
}
|
||||
|
||||
$transaction = $this->specialTransaction ?? new InventoryTransaction($this->player);
|
||||
foreach($inventoryActions as $action){
|
||||
@ -389,12 +405,16 @@ class ItemStackRequestExecutor{
|
||||
return $transaction;
|
||||
}
|
||||
|
||||
public function buildItemStackResponse() : ItemStackResponse{
|
||||
public function getItemStackResponseBuilder() : ItemStackResponseBuilder{
|
||||
$builder = new ItemStackResponseBuilder($this->request->getRequestId(), $this->inventoryManager);
|
||||
foreach($this->requestSlotInfos as $requestInfo){
|
||||
$builder->addSlot($requestInfo->getContainerName()->getContainerId(), $requestInfo->getSlotId());
|
||||
}
|
||||
|
||||
return $builder->build();
|
||||
return $builder;
|
||||
}
|
||||
|
||||
public function buildItemStackResponse() : ItemStackResponse{
|
||||
return $this->getItemStackResponseBuilder()->build();
|
||||
}
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ class PreSpawnPacketHandler extends PacketHandler{
|
||||
$this->server->getMotd(),
|
||||
"",
|
||||
false,
|
||||
new PlayerMovementSettings(ServerAuthMovementMode::SERVER_AUTHORITATIVE_V2, 0, false),
|
||||
new PlayerMovementSettings(ServerAuthMovementMode::SERVER_AUTHORITATIVE_V3, 0, true),
|
||||
0,
|
||||
0,
|
||||
"",
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\player;
|
||||
use pocketmine\block\BaseSign;
|
||||
use pocketmine\block\Bed;
|
||||
use pocketmine\block\BlockTypeTags;
|
||||
use pocketmine\block\RespawnAnchor;
|
||||
use pocketmine\block\UnknownBlock;
|
||||
use pocketmine\block\VanillaBlocks;
|
||||
use pocketmine\command\CommandSender;
|
||||
@ -45,6 +46,7 @@ use pocketmine\entity\projectile\Arrow;
|
||||
use pocketmine\entity\Skin;
|
||||
use pocketmine\event\entity\EntityDamageByEntityEvent;
|
||||
use pocketmine\event\entity\EntityDamageEvent;
|
||||
use pocketmine\event\entity\EntityExtinguishEvent;
|
||||
use pocketmine\event\inventory\InventoryCloseEvent;
|
||||
use pocketmine\event\inventory\InventoryOpenEvent;
|
||||
use pocketmine\event\player\PlayerBedEnterEvent;
|
||||
@ -135,6 +137,7 @@ use pocketmine\world\sound\EntityAttackNoDamageSound;
|
||||
use pocketmine\world\sound\EntityAttackSound;
|
||||
use pocketmine\world\sound\FireExtinguishSound;
|
||||
use pocketmine\world\sound\ItemBreakSound;
|
||||
use pocketmine\world\sound\RespawnAnchorDepleteSound;
|
||||
use pocketmine\world\sound\Sound;
|
||||
use pocketmine\world\World;
|
||||
use pocketmine\YmlServerProperties;
|
||||
@ -408,7 +411,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
||||
|
||||
public function getLeaveMessage() : Translatable|string{
|
||||
if($this->spawned){
|
||||
return KnownTranslationFactory::multiplayer_player_left($this->getDisplayName())->prefix(TextFormat::YELLOW);
|
||||
return KnownTranslationFactory::multiplayer_player_left($this->getDisplayName())->baseTextFormat(TextFormat::YELLOW);
|
||||
}
|
||||
|
||||
return "";
|
||||
@ -943,7 +946,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
||||
});
|
||||
|
||||
$ev = new PlayerJoinEvent($this,
|
||||
KnownTranslationFactory::multiplayer_player_joined($this->getDisplayName())->prefix(TextFormat::YELLOW)
|
||||
KnownTranslationFactory::multiplayer_player_joined($this->getDisplayName())->baseTextFormat(TextFormat::YELLOW)
|
||||
);
|
||||
$ev->call();
|
||||
if($ev->getJoinMessage() !== ""){
|
||||
@ -1641,7 +1644,10 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
||||
$newReplica = clone $oldHeldItem;
|
||||
$newReplica->setCount($newHeldItem->getCount());
|
||||
if($newReplica instanceof Durable && $newHeldItem instanceof Durable){
|
||||
$newReplica->setDamage($newHeldItem->getDamage());
|
||||
$newDamage = $newHeldItem->getDamage();
|
||||
if($newDamage >= 0 && $newDamage <= $newReplica->getMaxDurability()){
|
||||
$newReplica->setDamage($newDamage);
|
||||
}
|
||||
}
|
||||
$damagedOrDeducted = $newReplica->equalsExact($newHeldItem);
|
||||
|
||||
@ -2537,6 +2543,21 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
||||
}
|
||||
$this->logger->debug("Respawn position located, completing respawn");
|
||||
$ev = new PlayerRespawnEvent($this, $safeSpawn);
|
||||
$spawnPosition = $ev->getRespawnPosition();
|
||||
$spawnBlock = $spawnPosition->getWorld()->getBlock($spawnPosition);
|
||||
if($spawnBlock instanceof RespawnAnchor){
|
||||
if($spawnBlock->getCharges() > 0){
|
||||
$spawnPosition->getWorld()->setBlock($spawnPosition, $spawnBlock->setCharges($spawnBlock->getCharges() - 1));
|
||||
$spawnPosition->getWorld()->addSound($spawnPosition, new RespawnAnchorDepleteSound());
|
||||
}else{
|
||||
$defaultSpawn = $this->server->getWorldManager()->getDefaultWorld()?->getSpawnLocation();
|
||||
if($defaultSpawn !== null){
|
||||
$this->setSpawn($defaultSpawn);
|
||||
$ev->setRespawnPosition($defaultSpawn);
|
||||
$this->sendMessage(KnownTranslationFactory::tile_respawn_anchor_notValid()->prefix(TextFormat::GRAY));
|
||||
}
|
||||
}
|
||||
}
|
||||
$ev->call();
|
||||
|
||||
$realSpawn = Position::fromObject($ev->getRespawnPosition()->add(0.5, 0, 0.5), $ev->getRespawnPosition()->getWorld());
|
||||
@ -2546,7 +2567,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
||||
$this->setSneaking(false);
|
||||
$this->setFlying(false);
|
||||
|
||||
$this->extinguish();
|
||||
$this->extinguish(EntityExtinguishEvent::CAUSE_RESPAWN);
|
||||
$this->setAirSupplyTicks($this->getMaxAirSupplyTicks());
|
||||
$this->deadTicks = 0;
|
||||
$this->noDamageTicks = 60;
|
||||
|
@ -94,7 +94,17 @@ trait CommonThreadPartsTrait{
|
||||
}
|
||||
}
|
||||
|
||||
public function getCrashInfo() : ?ThreadCrashInfo{ return $this->crashInfo; }
|
||||
public function getCrashInfo() : ?ThreadCrashInfo{
|
||||
//TODO: Joining a crashed worker might be a bit sus, but we need to make sure the thread's shutdown
|
||||
//handler has run before we try to collect the crash info. As of 6.1.1, pmmpthread sets isTerminated=true
|
||||
//*before* the shutdown handler is invoked, so we might land here before the crash info has been set.
|
||||
//In the future this should probably be fixed by running the shutdown handlers before setting isTerminated,
|
||||
//but this workaround should be good enough for now.
|
||||
if($this->isTerminated() && !$this->isJoined()){
|
||||
$this->join();
|
||||
}
|
||||
return $this->crashInfo;
|
||||
}
|
||||
|
||||
public function start(int $options = NativeThread::INHERIT_NONE) : bool{
|
||||
ThreadManager::getInstance()->add($this);
|
||||
|
@ -84,6 +84,6 @@ final class ThreadCrashInfo extends ThreadSafe{
|
||||
public function getThreadName() : string{ return $this->threadName; }
|
||||
|
||||
public function makePrettyMessage() : string{
|
||||
return sprintf("%s: \"%s\" in \"%s\" on line %d", $this->type ?? "Fatal error", $this->message, Filesystem::cleanPath($this->file), $this->line);
|
||||
return sprintf("%s: \"%s\" in \"%s\" on line %d", $this->type, $this->message, Filesystem::cleanPath($this->file), $this->line);
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,6 @@ namespace pocketmine\utils;
|
||||
|
||||
use pocketmine\VersionInfo;
|
||||
use function array_merge;
|
||||
use function curl_close;
|
||||
use function curl_error;
|
||||
use function curl_exec;
|
||||
use function curl_getinfo;
|
||||
@ -217,34 +216,30 @@ class Internet{
|
||||
CURLOPT_HTTPHEADER => array_merge(["User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0 " . VersionInfo::NAME . "/" . VersionInfo::VERSION()->getFullVersion(true)], $extraHeaders),
|
||||
CURLOPT_HEADER => true
|
||||
]);
|
||||
try{
|
||||
$raw = curl_exec($ch);
|
||||
if($raw === false){
|
||||
throw new InternetException(curl_error($ch));
|
||||
}
|
||||
if(!is_string($raw)) throw new AssumptionFailedError("curl_exec() should return string|false when CURLOPT_RETURNTRANSFER is set");
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
$headerSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
|
||||
$rawHeaders = substr($raw, 0, $headerSize);
|
||||
$body = substr($raw, $headerSize);
|
||||
$headers = [];
|
||||
//TODO: explore if we can set these limits lower
|
||||
foreach(explode("\r\n\r\n", $rawHeaders, limit: PHP_INT_MAX) as $rawHeaderGroup){
|
||||
$headerGroup = [];
|
||||
foreach(explode("\r\n", $rawHeaderGroup, limit: PHP_INT_MAX) as $line){
|
||||
$nameValue = explode(":", $line, 2);
|
||||
if(isset($nameValue[1])){
|
||||
$headerGroup[trim(strtolower($nameValue[0]))] = trim($nameValue[1]);
|
||||
}
|
||||
}
|
||||
$headers[] = $headerGroup;
|
||||
}
|
||||
if($onSuccess !== null){
|
||||
$onSuccess($ch);
|
||||
}
|
||||
return new InternetRequestResult($headers, $body, $httpCode);
|
||||
}finally{
|
||||
curl_close($ch);
|
||||
$raw = curl_exec($ch);
|
||||
if($raw === false){
|
||||
throw new InternetException(curl_error($ch));
|
||||
}
|
||||
if(!is_string($raw)) throw new AssumptionFailedError("curl_exec() should return string|false when CURLOPT_RETURNTRANSFER is set");
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
$headerSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
|
||||
$rawHeaders = substr($raw, 0, $headerSize);
|
||||
$body = substr($raw, $headerSize);
|
||||
$headers = [];
|
||||
//TODO: explore if we can set these limits lower
|
||||
foreach(explode("\r\n\r\n", $rawHeaders, limit: PHP_INT_MAX) as $rawHeaderGroup){
|
||||
$headerGroup = [];
|
||||
foreach(explode("\r\n", $rawHeaderGroup, limit: PHP_INT_MAX) as $line){
|
||||
$nameValue = explode(":", $line, 2);
|
||||
if(isset($nameValue[1])){
|
||||
$headerGroup[trim(strtolower($nameValue[0]))] = trim($nameValue[1]);
|
||||
}
|
||||
}
|
||||
$headers[] = $headerGroup;
|
||||
}
|
||||
if($onSuccess !== null){
|
||||
$onSuccess($ch);
|
||||
}
|
||||
return new InternetRequestResult($headers, $body, $httpCode);
|
||||
}
|
||||
}
|
||||
|
@ -190,8 +190,10 @@ abstract class TextFormat{
|
||||
* - Base format "§c" (red) + "Hello" (no format) = "§r§cHello"
|
||||
* - Base format "§c" + "Hello §rWorld" = "§r§cHello §r§cWorld"
|
||||
*
|
||||
* Note: Adding base formatting to the output string a second time will result in a combination of formats from both
|
||||
* calls. This is not by design, but simply a consequence of the way the function is implemented.
|
||||
* Note: Adding base formatting to the output string a second time won't override conflicting formatting from the
|
||||
* earlier call (e.g. adding base format BLUE to a string which already has YELLOW base formatting will
|
||||
* still result in yellow text after any RESET code). However, complementary codes (e.g. italic, bold) will combine
|
||||
* with the existing codes (e.g. adding ITALIC to a string with base format YELLOW will give yellow & italic text).
|
||||
*/
|
||||
public static function addBase(string $baseFormat, string $string) : string{
|
||||
$baseFormatParts = self::tokenize($baseFormat);
|
||||
|
@ -584,7 +584,7 @@ final class Utils{
|
||||
/**
|
||||
* @phpstan-template TMemberType
|
||||
* @phpstan-param array<mixed, TMemberType> $array
|
||||
* @phpstan-param \Closure(TMemberType) : void $validator
|
||||
* @phpstan-param \Closure(TMemberType) : mixed $validator
|
||||
*/
|
||||
public static function validateArrayValueType(array $array, \Closure $validator) : void{
|
||||
foreach(Utils::promoteKeys($array) as $k => $v){
|
||||
|
@ -26,16 +26,20 @@ namespace pocketmine\world;
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\block\RuntimeBlockStateRegistry;
|
||||
use pocketmine\block\TNT;
|
||||
use pocketmine\block\utils\SupportType;
|
||||
use pocketmine\block\VanillaBlocks;
|
||||
use pocketmine\entity\Entity;
|
||||
use pocketmine\event\block\BlockExplodeEvent;
|
||||
use pocketmine\event\entity\EntityDamageByBlockEvent;
|
||||
use pocketmine\event\entity\EntityDamageByEntityEvent;
|
||||
use pocketmine\event\entity\EntityDamageEvent;
|
||||
use pocketmine\event\entity\EntityExplodeEvent;
|
||||
use pocketmine\item\VanillaItems;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\utils\AssumptionFailedError;
|
||||
use pocketmine\utils\Utils;
|
||||
use pocketmine\world\format\SubChunk;
|
||||
use pocketmine\world\particle\HugeExplodeSeedParticle;
|
||||
use pocketmine\world\sound\ExplodeSound;
|
||||
@ -48,25 +52,36 @@ use function mt_rand;
|
||||
use function sqrt;
|
||||
|
||||
class Explosion{
|
||||
public const DEFAULT_FIRE_CHANCE = 1.0 / 3.0;
|
||||
|
||||
private int $rays = 16;
|
||||
public World $world;
|
||||
|
||||
/** @var Block[] */
|
||||
/**
|
||||
* @var Block[]
|
||||
* @phpstan-var array<int, Block>
|
||||
*/
|
||||
public array $affectedBlocks = [];
|
||||
public float $stepLen = 0.3;
|
||||
/** @var Block[] */
|
||||
private array $fireIgnitions = [];
|
||||
|
||||
private SubChunkExplorer $subChunkExplorer;
|
||||
|
||||
public function __construct(
|
||||
public Position $source,
|
||||
public float $radius,
|
||||
private Entity|Block|null $what = null
|
||||
private Entity|Block|null $what = null,
|
||||
private float $fireChance = 0.0
|
||||
){
|
||||
if(!$this->source->isValid()){
|
||||
throw new \InvalidArgumentException("Position does not have a valid world");
|
||||
}
|
||||
$this->world = $this->source->getWorld();
|
||||
|
||||
Utils::checkFloatNotInfOrNaN("fireChance", $fireChance);
|
||||
if($fireChance < 0.0 || $fireChance > 1.0){
|
||||
throw new \InvalidArgumentException("Fire chance must be a number between 0 and 1.");
|
||||
}
|
||||
if($radius <= 0){
|
||||
throw new \InvalidArgumentException("Explosion radius must be greater than 0, got $radius");
|
||||
}
|
||||
@ -85,6 +100,7 @@ class Explosion{
|
||||
$blockFactory = RuntimeBlockStateRegistry::getInstance();
|
||||
|
||||
$mRays = $this->rays - 1;
|
||||
$incendiary = $this->fireChance > 0;
|
||||
for($i = 0; $i < $this->rays; ++$i){
|
||||
for($j = 0; $j < $this->rays; ++$j){
|
||||
for($k = 0; $k < $this->rays; ++$k){
|
||||
@ -127,7 +143,12 @@ class Explosion{
|
||||
$_block = $this->world->getBlockAt($vBlockX, $vBlockY, $vBlockZ, true, false);
|
||||
foreach($_block->getAffectedBlocks() as $_affectedBlock){
|
||||
$_affectedBlockPos = $_affectedBlock->getPosition();
|
||||
$this->affectedBlocks[World::blockHash($_affectedBlockPos->x, $_affectedBlockPos->y, $_affectedBlockPos->z)] = $_affectedBlock;
|
||||
$posHash = World::blockHash($_affectedBlockPos->x, $_affectedBlockPos->y, $_affectedBlockPos->z);
|
||||
$this->affectedBlocks[$posHash] = $_affectedBlock;
|
||||
|
||||
if($incendiary && Utils::getRandomFloat() <= $this->fireChance){
|
||||
$this->fireIgnitions[$posHash] = $_affectedBlock;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -150,13 +171,32 @@ class Explosion{
|
||||
$yield = min(100, (1 / $this->radius) * 100);
|
||||
|
||||
if($this->what instanceof Entity){
|
||||
$ev = new EntityExplodeEvent($this->what, $this->source, $this->affectedBlocks, $yield);
|
||||
$ev = new EntityExplodeEvent($this->what, $this->source, $this->affectedBlocks, $yield, $this->fireIgnitions);
|
||||
|
||||
$ev->call();
|
||||
if($ev->isCancelled()){
|
||||
return false;
|
||||
}
|
||||
|
||||
$yield = $ev->getYield();
|
||||
$this->affectedBlocks = $ev->getBlockList();
|
||||
$this->fireIgnitions = $ev->getIgnitions();
|
||||
}elseif($this->what instanceof Block){
|
||||
$ev = new BlockExplodeEvent(
|
||||
$this->what,
|
||||
$this->source,
|
||||
$this->affectedBlocks,
|
||||
$yield,
|
||||
$this->fireIgnitions,
|
||||
);
|
||||
|
||||
$ev->call();
|
||||
if($ev->isCancelled()){
|
||||
return false;
|
||||
}else{
|
||||
$yield = $ev->getYield();
|
||||
$this->affectedBlocks = $ev->getBlockList();
|
||||
$this->affectedBlocks = $ev->getAffectedBlocks();
|
||||
$this->fireIgnitions = $ev->getIgnitions();
|
||||
}
|
||||
}
|
||||
|
||||
@ -198,8 +238,9 @@ class Explosion{
|
||||
|
||||
$air = VanillaItems::AIR();
|
||||
$airBlock = VanillaBlocks::AIR();
|
||||
$fireBlock = VanillaBlocks::FIRE();
|
||||
|
||||
foreach($this->affectedBlocks as $block){
|
||||
foreach($this->affectedBlocks as $hash => $block){
|
||||
$pos = $block->getPosition();
|
||||
if($block instanceof TNT){
|
||||
$block->ignite(mt_rand(10, 30));
|
||||
@ -212,7 +253,13 @@ class Explosion{
|
||||
if(($t = $this->world->getTileAt($pos->x, $pos->y, $pos->z)) !== null){
|
||||
$t->onBlockDestroyed(); //needed to create drops for inventories
|
||||
}
|
||||
$this->world->setBlockAt($pos->x, $pos->y, $pos->z, $airBlock);
|
||||
$targetBlock =
|
||||
isset($this->fireIgnitions[$hash]) &&
|
||||
$block->getSide(Facing::DOWN)->getSupportType(Facing::UP) === SupportType::FULL ?
|
||||
$fireBlock :
|
||||
$airBlock;
|
||||
|
||||
$this->world->setBlockAt($pos->x, $pos->y, $pos->z, $targetBlock);
|
||||
}
|
||||
}
|
||||
|
||||
@ -221,4 +268,18 @@ class Explosion{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a chance between 0 and 1 of creating a fire.
|
||||
* For example, if the chance is 1/3, then that amount of affected blocks will be ignited.
|
||||
*
|
||||
* @param float $fireChance 0 ... 1
|
||||
*/
|
||||
public function setFireChance(float $fireChance) : void{
|
||||
Utils::checkFloatNotInfOrNaN("fireChance", $fireChance);
|
||||
if($fireChance < 0.0 || $fireChance > 1.0){
|
||||
throw new \InvalidArgumentException("Fire chance must be a number between 0 and 1.");
|
||||
}
|
||||
$this->fireChance = $fireChance;
|
||||
}
|
||||
}
|
||||
|
@ -93,9 +93,11 @@ use pocketmine\world\format\io\GlobalBlockStateHandlers;
|
||||
use pocketmine\world\format\io\WritableWorldProvider;
|
||||
use pocketmine\world\format\LightArray;
|
||||
use pocketmine\world\format\SubChunk;
|
||||
use pocketmine\world\generator\executor\AsyncGeneratorExecutor;
|
||||
use pocketmine\world\generator\executor\GeneratorExecutor;
|
||||
use pocketmine\world\generator\executor\GeneratorExecutorSetupParameters;
|
||||
use pocketmine\world\generator\executor\SyncGeneratorExecutor;
|
||||
use pocketmine\world\generator\GeneratorManager;
|
||||
use pocketmine\world\generator\GeneratorRegisterTask;
|
||||
use pocketmine\world\generator\GeneratorUnregisterTask;
|
||||
use pocketmine\world\generator\PopulationTask;
|
||||
use pocketmine\world\light\BlockLightUpdate;
|
||||
use pocketmine\world\light\LightPopulationTask;
|
||||
@ -336,11 +338,7 @@ class World implements ChunkManager{
|
||||
*/
|
||||
private array $chunkPopulationRequestQueueIndex = [];
|
||||
|
||||
/**
|
||||
* @var true[]
|
||||
* @phpstan-var array<int, true>
|
||||
*/
|
||||
private array $generatorRegisteredWorkers = [];
|
||||
private readonly GeneratorExecutor $generatorExecutor;
|
||||
|
||||
private bool $autoSave = true;
|
||||
|
||||
@ -360,9 +358,6 @@ class World implements ChunkManager{
|
||||
|
||||
private bool $doingTick = false;
|
||||
|
||||
/** @phpstan-var class-string<\pocketmine\world\generator\Generator> */
|
||||
private string $generator;
|
||||
|
||||
private bool $unloaded = false;
|
||||
/**
|
||||
* @var \Closure[]
|
||||
@ -498,7 +493,23 @@ class World implements ChunkManager{
|
||||
$generator = GeneratorManager::getInstance()->getGenerator($this->provider->getWorldData()->getGenerator()) ??
|
||||
throw new AssumptionFailedError("WorldManager should already have checked that the generator exists");
|
||||
$generator->validateGeneratorOptions($this->provider->getWorldData()->getGeneratorOptions());
|
||||
$this->generator = $generator->getGeneratorClass();
|
||||
|
||||
$executorSetupParameters = new GeneratorExecutorSetupParameters(
|
||||
worldMinY: $this->minY,
|
||||
worldMaxY: $this->maxY,
|
||||
generatorSeed: $this->getSeed(),
|
||||
generatorClass: $generator->getGeneratorClass(),
|
||||
generatorSettings: $this->provider->getWorldData()->getGeneratorOptions()
|
||||
);
|
||||
$this->generatorExecutor = $generator->isFast() ?
|
||||
new SyncGeneratorExecutor($executorSetupParameters) :
|
||||
new AsyncGeneratorExecutor(
|
||||
$this->logger,
|
||||
$this->workerPool,
|
||||
$executorSetupParameters,
|
||||
$this->worldId
|
||||
);
|
||||
|
||||
$this->chunkPopulationRequestQueue = new \SplQueue();
|
||||
$this->addOnUnloadCallback(function() : void{
|
||||
$this->logger->debug("Cancelling unfulfilled generation requests");
|
||||
@ -534,17 +545,6 @@ class World implements ChunkManager{
|
||||
$this->initRandomTickBlocksFromConfig($cfg);
|
||||
|
||||
$this->timings = new WorldTimings($this);
|
||||
|
||||
$this->workerPool->addWorkerStartHook($workerStartHook = function(int $workerId) : void{
|
||||
if(array_key_exists($workerId, $this->generatorRegisteredWorkers)){
|
||||
$this->logger->debug("Worker $workerId with previously registered generator restarted, flagging as unregistered");
|
||||
unset($this->generatorRegisteredWorkers[$workerId]);
|
||||
}
|
||||
});
|
||||
$workerPool = $this->workerPool;
|
||||
$this->addOnUnloadCallback(static function() use ($workerPool, $workerStartHook) : void{
|
||||
$workerPool->removeWorkerStartHook($workerStartHook);
|
||||
});
|
||||
}
|
||||
|
||||
private function initRandomTickBlocksFromConfig(ServerConfigGroup $cfg) : void{
|
||||
@ -585,21 +585,6 @@ class World implements ChunkManager{
|
||||
return $this->tickRateTime;
|
||||
}
|
||||
|
||||
public function registerGeneratorToWorker(int $worker) : void{
|
||||
$this->logger->debug("Registering generator on worker $worker");
|
||||
$this->workerPool->submitTaskToWorker(new GeneratorRegisterTask($this, $this->generator, $this->provider->getWorldData()->getGeneratorOptions()), $worker);
|
||||
$this->generatorRegisteredWorkers[$worker] = true;
|
||||
}
|
||||
|
||||
public function unregisterGenerator() : void{
|
||||
foreach($this->workerPool->getRunningWorkers() as $i){
|
||||
if(isset($this->generatorRegisteredWorkers[$i])){
|
||||
$this->workerPool->submitTaskToWorker(new GeneratorUnregisterTask($this), $i);
|
||||
}
|
||||
}
|
||||
$this->generatorRegisteredWorkers = [];
|
||||
}
|
||||
|
||||
public function getServer() : Server{
|
||||
return $this->server;
|
||||
}
|
||||
@ -657,7 +642,7 @@ class World implements ChunkManager{
|
||||
|
||||
$this->save();
|
||||
|
||||
$this->unregisterGenerator();
|
||||
$this->generatorExecutor->shutdown();
|
||||
|
||||
$this->provider->close();
|
||||
$this->blockCache = [];
|
||||
@ -2047,6 +2032,15 @@ class World implements ChunkManager{
|
||||
throw new WorldException("Cannot set a block in un-generated terrain");
|
||||
}
|
||||
|
||||
//TODO: this computes state ID twice (we do it again in writeStateToWorld()). Not great for performance :(
|
||||
$stateId = $block->getStateId();
|
||||
if(!$this->blockStateRegistry->hasStateId($stateId)){
|
||||
throw new \LogicException("Block state ID not known to RuntimeBlockStateRegistry (probably not registered)");
|
||||
}
|
||||
if(!GlobalBlockStateHandlers::getSerializer()->isRegistered($block)){
|
||||
throw new \LogicException("Block not registered with GlobalBlockStateHandlers serializer");
|
||||
}
|
||||
|
||||
$this->timings->setBlock->startTiming();
|
||||
|
||||
$this->unlockChunk($chunkX, $chunkZ, null);
|
||||
@ -2769,6 +2763,11 @@ class World implements ChunkManager{
|
||||
throw new AssumptionFailedError("Found two different entities sharing entity ID " . $entity->getId());
|
||||
}
|
||||
}
|
||||
if(!EntityFactory::getInstance()->isRegistered($entity::class) && !$entity instanceof Player){
|
||||
//canSaveWithChunk is mutable, so that means it could be toggled after adding the entity and cause a crash
|
||||
//later on. Better we just force all entities to have a save ID, even if it might not be needed.
|
||||
throw new \LogicException("Entity " . $entity::class . " is not registered for a save ID in EntityFactory");
|
||||
}
|
||||
$pos = $entity->getPosition()->asVector3();
|
||||
$this->entitiesByChunk[World::chunkHash($pos->getFloorX() >> Chunk::COORD_BIT_SIZE, $pos->getFloorZ() >> Chunk::COORD_BIT_SIZE)][$entity->getId()] = $entity;
|
||||
$this->entityLastKnownPositions[$entity->getId()] = $pos;
|
||||
@ -2870,6 +2869,9 @@ class World implements ChunkManager{
|
||||
if(!$this->isInWorld($pos->getFloorX(), $pos->getFloorY(), $pos->getFloorZ())){
|
||||
throw new \InvalidArgumentException("Tile position is outside the world bounds");
|
||||
}
|
||||
if(!TileFactory::getInstance()->isRegistered($tile::class)){
|
||||
throw new \LogicException("Tile " . $tile::class . " is not registered for a save ID in TileFactory");
|
||||
}
|
||||
|
||||
$chunkX = $pos->getFloorX() >> Chunk::COORD_BIT_SIZE;
|
||||
$chunkZ = $pos->getFloorZ() >> Chunk::COORD_BIT_SIZE;
|
||||
@ -2980,6 +2982,8 @@ class World implements ChunkManager{
|
||||
if(count($chunkData->getEntityNBT()) !== 0){
|
||||
$this->timings->syncChunkLoadEntities->startTiming();
|
||||
$entityFactory = EntityFactory::getInstance();
|
||||
|
||||
$deletedEntities = [];
|
||||
foreach($chunkData->getEntityNBT() as $k => $nbt){
|
||||
try{
|
||||
$entity = $entityFactory->createFromData($this, $nbt);
|
||||
@ -2996,18 +3000,23 @@ class World implements ChunkManager{
|
||||
}elseif($saveIdTag instanceof IntTag){ //legacy MCPE format
|
||||
$saveId = "legacy(" . $saveIdTag->getValue() . ")";
|
||||
}
|
||||
$logger->warning("Deleted unknown entity type $saveId");
|
||||
$deletedEntities[$saveId] = ($deletedEntities[$saveId] ?? 0) + 1;
|
||||
}
|
||||
//TODO: we can't prevent entities getting added to unloaded chunks if they were saved in the wrong place
|
||||
//here, because entities currently add themselves to the world
|
||||
}
|
||||
|
||||
foreach(Utils::promoteKeys($deletedEntities) as $saveId => $count){
|
||||
$logger->warning("Deleted unknown entity type $saveId x$count");
|
||||
}
|
||||
$this->timings->syncChunkLoadEntities->stopTiming();
|
||||
}
|
||||
|
||||
if(count($chunkData->getTileNBT()) !== 0){
|
||||
$this->timings->syncChunkLoadTileEntities->startTiming();
|
||||
$tileFactory = TileFactory::getInstance();
|
||||
|
||||
$deletedTiles = [];
|
||||
foreach($chunkData->getTileNBT() as $k => $nbt){
|
||||
try{
|
||||
$tile = $tileFactory->createFromData($this, $nbt);
|
||||
@ -3017,7 +3026,8 @@ class World implements ChunkManager{
|
||||
continue;
|
||||
}
|
||||
if($tile === null){
|
||||
$logger->warning("Deleted unknown tile entity type " . $nbt->getString("id", "<unknown>"));
|
||||
$saveId = $nbt->getString("id", "<unknown>");
|
||||
$deletedTiles[$saveId] = ($deletedTiles[$saveId] ?? 0) + 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -3033,6 +3043,10 @@ class World implements ChunkManager{
|
||||
}
|
||||
}
|
||||
|
||||
foreach(Utils::promoteKeys($deletedTiles) as $saveId => $count){
|
||||
$logger->warning("Deleted unknown tile entity type $saveId x$count");
|
||||
}
|
||||
|
||||
$this->timings->syncChunkLoadTileEntities->stopTiming();
|
||||
}
|
||||
}
|
||||
@ -3469,8 +3483,8 @@ class World implements ChunkManager{
|
||||
|
||||
$centerChunk = $this->loadChunk($chunkX, $chunkZ);
|
||||
$adjacentChunks = $this->getAdjacentChunks($chunkX, $chunkZ);
|
||||
$task = new PopulationTask(
|
||||
$this->worldId,
|
||||
|
||||
$this->generatorExecutor->populate(
|
||||
$chunkX,
|
||||
$chunkZ,
|
||||
$centerChunk,
|
||||
@ -3483,15 +3497,6 @@ class World implements ChunkManager{
|
||||
$this->generateChunkCallback($chunkPopulationLockId, $chunkX, $chunkZ, $centerChunk, $adjacentChunks, $temporaryChunkLoader);
|
||||
}
|
||||
);
|
||||
$workerId = $this->workerPool->selectWorker();
|
||||
if(!isset($this->workerPool->getRunningWorkers()[$workerId]) && isset($this->generatorRegisteredWorkers[$workerId])){
|
||||
$this->logger->debug("Selected worker $workerId previously had generator registered, but is now offline");
|
||||
unset($this->generatorRegisteredWorkers[$workerId]);
|
||||
}
|
||||
if(!isset($this->generatorRegisteredWorkers[$workerId])){
|
||||
$this->registerGeneratorToWorker($workerId);
|
||||
}
|
||||
$this->workerPool->submitTaskToWorker($task, $workerId);
|
||||
|
||||
return $resolver->getPromise();
|
||||
}finally{
|
||||
|
69
src/world/biome/model/BiomeDefinitionEntryData.php
Normal file
69
src/world/biome/model/BiomeDefinitionEntryData.php
Normal file
@ -0,0 +1,69 @@
|
||||
<?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\world\biome\model;
|
||||
|
||||
/**
|
||||
* Model for loading biome definition entries data from JSON.
|
||||
*/
|
||||
final class BiomeDefinitionEntryData{
|
||||
/** @required */
|
||||
public ?int $id;
|
||||
|
||||
/** @required */
|
||||
public float $temperature;
|
||||
|
||||
/** @required */
|
||||
public float $downfall;
|
||||
|
||||
/** @required */
|
||||
public float $redSporeDensity;
|
||||
|
||||
/** @required */
|
||||
public float $blueSporeDensity;
|
||||
|
||||
/** @required */
|
||||
public float $ashDensity;
|
||||
|
||||
/** @required */
|
||||
public float $whiteAshDensity;
|
||||
|
||||
/** @required */
|
||||
public float $depth;
|
||||
|
||||
/** @required */
|
||||
public float $scale;
|
||||
|
||||
/** @required */
|
||||
public ColorData $mapWaterColour;
|
||||
|
||||
/** @required */
|
||||
public bool $rain;
|
||||
|
||||
/**
|
||||
* @required
|
||||
* @var string[]
|
||||
* @phpstan-var list<string>
|
||||
*/
|
||||
public array $tags;
|
||||
}
|
41
src/world/biome/model/ColorData.php
Normal file
41
src/world/biome/model/ColorData.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\world\biome\model;
|
||||
|
||||
/**
|
||||
* Model for loading color data from JSON.
|
||||
*/
|
||||
final class ColorData{
|
||||
/** @required */
|
||||
public int $r;
|
||||
|
||||
/** @required */
|
||||
public int $g;
|
||||
|
||||
/** @required */
|
||||
public int $b;
|
||||
|
||||
/** @required */
|
||||
public int $a;
|
||||
}
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\world\format\io\data;
|
||||
|
||||
use pocketmine\data\bedrock\WorldDataVersions;
|
||||
use pocketmine\nbt\LittleEndianNbtSerializer;
|
||||
use pocketmine\nbt\NbtDataException;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
@ -50,15 +51,9 @@ use function time;
|
||||
|
||||
class BedrockWorldData extends BaseNbtWorldData{
|
||||
|
||||
public const CURRENT_STORAGE_VERSION = 10;
|
||||
public const CURRENT_STORAGE_NETWORK_VERSION = 786;
|
||||
public const CURRENT_CLIENT_VERSION_TARGET = [
|
||||
1, //major
|
||||
21, //minor
|
||||
70, //patch
|
||||
3, //revision
|
||||
0 //is beta
|
||||
];
|
||||
public const CURRENT_STORAGE_VERSION = WorldDataVersions::STORAGE;
|
||||
public const CURRENT_STORAGE_NETWORK_VERSION = WorldDataVersions::NETWORK;
|
||||
public const CURRENT_CLIENT_VERSION_TARGET = WorldDataVersions::LAST_OPENED_IN;
|
||||
|
||||
public const GENERATOR_LIMITED = 0;
|
||||
public const GENERATOR_INFINITE = 1;
|
||||
|
@ -27,6 +27,7 @@ use pocketmine\block\Block;
|
||||
use pocketmine\data\bedrock\BiomeIds;
|
||||
use pocketmine\data\bedrock\block\BlockStateDeserializeException;
|
||||
use pocketmine\data\bedrock\block\convert\UnsupportedBlockStateException;
|
||||
use pocketmine\data\bedrock\WorldDataVersions;
|
||||
use pocketmine\nbt\LittleEndianNbtSerializer;
|
||||
use pocketmine\nbt\NBT;
|
||||
use pocketmine\nbt\NbtDataException;
|
||||
@ -35,6 +36,7 @@ use pocketmine\nbt\TreeRoot;
|
||||
use pocketmine\utils\Binary;
|
||||
use pocketmine\utils\BinaryDataException;
|
||||
use pocketmine\utils\BinaryStream;
|
||||
use pocketmine\utils\Utils;
|
||||
use pocketmine\VersionInfo;
|
||||
use pocketmine\world\format\Chunk;
|
||||
use pocketmine\world\format\io\BaseWorldProvider;
|
||||
@ -78,8 +80,8 @@ class LevelDB extends BaseWorldProvider implements WritableWorldProvider{
|
||||
|
||||
protected const ENTRY_FLAT_WORLD_LAYERS = "game_flatworldlayers";
|
||||
|
||||
protected const CURRENT_LEVEL_CHUNK_VERSION = ChunkVersion::v1_21_40;
|
||||
protected const CURRENT_LEVEL_SUBCHUNK_VERSION = SubChunkVersion::PALETTED_MULTI;
|
||||
protected const CURRENT_LEVEL_CHUNK_VERSION = WorldDataVersions::CHUNK;
|
||||
protected const CURRENT_LEVEL_SUBCHUNK_VERSION = WorldDataVersions::SUBCHUNK;
|
||||
|
||||
private const CAVES_CLIFFS_EXPERIMENTAL_SUBCHUNK_KEY_OFFSET = 4;
|
||||
|
||||
@ -203,23 +205,29 @@ class LevelDB extends BaseWorldProvider implements WritableWorldProvider{
|
||||
$blockStateData = $this->blockDataUpgrader->upgradeBlockStateNbt($blockStateNbt);
|
||||
}catch(BlockStateDeserializeException $e){
|
||||
//while not ideal, this is not a fatal error
|
||||
$blockDecodeErrors[] = "Palette offset $i / Upgrade error: " . $e->getMessage() . ", NBT: " . $blockStateNbt->toString();
|
||||
$errorMessage = "Upgrade error: " . $e->getMessage() . ", NBT: " . $blockStateNbt->toString();
|
||||
$blockDecodeErrors[$errorMessage][] = $i;
|
||||
$palette[] = $this->blockStateDeserializer->deserialize(GlobalBlockStateHandlers::getUnknownBlockStateData());
|
||||
continue;
|
||||
}
|
||||
try{
|
||||
$palette[] = $this->blockStateDeserializer->deserialize($blockStateData);
|
||||
}catch(UnsupportedBlockStateException $e){
|
||||
$blockDecodeErrors[] = "Palette offset $i / " . $e->getMessage();
|
||||
$blockDecodeErrors[$e->getMessage()][] = $i;
|
||||
$palette[] = $this->blockStateDeserializer->deserialize(GlobalBlockStateHandlers::getUnknownBlockStateData());
|
||||
}catch(BlockStateDeserializeException $e){
|
||||
$blockDecodeErrors[] = "Palette offset $i / Deserialize error: " . $e->getMessage() . ", NBT: " . $blockStateNbt->toString();
|
||||
$errorMessage = "Deserialize error: " . $e->getMessage() . ", NBT: " . $blockStateNbt->toString();
|
||||
$blockDecodeErrors[$errorMessage][] = $i;
|
||||
$palette[] = $this->blockStateDeserializer->deserialize(GlobalBlockStateHandlers::getUnknownBlockStateData());
|
||||
}
|
||||
}
|
||||
|
||||
if(count($blockDecodeErrors) > 0){
|
||||
$logger->error("Errors decoding blocks:\n - " . implode("\n - ", $blockDecodeErrors));
|
||||
$finalErrors = [];
|
||||
foreach(Utils::promoteKeys($blockDecodeErrors) as $errorMessage => $paletteOffsets){
|
||||
$finalErrors[] = "$errorMessage (palette offsets: " . implode(", ", $paletteOffsets) . ")";
|
||||
}
|
||||
$logger->error("Errors decoding blocks:\n - " . implode("\n - ", $finalErrors));
|
||||
}
|
||||
|
||||
//TODO: exceptions
|
||||
|
@ -50,7 +50,7 @@ final class GeneratorManager{
|
||||
}catch(InvalidGeneratorOptionsException $e){
|
||||
return $e;
|
||||
}
|
||||
});
|
||||
}, fast: true);
|
||||
$this->addGenerator(Normal::class, "normal", fn() => null);
|
||||
$this->addAlias("normal", "default");
|
||||
$this->addGenerator(Nether::class, "nether", fn() => null);
|
||||
@ -62,6 +62,7 @@ final class GeneratorManager{
|
||||
* @param string $name Alias for this generator type that can be written in configs
|
||||
* @param \Closure $presetValidator Callback to validate generator options for new worlds
|
||||
* @param bool $overwrite Whether to force overwriting any existing registered generator with the same name
|
||||
* @param bool $fast Whether this generator is fast enough to run without async tasks
|
||||
*
|
||||
* @phpstan-param \Closure(string) : ?InvalidGeneratorOptionsException $presetValidator
|
||||
*
|
||||
@ -69,7 +70,7 @@ final class GeneratorManager{
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function addGenerator(string $class, string $name, \Closure $presetValidator, bool $overwrite = false) : void{
|
||||
public function addGenerator(string $class, string $name, \Closure $presetValidator, bool $overwrite = false, bool $fast = false) : void{
|
||||
Utils::testValidInstance($class, Generator::class);
|
||||
|
||||
$name = strtolower($name);
|
||||
@ -77,7 +78,7 @@ final class GeneratorManager{
|
||||
throw new \InvalidArgumentException("Alias \"$name\" is already assigned");
|
||||
}
|
||||
|
||||
$this->list[$name] = new GeneratorManagerEntry($class, $presetValidator);
|
||||
$this->list[$name] = new GeneratorManagerEntry($class, $presetValidator, $fast);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -31,12 +31,15 @@ final class GeneratorManagerEntry{
|
||||
*/
|
||||
public function __construct(
|
||||
private string $generatorClass,
|
||||
private \Closure $presetValidator
|
||||
private \Closure $presetValidator,
|
||||
private readonly bool $fast
|
||||
){}
|
||||
|
||||
/** @phpstan-return class-string<Generator> */
|
||||
public function getGeneratorClass() : string{ return $this->generatorClass; }
|
||||
|
||||
public function isFast() : bool{ return $this->fast; }
|
||||
|
||||
/**
|
||||
* @throws InvalidGeneratorOptionsException
|
||||
*/
|
||||
|
@ -27,13 +27,18 @@ use pocketmine\scheduler\AsyncTask;
|
||||
use pocketmine\utils\AssumptionFailedError;
|
||||
use pocketmine\world\format\Chunk;
|
||||
use pocketmine\world\format\io\FastChunkSerializer;
|
||||
use pocketmine\world\SimpleChunkManager;
|
||||
use pocketmine\world\World;
|
||||
use pocketmine\world\generator\executor\ThreadLocalGeneratorContext;
|
||||
use function array_map;
|
||||
use function igbinary_serialize;
|
||||
use function igbinary_unserialize;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* TODO: this should be moved to the executor namespace, but plugins have unfortunately used it directly due to the
|
||||
* difficulty of regenerating chunks. This should be addressed in the future.
|
||||
* For the remainder of PM5, we can't relocate this class.
|
||||
*
|
||||
* @phpstan-type OnCompletion \Closure(Chunk $centerChunk, array<int, Chunk> $adjacentChunks) : void
|
||||
*/
|
||||
class PopulationTask extends AsyncTask{
|
||||
@ -71,8 +76,6 @@ class PopulationTask extends AsyncTask{
|
||||
if($context === null){
|
||||
throw new AssumptionFailedError("Generator context should have been initialized before any PopulationTask execution");
|
||||
}
|
||||
$generator = $context->getGenerator();
|
||||
$manager = new SimpleChunkManager($context->getWorldMinY(), $context->getWorldMaxY());
|
||||
|
||||
$chunk = $this->chunk !== null ? FastChunkSerializer::deserializeTerrain($this->chunk) : null;
|
||||
|
||||
@ -93,21 +96,15 @@ class PopulationTask extends AsyncTask{
|
||||
$serialChunks
|
||||
);
|
||||
|
||||
self::setOrGenerateChunk($manager, $generator, $this->chunkX, $this->chunkZ, $chunk);
|
||||
|
||||
$resultChunks = []; //this is just to keep phpstan's type inference happy
|
||||
foreach($chunks as $relativeChunkHash => $c){
|
||||
World::getXZ($relativeChunkHash, $relativeX, $relativeZ);
|
||||
$resultChunks[$relativeChunkHash] = self::setOrGenerateChunk($manager, $generator, $this->chunkX + $relativeX, $this->chunkZ + $relativeZ, $c);
|
||||
}
|
||||
$chunks = $resultChunks;
|
||||
|
||||
$generator->populateChunk($manager, $this->chunkX, $this->chunkZ);
|
||||
$chunk = $manager->getChunk($this->chunkX, $this->chunkZ);
|
||||
if($chunk === null){
|
||||
throw new AssumptionFailedError("We just generated this chunk, so it must exist");
|
||||
}
|
||||
$chunk->setPopulated();
|
||||
[$chunk, $chunks] = PopulationUtils::populateChunkWithAdjacents(
|
||||
$context->getWorldMinY(),
|
||||
$context->getWorldMaxY(),
|
||||
$context->getGenerator(),
|
||||
$this->chunkX,
|
||||
$this->chunkZ,
|
||||
$chunk,
|
||||
$chunks
|
||||
);
|
||||
|
||||
$this->chunk = FastChunkSerializer::serializeTerrain($chunk);
|
||||
|
||||
@ -118,18 +115,6 @@ class PopulationTask extends AsyncTask{
|
||||
$this->adjacentChunks = igbinary_serialize($serialChunks) ?? throw new AssumptionFailedError("igbinary_serialize() returned null");
|
||||
}
|
||||
|
||||
private static function setOrGenerateChunk(SimpleChunkManager $manager, Generator $generator, int $chunkX, int $chunkZ, ?Chunk $chunk) : Chunk{
|
||||
$manager->setChunk($chunkX, $chunkZ, $chunk ?? new Chunk([], false));
|
||||
if($chunk === null){
|
||||
$generator->generateChunk($manager, $chunkX, $chunkZ);
|
||||
$chunk = $manager->getChunk($chunkX, $chunkZ);
|
||||
if($chunk === null){
|
||||
throw new AssumptionFailedError("We just set this chunk, so it must exist");
|
||||
}
|
||||
}
|
||||
return $chunk;
|
||||
}
|
||||
|
||||
public function onCompletion() : void{
|
||||
/**
|
||||
* @var \Closure $onCompletion
|
||||
|
74
src/world/generator/PopulationUtils.php
Normal file
74
src/world/generator/PopulationUtils.php
Normal 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\world\generator;
|
||||
|
||||
use pocketmine\utils\AssumptionFailedError;
|
||||
use pocketmine\world\format\Chunk;
|
||||
use pocketmine\world\SimpleChunkManager;
|
||||
use pocketmine\world\World;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class PopulationUtils{
|
||||
|
||||
private static function setOrGenerateChunk(SimpleChunkManager $manager, Generator $generator, int $chunkX, int $chunkZ, ?Chunk $chunk) : Chunk{
|
||||
$manager->setChunk($chunkX, $chunkZ, $chunk ?? new Chunk([], false));
|
||||
if($chunk === null){
|
||||
$generator->generateChunk($manager, $chunkX, $chunkZ);
|
||||
$chunk = $manager->getChunk($chunkX, $chunkZ);
|
||||
if($chunk === null){
|
||||
throw new AssumptionFailedError("We just set this chunk, so it must exist");
|
||||
}
|
||||
}
|
||||
return $chunk;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Chunk[]|null[] $adjacentChunks
|
||||
* @phpstan-param array<int, Chunk|null> $adjacentChunks
|
||||
*
|
||||
* @return Chunk[]|Chunk[][]
|
||||
* @phpstan-return array{Chunk, array<int, Chunk>}
|
||||
*/
|
||||
public static function populateChunkWithAdjacents(int $minY, int $maxY, Generator $generator, int $chunkX, int $chunkZ, ?Chunk $centerChunk, array $adjacentChunks) : array{
|
||||
$manager = new SimpleChunkManager($minY, $maxY);
|
||||
self::setOrGenerateChunk($manager, $generator, $chunkX, $chunkZ, $centerChunk);
|
||||
|
||||
$resultChunks = []; //this is just to keep phpstan's type inference happy
|
||||
foreach($adjacentChunks as $relativeChunkHash => $c){
|
||||
World::getXZ($relativeChunkHash, $relativeX, $relativeZ);
|
||||
$resultChunks[$relativeChunkHash] = self::setOrGenerateChunk($manager, $generator, $chunkX + $relativeX, $chunkZ + $relativeZ, $c);
|
||||
}
|
||||
$adjacentChunks = $resultChunks;
|
||||
|
||||
$generator->populateChunk($manager, $chunkX, $chunkZ);
|
||||
$centerChunk = $manager->getChunk($chunkX, $chunkZ);
|
||||
if($centerChunk === null){
|
||||
throw new AssumptionFailedError("We just generated this chunk, so it must exist");
|
||||
}
|
||||
$centerChunk->setPopulated();
|
||||
return [$centerChunk, $adjacentChunks];
|
||||
}
|
||||
}
|
106
src/world/generator/executor/AsyncGeneratorExecutor.php
Normal file
106
src/world/generator/executor/AsyncGeneratorExecutor.php
Normal file
@ -0,0 +1,106 @@
|
||||
<?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\world\generator\executor;
|
||||
|
||||
use pocketmine\scheduler\AsyncPool;
|
||||
use pocketmine\world\format\Chunk;
|
||||
use pocketmine\world\generator\PopulationTask;
|
||||
use function array_key_exists;
|
||||
|
||||
final class AsyncGeneratorExecutor implements GeneratorExecutor{
|
||||
private static int $nextAsyncContextId = 1;
|
||||
|
||||
private readonly \Logger $logger;
|
||||
|
||||
/** @phpstan-var \Closure(int) : void */
|
||||
private readonly \Closure $workerStartHook;
|
||||
|
||||
private readonly int $asyncContextId;
|
||||
|
||||
/**
|
||||
* @var true[]
|
||||
* @phpstan-var array<int, true>
|
||||
*/
|
||||
private array $generatorRegisteredWorkers = [];
|
||||
|
||||
public function __construct(
|
||||
\Logger $logger,
|
||||
private readonly AsyncPool $workerPool,
|
||||
private readonly GeneratorExecutorSetupParameters $setupParameters,
|
||||
int $asyncContextId = null
|
||||
){
|
||||
$this->logger = new \PrefixedLogger($logger, "AsyncGeneratorExecutor");
|
||||
|
||||
//TODO: we only allow setting this for PM5 because of PopulationTask uses in plugins
|
||||
$this->asyncContextId = $asyncContextId ?? self::$nextAsyncContextId++;
|
||||
|
||||
$this->workerStartHook = function(int $workerId) : void{
|
||||
if(array_key_exists($workerId, $this->generatorRegisteredWorkers)){
|
||||
$this->logger->debug("Worker $workerId with previously registered generator restarted, flagging as unregistered");
|
||||
unset($this->generatorRegisteredWorkers[$workerId]);
|
||||
}
|
||||
};
|
||||
$this->workerPool->addWorkerStartHook($this->workerStartHook);
|
||||
}
|
||||
|
||||
private function registerGeneratorToWorker(int $worker) : void{
|
||||
$this->logger->debug("Registering generator on worker $worker");
|
||||
$this->workerPool->submitTaskToWorker(new AsyncGeneratorRegisterTask($this->setupParameters, $this->asyncContextId), $worker);
|
||||
$this->generatorRegisteredWorkers[$worker] = true;
|
||||
}
|
||||
|
||||
private function unregisterGenerator() : void{
|
||||
foreach($this->workerPool->getRunningWorkers() as $i){
|
||||
if(isset($this->generatorRegisteredWorkers[$i])){
|
||||
$this->workerPool->submitTaskToWorker(new AsyncGeneratorUnregisterTask($this->asyncContextId), $i);
|
||||
}
|
||||
}
|
||||
$this->generatorRegisteredWorkers = [];
|
||||
}
|
||||
|
||||
public function populate(int $chunkX, int $chunkZ, ?Chunk $centerChunk, array $adjacentChunks, \Closure $onCompletion) : void{
|
||||
$task = new PopulationTask(
|
||||
$this->asyncContextId,
|
||||
$chunkX,
|
||||
$chunkZ,
|
||||
$centerChunk,
|
||||
$adjacentChunks,
|
||||
$onCompletion
|
||||
);
|
||||
$workerId = $this->workerPool->selectWorker();
|
||||
if(!isset($this->workerPool->getRunningWorkers()[$workerId]) && isset($this->generatorRegisteredWorkers[$workerId])){
|
||||
$this->logger->debug("Selected worker $workerId previously had generator registered, but is now offline");
|
||||
unset($this->generatorRegisteredWorkers[$workerId]);
|
||||
}
|
||||
if(!isset($this->generatorRegisteredWorkers[$workerId])){
|
||||
$this->registerGeneratorToWorker($workerId);
|
||||
}
|
||||
$this->workerPool->submitTaskToWorker($task, $workerId);
|
||||
}
|
||||
|
||||
public function shutdown() : void{
|
||||
$this->unregisterGenerator();
|
||||
$this->workerPool->removeWorkerStartHook($this->workerStartHook);
|
||||
}
|
||||
}
|
@ -21,37 +21,20 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\world\generator;
|
||||
namespace pocketmine\world\generator\executor;
|
||||
|
||||
use pocketmine\scheduler\AsyncTask;
|
||||
use pocketmine\world\World;
|
||||
|
||||
class GeneratorRegisterTask extends AsyncTask{
|
||||
public int $seed;
|
||||
public int $worldId;
|
||||
public int $worldMinY;
|
||||
public int $worldMaxY;
|
||||
class AsyncGeneratorRegisterTask extends AsyncTask{
|
||||
|
||||
/**
|
||||
* @phpstan-param class-string<Generator> $generatorClass
|
||||
*/
|
||||
public function __construct(
|
||||
World $world,
|
||||
public string $generatorClass,
|
||||
public string $generatorSettings
|
||||
){
|
||||
$this->seed = $world->getSeed();
|
||||
$this->worldId = $world->getId();
|
||||
$this->worldMinY = $world->getMinY();
|
||||
$this->worldMaxY = $world->getMaxY();
|
||||
}
|
||||
private readonly GeneratorExecutorSetupParameters $setupParameters,
|
||||
private readonly int $contextId
|
||||
){}
|
||||
|
||||
public function onRun() : void{
|
||||
/**
|
||||
* @var Generator $generator
|
||||
* @see Generator::__construct()
|
||||
*/
|
||||
$generator = new $this->generatorClass($this->seed, $this->generatorSettings);
|
||||
ThreadLocalGeneratorContext::register(new ThreadLocalGeneratorContext($generator, $this->worldMinY, $this->worldMaxY), $this->worldId);
|
||||
$setupParameters = $this->setupParameters;
|
||||
$generator = $setupParameters->createGenerator();
|
||||
ThreadLocalGeneratorContext::register(new ThreadLocalGeneratorContext($generator, $setupParameters->worldMinY, $setupParameters->worldMaxY), $this->contextId);
|
||||
}
|
||||
}
|
@ -21,19 +21,16 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\world\generator;
|
||||
namespace pocketmine\world\generator\executor;
|
||||
|
||||
use pocketmine\scheduler\AsyncTask;
|
||||
use pocketmine\world\World;
|
||||
|
||||
class GeneratorUnregisterTask extends AsyncTask{
|
||||
public int $worldId;
|
||||
|
||||
public function __construct(World $world){
|
||||
$this->worldId = $world->getId();
|
||||
}
|
||||
class AsyncGeneratorUnregisterTask extends AsyncTask{
|
||||
public function __construct(
|
||||
private readonly int $contextId
|
||||
){}
|
||||
|
||||
public function onRun() : void{
|
||||
ThreadLocalGeneratorContext::unregister($this->worldId);
|
||||
ThreadLocalGeneratorContext::unregister($this->contextId);
|
||||
}
|
||||
}
|
38
src/world/generator/executor/GeneratorExecutor.php
Normal file
38
src/world/generator/executor/GeneratorExecutor.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?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\world\generator\executor;
|
||||
|
||||
use pocketmine\world\format\Chunk;
|
||||
|
||||
interface GeneratorExecutor{
|
||||
/**
|
||||
* @param Chunk[]|null[] $adjacentChunks
|
||||
* @phpstan-param array<int, Chunk|null> $adjacentChunks
|
||||
* @phpstan-param \Closure(Chunk $centerChunk, array<int, Chunk> $adjacentChunks) : void $onCompletion
|
||||
*/
|
||||
public function populate(int $chunkX, int $chunkZ, ?Chunk $centerChunk, array $adjacentChunks, \Closure $onCompletion) : void;
|
||||
|
||||
public function shutdown() : void;
|
||||
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
<?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\world\generator\executor;
|
||||
|
||||
use pmmp\thread\ThreadSafe;
|
||||
use pocketmine\world\generator\Generator;
|
||||
|
||||
final class GeneratorExecutorSetupParameters extends ThreadSafe{
|
||||
|
||||
/**
|
||||
* @phpstan-param class-string<covariant \pocketmine\world\generator\Generator> $generatorClass
|
||||
*/
|
||||
public function __construct(
|
||||
public readonly int $worldMinY,
|
||||
public readonly int $worldMaxY,
|
||||
public readonly int $generatorSeed,
|
||||
public readonly string $generatorClass,
|
||||
public readonly string $generatorSettings,
|
||||
){}
|
||||
|
||||
public function createGenerator() : Generator{
|
||||
/**
|
||||
* @var Generator $generator
|
||||
* @see Generator::__construct()
|
||||
*/
|
||||
$generator = new $this->generatorClass($this->generatorSeed, $this->generatorSettings);
|
||||
return $generator;
|
||||
}
|
||||
}
|
61
src/world/generator/executor/SyncGeneratorExecutor.php
Normal file
61
src/world/generator/executor/SyncGeneratorExecutor.php
Normal file
@ -0,0 +1,61 @@
|
||||
<?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\world\generator\executor;
|
||||
|
||||
use pocketmine\world\format\Chunk;
|
||||
use pocketmine\world\generator\Generator;
|
||||
use pocketmine\world\generator\PopulationUtils;
|
||||
|
||||
final class SyncGeneratorExecutor implements GeneratorExecutor{
|
||||
|
||||
private readonly Generator $generator;
|
||||
private readonly int $worldMinY;
|
||||
private readonly int $worldMaxY;
|
||||
|
||||
public function __construct(
|
||||
GeneratorExecutorSetupParameters $setupParameters
|
||||
){
|
||||
$this->generator = $setupParameters->createGenerator();
|
||||
$this->worldMinY = $setupParameters->worldMinY;
|
||||
$this->worldMaxY = $setupParameters->worldMaxY;
|
||||
}
|
||||
|
||||
public function populate(int $chunkX, int $chunkZ, ?Chunk $centerChunk, array $adjacentChunks, \Closure $onCompletion) : void{
|
||||
[$centerChunk, $adjacentChunks] = PopulationUtils::populateChunkWithAdjacents(
|
||||
$this->worldMinY,
|
||||
$this->worldMaxY,
|
||||
$this->generator,
|
||||
$chunkX,
|
||||
$chunkZ,
|
||||
$centerChunk,
|
||||
$adjacentChunks
|
||||
);
|
||||
|
||||
$onCompletion($centerChunk, $adjacentChunks);
|
||||
}
|
||||
|
||||
public function shutdown() : void{
|
||||
//NOOP
|
||||
}
|
||||
}
|
@ -21,7 +21,9 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\world\generator;
|
||||
namespace pocketmine\world\generator\executor;
|
||||
|
||||
use pocketmine\world\generator\Generator;
|
||||
|
||||
/**
|
||||
* Manages thread-local caches for generators and the things needed to support them
|
35
src/world/sound/RespawnAnchorChargeSound.php
Normal file
35
src/world/sound/RespawnAnchorChargeSound.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?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\world\sound;
|
||||
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\types\LevelSoundEvent;
|
||||
|
||||
class RespawnAnchorChargeSound implements Sound{
|
||||
|
||||
public function encode(Vector3 $pos) : array{
|
||||
return [LevelSoundEventPacket::nonActorSound(LevelSoundEvent::RESPAWN_ANCHOR_CHARGE, $pos, false)];
|
||||
}
|
||||
}
|
35
src/world/sound/RespawnAnchorDepleteSound.php
Normal file
35
src/world/sound/RespawnAnchorDepleteSound.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?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\world\sound;
|
||||
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\types\LevelSoundEvent;
|
||||
|
||||
class RespawnAnchorDepleteSound implements Sound{
|
||||
|
||||
public function encode(Vector3 $pos) : array{
|
||||
return [LevelSoundEventPacket::nonActorSound(LevelSoundEvent::RESPAWN_ANCHOR_DEPLETE, $pos, false)];
|
||||
}
|
||||
}
|
35
src/world/sound/RespawnAnchorSetSpawnSound.php
Normal file
35
src/world/sound/RespawnAnchorSetSpawnSound.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?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\world\sound;
|
||||
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\types\LevelSoundEvent;
|
||||
|
||||
class RespawnAnchorSetSpawnSound implements Sound{
|
||||
|
||||
public function encode(Vector3 $pos) : array{
|
||||
return [LevelSoundEventPacket::nonActorSound(LevelSoundEvent::RESPAWN_ANCHOR_SET_SPAWN, $pos, false)];
|
||||
}
|
||||
}
|
@ -702,12 +702,6 @@ parameters:
|
||||
count: 1
|
||||
path: ../../../src/inventory/transaction/InventoryTransaction.php
|
||||
|
||||
-
|
||||
message: '#^Cannot cast mixed to int\.$#'
|
||||
identifier: cast.int
|
||||
count: 2
|
||||
path: ../../../src/item/Item.php
|
||||
|
||||
-
|
||||
message: '#^Parameter \#1 \$buffer of method pocketmine\\nbt\\BaseNbtSerializer\:\:read\(\) expects string, mixed given\.$#'
|
||||
identifier: argument.type
|
||||
@ -1272,18 +1266,18 @@ parameters:
|
||||
count: 1
|
||||
path: ../../../src/world/format/io/region/RegionLoader.php
|
||||
|
||||
-
|
||||
message: '#^Dynamic new is not allowed\.$#'
|
||||
identifier: pocketmine.new.dynamic
|
||||
count: 1
|
||||
path: ../../../src/world/generator/GeneratorRegisterTask.php
|
||||
|
||||
-
|
||||
message: '#^Method pocketmine\\world\\generator\\biome\\BiomeSelector\:\:pickBiome\(\) should return pocketmine\\world\\biome\\Biome but returns pocketmine\\world\\biome\\Biome\|null\.$#'
|
||||
identifier: return.type
|
||||
count: 1
|
||||
path: ../../../src/world/generator/biome/BiomeSelector.php
|
||||
|
||||
-
|
||||
message: '#^Dynamic new is not allowed\.$#'
|
||||
identifier: pocketmine.new.dynamic
|
||||
count: 1
|
||||
path: ../../../src/world/generator/executor/GeneratorExecutorSetupParameters.php
|
||||
|
||||
-
|
||||
message: '#^Cannot call method getBiomeId\(\) on pocketmine\\world\\format\\Chunk\|null\.$#'
|
||||
identifier: method.nonObject
|
||||
|
@ -256,5 +256,5 @@ parameters:
|
||||
message: '#^Strict comparison using \=\=\= between 0 and 0 will always evaluate to true\.$#'
|
||||
identifier: identical.alwaysTrue
|
||||
count: 1
|
||||
path: ../rules/UnsafeForeachArrayOfStringRule.php
|
||||
path: ../rules/UnsafeForeachArrayWithStringKeysRule.php
|
||||
|
||||
|
@ -41,7 +41,7 @@ use function sprintf;
|
||||
/**
|
||||
* @implements Rule<Foreach_>
|
||||
*/
|
||||
final class UnsafeForeachArrayOfStringRule implements Rule{
|
||||
final class UnsafeForeachRule implements Rule{
|
||||
|
||||
public function getNodeType() : string{
|
||||
return Foreach_::class;
|
||||
@ -73,7 +73,7 @@ final class UnsafeForeachArrayOfStringRule implements Rule{
|
||||
$benevolentUnionDepth--;
|
||||
return $result;
|
||||
}
|
||||
if($type instanceof IntegerType && $benevolentUnionDepth === 0){
|
||||
if($type instanceof IntegerType){
|
||||
$expectsIntKeyTypes = true;
|
||||
return $type;
|
||||
}
|
||||
@ -87,24 +87,31 @@ final class UnsafeForeachArrayOfStringRule implements Rule{
|
||||
$hasCastableKeyTypes = true;
|
||||
return $type;
|
||||
});
|
||||
if($hasCastableKeyTypes && !$expectsIntKeyTypes){
|
||||
$tip = $implicitType ?
|
||||
sprintf(
|
||||
"Declare a key type using @phpstan-var or @phpstan-param, or use %s() to promote the key type to get proper error reporting",
|
||||
$errors = [];
|
||||
if($implicitType){
|
||||
$errors[] = RuleErrorBuilder::message("Possible unreported errors in foreach on array with unspecified key type.")
|
||||
->tip(sprintf(
|
||||
<<<TIP
|
||||
PHPStan might not be reporting some type errors if the key type is not specified.
|
||||
Declare a key type using @phpstan-var or @phpstan-param, or use %s() to force PHPStan to report proper errors.
|
||||
TIP,
|
||||
Utils::getNiceClosureName(Utils::promoteKeys(...))
|
||||
) :
|
||||
sprintf(
|
||||
"Use %s() to get a \Generator that will force the keys to string",
|
||||
Utils::getNiceClosureName(Utils::stringifyKeys(...)),
|
||||
);
|
||||
return [
|
||||
RuleErrorBuilder::message(sprintf(
|
||||
"Unsafe foreach on array with key type %s (they might be casted to int).",
|
||||
$iterableType->getIterableKeyType()->describe(VerbosityLevel::value())
|
||||
))->tip($tip)->identifier('pocketmine.foreach.stringKeys')->build()
|
||||
];
|
||||
))->identifier('pocketmine.foreach.implicitKeys')->build();
|
||||
}
|
||||
return [];
|
||||
if($hasCastableKeyTypes && !$expectsIntKeyTypes){
|
||||
$errors[] = RuleErrorBuilder::message(sprintf(
|
||||
"Unsafe foreach on array with key type %s.",
|
||||
$iterableType->getIterableKeyType()->describe(VerbosityLevel::value())
|
||||
))
|
||||
->tip(sprintf(
|
||||
<<<TIP
|
||||
PHP coerces numeric strings to integers when used as array keys, which can lead to unexpected type errors when passing the key to a function.
|
||||
Use %s() to wrap the array in a \Generator that will force the keys back to string during iteration.
|
||||
TIP,
|
||||
Utils::getNiceClosureName(Utils::stringifyKeys(...))
|
||||
))->identifier('pocketmine.foreach.stringKeys')->build();
|
||||
}
|
||||
return $errors;
|
||||
}
|
||||
|
||||
}
|
@ -24,16 +24,22 @@ declare(strict_types=1);
|
||||
namespace pocketmine\block;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use pocketmine\data\bedrock\BedrockDataFiles;
|
||||
use pocketmine\data\bedrock\block\BlockTypeNames;
|
||||
use pocketmine\utils\AssumptionFailedError;
|
||||
use pocketmine\utils\Filesystem;
|
||||
use pocketmine\utils\Utils;
|
||||
use pocketmine\world\format\io\GlobalBlockStateHandlers;
|
||||
use function array_fill_keys;
|
||||
use function get_debug_type;
|
||||
use function implode;
|
||||
use function is_array;
|
||||
use function is_float;
|
||||
use function is_int;
|
||||
use function is_string;
|
||||
use function json_decode;
|
||||
use function log;
|
||||
use function round;
|
||||
use const JSON_THROW_ON_ERROR;
|
||||
|
||||
class BlockTest extends TestCase{
|
||||
@ -95,6 +101,55 @@ class BlockTest extends TestCase{
|
||||
}
|
||||
}
|
||||
|
||||
public function testBlockBreakInfo() : void{
|
||||
$propertiesTable = json_decode(Filesystem::fileGetContents(BedrockDataFiles::BLOCK_PROPERTIES_TABLE_JSON), true, 3, JSON_THROW_ON_ERROR);
|
||||
if(!is_array($propertiesTable)){
|
||||
throw new AssumptionFailedError("Block properties table must be an array");
|
||||
}
|
||||
$exceptions = array_fill_keys([
|
||||
BlockTypeNames::AIR,
|
||||
BlockTypeNames::WATER,
|
||||
BlockTypeNames::FLOWING_WATER,
|
||||
BlockTypeNames::LAVA,
|
||||
BlockTypeNames::FLOWING_LAVA,
|
||||
BlockTypeNames::MANGROVE_LOG, //For some reason ONLY this wood block has blast resistance 2 instead of 10...
|
||||
], true);
|
||||
|
||||
$serializer = GlobalBlockStateHandlers::getSerializer();
|
||||
$testedBlocks = [];
|
||||
$hardnessErrors = [];
|
||||
$blastResistanceErrors = [];
|
||||
foreach($this->blockFactory->getAllKnownStates() as $block){
|
||||
$vanillaId = $serializer->serializeBlock($block)->getName();
|
||||
if(isset($exceptions[$vanillaId]) || isset($testedBlocks[$vanillaId])){
|
||||
continue;
|
||||
}
|
||||
if(!isset($propertiesTable[$vanillaId]) || !is_array($propertiesTable[$vanillaId])){
|
||||
throw new AssumptionFailedError("$vanillaId does not exist in the vanilla block properties table or is not an array");
|
||||
}
|
||||
if(!isset($propertiesTable[$vanillaId]["hardness"]) || !is_float($propertiesTable[$vanillaId]["hardness"])){
|
||||
throw new AssumptionFailedError("Hardness property is missing for $vanillaId or is not a float value");
|
||||
}
|
||||
if(!isset($propertiesTable[$vanillaId]["blastResistance"]) || !is_float($propertiesTable[$vanillaId]["blastResistance"])){
|
||||
throw new AssumptionFailedError("Blast resistance property is missing for $vanillaId or is not a float value");
|
||||
}
|
||||
$testedBlocks[$vanillaId] = true;
|
||||
|
||||
$vanillaHardness = round($propertiesTable[$vanillaId]["hardness"], 5);
|
||||
$vanillaBlastResistance = round($propertiesTable[$vanillaId]["blastResistance"], 5) * 5;
|
||||
|
||||
$breakInfo = $block->getBreakInfo();
|
||||
if($breakInfo->getHardness() !== $vanillaHardness){
|
||||
$hardnessErrors[] = "Hardness mismatch for $vanillaId (expected: $vanillaHardness, got " . $breakInfo->getHardness() . ")";
|
||||
}
|
||||
if($breakInfo->getBlastResistance() !== $vanillaBlastResistance){
|
||||
$blastResistanceErrors[] = "Blast resistance mismatch for $vanillaId (expected: $vanillaBlastResistance, got " . $breakInfo->getBlastResistance() . ")";
|
||||
}
|
||||
}
|
||||
self::assertEmpty($hardnessErrors, "Block hardness test failed:\n" . implode("\n", $hardnessErrors));
|
||||
self::assertEmpty($blastResistanceErrors, "Block blast resistance test failed:\n" . implode("\n", $blastResistanceErrors));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int[][]|string[][]
|
||||
* @phpstan-return array{array<string, int>, array<string, string>}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user