mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-08 10:53:05 +00:00
Compare commits
323 Commits
Author | SHA1 | Date | |
---|---|---|---|
75a72786f9 | |||
3d205c6e5f | |||
2955a92837 | |||
7fb1669c6d | |||
a09817864b | |||
f5bbd30dbb | |||
69d5bfa0d4 | |||
549fb923bf | |||
6d5c463bdd | |||
911ad344c9 | |||
06eaf9f273 | |||
1e56ed2ea3 | |||
40895a86e5 | |||
b081394125 | |||
f48cf68cac | |||
264cff70ec | |||
3aabfa4ab0 | |||
cb0af44ccb | |||
d535f02096 | |||
7665f4f443 | |||
20d6b69813 | |||
6b7d0307af | |||
baeac2eb07 | |||
d5f81fe261 | |||
0aeac3af7d | |||
9931c1d50a | |||
8079ae341a | |||
ba295dc7dc | |||
c19174a174 | |||
f95142f6b6 | |||
7ace24caab | |||
32f619ac49 | |||
1bb6ac4fb6 | |||
52a891ba73 | |||
71b813d4f9 | |||
f2540a72ad | |||
7e0f6c02a1 | |||
c023c02b6c | |||
adff561483 | |||
472ffb28ff | |||
726c5652f7 | |||
fc7d297f60 | |||
7b4ef293bd | |||
3683884b9c | |||
db135788b9 | |||
7210db25b0 | |||
ada469bc45 | |||
dc8243f88b | |||
1beec348f9 | |||
7306a2d939 | |||
4bf338f783 | |||
255ff63fda | |||
d72f6a3ac6 | |||
3b34268ed6 | |||
76dad46e13 | |||
eb3530b6e6 | |||
b392651354 | |||
e0b07ff308 | |||
729f831b8f | |||
29e2d92098 | |||
f75a05d7fa | |||
3dae873731 | |||
5257755dc5 | |||
3214da8642 | |||
794142fe49 | |||
ff27c5f7db | |||
4d4362801f | |||
0babe0a1ab | |||
d696ebcda3 | |||
9f5c16bc46 | |||
8865bb73ba | |||
2dee1dbc28 | |||
0f0b6f0efa | |||
d5f13d8be2 | |||
27ae959e89 | |||
f8f39687e2 | |||
94737934de | |||
debb469de1 | |||
73dc0598e4 | |||
141fbde660 | |||
69952ae2af | |||
71f2a34616 | |||
d17cd65803 | |||
a8d5e8c5f6 | |||
089e62b44e | |||
f1cc168d26 | |||
f6e53f826b | |||
986b4e0651 | |||
dc07ac33d3 | |||
9c5cec77b1 | |||
f48b703533 | |||
70636f6eb4 | |||
ead9aae23c | |||
13068ba3a7 | |||
b54854529f | |||
974d08efd6 | |||
289553fa46 | |||
e38866c4ba | |||
58a95f8836 | |||
e032b8fe20 | |||
a27c14c00c | |||
003c002208 | |||
d417b1e2f5 | |||
65e468e3c2 | |||
a11cf8c296 | |||
d455188d03 | |||
14fba36636 | |||
43ac3fbf3e | |||
352162a6e6 | |||
b3601c9390 | |||
817fec9e3d | |||
ceeef7c729 | |||
7f1b2a0ee5 | |||
27324a3aeb | |||
33b5da3749 | |||
40e88f1686 | |||
4c65a0cdaa | |||
806f03bd37 | |||
39820be836 | |||
c948aa94aa | |||
5d0d1aa4c5 | |||
9b8be22015 | |||
b0b28ec6ed | |||
2fb4704269 | |||
0c0eb72b1b | |||
466107d3b8 | |||
4f59d3487a | |||
65220b4f7f | |||
85eb6b30a5 | |||
1c2eb35025 | |||
85ed7efcb4 | |||
183489e863 | |||
ac060f2ec6 | |||
6c85d4d254 | |||
f506c922b5 | |||
a5b08fc8f2 | |||
c3c4c80b70 | |||
5695fa9086 | |||
f78808bad0 | |||
dc0082162b | |||
ff4aa148ef | |||
63e86fe806 | |||
ab05bc7379 | |||
1a395a51c9 | |||
142c8f067b | |||
cd3c96aad2 | |||
19c47fa71f | |||
d670bc8bf8 | |||
7bd8d09023 | |||
5a970541f9 | |||
e561fa6222 | |||
025dde19ce | |||
28bfe9fbb4 | |||
cd53fa162b | |||
748e9705ba | |||
219ed81389 | |||
6a7196530c | |||
01fe497c49 | |||
3bbd088a09 | |||
85effa5240 | |||
81c5b83bd9 | |||
ef31a9fc66 | |||
dc56a99473 | |||
9477034a4a | |||
5844b59b12 | |||
3af18917f0 | |||
61528393c2 | |||
59b8453228 | |||
8cb48bfe1d | |||
8fb4d7b982 | |||
13f114f30e | |||
eccd258aeb | |||
bd5f379c4c | |||
2588895ab0 | |||
432999a7d7 | |||
68699dbff9 | |||
bfbe3d83de | |||
c32c21464c | |||
16faafa1ef | |||
4d6ac57a26 | |||
73ba1ba224 | |||
8b79253d3b | |||
1122131c8d | |||
a50ef2af6f | |||
72e4660800 | |||
e6285a0312 | |||
5420e76a9a | |||
de46a81cf4 | |||
0cdc04f9b5 | |||
8b1a84f2bf | |||
155e516f74 | |||
ea0a47dff7 | |||
0a6ce18322 | |||
11d73e5bb8 | |||
492ad6bb66 | |||
82e8eb46ac | |||
c7868a810d | |||
2cc22a29c1 | |||
8e2829bdd4 | |||
af79e787ea | |||
65c53e6512 | |||
5503fadf13 | |||
99964709c9 | |||
b85f3bd149 | |||
57d274901d | |||
f3e1c82246 | |||
908b627846 | |||
afb21c1df2 | |||
988be2a96b | |||
afe67f7502 | |||
b257348a3a | |||
12c66d3362 | |||
92fd2d35a4 | |||
61077c48f1 | |||
e0c61071e1 | |||
813d431208 | |||
ee112b992d | |||
c9b33e2b9f | |||
2f2be84b12 | |||
5a7736b179 | |||
e648f1c91e | |||
5116e11cea | |||
9c05e37fbe | |||
fb4796f35e | |||
0c2ba66078 | |||
c29cd8e2eb | |||
a13b0c98a1 | |||
e6ff908e18 | |||
c47ecb55c0 | |||
c19d2fe891 | |||
f195f24f4f | |||
4b5f279a3e | |||
89260d788c | |||
a7cd081002 | |||
361be8fe36 | |||
b01e4ab417 | |||
177b963d8e | |||
8d1a1628de | |||
6f80b8979d | |||
3c8eb29d4e | |||
b94bbf6f5e | |||
314a8a1297 | |||
547503e8f4 | |||
f74ff1fcd4 | |||
6c351357ab | |||
3433406cff | |||
b307cd0aa1 | |||
c9b83d7276 | |||
e22b6ff566 | |||
af88f49a21 | |||
599d5253db | |||
54cb5ee0fa | |||
cdae8b42eb | |||
a45a4a91ae | |||
21378b7f27 | |||
502aed41b0 | |||
125837324f | |||
609dff1aae | |||
b03212053c | |||
fd4ac885bb | |||
f35886f18a | |||
a9eaa55427 | |||
5c41f79be4 | |||
34c2b62ffe | |||
e42a691da9 | |||
3b3fb5e662 | |||
01ffe8bf57 | |||
4abf4aecad | |||
b29f83ee99 | |||
4bc57f00b8 | |||
ff61e1e018 | |||
fb20bb3832 | |||
3333df31df | |||
c09fcb2df2 | |||
c7cdaeae85 | |||
4416cd5a28 | |||
cb93095857 | |||
c8f396ecbc | |||
cb06be615a | |||
0d3c11699c | |||
3667e95ff6 | |||
0e2dc51ec8 | |||
eaf85b028a | |||
9479a1a0ab | |||
1bb2d162ab | |||
ee868bcccc | |||
cbc8576d4a | |||
edcf296086 | |||
9e27c47116 | |||
a0368a843e | |||
3f64906263 | |||
19bb8a00df | |||
4816a66fb8 | |||
06f4e1e4c2 | |||
5b8166c1f0 | |||
30c5cad5b3 | |||
a7a7fe3895 | |||
55ac2f07dc | |||
0660888029 | |||
0476e6bcfc | |||
72bd37e442 | |||
f95fcecb5b | |||
61391b6e23 | |||
fbb6f1f81c | |||
712df04bc4 | |||
1563e25378 | |||
ed84252942 | |||
3d90625020 | |||
9f6b914925 | |||
0e614ea8fd | |||
401bd09d60 | |||
649671cc69 | |||
e755e1dc23 | |||
e34a444dde | |||
78f9985377 | |||
fac2bd3379 | |||
fcfd51dfc7 | |||
ccc76cf338 | |||
10a73488ed | |||
9c5114084b | |||
11630ab1aa | |||
a3068b39a2 | |||
edbc73a72c |
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -4,6 +4,7 @@
|
||||
*.sh text eol=lf
|
||||
*.txt text eol=lf
|
||||
*.properties text eol=lf
|
||||
*.neon text eol=lf
|
||||
*.bat text eol=crlf
|
||||
*.cmd text eol=crlf
|
||||
*.ps1 text eol=crlf
|
||||
|
3
.github/ISSUE_TEMPLATE/bug_report.md
vendored
3
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@ -20,8 +20,9 @@ assignees: ''
|
||||
<!-- try the `version` command | LATEST IS NOT A VALID VERSION -->
|
||||
* PocketMine-MP:
|
||||
* PHP:
|
||||
* Using JIT: yes/no (delete as appropriate) <!-- look for the giant yellow warning in the log that says you're using JIT -->
|
||||
* Server OS:
|
||||
* Game version: PE/Win10 (delete as appropriate)
|
||||
* Game version: Android/iOS/Win10/Xbox/PS4/Switch (delete as appropriate)
|
||||
|
||||
### Plugins
|
||||
<!--- use the `plugins` command and paste the output below -->
|
||||
|
8
.github/dependabot.yml
vendored
Normal file
8
.github/dependabot.yml
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: composer
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: daily
|
||||
time: "10:00"
|
||||
open-pull-requests-limit: 10
|
119
.github/workflows/draft-release.yml
vendored
Normal file
119
.github/workflows/draft-release.yml
vendored
Normal file
@ -0,0 +1,119 @@
|
||||
name: Draft release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags: "*"
|
||||
|
||||
jobs:
|
||||
draft:
|
||||
name: Create GitHub draft release
|
||||
if: "startsWith(github.event.head_commit.message, 'Release ')"
|
||||
runs-on: ubuntu-20.04
|
||||
strategy:
|
||||
fail-fast: false
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: true
|
||||
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@2.12.0
|
||||
with:
|
||||
php-version: 8.0
|
||||
|
||||
- name: Restore Composer package cache
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: |
|
||||
~/.cache/composer/files
|
||||
~/.cache/composer/vcs
|
||||
key: "composer-v2-cache-${{ hashFiles('./composer.lock') }}"
|
||||
restore-keys: |
|
||||
composer-v2-cache-
|
||||
|
||||
- name: Install Composer dependencies
|
||||
run: composer install --no-dev --prefer-dist --no-interaction --ignore-platform-reqs
|
||||
|
||||
- name: Calculate build number
|
||||
id: build-number
|
||||
run: |
|
||||
BUILD_NUMBER=$((2000+$GITHUB_RUN_NUMBER)) #to stay above jenkins
|
||||
echo "Build number: $BUILD_NUMBER"
|
||||
echo ::set-output name=BUILD_NUMBER::$BUILD_NUMBER
|
||||
|
||||
- name: Minify BedrockData JSON files
|
||||
run: php src/pocketmine/resources/vanilla/.minify_json.php
|
||||
|
||||
- name: Run preprocessor
|
||||
run: |
|
||||
PM_PREPROCESSOR_PATH="$GITHUB_WORKSPACE/build/preprocessor"
|
||||
php "$PM_PREPROCESSOR_PATH/PreProcessor.php" --path=src --multisize || (echo "Preprocessor exited with code $?" && exit 1)
|
||||
#dump the diff of preprocessor replacements to a patch in case it has bugs
|
||||
git diff > preprocessor_diff.patch
|
||||
VENDOR_PM="$GITHUB_WORKSPACE/vendor"
|
||||
VENDOR_PM_BACKUP="$GITHUB_WORKSPACE/vendor-before-preprocess"
|
||||
cp -r "$VENDOR_PM" "$VENDOR_PM_BACKUP"
|
||||
for f in $(ls $VENDOR_PM/pocketmine); do
|
||||
echo "Processing directory \"$f\"..."
|
||||
php "$PM_PREPROCESSOR_PATH/PreProcessor.php" --path="$VENDOR_PM/pocketmine/$f/src" --multisize || (echo "Preprocessor exited with code $?" && exit 1)
|
||||
echo "Checking for changes in \"$f\"..."
|
||||
DIFF=$(git diff --no-index "$VENDOR_PM_BACKUP/pocketmine/$f" "$VENDOR_PM/pocketmine/$f" || true)
|
||||
if [ "$DIFF" != "" ]; then
|
||||
PATCH="$GITHUB_WORKSPACE/preprocessor_diff_$f.patch"
|
||||
echo "$DIFF" > "$PATCH"
|
||||
echo "Generated patch file \"$PATCH\""
|
||||
else
|
||||
echo "No diff generated for \"$f\" (preprocessor made no changes)"
|
||||
fi
|
||||
done
|
||||
|
||||
- name: Build PocketMine-MP.phar
|
||||
run: php -dphar.readonly=0 build/server-phar.php --git ${{ github.sha }} --build ${{ steps.build-number.outputs.BUILD_NUMBER }}
|
||||
|
||||
- name: Get PocketMine-MP release version
|
||||
id: get-pm-version
|
||||
run: |
|
||||
echo ::set-output name=PM_VERSION::$(php -r 'require "vendor/autoload.php"; echo \pocketmine\BASE_VERSION;')
|
||||
echo ::set-output name=MCPE_VERSION::$(php -r 'require "vendor/autoload.php"; echo \pocketmine\network\mcpe\protocol\ProtocolInfo::MINECRAFT_VERSION_NETWORK;')
|
||||
echo ::set-output name=PM_VERSION_SHORT::$(php -r 'require "vendor/autoload.php"; $v = explode(".", \pocketmine\BASE_VERSION); array_pop($v); echo implode(".", $v);')
|
||||
echo ::set-output name=PM_VERSION_MD::$(php -r 'require "vendor/autoload.php"; echo str_replace(".", "", \pocketmine\BASE_VERSION);')
|
||||
|
||||
- name: Generate build info
|
||||
run: php build/generate-build-info-json.php ${{ github.sha }} ${{ steps.get-pm-version.outputs.PM_VERSION }} ${{ github.repository }} ${{ steps.build-number.outputs.BUILD_NUMBER }} > build_info.json
|
||||
|
||||
- name: Upload release artifacts
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: release_artifacts
|
||||
path: |
|
||||
${{ github.workspace }}/PocketMine-MP.phar
|
||||
${{ github.workspace }}/start.*
|
||||
${{ github.workspace }}/build_info.json
|
||||
|
||||
- name: Create draft release
|
||||
uses: ncipollo/release-action@v1.8.6
|
||||
with:
|
||||
artifacts: ${{ github.workspace }}/PocketMine-MP.phar,${{ github.workspace }}/start.*,${{ github.workspace }}/build_info.json
|
||||
commit: ${{ github.sha }}
|
||||
draft: true
|
||||
name: PocketMine-MP ${{ steps.get-pm-version.outputs.PM_VERSION }}
|
||||
tag: ${{ steps.get-pm-version.outputs.PM_VERSION }}
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
body: |
|
||||
**For Minecraft: Bedrock Edition ${{ steps.get-pm-version.outputs.MCPE_VERSION }}**
|
||||
|
||||
Please see the [changelogs](/changelogs/${{ steps.get-pm-version.outputs.PM_VERSION_SHORT }}.md#${{ steps.get-pm-version.outputs.PM_VERSION_MD }}) for details.
|
||||
|
||||
## WARNING
|
||||
|
||||
The 3.x line of releases is now OBSOLETE. It will be discontinued after **March 1st, 2022**.
|
||||
Please prepare to upgrade to 4.0 or newer before that date.
|
||||
|
||||
- name: Upload preprocessor diffs
|
||||
uses: actions/upload-artifact@v2
|
||||
if: always()
|
||||
with:
|
||||
name: preprocessor_diffs
|
||||
path: ${{ github.workspace }}/preprocessor_diff*.patch
|
||||
|
169
.github/workflows/main.yml
vendored
169
.github/workflows/main.yml
vendored
@ -13,20 +13,14 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
image: [ubuntu-20.04]
|
||||
php: [7.3.27, 7.4.15]
|
||||
php: [8.0.11]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2 #needed for build.sh
|
||||
- name: Check for PHP build cache
|
||||
id: php-build-cache
|
||||
uses: actions/cache@v2
|
||||
- name: Build and prepare PHP cache
|
||||
uses: pmmp/setup-php-action@e232f72a4330a07aae8418e8aa56b64efcdda636
|
||||
with:
|
||||
path: "./bin"
|
||||
key: "php-build-generic-${{ matrix.php }}-${{ matrix.image }}-${{ hashFiles('./tests/gh-actions/build.sh') }}"
|
||||
|
||||
- name: Compile PHP
|
||||
if: steps.php-build-cache.outputs.cache-hit != 'true'
|
||||
run: ./tests/gh-actions/build.sh "${{ matrix.php }}"
|
||||
php-version: ${{ matrix.php }}
|
||||
install-path: "./bin"
|
||||
|
||||
phpstan:
|
||||
name: PHPStan analysis
|
||||
@ -37,28 +31,16 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
image: [ubuntu-20.04]
|
||||
php: [7.3.27, 7.4.15]
|
||||
php: [8.0.11]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Restore PHP build cache
|
||||
id: php-build-cache
|
||||
uses: actions/cache@v2
|
||||
- name: Setup PHP
|
||||
uses: pmmp/setup-php-action@e232f72a4330a07aae8418e8aa56b64efcdda636
|
||||
with:
|
||||
path: "./bin"
|
||||
key: "php-build-generic-${{ matrix.php }}-${{ matrix.image }}-${{ hashFiles('./tests/gh-actions/build.sh') }}"
|
||||
|
||||
- name: Kill build on PHP build cache miss (should never happen)
|
||||
if: steps.php-build-cache.outputs.cache-hit != 'true'
|
||||
run: exit 1
|
||||
|
||||
- name: Install cached PHP's dependencies
|
||||
if: steps.php-build-cache.outputs.cache-hit == 'true'
|
||||
run: chmod +x ./bin/php7/install-dependencies.sh && ./bin/php7/install-dependencies.sh
|
||||
|
||||
- name: Prefix PHP to PATH
|
||||
run: echo "$(pwd)/bin/php7/bin" >> $GITHUB_PATH
|
||||
php-version: ${{ matrix.php }}
|
||||
install-path: "./bin"
|
||||
|
||||
- name: Install Composer
|
||||
run: curl -sS https://getcomposer.org/installer | php
|
||||
@ -87,28 +69,16 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
image: [ubuntu-20.04]
|
||||
php: [7.3.27, 7.4.15]
|
||||
php: [8.0.11]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Restore PHP build cache
|
||||
id: php-build-cache
|
||||
uses: actions/cache@v2
|
||||
- name: Setup PHP
|
||||
uses: pmmp/setup-php-action@e232f72a4330a07aae8418e8aa56b64efcdda636
|
||||
with:
|
||||
path: "./bin"
|
||||
key: "php-build-generic-${{ matrix.php }}-${{ matrix.image }}-${{ hashFiles('./tests/gh-actions/build.sh') }}"
|
||||
|
||||
- name: Kill build on PHP build cache miss (should never happen)
|
||||
if: steps.php-build-cache.outputs.cache-hit != 'true'
|
||||
run: exit 1
|
||||
|
||||
- name: Install cached PHP's dependencies
|
||||
if: steps.php-build-cache.outputs.cache-hit == 'true'
|
||||
run: chmod +x ./bin/php7/install-dependencies.sh && ./bin/php7/install-dependencies.sh
|
||||
|
||||
- name: Prefix PHP to PATH
|
||||
run: echo "$(pwd)/bin/php7/bin" >> $GITHUB_PATH
|
||||
php-version: ${{ matrix.php }}
|
||||
install-path: "./bin"
|
||||
|
||||
- name: Install Composer
|
||||
run: curl -sS https://getcomposer.org/installer | php
|
||||
@ -137,30 +107,18 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
image: [ubuntu-20.04]
|
||||
php: [7.3.27, 7.4.15]
|
||||
php: [8.0.11]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: true
|
||||
|
||||
- name: Restore PHP build cache
|
||||
id: php-build-cache
|
||||
uses: actions/cache@v2
|
||||
- name: Setup PHP
|
||||
uses: pmmp/setup-php-action@e232f72a4330a07aae8418e8aa56b64efcdda636
|
||||
with:
|
||||
path: "./bin"
|
||||
key: "php-build-generic-${{ matrix.php }}-${{ matrix.image }}-${{ hashFiles('./tests/gh-actions/build.sh') }}"
|
||||
|
||||
- name: Kill build on PHP build cache miss (should never happen)
|
||||
if: steps.php-build-cache.outputs.cache-hit != 'true'
|
||||
run: exit 1
|
||||
|
||||
- name: Install cached PHP's dependencies
|
||||
if: steps.php-build-cache.outputs.cache-hit == 'true'
|
||||
run: chmod +x ./bin/php7/install-dependencies.sh && ./bin/php7/install-dependencies.sh
|
||||
|
||||
- name: Prefix PHP to PATH
|
||||
run: echo "$(pwd)/bin/php7/bin" >> $GITHUB_PATH
|
||||
php-version: ${{ matrix.php }}
|
||||
install-path: "./bin"
|
||||
|
||||
- name: Install Composer
|
||||
run: curl -sS https://getcomposer.org/installer | php
|
||||
@ -180,3 +138,90 @@ jobs:
|
||||
|
||||
- name: Run integration tests
|
||||
run: ./tests/travis.sh -t4
|
||||
|
||||
preprocessor:
|
||||
name: Preprocessor tests
|
||||
needs: build-php
|
||||
runs-on: ${{ matrix.image }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
image: [ubuntu-20.04]
|
||||
php: [8.0.11]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: true
|
||||
|
||||
- name: Setup PHP
|
||||
uses: pmmp/setup-php-action@e232f72a4330a07aae8418e8aa56b64efcdda636
|
||||
with:
|
||||
php-version: ${{ matrix.php }}
|
||||
install-path: "./bin"
|
||||
|
||||
- name: Install Composer
|
||||
run: curl -sS https://getcomposer.org/installer | php
|
||||
|
||||
- name: Restore Composer package cache
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: |
|
||||
~/.cache/composer/files
|
||||
~/.cache/composer/vcs
|
||||
key: "composer-v2-cache-${{ matrix.php }}-${{ hashFiles('./composer.lock') }}"
|
||||
restore-keys: |
|
||||
composer-v2-cache-
|
||||
|
||||
- name: Install Composer dependencies
|
||||
run: php composer.phar install --no-dev --prefer-dist --no-interaction
|
||||
|
||||
- name: Run preprocessor
|
||||
run: |
|
||||
PM_PREPROCESSOR_PATH="$GITHUB_WORKSPACE/build/preprocessor"
|
||||
php "$PM_PREPROCESSOR_PATH/PreProcessor.php" --path=src --multisize || (echo "Preprocessor exited with code $?" && exit 1)
|
||||
|
||||
#dump the diff of preprocessor replacements to a patch in case it has bugs
|
||||
git diff > preprocessor_diff.patch
|
||||
|
||||
VENDOR_PM="$GITHUB_WORKSPACE/vendor"
|
||||
VENDOR_PM_BACKUP="$GITHUB_WORKSPACE/vendor-before-preprocess"
|
||||
cp -r "$VENDOR_PM" "$VENDOR_PM_BACKUP"
|
||||
for f in $(ls $VENDOR_PM/pocketmine); do
|
||||
echo "Processing directory \"$f\"..."
|
||||
php "$PM_PREPROCESSOR_PATH/PreProcessor.php" --path="$VENDOR_PM/pocketmine/$f/src" --multisize || (echo "Preprocessor exited with code $?" && exit 1)
|
||||
echo "Checking for changes in \"$f\"..."
|
||||
DIFF=$(git diff --no-index "$VENDOR_PM_BACKUP/pocketmine/$f" "$VENDOR_PM/pocketmine/$f" || true)
|
||||
if [ "$DIFF" != "" ]; then
|
||||
PATCH="$GITHUB_WORKSPACE/preprocessor_diff_$f.patch"
|
||||
echo "$DIFF" > "$PATCH"
|
||||
echo "Generated patch file \"$PATCH\""
|
||||
else
|
||||
echo "No diff generated for \"$f\" (preprocessor made no changes)"
|
||||
fi
|
||||
done
|
||||
|
||||
- name: Upload preprocessor diffs
|
||||
uses: actions/upload-artifact@v2
|
||||
if: always()
|
||||
with:
|
||||
name: preprocessor_diffs_${{ matrix.php }}_${{ matrix.image }}
|
||||
path: ${{ github.workspace }}/preprocessor_diff*.patch
|
||||
|
||||
codestyle:
|
||||
name: Code Style checks
|
||||
runs-on: ubuntu-20.04
|
||||
strategy:
|
||||
fail-fast: false
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Setup PHP and tools
|
||||
uses: shivammathur/setup-php@2.15.0
|
||||
with:
|
||||
php-version: 8.0
|
||||
tools: php-cs-fixer:3.2
|
||||
|
||||
- name: Run PHP-CS-Fixer
|
||||
run: php-cs-fixer fix --dry-run --diff
|
||||
|
49
.github/workflows/update-php-versions.php
vendored
Normal file
49
.github/workflows/update-php-versions.php
vendored
Normal file
@ -0,0 +1,49 @@
|
||||
<?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);
|
||||
|
||||
const VERSIONS = [
|
||||
"8.0"
|
||||
];
|
||||
|
||||
$workflowFile = file_get_contents(__DIR__ . '/main.yml');
|
||||
$newWorkflowFile = $workflowFile;
|
||||
foreach(VERSIONS as $v){
|
||||
$releaseInfo = file_get_contents("https://secure.php.net/releases?json&version=$v");
|
||||
if($releaseInfo === false){
|
||||
throw new \RuntimeException("Failed to contact php.net API");
|
||||
}
|
||||
$data = json_decode($releaseInfo, true);
|
||||
if(!is_array($data) || !isset($data["version"]) || !is_string($data["version"]) || preg_match('/^\d+\.\d+\.\d+(-[A-Za-z\d]+)?$/', $data["version"]) === 0){
|
||||
throw new \RuntimeException("Invalid data returned by API");
|
||||
}
|
||||
$updated = preg_replace("/$v\.\d+/", $data["version"], $newWorkflowFile);
|
||||
if($updated !== $newWorkflowFile){
|
||||
echo "Updated $v revision to " . $data["version"] . "\n";
|
||||
}
|
||||
$newWorkflowFile = $updated;
|
||||
}
|
||||
|
||||
if($workflowFile !== $newWorkflowFile){
|
||||
echo "Writing modified workflow file\n";
|
||||
file_put_contents(__DIR__ . '/main.yml', $newWorkflowFile);
|
||||
}
|
45
.github/workflows/update-updater-api.yml
vendored
Normal file
45
.github/workflows/update-updater-api.yml
vendored
Normal file
@ -0,0 +1,45 @@
|
||||
name: Update update.pmmp.io API info
|
||||
|
||||
on:
|
||||
release:
|
||||
types:
|
||||
- published
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Install jq
|
||||
run: sudo apt update && sudo apt install jq -y
|
||||
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
repository: pmmp/update.pmmp.io
|
||||
ssh-key: ${{ secrets.UPDATE_PMMP_IO_DEPLOY_KEY }}
|
||||
|
||||
- name: Get actual tag name
|
||||
id: tag-name
|
||||
run: echo ::set-output name=TAG_NAME::$(echo "${{ github.ref }}" | sed 's{^refs/tags/{{')
|
||||
|
||||
- name: Download new release information
|
||||
run: curl -f -L ${{ github.server_url }}/${{ github.repository }}/releases/download/${{ steps.tag-name.outputs.TAG_NAME }}/build_info.json -o new_build_info.json
|
||||
|
||||
- name: Detect channel
|
||||
id: channel
|
||||
run: echo ::set-output name=CHANNEL::$(jq -r '.channel' new_build_info.json)
|
||||
|
||||
- name: Copy release information
|
||||
run: |
|
||||
cp new_build_info.json channels/${{ steps.channel.outputs.CHANNEL }}.json
|
||||
rm new_build_info.json
|
||||
|
||||
- name: Commit changes
|
||||
run: |
|
||||
git config user.name github-actions
|
||||
git config user.email github-actions@github.com
|
||||
git add .
|
||||
git diff-index --quiet HEAD || git commit -m "New ${{ steps.channel.outputs.CHANNEL }} release: ${{ github.repository }} ${{ steps.tag-name.outputs.TAG_NAME }}"
|
||||
|
||||
- name: Push changes
|
||||
run: git push
|
5
.gitignore
vendored
5
.gitignore
vendored
@ -16,7 +16,9 @@ server.lock
|
||||
/phpstan.neon
|
||||
|
||||
# Common IDEs
|
||||
.idea/
|
||||
.idea/*
|
||||
!.idea/codeStyles/
|
||||
!.idea/fileTemplates/
|
||||
nbproject/*
|
||||
|
||||
# Windows image file caches
|
||||
@ -47,3 +49,4 @@ Documentation/*
|
||||
|
||||
# php-cs-fixer
|
||||
/.php_cs.cache
|
||||
/.php-cs-fixer.cache
|
||||
|
71
.idea/codeStyles/Project.xml
generated
Normal file
71
.idea/codeStyles/Project.xml
generated
Normal file
@ -0,0 +1,71 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<code_scheme name="Project" version="173">
|
||||
<option name="LINE_SEPARATOR" value=" " />
|
||||
<HTMLCodeStyleSettings>
|
||||
<option name="HTML_TEXT_WRAP" value="0" />
|
||||
<option name="HTML_DO_NOT_INDENT_CHILDREN_OF" value="thead,tbody,tfoot" />
|
||||
</HTMLCodeStyleSettings>
|
||||
<PHPCodeStyleSettings>
|
||||
<option name="ALIGN_PHPDOC_PARAM_NAMES" value="true" />
|
||||
<option name="PHPDOC_BLANK_LINES_AROUND_PARAMETERS" value="true" />
|
||||
<option name="LOWER_CASE_BOOLEAN_CONST" value="true" />
|
||||
<option name="LOWER_CASE_NULL_CONST" value="true" />
|
||||
<option name="VARIABLE_NAMING_STYLE" value="CAMEL_CASE" />
|
||||
<option name="SPACES_WITHIN_SHORT_ECHO_TAGS" value="false" />
|
||||
<option name="SPACE_BEFORE_CLOSURE_LEFT_PARENTHESIS" value="false" />
|
||||
<option name="FORCE_SHORT_DECLARATION_ARRAY_STYLE" value="true" />
|
||||
<option name="SPACE_BEFORE_COLON_IN_RETURN_TYPE" value="true" />
|
||||
</PHPCodeStyleSettings>
|
||||
<editorconfig>
|
||||
<option name="ENABLED" value="false" />
|
||||
</editorconfig>
|
||||
<codeStyleSettings language="HTML">
|
||||
<indentOptions>
|
||||
<option name="USE_TAB_CHARACTER" value="true" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="JSON">
|
||||
<indentOptions>
|
||||
<option name="INDENT_SIZE" value="4" />
|
||||
<option name="USE_TAB_CHARACTER" value="true" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="PHP">
|
||||
<option name="CLASS_BRACE_STYLE" value="1" />
|
||||
<option name="METHOD_BRACE_STYLE" value="1" />
|
||||
<option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
|
||||
<option name="ALIGN_MULTILINE_FOR" value="false" />
|
||||
<option name="ALIGN_MULTILINE_EXTENDS_LIST" value="true" />
|
||||
<option name="SPACE_AFTER_TYPE_CAST" value="true" />
|
||||
<option name="SPACE_BEFORE_IF_PARENTHESES" value="false" />
|
||||
<option name="SPACE_BEFORE_WHILE_PARENTHESES" value="false" />
|
||||
<option name="SPACE_BEFORE_FOR_PARENTHESES" value="false" />
|
||||
<option name="SPACE_BEFORE_CATCH_PARENTHESES" value="false" />
|
||||
<option name="SPACE_BEFORE_SWITCH_PARENTHESES" value="false" />
|
||||
<option name="SPACE_BEFORE_CLASS_LBRACE" value="false" />
|
||||
<option name="SPACE_BEFORE_METHOD_LBRACE" value="false" />
|
||||
<option name="SPACE_BEFORE_IF_LBRACE" value="false" />
|
||||
<option name="SPACE_BEFORE_ELSE_LBRACE" value="false" />
|
||||
<option name="SPACE_BEFORE_WHILE_LBRACE" value="false" />
|
||||
<option name="SPACE_BEFORE_FOR_LBRACE" value="false" />
|
||||
<option name="SPACE_BEFORE_DO_LBRACE" value="false" />
|
||||
<option name="SPACE_BEFORE_SWITCH_LBRACE" value="false" />
|
||||
<option name="SPACE_BEFORE_TRY_LBRACE" value="false" />
|
||||
<option name="SPACE_BEFORE_CATCH_LBRACE" value="false" />
|
||||
<option name="SPACE_BEFORE_FINALLY_LBRACE" value="false" />
|
||||
<option name="SPACE_BEFORE_ELSE_KEYWORD" value="false" />
|
||||
<option name="SPACE_BEFORE_WHILE_KEYWORD" value="false" />
|
||||
<option name="SPACE_BEFORE_CATCH_KEYWORD" value="false" />
|
||||
<option name="SPACE_BEFORE_FINALLY_KEYWORD" value="false" />
|
||||
<option name="KEEP_SIMPLE_METHODS_IN_ONE_LINE" value="true" />
|
||||
<indentOptions>
|
||||
<option name="USE_TAB_CHARACTER" value="true" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="neon">
|
||||
<indentOptions>
|
||||
<option name="USE_TAB_CHARACTER" value="true" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
</code_scheme>
|
||||
</component>
|
5
.idea/codeStyles/codeStyleConfig.xml
generated
Normal file
5
.idea/codeStyles/codeStyleConfig.xml
generated
Normal file
@ -0,0 +1,5 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<state>
|
||||
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
|
||||
</state>
|
||||
</component>
|
8
.idea/fileTemplates/code/PHP Constructor.php
generated
Normal file
8
.idea/fileTemplates/code/PHP Constructor.php
generated
Normal file
@ -0,0 +1,8 @@
|
||||
#if(${THROWS_DOC} != "")
|
||||
/**
|
||||
${THROWS_DOC}
|
||||
*/
|
||||
#end
|
||||
public function __construct(${PARAM_LIST}) {
|
||||
${BODY}
|
||||
}
|
6
.idea/fileTemplates/code/PHP Fluent Setter Method.php
generated
Normal file
6
.idea/fileTemplates/code/PHP Fluent Setter Method.php
generated
Normal file
@ -0,0 +1,6 @@
|
||||
/** @return $this */
|
||||
public function set${NAME}(#if (${SCALAR_TYPE_HINT})${SCALAR_TYPE_HINT} #else#end$${PARAM_NAME})#if(${RETURN_TYPE}): self#else#end
|
||||
{
|
||||
$this->${FIELD_NAME} = $${PARAM_NAME};
|
||||
return $this;
|
||||
}
|
3
.idea/fileTemplates/code/PHP Getter Method.php
generated
Normal file
3
.idea/fileTemplates/code/PHP Getter Method.php
generated
Normal file
@ -0,0 +1,3 @@
|
||||
#if(${TYPE_HINT} != ${RETURN_TYPE} && ${TYPE_HINT} != "")/** @return ${TYPE_HINT} */#end
|
||||
public ${STATIC} function ${GET_OR_IS}${NAME}()#if(${RETURN_TYPE}): ${RETURN_TYPE}#else#end
|
||||
{ return #if(${STATIC} == "static")self::$${FIELD_NAME};#else$this->${FIELD_NAME};#end }
|
2
.idea/fileTemplates/code/PHP Setter Method.php
generated
Normal file
2
.idea/fileTemplates/code/PHP Setter Method.php
generated
Normal file
@ -0,0 +1,2 @@
|
||||
public ${STATIC} function set${NAME}(#if (${SCALAR_TYPE_HINT})${SCALAR_TYPE_HINT} #end$${PARAM_NAME})#if (${VOID_RETURN_TYPE}):void #end
|
||||
{#if (${STATIC} == "static") self::$${FIELD_NAME} = $${PARAM_NAME}; #else $this->${FIELD_NAME} = $${PARAM_NAME}; #end}
|
0
.idea/fileTemplates/includes/PHP Class Doc Comment.php
generated
Normal file
0
.idea/fileTemplates/includes/PHP Class Doc Comment.php
generated
Normal file
21
.idea/fileTemplates/includes/PHP File Header.php
generated
Normal file
21
.idea/fileTemplates/includes/PHP File Header.php
generated
Normal file
@ -0,0 +1,21 @@
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* 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);
|
5
.idea/fileTemplates/includes/PHP Function Doc Comment.php
generated
Normal file
5
.idea/fileTemplates/includes/PHP Function Doc Comment.php
generated
Normal file
@ -0,0 +1,5 @@
|
||||
#if (${THROWS_DOC} != "")
|
||||
/**
|
||||
${THROWS_DOC}
|
||||
*/
|
||||
#end
|
0
.idea/fileTemplates/includes/PHP Interface Doc Comment.php
generated
Normal file
0
.idea/fileTemplates/includes/PHP Interface Doc Comment.php
generated
Normal file
1
.idea/fileTemplates/includes/PHP Property Doc Comment.php
generated
Normal file
1
.idea/fileTemplates/includes/PHP Property Doc Comment.php
generated
Normal file
@ -0,0 +1 @@
|
||||
/** @var ${TYPE_HINT} */
|
0
.idea/fileTemplates/includes/PHP Trait Doc Comment.php
generated
Normal file
0
.idea/fileTemplates/includes/PHP Trait Doc Comment.php
generated
Normal file
10
.idea/fileTemplates/internal/PHP Class.php
generated
Normal file
10
.idea/fileTemplates/internal/PHP Class.php
generated
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
#parse("PHP File Header.php")
|
||||
|
||||
#if (${NAMESPACE})
|
||||
namespace ${NAMESPACE};
|
||||
#end
|
||||
|
||||
final class ${NAME} {
|
||||
|
||||
}
|
4
.idea/fileTemplates/internal/PHP File.php
generated
Normal file
4
.idea/fileTemplates/internal/PHP File.php
generated
Normal file
@ -0,0 +1,4 @@
|
||||
<?php
|
||||
#parse("PHP File Header.php")
|
||||
|
||||
|
10
.idea/fileTemplates/internal/PHP Interface.php
generated
Normal file
10
.idea/fileTemplates/internal/PHP Interface.php
generated
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
#parse("PHP File Header.php")
|
||||
|
||||
#if (${NAMESPACE})
|
||||
namespace ${NAMESPACE};
|
||||
#end
|
||||
|
||||
interface ${NAME} {
|
||||
|
||||
}
|
10
.idea/fileTemplates/internal/PHP Trait.php
generated
Normal file
10
.idea/fileTemplates/internal/PHP Trait.php
generated
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
#parse("PHP File Header.php")
|
||||
|
||||
#if (${NAMESPACE})
|
||||
namespace ${NAMESPACE};
|
||||
#end
|
||||
|
||||
trait ${NAME} {
|
||||
|
||||
}
|
84
.php-cs-fixer.php
Normal file
84
.php-cs-fixer.php
Normal file
@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
$finder = PhpCsFixer\Finder::create()
|
||||
->in(__DIR__ . '/src')
|
||||
->in(__DIR__ . '/build')
|
||||
->in(__DIR__ . '/tests')
|
||||
->notPath('plugins/DevTools')
|
||||
->notPath('preprocessor')
|
||||
->notContains('#ifndef COMPILE') //preprocessor will break if these are changed
|
||||
->notName('PocketMine.php');
|
||||
|
||||
return (new PhpCsFixer\Config)
|
||||
->setRiskyAllowed(true)
|
||||
->setRules([
|
||||
'align_multiline_comment' => [
|
||||
'comment_type' => 'phpdocs_only'
|
||||
],
|
||||
'array_indentation' => true,
|
||||
'array_syntax' => [
|
||||
'syntax' => 'short'
|
||||
],
|
||||
'binary_operator_spaces' => [
|
||||
'default' => 'single_space'
|
||||
],
|
||||
'blank_line_after_namespace' => true,
|
||||
'blank_line_after_opening_tag' => true,
|
||||
'blank_line_before_statement' => [
|
||||
'statements' => [
|
||||
'declare'
|
||||
]
|
||||
],
|
||||
'cast_spaces' => [
|
||||
'space' => 'single'
|
||||
],
|
||||
'concat_space' => [
|
||||
'spacing' => 'one'
|
||||
],
|
||||
'declare_strict_types' => true,
|
||||
'elseif' => true,
|
||||
'global_namespace_import' => [
|
||||
'import_constants' => true,
|
||||
'import_functions' => true,
|
||||
'import_classes' => null,
|
||||
],
|
||||
'indentation_type' => true,
|
||||
'native_function_invocation' => [
|
||||
'scope' => 'namespaced',
|
||||
'include' => ['@all'],
|
||||
],
|
||||
'no_closing_tag' => true,
|
||||
'no_empty_phpdoc' => true,
|
||||
'no_extra_blank_lines' => true,
|
||||
'no_superfluous_phpdoc_tags' => [
|
||||
'allow_mixed' => true,
|
||||
],
|
||||
'no_trailing_whitespace' => true,
|
||||
'no_trailing_whitespace_in_comment' => true,
|
||||
'no_whitespace_in_blank_line' => true,
|
||||
'no_unused_imports' => true,
|
||||
'ordered_imports' => [
|
||||
'imports_order' => [
|
||||
'class',
|
||||
'function',
|
||||
'const',
|
||||
],
|
||||
'sort_algorithm' => 'alpha'
|
||||
],
|
||||
'phpdoc_line_span' => [
|
||||
'property' => 'single',
|
||||
'method' => null,
|
||||
'const' => null
|
||||
],
|
||||
'phpdoc_trim' => true,
|
||||
'phpdoc_trim_consecutive_blank_line_separation' => true,
|
||||
'return_type_declaration' => [
|
||||
'space_before' => 'one'
|
||||
],
|
||||
'single_import_per_statement' => true,
|
||||
'strict_param' => true,
|
||||
'unary_operator_spaces' => true,
|
||||
])
|
||||
->setFinder($finder)
|
||||
->setIndent("\t")
|
||||
->setLineEnding("\n");
|
@ -2,13 +2,13 @@
|
||||
## Pre-requisites
|
||||
- A bash shell (git bash is sufficient for Windows)
|
||||
- [`git`](https://git-scm.com) available in your shell
|
||||
- PHP 7.3 or newer available in your shell
|
||||
- PHP 8.0 or newer available in your shell
|
||||
- [`composer`](https://getcomposer.org) available in your shell
|
||||
|
||||
## Custom PHP binaries
|
||||
Because PocketMine-MP requires several non-standard PHP extensions and configuration, PMMP provides scripts to build custom binaries for running PocketMine-MP, as well as prebuilt binaries.
|
||||
|
||||
- [Prebuilt binaries](https://jenkins.pmmp.io/job/PHP-7.3-Aggregate)
|
||||
- [Prebuilt binaries](https://jenkins.pmmp.io/job/PHP-8.0-Aggregate)
|
||||
- [Compile scripts](https://github.com/pmmp/php-build-scripts) are provided as a submodule in the path `build/php`
|
||||
|
||||
If you use a custom binary, you'll need to replace `composer` usages in this guide with `path/to/your/php path/to/your/composer.phar`.
|
||||
@ -38,7 +38,7 @@ There is a bug in PHP that might cause an error which looks like this:
|
||||
```
|
||||
Fatal error: Uncaught BadMethodCallException: unable to create temporary file in PocketMine-MP/build/server-phar.php:119
|
||||
```
|
||||
You can work around it by setting `ulimit -n` to some bigger number, e.g. `8192`, or by updating your PHP version to at least 7.4.16 or 8.0.3.
|
||||
You can work around it by setting `ulimit -n` to some bigger number, e.g. `8192`, or by updating your PHP version to at least 8.0.3.
|
||||
|
||||
## Running PocketMine-MP from source code
|
||||
Run `src/pocketmine/PocketMine.php` using your preferred PHP binary.
|
||||
|
181
CONTRIBUTING.md
181
CONTRIBUTING.md
@ -2,125 +2,102 @@
|
||||
|
||||
# PocketMine-MP Contribution Guidelines
|
||||
|
||||
PocketMine-MP is an open source project, and contributions from the community are welcomed, as long as they comply with our quality standards and licensing.
|
||||
|
||||
## Creating an Issue
|
||||
- If you are reporting a bug:
|
||||
- **make sure that you are using the latest supported version** before opening an issue.
|
||||
- **test it on a clean test server, WITHOUT PLUGINS**, to see if the issue still occurs. If not then it may be a plugin issue. Please also indicate the result of such tests.
|
||||
- **[Search the issue tracker](https://github.com/pmmp/PocketMine-MP/issues?utf8=%E2%9C%93&q=is%3Aissue)** to check if anyone has already reported it, to avoid needlessly creating duplicate issues. Make sure you also check closed issues, as an issue you think is valid may already have been resolved.
|
||||
- **Do not report plugin issues here.** If your issue is related to a plugin, contact the plugin's original author instead.
|
||||
- **Support requests are not bugs.** Issues such as "How do I do this" are not bugs and will be closed. If you need help, please see [here](README.md#discussion) and do not misuse our issue tracker.
|
||||
- **No generic titles** such as "Question", "Help", "Crash Report" etc. A good issue report provides a quick summary in the title. If you just got a crash report but you don't understand it, please look for a line starting with `Message`. It summarizes the bug.
|
||||
- **Provide information in the issue body, not in the title.** No tags like `[BUG]` are allowed in the title, including `[SOLVED]` for solved issues.
|
||||
- **No generic issue reports.** For bugs, it is the issue author's responsibility to provide us an issue that is **trackable, debuggable, reproducible, reported professionally and is an actual bug**.
|
||||
<br>Valid issue reports must include instructions how to reproduce the issue or a crashdump/backtrace (unless the cause of the issue is obvious).
|
||||
<br>**If you do not provide us with a summary or instructions on how to reproduce the issue, it will be treated as spam and will therefore be closed.**
|
||||
<br>In simple words, if the issue cannot be properly confirmed to be valid or lacks required information, the issue will be closed until further information is provided.
|
||||
- To express appreciation, objection, confusion or other supported reactions on pull requests, issues or comments on them, use GitHub [reactions](https://github.com/blog/2119-add-reactions-to-pull-requests-issues-and-comments) rather than posting an individual comment with an emoji only. This helps keeping the issue/pull request conversation clean and readable.
|
||||
- If your issue is related to the PocketMine-MP website, forums, etc., please [talk to a human directly](README.md#discussion).
|
||||
Code contributions must be submitted using [GitHub Pull Requests](https://github.com/pmmp/PocketMine-MP/pulls), where they will be reviewed by maintainers.
|
||||
|
||||
Small contributions (e.g. minor bug fixes) can be submitted as pull requests directly.
|
||||
|
||||
Larger contributions like feature additions should be preceded by a [Change Proposal](#rfcs--change-proposals) to allow maintainers and other people to discuss and decide if it's a good idea or not.
|
||||
|
||||
## Contributing
|
||||
To contribute to the repository, [fork it on GitHub](https://github.com/pmmp/PocketMine-MP/fork), create a branch on your fork, and make your changes on your fork. You can then make a [pull request](https://github.com/pmmp/PocketMine-MP/pull/new) to the project to compare your branch to ours and propose your changes to our repository. We use the Pull Request system to allow members of the team to review changes before they are merged.
|
||||
## Useful documentation from github.com
|
||||
- [About pull requests](https://docs.github.com/en/github/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests)
|
||||
- [About forks](https://docs.github.com/en/github/collaborating-with-pull-requests/working-with-forks/about-forks)
|
||||
- [Creating a pull request from a fork](https://docs.github.com/en/github/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork)
|
||||
|
||||
### Licensing
|
||||
By proposing a pull request to the project, you agree to your code being distributed within PocketMine-MP under the [LGPL license](LICENSE).
|
||||
## Other things you'll need
|
||||
- [git](https://git-scm.com/)
|
||||
|
||||
### Contribution standards
|
||||
- **We enforce a very high standard for contributions**. This is because PocketMine-MP and its related projects are used very widely in production. While this might seem like we are being mean at times, **our priority is what is best for PocketMine-MP itself**.
|
||||
We try to ensure that our project's codebase is as clean as possible and ensure that only top-quality material makes it through to PocketMine-MP itself.
|
||||
- **If a contribution does not meet our standards, changes may be requested or the pull request may be closed.**
|
||||
## Making a pull request
|
||||
The basic procedure to create a pull request is:
|
||||
1. [Fork the repository on GitHub](https://github.com/pmmp/PocketMine-MP/fork). This gives you your own copy of the repository to make changes to.
|
||||
2. Create a branch on your fork for your changes.
|
||||
3. Make the changes you want to make on this branch.
|
||||
4. You can then make a [pull request](https://github.com/pmmp/PocketMine-MP/pull/new) to the project.
|
||||
|
||||
### Pull requests
|
||||
- **Create a new branch for each pull request.** Do not create a pull request with commits that exist in another pull request.
|
||||
## Pull request reviews
|
||||
Pull requests will be reviewed by maintainers when they are available.
|
||||
Note that there might be a long wait time before a reviewer looks at your PR.
|
||||
|
||||
Depending on the changes, maintainers might ask you to make changes to the PR to fix problems or to improve the code.
|
||||
**Do not delete your fork** while your pull request remains open, otherwise you won't be able to make any requested changes and the PR will end up being declined.
|
||||
|
||||
### Requirements
|
||||
The following are required as a minimum for pull requests. PRs that don't meet these requirements will be declined unless updated to meet them.
|
||||
|
||||
#### Licensing
|
||||
PocketMine-MP is licensed under [LGPLv3 license](LICENSE).
|
||||
By proposing a pull request, you agree to your code being distributed within PocketMine-MP under the same license.
|
||||
If you take code from other projects, that code MUST be licensed under an LGPL-compatible license.
|
||||
|
||||
#### PRs should be about exactly ONE thing
|
||||
If you want to make multiple changes, those changes should each be contributed as separate pull requests. **DO NOT** mix unrelated changes.
|
||||
|
||||
#### PRs must not include unnecessary/unrelated changes
|
||||
Do not include changes which aren't strictly necessary. This makes it harder to review a PR, because the code diff becomes larger and harder to review.
|
||||
This means:
|
||||
- don't reformat or rearrange existing code
|
||||
- don't change things that aren't related to the PR's objective
|
||||
- don't rewrite existing code just to make it "look nicer"
|
||||
- don't change PhpDocs to native types in code you didn't write
|
||||
|
||||
#### Tests must be provided
|
||||
Where possible, PHPUnit tests should be written for new or changed code.
|
||||
If that's not possible (e.g. for in-game functionality), the code must be tested manually and details of the tests done must be provided.
|
||||
**Simply saying "Tested" is not acceptable** and will lead to your PR being declined.
|
||||
|
||||
#### Comments and documentation must be written in American English
|
||||
English is the shared languages of all current maintainers.
|
||||
|
||||
#### Code must be in the PocketMine-MP style
|
||||
It's your responsibility to ensure your code matches the formatting and styling of the rest of the code.
|
||||
If you use PhpStorm, a `Project` code style is provided, which you can use to automatically format new code.
|
||||
You can also use [`php-cs-fixer`](https://github.com/FriendsOfPHP/PHP-CS-Fixer) to format your code.
|
||||
|
||||
### Recommendations
|
||||
|
||||
- **Do not edit code directly on github.com.** We recommend learning how to use [`git`](https://git-scm.com). `git` allows you to "clone" a repository onto your computer, so that you can make changes using an IDE.
|
||||
- **Use an IDE, not a text editor.** We recommend PhpStorm or VSCode.
|
||||
- **Create a new branch on your fork for each pull request.** This allows you to use the same fork to make multiple pull requests at the same time.
|
||||
- **Use descriptive commit titles.** You can see an example [here](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).
|
||||
- **Do not include multiple unrelated changes in one commit.** An atomic style for commits is preferred - this means that changes included in a commit should be part of a single distinct change set. See [this link](https://www.freshconsulting.com/atomic-commits/) for more information on atomic commits. See the [documentation on `git add`](https://git-scm.com/docs/git-add) for information on how to isolate local changes for committing.
|
||||
- **Your pull request will be checked and discussed in due time.** Since the team is scattered all around the world, your PR may not receive any attention for some time.
|
||||
- **It is inadvisable to create large pull requests with lots of changes** unless this has been discussed with the team beforehand. Large pull requests are difficult to review, and such pull requests may end up being closed. The only exception is when all features in the pull request are related to each other, and share the same core changes.
|
||||
- **You may be asked to rebase your pull request** if the branch becomes outdated and/or if possibly conflicting changes are made to the target branch. To see how to do this, read [this page](https://github.com/edx/edx-platform/wiki/How-to-Rebase-a-Pull-Request).
|
||||
- **Details should be provided of tests done.** Simply saying "Tested" or equivalent is not acceptable.
|
||||
|
||||
### Code contributions
|
||||
- **Avoid committing changes directly on GitHub. This includes use of the web editor, and also uploading files.** The web editor lacks most useful GIT features and **should only be used for very minor changes**. It is immediately clear if the web editor has been used, and if so the PR is more likely to be rejected. If you want to make serious contributions, **please learn how to use [GIT version control](https://git-scm.com/)**.
|
||||
- **Do not copy-paste code**. There are potential license issues implicit with copy-pasting, and copy-paste usually indicates a lack of understanding of the actual code. Copy-pasted code is obvious a mile off and **any PR like this is likely to be closed**. If you want to use somebody else's code from a Git repository, **use [GIT's cherry-pick feature](https://git-scm.com/docs/git-cherry-pick)** to cherry-pick the commit. **Cherry-picking is the politer way to copy somebody's changes** and retains all the original accreditation, so there is no need for copy-pasted commits with descriptions like `Some code, thanks @exampleperson`.
|
||||
- **Make sure you can explain your changes**. If you can't provide a good explanation of changes, your PR may be rejected.
|
||||
- **Code should use the same style as in PocketMine-MP.** See [below](#code-syntax) for an example.
|
||||
- **The code must be clear** and written in English, comments included.
|
||||
- **Do not make large pull requests without an RFC.** Large changes should be discussed beforehand using the [RFC / Change Proposal](#rfcs--change-proposals) process. Large changes are much harder to review and are more likely to be declined if maintainers don't have a good idea what you're trying to do in advance.
|
||||
- **Do not copy-paste code**. There are potential license issues implicit with copy-pasting, and copy-paste usually indicates a lack of understanding of the actual code. Copy-pasted code is obvious a mile off and **any PR like this is likely to be closed**. If you want to use somebody else's code from a Git repository, **use [GIT's cherry-pick feature](https://git-scm.com/docs/git-cherry-pick)** to cherry-pick the commit.
|
||||
|
||||
|
||||
**Thanks for contributing to PocketMine-MP!**
|
||||
|
||||
## RFCs / Change Proposals
|
||||
Change Proposals are issues or discussions which describe a new feature proposal or behavioural change.
|
||||
They are used to get feedback from maintainers and the community about an idea for a change, to decide whether or not it's a good idea.
|
||||
|
||||
### Submitting an RFC
|
||||
RFCs should be submitted using Issues or Discussions.
|
||||
RFCs _can_ be submitted as pull requests if you've already written the code, but this is not recommended, since it's not guaranteed that an RFC will pass, in which case your effort would be wasted.
|
||||
|
||||
### Code Syntax
|
||||
RFCs should include the following:
|
||||
- A summary of what you want to change
|
||||
- Why you want to change it (e.g. what problems it solves)
|
||||
- Alternative methods you've considered to solve the problem. This should include any possible ways that what you want can be done without the change.
|
||||
|
||||
It is mainly [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-1-basic-coding-standard.md) with a few exceptions.
|
||||
### Voting on RFCs
|
||||
Community members can vote on RFCs. This gives maintainers an idea of how popular the idea is.
|
||||
Votes can be cast using :+1: and :-1: reactions.
|
||||
|
||||
- Opening braces MUST go on the same line, and MUST NOT have spaces before.
|
||||
- `else if` MUST be written as `elseif`. _(It is in PSR-2, but using a SHOULD)_
|
||||
- Control structure keywords or opening braces MUST NOT have one space before or after them.
|
||||
- Code MUST use tabs for indenting.
|
||||
- Long arrays MAY be split across multiple lines, where each subsequent line is indented once.
|
||||
- Files MUST use only the `<?php` tag.
|
||||
- Files MUST NOT have an ending `?>` tag.
|
||||
- Code MUST use namespaces.
|
||||
- Strings SHOULD use the double quote `"` except when the single quote is required.
|
||||
- All code SHOULD have parameter and type declarations where possible.
|
||||
- Strict types SHOULD be enabled on new files where it is sensible to do so.
|
||||
- All constant declarations SHOULD be preceded by a visibility modifier.
|
||||
**Please don't downvote without providing a reason why!**
|
||||
|
||||
```php
|
||||
<?php
|
||||
### Implementing RFCs
|
||||
Anyone can write the code to implement an RFC, and submit a pull request for it. It doesn't have to be the RFC author.
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\example;
|
||||
|
||||
class ExampleClass{
|
||||
|
||||
public const EXAMPLE_CLASS_CONSTANT = 1;
|
||||
|
||||
public $examplePublicVariable = "defaultValue";
|
||||
private $examplePrivateVariable;
|
||||
|
||||
/**
|
||||
* Creates an instance of ExampleClass
|
||||
*
|
||||
* @param string $firstArgument the first argument
|
||||
* @param string|null $secondArgument default null
|
||||
*/
|
||||
public function __construct(string $firstArgument, ?string &$secondArgument = null){
|
||||
if($firstArgument === "exampleValue"){ //Remember to use === instead of == when possible
|
||||
//do things
|
||||
}elseif($firstArgument === "otherValue"){
|
||||
$secondArgument = function(){
|
||||
$this->examplePrivateVariable = [
|
||||
0 => "value1",
|
||||
1 => "value2",
|
||||
2 => "value3",
|
||||
3 => "value4",
|
||||
4 => "value5",
|
||||
5 => "value6",
|
||||
];
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public function doStuff(string $stuff) : string{
|
||||
return $stuff;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
<!-- TODO: RFC and voting on the forums instead -->
|
||||
### RFC and Voting
|
||||
* These are big Pull Requests or contributions that change important behavior.
|
||||
* RFCs will be tagged with the *Type: Request For Comments* label
|
||||
* A vote will be held once the RFC is ready. All users can vote commenting on the Pull Request
|
||||
* Comments MUST use "Yes" or "No" on the FIRST sentence to signify the vote, except when they don't want it to be counted.
|
||||
* If your comment is a voting comment, specify the reason of your vote or it won't be counted.
|
||||
* After voting has been closed, no further votes will be counted.
|
||||
* An RFC will be rejected if less than 50% + 1 (simple majority) has voted Yes.
|
||||
* If the RFC is approved, Team Members have the final word on its implementation or rejection.
|
||||
* RFCs with complex voting options will specify the vote percentage or other details.
|
||||
Implementations should be submitted as pull requests. The pull request description must include a link to the RFC.
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
<p align="center">
|
||||
<img src="https://github.com/pmmp/PocketMine-MP/workflows/CI/badge.svg" alt="CI" />
|
||||
<a href="https://github.com/pmmp/PocketMine-MP/releases"><img src="https://img.shields.io/github/v/tag/pmmp/PocketMine-MP?label=release&logo=github" alt="GitHub tag (latest semver)" /></a>
|
||||
<img alt="GitHub release (latest SemVer)" src="https://img.shields.io/github/v/release/pmmp/PocketMine-MP?label=release&sort=semver">
|
||||
<a href="https://hub.docker.com/r/pmmp/pocketmine-mp"><img src="https://img.shields.io/docker/v/pmmp/pocketmine-mp?logo=docker&label=image" alt="Docker image version (latest semver)" /></a>
|
||||
<a href="https://discord.gg/bmSAZBG"><img src="https://img.shields.io/discord/373199722573201408?label=discord&color=7289DA&logo=discord" alt="Discord" /></a>
|
||||
</p>
|
||||
@ -23,6 +23,7 @@
|
||||
|
||||
## For developers
|
||||
* [Building and running from source](BUILDING.md)
|
||||
* [Developer documentation](https://devdoc.pmmp.io) - General documentation for PocketMine-MP plugin developers
|
||||
* [Latest API documentation](https://jenkins.pmmp.io/job/PocketMine-MP-doc/doxygen/) - Doxygen documentation generated from development
|
||||
* [DevTools](https://github.com/pmmp/DevTools/) - Development tools plugin for creating plugins
|
||||
* [ExamplePlugin](https://github.com/pmmp/ExamplePlugin/) - Example plugin demonstrating some basic API features
|
||||
|
@ -1,13 +1,5 @@
|
||||
# Security Policy
|
||||
|
||||
## Supported Versions
|
||||
The following release lines are currently receiving active security updates and bug fixes:
|
||||
|
||||
| Version | Supported |
|
||||
| -------- | ------------------ |
|
||||
| 3.15.x | :white_check_mark: |
|
||||
| < 3.15.0 | :x: |
|
||||
|
||||
## Reporting a Vulnerability
|
||||
|
||||
**DO NOT report vulnerabilities on the GitHub issue tracker.**
|
||||
|
43
build/generate-build-info-json.php
Normal file
43
build/generate-build-info-json.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?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);
|
||||
|
||||
require dirname(__DIR__) . '/vendor/autoload.php';
|
||||
|
||||
if(count($argv) !== 5){
|
||||
fwrite(STDERR, "required args: <git hash> <tag name> <github repo (owner/name)> <build number>");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
echo json_encode([
|
||||
"php_version" => sprintf("%d.%d", PHP_MAJOR_VERSION, PHP_MINOR_VERSION),
|
||||
"base_version" => \pocketmine\BASE_VERSION,
|
||||
"build" => (int) $argv[4],
|
||||
"is_dev" => \pocketmine\IS_DEVELOPMENT_BUILD,
|
||||
"channel" => \pocketmine\BUILD_CHANNEL,
|
||||
"git_commit" => $argv[1],
|
||||
"mcpe_version" => \pocketmine\network\mcpe\protocol\ProtocolInfo::MINECRAFT_VERSION_NETWORK,
|
||||
"date" => time(), //TODO: maybe we should embed this in VersionInfo?
|
||||
"details_url" => "https://github.com/$argv[3]/releases/tag/$argv[2]",
|
||||
"download_url" => "https://github.com/$argv[3]/releases/download/$argv[2]/PocketMine-MP.phar",
|
||||
"source_url" => "https://github.com/$argv[3]/tree/$argv[2]",
|
||||
], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . "\n";
|
@ -24,60 +24,108 @@ declare(strict_types=1);
|
||||
namespace pocketmine\build\make_release;
|
||||
|
||||
use pocketmine\utils\VersionString;
|
||||
use function array_keys;
|
||||
use function array_map;
|
||||
use function dirname;
|
||||
use function fgets;
|
||||
use function file_get_contents;
|
||||
use function file_put_contents;
|
||||
use function fwrite;
|
||||
use function getopt;
|
||||
use function is_string;
|
||||
use function max;
|
||||
use function preg_replace;
|
||||
use function sleep;
|
||||
use function sprintf;
|
||||
use function str_pad;
|
||||
use function strlen;
|
||||
use function system;
|
||||
use const pocketmine\BASE_VERSION;
|
||||
use const pocketmine\BUILD_CHANNEL;
|
||||
use const STDERR;
|
||||
use const STDIN;
|
||||
use const STDOUT;
|
||||
use const STR_PAD_LEFT;
|
||||
|
||||
require_once dirname(__DIR__) . '/vendor/autoload.php';
|
||||
|
||||
function replaceVersion(string $versionInfoPath, string $newVersion, bool $isDev) : void{
|
||||
function replaceVersion(string $versionInfoPath, string $newVersion, bool $isDev, string $channel) : void{
|
||||
$versionInfo = file_get_contents($versionInfoPath);
|
||||
$versionInfo = preg_replace(
|
||||
$pattern = '/^const BASE_VERSION = "(\d+)\.(\d+)\.(\d+)(?:-(.*))?";$/m',
|
||||
'const BASE_VERSION = "' . $newVersion . '";',
|
||||
$pattern = '/^([\t ]*public )?const BASE_VERSION = "(\d+)\.(\d+)\.(\d+)(?:-(.*))?";$/m',
|
||||
'$1const BASE_VERSION = "' . $newVersion . '";',
|
||||
$versionInfo
|
||||
);
|
||||
$versionInfo = preg_replace(
|
||||
'/^const IS_DEVELOPMENT_BUILD = (?:true|false);$/m',
|
||||
'const IS_DEVELOPMENT_BUILD = ' . ($isDev ? 'true' : 'false') . ';',
|
||||
'/^([\t ]*public )?const IS_DEVELOPMENT_BUILD = (?:true|false);$/m',
|
||||
'$1const IS_DEVELOPMENT_BUILD = ' . ($isDev ? 'true' : 'false') . ';',
|
||||
$versionInfo
|
||||
);
|
||||
$versionInfo = preg_replace(
|
||||
'/^([\t ]*public )?const BUILD_CHANNEL = ".*";$/m',
|
||||
'$1const BUILD_CHANNEL = "' . $channel . '";',
|
||||
$versionInfo
|
||||
);
|
||||
file_put_contents($versionInfoPath, $versionInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string[] $argv
|
||||
* @phpstan-param list<string> $argv
|
||||
*/
|
||||
function main(array $argv) : void{
|
||||
if(isset($argv[1])){
|
||||
$currentVer = new VersionString($argv[1]);
|
||||
const ACCEPTED_OPTS = [
|
||||
"current" => "Version to insert and tag",
|
||||
"next" => "Version to put in the file after tagging",
|
||||
"channel" => "Release channel to post this build into"
|
||||
];
|
||||
|
||||
function main() : void{
|
||||
$filteredOpts = [];
|
||||
foreach(getopt("", ["current:", "next:", "channel:", "help"]) as $optName => $optValue){
|
||||
if($optName === "help"){
|
||||
fwrite(STDOUT, "Options:\n");
|
||||
|
||||
$maxLength = max(array_map(fn(string $str) => strlen($str), array_keys(ACCEPTED_OPTS)));
|
||||
foreach(ACCEPTED_OPTS as $acceptedName => $description){
|
||||
fwrite(STDOUT, str_pad("--$acceptedName", $maxLength + 4, " ", STR_PAD_LEFT) . ": $description\n");
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
if(!is_string($optValue)){
|
||||
fwrite(STDERR, "--$optName expects exactly 1 value\n");
|
||||
exit(1);
|
||||
}
|
||||
$filteredOpts[$optName] = $optValue;
|
||||
}
|
||||
|
||||
if(isset($filteredOpts["current"])){
|
||||
$currentVer = new VersionString($filteredOpts["current"]);
|
||||
}else{
|
||||
$currentVer = new VersionString(BASE_VERSION);
|
||||
}
|
||||
$nextVer = new VersionString(sprintf(
|
||||
"%u.%u.%u",
|
||||
$currentVer->getMajor(),
|
||||
$currentVer->getMinor(),
|
||||
$currentVer->getPatch() + 1
|
||||
));
|
||||
if(isset($filteredOpts["next"])){
|
||||
$nextVer = new VersionString($filteredOpts["next"]);
|
||||
}else{
|
||||
$nextVer = new VersionString(sprintf(
|
||||
"%u.%u.%u",
|
||||
$currentVer->getMajor(),
|
||||
$currentVer->getMinor(),
|
||||
$currentVer->getPatch() + 1
|
||||
));
|
||||
}
|
||||
$channel = $filteredOpts["channel"] ?? BUILD_CHANNEL;
|
||||
|
||||
$versionInfoPath = dirname(__DIR__) . '/src/pocketmine/VersionInfo.php';
|
||||
replaceVersion($versionInfoPath, $currentVer->getBaseVersion(), false);
|
||||
|
||||
echo "About to tag version $currentVer. Next version will be $nextVer.\n";
|
||||
echo "$currentVer will be published on release channel \"$channel\".\n";
|
||||
echo "please add appropriate notes to the changelog and press enter...";
|
||||
fgets(STDIN);
|
||||
system('git add "' . dirname(__DIR__) . '/changelogs"');
|
||||
system('git diff --cached --quiet "' . dirname(__DIR__) . '/changelogs"', $result);
|
||||
if($result === 0){
|
||||
echo "error: no changelog changes detected; aborting\n";
|
||||
exit(1);
|
||||
}
|
||||
$versionInfoPath = dirname(__DIR__) . '/src/pocketmine/VersionInfo.php';
|
||||
replaceVersion($versionInfoPath, $currentVer->getBaseVersion(), false, $channel);
|
||||
system('git commit -m "Release ' . $currentVer->getBaseVersion() . '" --include "' . $versionInfoPath . '"');
|
||||
system('git tag ' . $currentVer->getBaseVersion());
|
||||
replaceVersion($versionInfoPath, $nextVer->getBaseVersion(), true);
|
||||
replaceVersion($versionInfoPath, $nextVer->getBaseVersion(), true, $channel);
|
||||
system('git add "' . $versionInfoPath . '"');
|
||||
system('git commit -m "' . $nextVer->getBaseVersion() . ' is next" --include "' . $versionInfoPath . '"');
|
||||
echo "pushing changes in 5 seconds\n";
|
||||
@ -85,4 +133,4 @@ function main(array $argv) : void{
|
||||
system('git push origin HEAD ' . $currentVer->getBaseVersion());
|
||||
}
|
||||
|
||||
main($argv);
|
||||
main();
|
||||
|
Submodule build/php updated: 60194e8b14...bd329dba08
Submodule build/preprocessor updated: da363df5f1...1b9304de61
@ -134,13 +134,18 @@ function main() : void{
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$opts = getopt("", ["out:", "git:"]);
|
||||
$opts = getopt("", ["out:", "git:", "build:"]);
|
||||
if(isset($opts["git"])){
|
||||
$gitHash = $opts["git"];
|
||||
}else{
|
||||
$gitHash = Git::getRepositoryStatePretty(dirname(__DIR__));
|
||||
echo "Git hash detected as $gitHash" . PHP_EOL;
|
||||
}
|
||||
if(isset($opts["build"])){
|
||||
$build = (int) $opts["build"];
|
||||
}else{
|
||||
$build = 0;
|
||||
}
|
||||
foreach(buildPhar(
|
||||
$opts["out"] ?? getcwd() . DIRECTORY_SEPARATOR . "PocketMine-MP.phar",
|
||||
dirname(__DIR__) . DIRECTORY_SEPARATOR,
|
||||
@ -149,7 +154,8 @@ function main() : void{
|
||||
'vendor'
|
||||
],
|
||||
[
|
||||
'git' => $gitHash
|
||||
'git' => $gitHash,
|
||||
'build' => $build
|
||||
],
|
||||
<<<'STUB'
|
||||
<?php
|
||||
|
@ -48,3 +48,16 @@ Plugin developers should **only** update their required API to this version if y
|
||||
- Added some protocol changes for 1.16.200 which were previously overlooked.
|
||||
- Player XUIDs are now tracked. If a player's XUID does not match the previously recorded XUID when they next join the server, they will be kicked. This can be disabled by the `player.verify-xuid` setting in `pocketmine.yml`.
|
||||
- `BUILDING.md` now has a note about `build/server-phar.php`'s compression bug (a bug in PHP).
|
||||
|
||||
# 3.17.6
|
||||
- Fixed core race conditions that could have led to server freezes (race conditions in pmmp/Snooze).
|
||||
- The log message about Xbox Live authentication being enabled has been reduced to INFO, and the tip on how to turn it off removed (disabling it should usually only be done by power users anyway).
|
||||
- Fixed `PlayerMoveEvent->getFrom()` returning incorrect results for players who experienced movement reversions.
|
||||
- Fixed a bug in `ResourcePackClientResponsePacket` decoding that caused unexpected results when decoding the packet twice.
|
||||
- XUID verification now compares XUIDs against players who are already on the server to detect mismatches to avoid unnecessary loading of playerdata.
|
||||
- Fixed an inventory duplication bug which could occur when the same player joined with two devices at the same time.
|
||||
- Fixed cursor item not being synced on inventory transaction rollbacks.
|
||||
- Fixed items with TAG_Float in their NBT not being able to be moved around in the inventory.
|
||||
|
||||
# 3.17.7
|
||||
- Fixed crash caused by preprocessor in 3.17.6.
|
||||
|
31
changelogs/3.18.md
Normal file
31
changelogs/3.18.md
Normal file
@ -0,0 +1,31 @@
|
||||
**For Minecraft: Bedrock Edition 1.16.210**
|
||||
|
||||
### Note about API versions
|
||||
Plugins which don't touch the protocol and compatible with any previous 3.x.y version will also run on these releases and do not need API bumps.
|
||||
Plugin developers should **only** update their required API to this version if you need the changes in this build.
|
||||
|
||||
**WARNING: If your plugin uses the protocol, you're not shielded by API change constraints.** You should consider using the `mcpe-protocol` directive in `plugin.yml` as a constraint if you do.
|
||||
|
||||
# 3.18.0
|
||||
- Added support for Minecraft: Bedrock Edition 1.16.210.
|
||||
- Removed compatibility with earlier versions.
|
||||
|
||||
## Known issues (please don't open issues for these)
|
||||
- Walls don't connect to each other
|
||||
- Pumpkin and melon stems may not connect to their corresponding pumpkin/melon
|
||||
- New blocks, items & mobs aren't implemented
|
||||
- Nether doesn't exist
|
||||
- Items can't be removed from item frames in Survival mode
|
||||
|
||||
# 3.18.1
|
||||
- UPnP is now supported on all platforms instead of just Windows. Note that it's still experimental. Please file issues for any bugs that you find.
|
||||
- Fixed server joining when default game mode is set to Spectator mode.
|
||||
- Fixed items not being able to be removed from item frames in Survival mode.
|
||||
- Fixed field order in ClientCacheBlobStatusPacket (hits and misses were inverted).
|
||||
- Fixed a deadlock that could occur when MainLogger->syncFlushBuffer() was used (usually only used during exception logging).
|
||||
- Updated constants for various things in the protocol.
|
||||
|
||||
# 3.18.2
|
||||
- Fixed `InventoryCloseEvent` not being called on server-initiated inventory closures.
|
||||
- `PlayerToggleFlightEvent` may now be pre-cancelled if the player attempted to enable flight when flying was not allowed. This replaces the previous behaviour of kicking the player.
|
||||
- Fixed being unable to change the item in hand from the inventory window when looking at an entity.
|
31
changelogs/3.19.md
Normal file
31
changelogs/3.19.md
Normal file
@ -0,0 +1,31 @@
|
||||
**For Minecraft: Bedrock Edition 1.16.220**
|
||||
|
||||
### Note about API versions
|
||||
Plugins which don't touch the protocol and compatible with any previous 3.x.y version will also run on these releases and do not need API bumps.
|
||||
Plugin developers should **only** update their required API to this version if you need the changes in this build.
|
||||
|
||||
**WARNING: If your plugin uses the protocol, you're not shielded by API change constraints.** You should consider using the `mcpe-protocol` directive in `plugin.yml` as a constraint if you do.
|
||||
|
||||
# 3.19.0
|
||||
- Added support for Minecraft: Bedrock Edition 1.16.220.
|
||||
- Removed compatibility with earlier versions.
|
||||
|
||||
## Known issues (please don't open issues for these)
|
||||
- Walls don't connect to each other
|
||||
- Pumpkin and melon stems may not connect to their corresponding pumpkin/melon
|
||||
- New blocks, items & mobs aren't implemented
|
||||
- Nether doesn't exist
|
||||
|
||||
# 3.19.1
|
||||
- Fixed some particles not working since 1.16.220.
|
||||
- Fixed issues with creative inventory items appearing in the wrong places since 1.16.220.
|
||||
- `Item->removeEnchantment()` now removes the `ench` tag from item NBT when removing the only enchantment on an item.
|
||||
- Fixed temporary memory leak of repeating tasks which cancelled themselves during their `onRun()` handler (they were pushed back onto the task queue even though cancelled, and only removed at their next attempted repeat).
|
||||
|
||||
# 3.19.2
|
||||
- Signs can now only be edited by the player who placed them. They will become finalized if the chunk containing them is unloaded and reloaded, or if the creating player quits the server.
|
||||
|
||||
# 3.19.3
|
||||
- Fixed `Worker->quit()` returning without stopping the thread.
|
||||
- Added some protocol constants in `SetDisplayObjectivePacket`.
|
||||
- Fixed possible client crash caused by `CraftingDataPacket`.
|
11
changelogs/3.20.md
Normal file
11
changelogs/3.20.md
Normal file
@ -0,0 +1,11 @@
|
||||
**For Minecraft: Bedrock Edition 1.17.0**
|
||||
|
||||
### Note about API versions
|
||||
Plugins which don't touch the protocol and compatible with any previous 3.x.y version will also run on these releases and do not need API bumps.
|
||||
Plugin developers should **only** update their required API to this version if you need the changes in this build.
|
||||
|
||||
**WARNING: If your plugin uses the protocol, you're not shielded by API change constraints.** You should consider using the `mcpe-protocol` directive in `plugin.yml` as a constraint if you do.
|
||||
|
||||
# 3.20.0
|
||||
- Added support for Minecraft: Bedrock Edition 1.17.0
|
||||
- Removed compatibility with earlier versions.
|
15
changelogs/3.21.md
Normal file
15
changelogs/3.21.md
Normal file
@ -0,0 +1,15 @@
|
||||
**For Minecraft: Bedrock Edition 1.17.0**
|
||||
|
||||
### Note about API versions
|
||||
Plugins which don't touch the protocol and compatible with any previous 3.x.y version will also run on these releases and do not need API bumps.
|
||||
Plugin developers should **only** update their required API to this version if you need the changes in this build.
|
||||
|
||||
**WARNING: If your plugin uses the protocol, you're not shielded by API change constraints.** You should consider using the `mcpe-protocol` directive in `plugin.yml` as a constraint if you do.
|
||||
|
||||
# 3.21.0
|
||||
- PHP 7.4 is now required as a minimum.
|
||||
- A workaround for player movement added in 1.14.30 has been removed.
|
||||
|
||||
# 3.21.1
|
||||
- Fixed so-called 'pot lag' - a bug that could occur when using items while rapidly switching hotbar slots.
|
||||
- Plugins in crashdumps are now ordered alphabetically for easier reading.
|
36
changelogs/3.22.md
Normal file
36
changelogs/3.22.md
Normal file
@ -0,0 +1,36 @@
|
||||
**For Minecraft: Bedrock Edition 1.17.10**
|
||||
|
||||
### Note about API versions
|
||||
Plugins which don't touch the protocol and compatible with any previous 3.x.y version will also run on these releases and do not need API bumps.
|
||||
Plugin developers should **only** update their required API to this version if you need the changes in this build.
|
||||
|
||||
**WARNING: If your plugin uses the protocol, you're not shielded by API change constraints.** You should consider using the `mcpe-protocol` directive in `plugin.yml` as a constraint if you do.
|
||||
|
||||
# 3.22.0
|
||||
- Added support for Minecraft: Bedrock Edition 1.17.10.
|
||||
- Removed compatibility with earlier versions.
|
||||
|
||||
# 3.22.1
|
||||
- Added a giant yellow startup warning if using OPcache JIT on PHP 8.0. JIT is currently considered highly unstable and not recommended for production use.
|
||||
- When using a bad PHP binary, the bootstrap will now report the used `php.ini` path. This can be useful for debugging issues with extension loading when the wrong `php.ini` file is loaded for some reason.
|
||||
- Fixed `start.cmd` causing the wrong `php.ini` to be loaded on Windows when a global PHP installation is used.
|
||||
- A debug message is now logged containing expected vs. actual XUID of players when an XUID mismatch is detected.
|
||||
- Improved the documentation for `Player->getUniqueId()`.
|
||||
- Fixed a mistake in the documentation of `PlayerAuthInputFlags`.
|
||||
- Fixed incorrect encoding of `NpcDialoguePacket`.
|
||||
|
||||
# 3.22.2
|
||||
- PHP 8.0 is now the primary supported version. PHP 7.4 is still supported for now, but it will be dropped in the coming weeks. It's recommended to start testing your servers on 8.0 now so you're ready.
|
||||
- Fixed items in the crafting grid getting deleted on server-side disconnect or session timeout.
|
||||
- A warning is now logged on startup if a debug build of PHP is used to run the server (because it has a significant performance impact).
|
||||
- GitHub Actions is now used to build new releases, instead of Jenkins. You can see build logs [here](https://github.com/pmmp/PocketMine-MP/actions/workflows/draft-release.yml).
|
||||
|
||||
# 3.22.3
|
||||
- Fixed a bug in the release build of 3.22.2 which caused the crash archive to reject all crashdumps.
|
||||
- Fixed possible server crash during player spawning.
|
||||
|
||||
# 3.22.4
|
||||
- Fixed a bug which broke the build of 3.22.3.
|
||||
|
||||
# 3.22.5
|
||||
- Added a workaround for polyfilled solid-colour Persona skin replacements turning into a corrupted mess (caused by https://bugs.mojang.com/browse/MCPE-130275).
|
14
changelogs/3.23.md
Normal file
14
changelogs/3.23.md
Normal file
@ -0,0 +1,14 @@
|
||||
**For Minecraft: Bedrock Edition 1.17.30**
|
||||
|
||||
### Note about API versions
|
||||
Plugins which don't touch the protocol and compatible with any previous 3.x.y version will also run on these releases and do not need API bumps.
|
||||
Plugin developers should **only** update their required API to this version if you need the changes in this build.
|
||||
|
||||
**WARNING: If your plugin uses the protocol, you're not shielded by API change constraints.** You should consider using the `mcpe-protocol` directive in `plugin.yml` as a constraint if you do.
|
||||
|
||||
# 3.23.0
|
||||
- Added support for Minecraft: Bedrock Edition 1.17.30.
|
||||
- Removed compatibility with earlier versions.
|
||||
|
||||
# 3.23.1
|
||||
- Fixed broken build of 3.23.0.
|
12
changelogs/3.24.md
Normal file
12
changelogs/3.24.md
Normal file
@ -0,0 +1,12 @@
|
||||
**For Minecraft: Bedrock Edition 1.17.30**
|
||||
|
||||
### Note about API versions
|
||||
Plugins which don't touch the protocol and compatible with any previous 3.x.y version will also run on these releases and do not need API bumps.
|
||||
Plugin developers should **only** update their required API to this version if you need the changes in this build.
|
||||
|
||||
**WARNING: If your plugin uses the protocol, you're not shielded by API change constraints.** You should consider using the `mcpe-protocol` directive in `plugin.yml` as a constraint if you do.
|
||||
|
||||
# 3.24.0
|
||||
- PHP 8.0 is now required as a minimum.
|
||||
- Fixed stats reporting checking the wrong `pocketmine.yml` property.
|
||||
- Fixed `Projectile->move()` not respecting the given `dx`/`dy`/`dz` and using its own motion instead.
|
38
changelogs/3.25.md
Normal file
38
changelogs/3.25.md
Normal file
@ -0,0 +1,38 @@
|
||||
**For Minecraft: Bedrock Edition 1.17.40**
|
||||
|
||||
### Note about API versions
|
||||
Plugins which don't touch the protocol and compatible with any previous 3.x.y version will also run on these releases and do not need API bumps.
|
||||
Plugin developers should **only** update their required API to this version if you need the changes in this build.
|
||||
|
||||
**WARNING: If your plugin uses the protocol, you're not shielded by API change constraints.** You should consider using the `mcpe-protocol` directive in `plugin.yml` as a constraint if you do.
|
||||
|
||||
# 3.25.0
|
||||
- Added support for Minecraft: Bedrock Edition 1.17.40.
|
||||
- Removed compatibility with earlier versions.
|
||||
|
||||
# 3.25.1
|
||||
- Fixed autosave bug that caused unmodified chunks to be saved at least once (during the first autosave after they were loaded).
|
||||
- `Entity->spawnTo()` now has an additional sanity check for matching worlds (might expose a few new errors in plugins).
|
||||
- Fixed a missing field in `CraftRecipeAuto` item stack request type.
|
||||
|
||||
# 3.25.2
|
||||
- Now analysed using level 9 on PHPStan 1.0.0.
|
||||
- `ext-pthreads` v4.0.0 or newer is now required.
|
||||
- Fixed crash in `Player->showPlayer()` when the target is not in the same world.
|
||||
- `Human->setLifetimeTotalXp()` now limits the maximum value to 2^31.
|
||||
- Fixed players, who died in hardcore mode and were unbanned, getting re-banned on next server join.
|
||||
|
||||
# 3.25.3
|
||||
- Fixed crash when players try to pickup XP while already having max XP.
|
||||
- Added a sanity check to `Human->setCurrentTotalXp()` to try and catch an elusive bug that's been appearing in the wild - please get in touch if you know how to reproduce it!
|
||||
|
||||
# 3.25.4
|
||||
- Fixed a long-standing issue with `Player->removeWindow()` breaking inventory UIs on the client.
|
||||
|
||||
# 3.25.5
|
||||
- Protocol: Fixed incorrect encoding in `StructureSettings`
|
||||
- Fixed reading tags from non-docblock comments in script plugins.
|
||||
- Build number is now defined in phar metadata instead of being patched into the source code directly.
|
||||
|
||||
# 3.25.6
|
||||
- Fixed borked build number in release build of 3.25.5.
|
28
changelogs/3.26.md
Normal file
28
changelogs/3.26.md
Normal file
@ -0,0 +1,28 @@
|
||||
**For Minecraft: Bedrock Edition 1.18.0**
|
||||
|
||||
### Note about API versions
|
||||
Plugins which don't touch the protocol and compatible with any previous 3.x.y version will also run on these releases and do not need API bumps.
|
||||
Plugin developers should **only** update their required API to this version if you need the changes in this build.
|
||||
|
||||
**WARNING: If your plugin uses the protocol, you're not shielded by API change constraints.** You should consider using the `mcpe-protocol` directive in `plugin.yml` as a constraint if you do.
|
||||
|
||||
# 3.26.0
|
||||
- Added support for Minecraft: Bedrock Edition 1.18.0.
|
||||
- Removed compatibility with earlier versions.
|
||||
|
||||
# 3.26.1
|
||||
- Fixed a bug in chunk sending that caused double chests to not be paired, signs to be blank, and various other issues.
|
||||
|
||||
# 3.26.2
|
||||
- Improved error messages shown by `start.cmd`, `start.sh` and `start.ps1` when the PHP binary was not found.
|
||||
- The value of PHPRC is now shown when erroring out due to unsatisfied PHP requirements.
|
||||
- Removed restriction on the range of valid channels for `auto-updater.channel` in `pocketmine.yml`.
|
||||
|
||||
# 3.26.3
|
||||
- `PlayerExperienceChangeEvent->setNewProgress()` now performs range checks. This fixes the root of a very old and confusing crash bug which took several years to identify the cause of.
|
||||
- Note that the defective plugin(s) which caused this problem will still cause a server crash, but the plugin responsible will now get blamed correctly.
|
||||
|
||||
# 3.26.4
|
||||
- Fixed skins appearing black when using RTX resource packs.
|
||||
- Fixed chunks containing furnaces in old worlds (pre-2017) being discarded as corrupted.
|
||||
- This was caused by a strict corruption check detecting bad data created by a bug in PocketMine-MP that was fixed in 2017.
|
@ -1,12 +1,13 @@
|
||||
{
|
||||
"name": "pocketmine/pocketmine-mp",
|
||||
"description": "A server software for Minecraft: Pocket Edition written in PHP",
|
||||
"description": "A server software for Minecraft: Bedrock Edition written in PHP",
|
||||
"type": "project",
|
||||
"homepage": "https://pmmp.io",
|
||||
"license": "LGPL-3.0",
|
||||
"require": {
|
||||
"php": "^7.3 || ^8.0",
|
||||
"php": "^8.0",
|
||||
"php-64bit": "*",
|
||||
"ext-chunkutils2": "^0.3.1",
|
||||
"ext-ctype": "*",
|
||||
"ext-curl": "*",
|
||||
"ext-date": "*",
|
||||
@ -16,30 +17,31 @@
|
||||
"ext-openssl": "*",
|
||||
"ext-pcre": "*",
|
||||
"ext-phar": "*",
|
||||
"ext-pthreads": "~3.2.0",
|
||||
"ext-pthreads": "^4.0",
|
||||
"ext-reflection": "*",
|
||||
"ext-simplexml": "*",
|
||||
"ext-sockets": "*",
|
||||
"ext-spl": "*",
|
||||
"ext-yaml": ">=2.0.0",
|
||||
"ext-zip": "*",
|
||||
"ext-zlib": ">=1.2.11",
|
||||
"composer-runtime-api": "^2.0",
|
||||
"adhocore/json-comment": "^0.1.0",
|
||||
"adhocore/json-comment": "^1.1",
|
||||
"pocketmine/binaryutils": "^0.1.9",
|
||||
"pocketmine/callback-validator": "^1.0.2",
|
||||
"pocketmine/classloader": "^0.1.0",
|
||||
"pocketmine/log": "^0.2.0",
|
||||
"pocketmine/log-pthreads": "^0.1.0",
|
||||
"pocketmine/math": "^0.2.0",
|
||||
"pocketmine/nbt": "^0.2.10",
|
||||
"pocketmine/nbt": "^0.2.19",
|
||||
"pocketmine/raklib": "^0.12.7",
|
||||
"pocketmine/snooze": "^0.1.0",
|
||||
"pocketmine/spl": "^0.4.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpstan/phpstan": "0.12.76",
|
||||
"phpstan/phpstan-phpunit": "^0.12.6",
|
||||
"phpstan/phpstan-strict-rules": "^0.12.2",
|
||||
"phpstan/phpstan": "1.2.0",
|
||||
"phpstan/phpstan-phpunit": "^1.0.0",
|
||||
"phpstan/phpstan-strict-rules": "^1.0.0",
|
||||
"phpunit/phpunit": "^9.2"
|
||||
},
|
||||
"autoload": {
|
||||
@ -59,14 +61,14 @@
|
||||
},
|
||||
"config": {
|
||||
"platform": {
|
||||
"php": "7.3.0"
|
||||
"php": "8.0.0"
|
||||
},
|
||||
"sort-packages": true
|
||||
},
|
||||
"scripts": {
|
||||
"make-devtools": "@php -dphar.readonly=0 tests/plugins/DevTools/src/DevTools/ConsoleScript.php --make tests/plugins/DevTools --out plugins/DevTools.phar",
|
||||
"make-server": [
|
||||
"@composer install --no-dev --classmap-authoritative",
|
||||
"@composer install --no-dev --classmap-authoritative --ignore-platform-reqs",
|
||||
"@php -dphar.readonly=0 build/server-phar.php"
|
||||
]
|
||||
}
|
||||
|
391
composer.lock
generated
391
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@ -7,4 +7,4 @@ This site can be accessed via https://apidoc.pmmp.io.
|
||||
### Additional developer resources
|
||||
- [DevTools](https://github.com/pmmp/DevTools/) - Development tools plugin for creating plugins
|
||||
- [ExamplePlugin](https://github.com/pmmp/ExamplePlugin/) - Example plugin demonstrating some basic API features
|
||||
- [DeveloperDocs](https://github.com/pmmp/DeveloperDocs/) - Reference, guides and specifications for the PocketMine-MP API
|
||||
- [DeveloperDocs](https://devdoc.pmmp.io) - General documentation for PocketMine-MP plugin developers
|
||||
|
@ -1,50 +1,51 @@
|
||||
includes:
|
||||
- tests/phpstan/configs/actual-problems.neon
|
||||
- tests/phpstan/configs/check-explicit-mixed-baseline.neon
|
||||
- tests/phpstan/configs/com-dotnet-magic.neon
|
||||
- tests/phpstan/configs/gc-hacks.neon
|
||||
- tests/phpstan/configs/l7-baseline.neon
|
||||
- tests/phpstan/configs/l8-baseline.neon
|
||||
- tests/phpstan/configs/php-bugs.neon
|
||||
- tests/phpstan/configs/phpstan-bugs.neon
|
||||
- tests/phpstan/configs/phpunit-wiring-tests.neon
|
||||
- tests/phpstan/configs/pthreads-bugs.neon
|
||||
- tests/phpstan/configs/runtime-type-checks.neon
|
||||
- tests/phpstan/configs/spl-fixed-array-sucks.neon
|
||||
- vendor/phpstan/phpstan-phpunit/extension.neon
|
||||
- vendor/phpstan/phpstan-phpunit/rules.neon
|
||||
- vendor/phpstan/phpstan-strict-rules/rules.neon
|
||||
|
||||
parameters:
|
||||
level: 8
|
||||
checkExplicitMixed: true
|
||||
level: 9
|
||||
checkMissingCallableSignature: true
|
||||
treatPhpDocTypesAsCertain: false
|
||||
bootstrapFiles:
|
||||
- tests/phpstan/bootstrap.php
|
||||
scanDirectories:
|
||||
- tests/plugins/TesterPlugin
|
||||
- build
|
||||
- tests/plugins/TesterPlugin
|
||||
scanFiles:
|
||||
- src/pocketmine/PocketMine.php
|
||||
- build/make-release.php
|
||||
- build/server-phar.php
|
||||
paths:
|
||||
- build
|
||||
- src
|
||||
- build/make-release.php
|
||||
- build/server-phar.php
|
||||
- tests/phpunit
|
||||
- tests/plugins/TesterPlugin
|
||||
excludePaths:
|
||||
analyseAndScan:
|
||||
- build/php
|
||||
- build/preprocessor
|
||||
analyse:
|
||||
- src/pocketmine/block/StoneSlab.php #overrides STONE constant
|
||||
- src/pocketmine/item/Potion.php #overrides WATER constant
|
||||
dynamicConstantNames:
|
||||
- pocketmine\IS_DEVELOPMENT_BUILD
|
||||
- pocketmine\DEBUG
|
||||
- pocketmine\IS_DEVELOPMENT_BUILD
|
||||
stubFiles:
|
||||
- tests/phpstan/stubs/pthreads.stub
|
||||
- tests/phpstan/stubs/chunkutils.stub
|
||||
- tests/phpstan/stubs/leveldb.stub
|
||||
- tests/phpstan/stubs/pthreads.stub
|
||||
reportUnmatchedIgnoredErrors: false #no other way to silence platform-specific non-warnings
|
||||
staticReflectionClassNamePatterns:
|
||||
- "#^COM$#"
|
||||
typeAliases:
|
||||
#variadics don't work for this - mixed probably shouldn't work either, but for now it does
|
||||
#what we actually need is something that accepts an infinite number of parameters, but in the absence of that,
|
||||
#we'll just fill it with 10 - it's very unlikely to encounter a callable with 10 parameters anyway.
|
||||
anyCallable: 'callable(mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed) : mixed'
|
||||
anyClosure: '\Closure(mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed, mixed) : mixed'
|
||||
#variadics don't work for this - mixed probably shouldn't work either, but for now it does
|
||||
#what we actually need is something that accepts an infinite number of parameters, but in the absence of that,
|
||||
#we'll just fill it with 10 - it's very unlikely to encounter a callable with 10 parameters anyway.
|
||||
anyCallable: 'callable(never, never, never, never, never, never, never, never, never, never) : mixed'
|
||||
anyClosure: '\Closure(never, never, never, never, never, never, never, never, never, never) : mixed'
|
||||
|
@ -30,7 +30,10 @@ use pocketmine\utils\TextFormat;
|
||||
* Handles the achievement list and a bit more
|
||||
*/
|
||||
abstract class Achievement{
|
||||
/** @var array[] */
|
||||
/**
|
||||
* @var mixed[][]
|
||||
* @phpstan-var array<string, array{name: string, requires: list<string>}>
|
||||
*/
|
||||
public static $list = [
|
||||
/*"openInventory" => array(
|
||||
"name" => "Taking Inventory",
|
||||
|
@ -46,6 +46,7 @@ use function is_dir;
|
||||
use function is_resource;
|
||||
use function json_encode;
|
||||
use function json_last_error_msg;
|
||||
use function ksort;
|
||||
use function max;
|
||||
use function microtime;
|
||||
use function mkdir;
|
||||
@ -81,6 +82,7 @@ use const FILE_IGNORE_NEW_LINES;
|
||||
use const JSON_UNESCAPED_SLASHES;
|
||||
use const PHP_EOL;
|
||||
use const PHP_OS;
|
||||
use const SORT_STRING;
|
||||
|
||||
class CrashDump{
|
||||
|
||||
@ -182,7 +184,9 @@ class CrashDump{
|
||||
$this->addLine();
|
||||
$this->addLine("Loaded plugins:");
|
||||
$this->data["plugins"] = [];
|
||||
foreach($this->server->getPluginManager()->getPlugins() as $p){
|
||||
$plugins = $this->server->getPluginManager()->getPlugins();
|
||||
ksort($plugins, SORT_STRING);
|
||||
foreach($plugins as $p){
|
||||
$d = $p->getDescription();
|
||||
$this->data["plugins"][$d->getName()] = [
|
||||
"name" => $d->getName(),
|
||||
@ -206,9 +210,16 @@ class CrashDump{
|
||||
|
||||
if($this->server->getProperty("auto-report.send-settings", true) !== false){
|
||||
$this->data["parameters"] = (array) $argv;
|
||||
$this->data["server.properties"] = @file_get_contents($this->server->getDataPath() . "server.properties");
|
||||
$this->data["server.properties"] = preg_replace("#^rcon\\.password=(.*)$#m", "rcon.password=******", $this->data["server.properties"]);
|
||||
$this->data["pocketmine.yml"] = @file_get_contents($this->server->getDataPath() . "pocketmine.yml");
|
||||
if(($serverDotProperties = @file_get_contents($this->server->getDataPath() . "server.properties")) !== false){
|
||||
$this->data["server.properties"] = preg_replace("#^rcon\\.password=(.*)$#m", "rcon.password=******", $serverDotProperties);
|
||||
}else{
|
||||
$this->data["server.properties"] = $serverDotProperties;
|
||||
}
|
||||
if(($pocketmineDotYml = @file_get_contents($this->server->getDataPath() . "pocketmine.yml")) !== false){
|
||||
$this->data["pocketmine.yml"] = $pocketmineDotYml;
|
||||
}else{
|
||||
$this->data["pocketmine.yml"] = "";
|
||||
}
|
||||
}else{
|
||||
$this->data["pocketmine.yml"] = "";
|
||||
$this->data["server.properties"] = "";
|
||||
@ -372,7 +383,7 @@ class CrashDump{
|
||||
$this->addLine("uname -a: " . php_uname("a"));
|
||||
$this->addLine("PHP Version: " . phpversion());
|
||||
$this->addLine("Zend version: " . zend_version());
|
||||
$this->addLine("OS : " . PHP_OS . ", " . Utils::getOS());
|
||||
$this->addLine("OS: " . PHP_OS . ", " . Utils::getOS());
|
||||
$this->addLine("Composer libraries: ");
|
||||
foreach($composerLibraries as $library => $libraryVersion){
|
||||
$this->addLine("- $library $libraryVersion");
|
||||
|
@ -353,35 +353,33 @@ class MemoryManager{
|
||||
file_put_contents($outputFolder . "/staticProperties.js", json_encode($staticProperties, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT));
|
||||
$logger->info("[Dump] Wrote $staticCount static properties");
|
||||
|
||||
if(isset($GLOBALS)){ //This might be null if we're on a different thread
|
||||
$globalVariables = [];
|
||||
$globalCount = 0;
|
||||
$globalVariables = [];
|
||||
$globalCount = 0;
|
||||
|
||||
$ignoredGlobals = [
|
||||
'GLOBALS' => true,
|
||||
'_SERVER' => true,
|
||||
'_REQUEST' => true,
|
||||
'_POST' => true,
|
||||
'_GET' => true,
|
||||
'_FILES' => true,
|
||||
'_ENV' => true,
|
||||
'_COOKIE' => true,
|
||||
'_SESSION' => true
|
||||
];
|
||||
$ignoredGlobals = [
|
||||
'GLOBALS' => true,
|
||||
'_SERVER' => true,
|
||||
'_REQUEST' => true,
|
||||
'_POST' => true,
|
||||
'_GET' => true,
|
||||
'_FILES' => true,
|
||||
'_ENV' => true,
|
||||
'_COOKIE' => true,
|
||||
'_SESSION' => true
|
||||
];
|
||||
|
||||
foreach($GLOBALS as $varName => $value){
|
||||
if(isset($ignoredGlobals[$varName])){
|
||||
continue;
|
||||
}
|
||||
|
||||
$globalCount++;
|
||||
$globalVariables[$varName] = self::continueDump($value, $objects, $refCounts, 0, $maxNesting, $maxStringSize);
|
||||
foreach($GLOBALS as $varName => $value){
|
||||
if(isset($ignoredGlobals[$varName])){
|
||||
continue;
|
||||
}
|
||||
|
||||
file_put_contents($outputFolder . "/globalVariables.js", json_encode($globalVariables, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT));
|
||||
$logger->info("[Dump] Wrote $globalCount global variables");
|
||||
$globalCount++;
|
||||
$globalVariables[$varName] = self::continueDump($value, $objects, $refCounts, 0, $maxNesting, $maxStringSize);
|
||||
}
|
||||
|
||||
file_put_contents($outputFolder . "/globalVariables.js", json_encode($globalVariables, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT));
|
||||
$logger->info("[Dump] Wrote $globalCount global variables");
|
||||
|
||||
$data = self::continueDump($startingObject, $objects, $refCounts, 0, $maxNesting, $maxStringSize);
|
||||
|
||||
do{
|
||||
|
@ -152,10 +152,17 @@ use pocketmine\network\mcpe\protocol\types\ContainerIds;
|
||||
use pocketmine\network\mcpe\protocol\types\DimensionIds;
|
||||
use pocketmine\network\mcpe\protocol\types\Experiments;
|
||||
use pocketmine\network\mcpe\protocol\types\GameMode;
|
||||
use pocketmine\network\mcpe\protocol\types\inventory\MismatchTransactionData;
|
||||
use pocketmine\network\mcpe\protocol\types\inventory\NormalTransactionData;
|
||||
use pocketmine\network\mcpe\protocol\types\inventory\ReleaseItemTransactionData;
|
||||
use pocketmine\network\mcpe\protocol\types\inventory\UIInventorySlotOffset;
|
||||
use pocketmine\network\mcpe\protocol\types\inventory\UseItemOnEntityTransactionData;
|
||||
use pocketmine\network\mcpe\protocol\types\inventory\UseItemTransactionData;
|
||||
use pocketmine\network\mcpe\protocol\types\NetworkInventoryAction;
|
||||
use pocketmine\network\mcpe\protocol\types\PersonaPieceTintColor;
|
||||
use pocketmine\network\mcpe\protocol\types\PersonaSkinPiece;
|
||||
use pocketmine\network\mcpe\protocol\types\PlayerMovementSettings;
|
||||
use pocketmine\network\mcpe\protocol\types\PlayerMovementType;
|
||||
use pocketmine\network\mcpe\protocol\types\PlayerPermissions;
|
||||
use pocketmine\network\mcpe\protocol\types\SkinAdapterSingleton;
|
||||
use pocketmine\network\mcpe\protocol\types\SkinAnimation;
|
||||
@ -194,7 +201,9 @@ use function get_class;
|
||||
use function gettype;
|
||||
use function implode;
|
||||
use function in_array;
|
||||
use function is_infinite;
|
||||
use function is_int;
|
||||
use function is_nan;
|
||||
use function is_object;
|
||||
use function is_string;
|
||||
use function json_encode;
|
||||
@ -206,6 +215,7 @@ use function min;
|
||||
use function preg_match;
|
||||
use function round;
|
||||
use function spl_object_hash;
|
||||
use function sprintf;
|
||||
use function sqrt;
|
||||
use function strlen;
|
||||
use function strpos;
|
||||
@ -409,7 +419,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
|
||||
/** @var float */
|
||||
protected $lastRightClickTime = 0.0;
|
||||
/** @var \stdClass|null */
|
||||
/** @var UseItemTransactionData|null */
|
||||
protected $lastRightClickData = null;
|
||||
|
||||
/**
|
||||
@ -473,19 +483,14 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the player's UUID. This should be preferred over their Xbox user ID (XUID) because UUID is a standard
|
||||
* format which will never change, and all players will have one regardless of whether they are logged into Xbox
|
||||
* Live.
|
||||
* Returns the player's UUID. This should be the preferred method to identify a player.
|
||||
* It does not change if the player changes their username.
|
||||
*
|
||||
* The UUID is comprised of:
|
||||
* - when logged into XBL: a hash of their XUID (and as such will not change for the lifetime of the XBL account)
|
||||
* - when NOT logged into XBL: a hash of their name + clientID + secret device ID.
|
||||
* All players will have a UUID, regardless of whether they are logged into Xbox Live or not. However, note that
|
||||
* non-XBL players can fake their UUIDs.
|
||||
*
|
||||
* WARNING: UUIDs of players **not logged into Xbox Live** CAN BE FAKED and SHOULD NOT be trusted!
|
||||
*
|
||||
* (In the olden days this method used to return a fake UUID computed by the server, which was used by plugins such
|
||||
* as SimpleAuth for authentication. This is NOT SAFE anymore as this UUID is now what was given by the client, NOT
|
||||
* a server-computed UUID.)
|
||||
* WARNING: DO NOT trust this before PlayerLoginEvent. Before PlayerLoginEvent, the player hasn't yet been
|
||||
* authenticated, and any of their data might be faked.
|
||||
*/
|
||||
public function getUniqueId() : ?UUID{
|
||||
return parent::getUniqueId();
|
||||
@ -558,7 +563,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
}
|
||||
|
||||
public function spawnTo(Player $player) : void{
|
||||
if($this->spawned and $player->spawned and $this->isAlive() and $player->isAlive() and $player->getLevelNonNull() === $this->level and $player->canSee($this) and !$this->isSpectator()){
|
||||
if($this->spawned and $player->spawned and $this->isAlive() and $player->isAlive() and $player->canSee($this) and !$this->isSpectator()){
|
||||
parent::spawnTo($player);
|
||||
}
|
||||
}
|
||||
@ -1068,7 +1073,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
* @return void
|
||||
*/
|
||||
public function doFirstSpawn(){
|
||||
if($this->spawned){
|
||||
if($this->spawned || !$this->constructed){
|
||||
return; //avoid player spawning twice (this can only happen on 3.x with a custom malicious client)
|
||||
}
|
||||
$this->spawned = true;
|
||||
@ -1112,7 +1117,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
}
|
||||
|
||||
if($this->getHealth() <= 0){
|
||||
$this->respawn();
|
||||
$this->actuallyRespawn();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1653,13 +1658,6 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
$deltaAngle = abs($this->lastYaw - $to->yaw) + abs($this->lastPitch - $to->pitch);
|
||||
|
||||
if($delta > 0.0001 or $deltaAngle > 1.0){
|
||||
$this->lastX = $to->x;
|
||||
$this->lastY = $to->y;
|
||||
$this->lastZ = $to->z;
|
||||
|
||||
$this->lastYaw = $to->yaw;
|
||||
$this->lastPitch = $to->pitch;
|
||||
|
||||
$ev = new PlayerMoveEvent($this, $from, $to);
|
||||
|
||||
$ev->call();
|
||||
@ -1674,6 +1672,12 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
return;
|
||||
}
|
||||
|
||||
$this->lastX = $to->x;
|
||||
$this->lastY = $to->y;
|
||||
$this->lastZ = $to->z;
|
||||
|
||||
$this->lastYaw = $to->yaw;
|
||||
$this->lastPitch = $to->pitch;
|
||||
$this->broadcastMovement();
|
||||
|
||||
$distance = sqrt((($from->x - $to->x) ** 2) + (($from->z - $to->z) ** 2));
|
||||
@ -1696,13 +1700,6 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
}
|
||||
|
||||
protected function revertMovement(Location $from) : void{
|
||||
$this->lastX = $from->x;
|
||||
$this->lastY = $from->y;
|
||||
$this->lastZ = $from->z;
|
||||
|
||||
$this->lastYaw = $from->yaw;
|
||||
$this->lastPitch = $from->pitch;
|
||||
|
||||
$this->setPosition($from);
|
||||
$this->sendPosition($from, $from->yaw, $from->pitch, MovePlayerPacket::MODE_RESET);
|
||||
}
|
||||
@ -1965,6 +1962,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
|
||||
$skinData = new SkinData(
|
||||
$packet->clientData["SkinId"],
|
||||
$packet->clientData["PlayFabId"],
|
||||
base64_decode($packet->clientData["SkinResourcePatch"] ?? "", true),
|
||||
new SkinImage(
|
||||
$packet->clientData["SkinImageHeight"],
|
||||
@ -1978,17 +1976,19 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
base64_decode($packet->clientData["CapeData"] ?? "", true)
|
||||
),
|
||||
base64_decode($packet->clientData["SkinGeometryData"] ?? "", true),
|
||||
base64_decode($packet->clientData["SkinGeometryDataEngineVersion"], true),
|
||||
base64_decode($packet->clientData["SkinAnimationData"] ?? "", true),
|
||||
$packet->clientData["PremiumSkin"] ?? false,
|
||||
$packet->clientData["PersonaSkin"] ?? false,
|
||||
$packet->clientData["CapeOnClassicSkin"] ?? false,
|
||||
$packet->clientData["CapeId"] ?? "",
|
||||
null,
|
||||
$packet->clientData["ArmSize"] ?? SkinData::ARM_SIZE_WIDE,
|
||||
$packet->clientData["SkinColor"] ?? "",
|
||||
$personaPieces,
|
||||
$pieceTintColors,
|
||||
true
|
||||
true,
|
||||
$packet->clientData["PremiumSkin"] ?? false,
|
||||
$packet->clientData["PersonaSkin"] ?? false,
|
||||
$packet->clientData["CapeOnClassicSkin"] ?? false,
|
||||
true, //assume this is true? there's no field for it ...
|
||||
);
|
||||
|
||||
try{
|
||||
@ -2081,32 +2081,41 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
* @return void
|
||||
*/
|
||||
protected function processLogin(){
|
||||
$this->namedtag = $this->server->getOfflinePlayerData($this->username);
|
||||
if((bool) $this->server->getProperty("player.verify-xuid", true)){
|
||||
$recordedXUID = $this->namedtag->getTag("LastKnownXUID");
|
||||
if(!($recordedXUID instanceof StringTag)){
|
||||
$this->server->getLogger()->debug("No previous XUID recorded for " . $this->getName() . ", no choice but to trust this player");
|
||||
}elseif($this->xuid !== $recordedXUID->getValue()){
|
||||
$checkXUID = (bool) $this->server->getProperty("player.verify-xuid", true);
|
||||
$kickForXUIDMismatch = function(string $xuid) use ($checkXUID) : bool{
|
||||
if($checkXUID && $this->xuid !== $xuid){
|
||||
$this->server->getLogger()->debug($this->getName() . " XUID mismatch: expected '$xuid', but got '$this->xuid'");
|
||||
if($this->kick("XUID does not match (possible impersonation attempt)", false)){
|
||||
//TODO: Longer term, we should be identifying playerdata using something more reliable, like XUID or UUID.
|
||||
//However, that would be a very disruptive change, so this will serve as a stopgap for now.
|
||||
//Side note: this will also prevent offline players hijacking XBL playerdata on online servers, since their
|
||||
//XUID will always be empty.
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
$this->server->getLogger()->debug("XUID mismatch for " . $this->getName() . ", but plugin cancelled event allowing them to join anyway");
|
||||
}else{
|
||||
$this->server->getLogger()->debug("XUID match for " . $this->getName());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
foreach($this->server->getLoggedInPlayers() as $p){
|
||||
if($p !== $this and ($p->iusername === $this->iusername or $this->getUniqueId()->equals($p->getUniqueId()))){
|
||||
if(!$p->kick("logged in from another location")){
|
||||
$this->close($this->getLeaveMessage(), "Logged in from another location");
|
||||
|
||||
if($kickForXUIDMismatch($p->getXuid())){
|
||||
return;
|
||||
}
|
||||
if(!$p->kick("logged in from another location")){
|
||||
$this->close($this->getLeaveMessage(), "Logged in from another location");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->namedtag = $this->server->getOfflinePlayerData($this->username);
|
||||
if($checkXUID){
|
||||
$recordedXUID = $this->namedtag->getTag("LastKnownXUID");
|
||||
if(!($recordedXUID instanceof StringTag)){
|
||||
$this->server->getLogger()->debug("No previous XUID recorded for " . $this->getName() . ", no choice but to trust this player");
|
||||
}elseif(!$kickForXUIDMismatch($recordedXUID->getValue())){
|
||||
$this->server->getLogger()->debug("XUID match for " . $this->getName());
|
||||
}
|
||||
}
|
||||
|
||||
@ -2268,6 +2277,9 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
$pk->worldName = $this->server->getMotd();
|
||||
$pk->experiments = new Experiments([], false);
|
||||
$pk->itemTable = ItemTypeDictionary::getInstance()->getEntries();
|
||||
$pk->playerMovementSettings = new PlayerMovementSettings(PlayerMovementType::LEGACY, 0, false);
|
||||
$pk->serverSoftwareVersion = sprintf("%s %s", \pocketmine\NAME, \pocketmine\VERSION);
|
||||
$pk->blockPaletteChecksum = 0; //we don't bother with this (0 skips verification) - the preimage is some dumb stringified NBT, not even actual NBT
|
||||
$this->dataPacket($pk);
|
||||
|
||||
$this->sendDataPacket(new AvailableActorIdentifiersPacket());
|
||||
@ -2353,8 +2365,15 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
}
|
||||
|
||||
public function handleMovePlayer(MovePlayerPacket $packet) : bool{
|
||||
$newPos = $packet->position->round(4)->subtract(0, $this->baseOffset, 0);
|
||||
$rawPos = $packet->position;
|
||||
foreach([$rawPos->x, $rawPos->y, $rawPos->z, $packet->yaw, $packet->headYaw, $packet->pitch] as $float){
|
||||
if(is_infinite($float) || is_nan($float)){
|
||||
$this->server->getLogger()->debug("Invalid movement from " . $this->getName() . ", contains NAN/INF components");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$newPos = $rawPos->round(4)->subtract(0, $this->baseOffset, 0);
|
||||
if($this->forceMoveSync !== null and $newPos->distanceSquared($this->forceMoveSync) > 1){ //Tolerate up to 1 block to avoid problems with client-sided physics when spawning in blocks
|
||||
$this->server->getLogger()->debug("Got outdated pre-teleport movement from " . $this->getName() . ", received " . $newPos . ", expected " . $this->asVector3());
|
||||
//Still getting movements from before teleport, ignore them
|
||||
@ -2422,14 +2441,14 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
/** @var InventoryAction[] $actions */
|
||||
$actions = [];
|
||||
$isCraftingPart = false;
|
||||
foreach($packet->actions as $networkInventoryAction){
|
||||
foreach($packet->trData->getActions() as $networkInventoryAction){
|
||||
if(
|
||||
$networkInventoryAction->sourceType === NetworkInventoryAction::SOURCE_TODO and (
|
||||
$networkInventoryAction->windowId === NetworkInventoryAction::SOURCE_TYPE_CRAFTING_RESULT or
|
||||
$networkInventoryAction->windowId === NetworkInventoryAction::SOURCE_TYPE_CRAFTING_USE_INGREDIENT
|
||||
) or (
|
||||
$this->craftingTransaction !== null &&
|
||||
!$networkInventoryAction->oldItem->equalsExact($networkInventoryAction->newItem) &&
|
||||
!$networkInventoryAction->oldItem->getItemStack()->equalsExact($networkInventoryAction->newItem->getItemStack()) &&
|
||||
$networkInventoryAction->sourceType === NetworkInventoryAction::SOURCE_CONTAINER &&
|
||||
$networkInventoryAction->windowId === ContainerIds::UI &&
|
||||
$networkInventoryAction->inventorySlot === UIInventorySlotOffset::CREATED_ITEM_OUTPUT
|
||||
@ -2480,321 +2499,325 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
$this->craftingTransaction = null;
|
||||
}
|
||||
|
||||
switch($packet->transactionType){
|
||||
case InventoryTransactionPacket::TYPE_NORMAL:
|
||||
$this->setUsingItem(false);
|
||||
$transaction = new InventoryTransaction($this, $actions);
|
||||
if($packet->trData instanceof NormalTransactionData){
|
||||
$this->setUsingItem(false);
|
||||
$transaction = new InventoryTransaction($this, $actions);
|
||||
|
||||
try{
|
||||
$transaction->execute();
|
||||
}catch(TransactionValidationException $e){
|
||||
$this->server->getLogger()->debug("Failed to execute inventory transaction from " . $this->getName() . ": " . $e->getMessage());
|
||||
$this->server->getLogger()->debug("Actions: " . json_encode($packet->actions));
|
||||
try{
|
||||
$transaction->execute();
|
||||
}catch(TransactionValidationException $e){
|
||||
$this->server->getLogger()->debug("Failed to execute inventory transaction from " . $this->getName() . ": " . $e->getMessage());
|
||||
$this->server->getLogger()->debug("Actions: " . json_encode($packet->trData->getActions()));
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//TODO: fix achievement for getting iron from furnace
|
||||
//TODO: fix achievement for getting iron from furnace
|
||||
|
||||
return true;
|
||||
case InventoryTransactionPacket::TYPE_MISMATCH:
|
||||
if(count($packet->actions) > 0){
|
||||
$this->server->getLogger()->debug("Expected 0 actions for mismatch, got " . count($packet->actions) . ", " . json_encode($packet->actions));
|
||||
}
|
||||
$this->setUsingItem(false);
|
||||
$this->sendAllInventories();
|
||||
return true;
|
||||
}elseif($packet->trData instanceof MismatchTransactionData){
|
||||
if(count($packet->trData->getActions()) > 0){
|
||||
$this->server->getLogger()->debug("Expected 0 actions for mismatch, got " . count($packet->trData->getActions()) . ", " . json_encode($packet->trData->getActions()));
|
||||
}
|
||||
$this->setUsingItem(false);
|
||||
$this->sendAllInventories();
|
||||
|
||||
return true;
|
||||
case InventoryTransactionPacket::TYPE_USE_ITEM:
|
||||
$blockVector = new Vector3($packet->trData->x, $packet->trData->y, $packet->trData->z);
|
||||
$face = $packet->trData->face;
|
||||
return true;
|
||||
}elseif($packet->trData instanceof UseItemTransactionData){
|
||||
|
||||
$type = $packet->trData->actionType;
|
||||
switch($type){
|
||||
case InventoryTransactionPacket::USE_ITEM_ACTION_CLICK_BLOCK:
|
||||
//TODO: start hack for client spam bug
|
||||
$spamBug = ($this->lastRightClickData !== null and
|
||||
microtime(true) - $this->lastRightClickTime < 0.1 and //100ms
|
||||
$this->lastRightClickData->playerPos->distanceSquared($packet->trData->playerPos) < 0.00001 and
|
||||
$this->lastRightClickData->x === $packet->trData->x and
|
||||
$this->lastRightClickData->y === $packet->trData->y and
|
||||
$this->lastRightClickData->z === $packet->trData->z and
|
||||
$this->lastRightClickData->clickPos->distanceSquared($packet->trData->clickPos) < 0.00001 //signature spam bug has 0 distance, but allow some error
|
||||
);
|
||||
//get rid of continued spam if the player clicks and holds right-click
|
||||
$this->lastRightClickData = $packet->trData;
|
||||
$this->lastRightClickTime = microtime(true);
|
||||
if($spamBug){
|
||||
return true;
|
||||
}
|
||||
//TODO: end hack for client spam bug
|
||||
$blockVector = $packet->trData->getBlockPos();
|
||||
$face = $packet->trData->getFace();
|
||||
|
||||
$this->setUsingItem(false);
|
||||
|
||||
if(!$this->canInteract($blockVector->add(0.5, 0.5, 0.5), 13)){
|
||||
}elseif($this->isCreative()){
|
||||
$item = $this->inventory->getItemInHand();
|
||||
if($this->level->useItemOn($blockVector, $item, $face, $packet->trData->clickPos, $this, true)){
|
||||
return true;
|
||||
}
|
||||
}elseif(!$this->inventory->getItemInHand()->equals($packet->trData->itemInHand)){
|
||||
$this->inventory->sendHeldItem($this);
|
||||
}else{
|
||||
$item = $this->inventory->getItemInHand();
|
||||
$oldItem = clone $item;
|
||||
if($this->level->useItemOn($blockVector, $item, $face, $packet->trData->clickPos, $this, true)){
|
||||
if(!$item->equalsExact($oldItem) and $oldItem->equalsExact($this->inventory->getItemInHand())){
|
||||
$this->inventory->setItemInHand($item);
|
||||
$this->inventory->sendHeldItem($this->hasSpawned);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
$this->inventory->sendHeldItem($this);
|
||||
|
||||
if($blockVector->distanceSquared($this) > 10000){
|
||||
return true;
|
||||
}
|
||||
|
||||
$target = $this->level->getBlock($blockVector);
|
||||
$block = $target->getSide($face);
|
||||
|
||||
/** @var Block[] $blocks */
|
||||
$blocks = array_merge($target->getAllSides(), $block->getAllSides()); //getAllSides() on each of these will include $target and $block because they are next to each other
|
||||
|
||||
$this->level->sendBlocks([$this], $blocks, UpdateBlockPacket::FLAG_ALL_PRIORITY);
|
||||
if($this->inventory->getHeldItemIndex() !== $packet->trData->getHotbarSlot()){
|
||||
$this->inventory->equipItem($packet->trData->getHotbarSlot());
|
||||
}
|
||||
|
||||
switch($packet->trData->getActionType()){
|
||||
case UseItemTransactionData::ACTION_CLICK_BLOCK:
|
||||
//TODO: start hack for client spam bug
|
||||
$spamBug = ($this->lastRightClickData !== null and
|
||||
microtime(true) - $this->lastRightClickTime < 0.1 and //100ms
|
||||
$this->lastRightClickData->getPlayerPos()->distanceSquared($packet->trData->getPlayerPos()) < 0.00001 and
|
||||
$this->lastRightClickData->getBlockPos()->equals($packet->trData->getBlockPos()) and
|
||||
$this->lastRightClickData->getClickPos()->distanceSquared($packet->trData->getClickPos()) < 0.00001 //signature spam bug has 0 distance, but allow some error
|
||||
);
|
||||
//get rid of continued spam if the player clicks and holds right-click
|
||||
$this->lastRightClickData = $packet->trData;
|
||||
$this->lastRightClickTime = microtime(true);
|
||||
if($spamBug){
|
||||
return true;
|
||||
case InventoryTransactionPacket::USE_ITEM_ACTION_BREAK_BLOCK:
|
||||
$this->doCloseInventory();
|
||||
}
|
||||
//TODO: end hack for client spam bug
|
||||
|
||||
$this->setUsingItem(false);
|
||||
|
||||
if(!$this->canInteract($blockVector->add(0.5, 0.5, 0.5), 13)){
|
||||
}elseif($this->isCreative()){
|
||||
$item = $this->inventory->getItemInHand();
|
||||
if($this->level->useItemOn($blockVector, $item, $face, $packet->trData->getClickPos(), $this, true)){
|
||||
return true;
|
||||
}
|
||||
}elseif(!$this->inventory->getItemInHand()->equals($packet->trData->getItemInHand()->getItemStack())){
|
||||
$this->inventory->sendHeldItem($this);
|
||||
}else{
|
||||
$item = $this->inventory->getItemInHand();
|
||||
$oldItem = clone $item;
|
||||
|
||||
if($this->canInteract($blockVector->add(0.5, 0.5, 0.5), $this->isCreative() ? 13 : 7) and $this->level->useBreakOn($blockVector, $item, $this, true)){
|
||||
if($this->isSurvival()){
|
||||
if(!$item->equalsExact($oldItem) and $oldItem->equalsExact($this->inventory->getItemInHand())){
|
||||
$this->inventory->setItemInHand($item);
|
||||
$this->inventory->sendHeldItem($this->hasSpawned);
|
||||
}
|
||||
|
||||
$this->exhaust(0.025, PlayerExhaustEvent::CAUSE_MINING);
|
||||
if($this->level->useItemOn($blockVector, $item, $face, $packet->trData->getClickPos(), $this, true)){
|
||||
if(!$item->equalsExact($oldItem) and $oldItem->equalsExact($this->inventory->getItemInHand())){
|
||||
$this->inventory->setItemInHand($item);
|
||||
$this->inventory->sendHeldItem($this->hasSpawned);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
$this->inventory->sendContents($this);
|
||||
$this->inventory->sendHeldItem($this);
|
||||
|
||||
$target = $this->level->getBlock($blockVector);
|
||||
/** @var Block[] $blocks */
|
||||
$blocks = $target->getAllSides();
|
||||
$blocks[] = $target;
|
||||
|
||||
$this->level->sendBlocks([$this], $blocks, UpdateBlockPacket::FLAG_ALL_PRIORITY);
|
||||
|
||||
foreach($blocks as $b){
|
||||
$tile = $this->level->getTile($b);
|
||||
if($tile instanceof Spawnable){
|
||||
$tile->spawnTo($this);
|
||||
}
|
||||
}
|
||||
$this->inventory->sendHeldItem($this);
|
||||
|
||||
if($blockVector->distanceSquared($this) > 10000){
|
||||
return true;
|
||||
case InventoryTransactionPacket::USE_ITEM_ACTION_CLICK_AIR:
|
||||
if($this->isUsingItem()){
|
||||
$slot = $this->inventory->getItemInHand();
|
||||
if($slot instanceof Consumable and !($slot instanceof MaybeConsumable and !$slot->canBeConsumed())){
|
||||
$ev = new PlayerItemConsumeEvent($this, $slot);
|
||||
if($this->hasItemCooldown($slot)){
|
||||
$ev->setCancelled();
|
||||
}
|
||||
$ev->call();
|
||||
if($ev->isCancelled() or !$this->consumeObject($slot)){
|
||||
$this->inventory->sendContents($this);
|
||||
return true;
|
||||
}
|
||||
$this->resetItemCooldown($slot);
|
||||
if($this->isSurvival()){
|
||||
$slot->pop();
|
||||
$this->inventory->setItemInHand($slot);
|
||||
$this->inventory->addItem($slot->getResidue());
|
||||
}
|
||||
$this->setUsingItem(false);
|
||||
}
|
||||
|
||||
$target = $this->level->getBlock($blockVector);
|
||||
$block = $target->getSide($face);
|
||||
|
||||
/** @var Block[] $blocks */
|
||||
$blocks = array_merge($target->getAllSides(), $block->getAllSides()); //getAllSides() on each of these will include $target and $block because they are next to each other
|
||||
|
||||
$this->level->sendBlocks([$this], $blocks, UpdateBlockPacket::FLAG_ALL_PRIORITY);
|
||||
|
||||
return true;
|
||||
case UseItemTransactionData::ACTION_BREAK_BLOCK:
|
||||
$this->doCloseInventory();
|
||||
|
||||
$item = $this->inventory->getItemInHand();
|
||||
$oldItem = clone $item;
|
||||
|
||||
if($this->canInteract($blockVector->add(0.5, 0.5, 0.5), $this->isCreative() ? 13 : 7) and $this->level->useBreakOn($blockVector, $item, $this, true)){
|
||||
if($this->isSurvival()){
|
||||
if(!$item->equalsExact($oldItem) and $oldItem->equalsExact($this->inventory->getItemInHand())){
|
||||
$this->inventory->setItemInHand($item);
|
||||
$this->inventory->sendHeldItem($this->hasSpawned);
|
||||
}
|
||||
}
|
||||
$directionVector = $this->getDirectionVector();
|
||||
|
||||
if($this->isCreative()){
|
||||
$item = $this->inventory->getItemInHand();
|
||||
}elseif(!$this->inventory->getItemInHand()->equals($packet->trData->itemInHand)){
|
||||
$this->inventory->sendHeldItem($this);
|
||||
return true;
|
||||
}else{
|
||||
$item = $this->inventory->getItemInHand();
|
||||
$this->exhaust(0.025, PlayerExhaustEvent::CAUSE_MINING);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
$ev = new PlayerInteractEvent($this, $item, null, $directionVector, $face, PlayerInteractEvent::RIGHT_CLICK_AIR);
|
||||
if($this->hasItemCooldown($item) or $this->isSpectator()){
|
||||
$ev->setCancelled();
|
||||
$this->inventory->sendContents($this);
|
||||
$this->inventory->sendHeldItem($this);
|
||||
|
||||
$target = $this->level->getBlock($blockVector);
|
||||
/** @var Block[] $blocks */
|
||||
$blocks = $target->getAllSides();
|
||||
$blocks[] = $target;
|
||||
|
||||
$this->level->sendBlocks([$this], $blocks, UpdateBlockPacket::FLAG_ALL_PRIORITY);
|
||||
|
||||
foreach($blocks as $b){
|
||||
$tile = $this->level->getTile($b);
|
||||
if($tile instanceof Spawnable){
|
||||
$tile->spawnTo($this);
|
||||
}
|
||||
}
|
||||
|
||||
$ev->call();
|
||||
if($ev->isCancelled()){
|
||||
$this->inventory->sendHeldItem($this);
|
||||
return true;
|
||||
}
|
||||
|
||||
if($item->onClickAir($this, $directionVector)){
|
||||
$this->resetItemCooldown($item);
|
||||
return true;
|
||||
case UseItemTransactionData::ACTION_CLICK_AIR:
|
||||
if($this->isUsingItem()){
|
||||
$slot = $this->inventory->getItemInHand();
|
||||
if($slot instanceof Consumable and !($slot instanceof MaybeConsumable and !$slot->canBeConsumed())){
|
||||
$ev = new PlayerItemConsumeEvent($this, $slot);
|
||||
if($this->hasItemCooldown($slot)){
|
||||
$ev->setCancelled();
|
||||
}
|
||||
$ev->call();
|
||||
if($ev->isCancelled() or !$this->consumeObject($slot)){
|
||||
$this->inventory->sendContents($this);
|
||||
return true;
|
||||
}
|
||||
$this->resetItemCooldown($slot);
|
||||
if($this->isSurvival()){
|
||||
$slot->pop();
|
||||
$this->inventory->setItemInHand($slot);
|
||||
$this->inventory->addItem($slot->getResidue());
|
||||
}
|
||||
$this->setUsingItem(false);
|
||||
}
|
||||
}
|
||||
$directionVector = $this->getDirectionVector();
|
||||
|
||||
if($this->isCreative()){
|
||||
$item = $this->inventory->getItemInHand();
|
||||
}elseif(!$this->inventory->getItemInHand()->equals($packet->trData->getItemInHand()->getItemStack())){
|
||||
$this->inventory->sendHeldItem($this);
|
||||
return true;
|
||||
}else{
|
||||
$item = $this->inventory->getItemInHand();
|
||||
}
|
||||
|
||||
$ev = new PlayerInteractEvent($this, $item, null, $directionVector, $face, PlayerInteractEvent::RIGHT_CLICK_AIR);
|
||||
if($this->hasItemCooldown($item) or $this->isSpectator()){
|
||||
$ev->setCancelled();
|
||||
}
|
||||
|
||||
$ev->call();
|
||||
if($ev->isCancelled()){
|
||||
$this->inventory->sendHeldItem($this);
|
||||
return true;
|
||||
}
|
||||
|
||||
if($item->onClickAir($this, $directionVector)){
|
||||
$this->resetItemCooldown($item);
|
||||
if($this->isSurvival()){
|
||||
$this->inventory->setItemInHand($item);
|
||||
}
|
||||
}
|
||||
|
||||
$this->setUsingItem(true);
|
||||
|
||||
return true;
|
||||
default:
|
||||
//unknown
|
||||
break;
|
||||
}
|
||||
|
||||
$this->inventory->sendContents($this);
|
||||
return false;
|
||||
}elseif($packet->trData instanceof UseItemOnEntityTransactionData){
|
||||
$target = $this->level->getEntity($packet->trData->getEntityRuntimeId());
|
||||
if($target === null){
|
||||
return false;
|
||||
}
|
||||
|
||||
if($this->inventory->getHeldItemIndex() !== $packet->trData->getHotbarSlot()){
|
||||
$this->inventory->equipItem($packet->trData->getHotbarSlot());
|
||||
}
|
||||
|
||||
switch($packet->trData->getActionType()){
|
||||
case UseItemOnEntityTransactionData::ACTION_INTERACT:
|
||||
break; //TODO
|
||||
case UseItemOnEntityTransactionData::ACTION_ATTACK:
|
||||
if(!$target->isAlive()){
|
||||
return true;
|
||||
}
|
||||
if($target instanceof ItemEntity or $target instanceof Arrow){
|
||||
$this->kick("Attempting to attack an invalid entity");
|
||||
$this->server->getLogger()->warning($this->getServer()->getLanguage()->translateString("pocketmine.player.invalidEntity", [$this->getName()]));
|
||||
return false;
|
||||
}
|
||||
|
||||
$cancelled = false;
|
||||
|
||||
$heldItem = $this->inventory->getItemInHand();
|
||||
$oldItem = clone $heldItem;
|
||||
|
||||
if(!$this->canInteract($target, 8) or $this->isSpectator()){
|
||||
$cancelled = true;
|
||||
}elseif($target instanceof Player){
|
||||
if(!$this->server->getConfigBool("pvp")){
|
||||
$cancelled = true;
|
||||
}
|
||||
}
|
||||
|
||||
$ev = new EntityDamageByEntityEvent($this, $target, EntityDamageEvent::CAUSE_ENTITY_ATTACK, $heldItem->getAttackPoints());
|
||||
|
||||
$meleeEnchantmentDamage = 0;
|
||||
/** @var EnchantmentInstance[] $meleeEnchantments */
|
||||
$meleeEnchantments = [];
|
||||
foreach($heldItem->getEnchantments() as $enchantment){
|
||||
$type = $enchantment->getType();
|
||||
if($type instanceof MeleeWeaponEnchantment and $type->isApplicableTo($target)){
|
||||
$meleeEnchantmentDamage += $type->getDamageBonus($enchantment->getLevel());
|
||||
$meleeEnchantments[] = $enchantment;
|
||||
}
|
||||
}
|
||||
$ev->setModifier($meleeEnchantmentDamage, EntityDamageEvent::MODIFIER_WEAPON_ENCHANTMENTS);
|
||||
|
||||
if($cancelled){
|
||||
$ev->setCancelled();
|
||||
}
|
||||
|
||||
if(!$this->isSprinting() and !$this->isFlying() and $this->fallDistance > 0 and !$this->hasEffect(Effect::BLINDNESS) and !$this->isUnderwater()){
|
||||
$ev->setModifier($ev->getFinalDamage() / 2, EntityDamageEvent::MODIFIER_CRITICAL);
|
||||
}
|
||||
|
||||
$target->attack($ev);
|
||||
|
||||
if($ev->isCancelled()){
|
||||
if($heldItem instanceof Durable and $this->isSurvival()){
|
||||
$this->inventory->sendContents($this);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if($ev->getModifier(EntityDamageEvent::MODIFIER_CRITICAL) > 0){
|
||||
$pk = new AnimatePacket();
|
||||
$pk->action = AnimatePacket::ACTION_CRITICAL_HIT;
|
||||
$pk->entityRuntimeId = $target->getId();
|
||||
$this->server->broadcastPacket($target->getViewers(), $pk);
|
||||
if($target instanceof Player){
|
||||
$target->dataPacket($pk);
|
||||
}
|
||||
}
|
||||
|
||||
foreach($meleeEnchantments as $enchantment){
|
||||
$type = $enchantment->getType();
|
||||
assert($type instanceof MeleeWeaponEnchantment);
|
||||
$type->onPostAttack($this, $target, $enchantment->getLevel());
|
||||
}
|
||||
|
||||
if($this->isAlive()){
|
||||
//reactive damage like thorns might cause us to be killed by attacking another mob, which
|
||||
//would mean we'd already have dropped the inventory by the time we reached here
|
||||
if($heldItem->onAttackEntity($target) and $this->isSurvival() and $oldItem->equalsExact($this->inventory->getItemInHand())){ //always fire the hook, even if we are survival
|
||||
$this->inventory->setItemInHand($heldItem);
|
||||
}
|
||||
|
||||
$this->exhaust(0.3, PlayerExhaustEvent::CAUSE_ATTACK);
|
||||
}
|
||||
|
||||
return true;
|
||||
default:
|
||||
break; //unknown
|
||||
}
|
||||
|
||||
$this->inventory->sendContents($this);
|
||||
return false;
|
||||
}elseif($packet->trData instanceof ReleaseItemTransactionData){
|
||||
if($this->inventory->getHeldItemIndex() !== $packet->trData->getHotbarSlot()){
|
||||
$this->inventory->equipItem($packet->trData->getHotbarSlot());
|
||||
}
|
||||
|
||||
try{
|
||||
switch($packet->trData->getActionType()){
|
||||
case ReleaseItemTransactionData::ACTION_RELEASE:
|
||||
if($this->isUsingItem()){
|
||||
$item = $this->inventory->getItemInHand();
|
||||
if($this->hasItemCooldown($item)){
|
||||
$this->inventory->sendContents($this);
|
||||
return false;
|
||||
}
|
||||
if($item->onReleaseUsing($this)){
|
||||
$this->resetItemCooldown($item);
|
||||
$this->inventory->setItemInHand($item);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
$this->setUsingItem(true);
|
||||
|
||||
return true;
|
||||
break;
|
||||
default:
|
||||
//unknown
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case InventoryTransactionPacket::TYPE_USE_ITEM_ON_ENTITY:
|
||||
$target = $this->level->getEntity($packet->trData->entityRuntimeId);
|
||||
if($target === null){
|
||||
return false;
|
||||
}
|
||||
|
||||
$type = $packet->trData->actionType;
|
||||
|
||||
switch($type){
|
||||
case InventoryTransactionPacket::USE_ITEM_ON_ENTITY_ACTION_INTERACT:
|
||||
break; //TODO
|
||||
case InventoryTransactionPacket::USE_ITEM_ON_ENTITY_ACTION_ATTACK:
|
||||
if(!$target->isAlive()){
|
||||
return true;
|
||||
}
|
||||
if($target instanceof ItemEntity or $target instanceof Arrow){
|
||||
$this->kick("Attempting to attack an invalid entity");
|
||||
$this->server->getLogger()->warning($this->getServer()->getLanguage()->translateString("pocketmine.player.invalidEntity", [$this->getName()]));
|
||||
return false;
|
||||
}
|
||||
|
||||
$cancelled = false;
|
||||
|
||||
$heldItem = $this->inventory->getItemInHand();
|
||||
$oldItem = clone $heldItem;
|
||||
|
||||
if(!$this->canInteract($target, 8) or $this->isSpectator()){
|
||||
$cancelled = true;
|
||||
}elseif($target instanceof Player){
|
||||
if(!$this->server->getConfigBool("pvp")){
|
||||
$cancelled = true;
|
||||
}
|
||||
}
|
||||
|
||||
$ev = new EntityDamageByEntityEvent($this, $target, EntityDamageEvent::CAUSE_ENTITY_ATTACK, $heldItem->getAttackPoints());
|
||||
|
||||
$meleeEnchantmentDamage = 0;
|
||||
/** @var EnchantmentInstance[] $meleeEnchantments */
|
||||
$meleeEnchantments = [];
|
||||
foreach($heldItem->getEnchantments() as $enchantment){
|
||||
$type = $enchantment->getType();
|
||||
if($type instanceof MeleeWeaponEnchantment and $type->isApplicableTo($target)){
|
||||
$meleeEnchantmentDamage += $type->getDamageBonus($enchantment->getLevel());
|
||||
$meleeEnchantments[] = $enchantment;
|
||||
}
|
||||
}
|
||||
$ev->setModifier($meleeEnchantmentDamage, EntityDamageEvent::MODIFIER_WEAPON_ENCHANTMENTS);
|
||||
|
||||
if($cancelled){
|
||||
$ev->setCancelled();
|
||||
}
|
||||
|
||||
if(!$this->isSprinting() and !$this->isFlying() and $this->fallDistance > 0 and !$this->hasEffect(Effect::BLINDNESS) and !$this->isUnderwater()){
|
||||
$ev->setModifier($ev->getFinalDamage() / 2, EntityDamageEvent::MODIFIER_CRITICAL);
|
||||
}
|
||||
|
||||
$target->attack($ev);
|
||||
|
||||
if($ev->isCancelled()){
|
||||
if($heldItem instanceof Durable and $this->isSurvival()){
|
||||
$this->inventory->sendContents($this);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if($ev->getModifier(EntityDamageEvent::MODIFIER_CRITICAL) > 0){
|
||||
$pk = new AnimatePacket();
|
||||
$pk->action = AnimatePacket::ACTION_CRITICAL_HIT;
|
||||
$pk->entityRuntimeId = $target->getId();
|
||||
$this->server->broadcastPacket($target->getViewers(), $pk);
|
||||
if($target instanceof Player){
|
||||
$target->dataPacket($pk);
|
||||
}
|
||||
}
|
||||
|
||||
foreach($meleeEnchantments as $enchantment){
|
||||
$type = $enchantment->getType();
|
||||
assert($type instanceof MeleeWeaponEnchantment);
|
||||
$type->onPostAttack($this, $target, $enchantment->getLevel());
|
||||
}
|
||||
|
||||
if($this->isAlive()){
|
||||
//reactive damage like thorns might cause us to be killed by attacking another mob, which
|
||||
//would mean we'd already have dropped the inventory by the time we reached here
|
||||
if($heldItem->onAttackEntity($target) and $this->isSurvival() and $oldItem->equalsExact($this->inventory->getItemInHand())){ //always fire the hook, even if we are survival
|
||||
$this->inventory->setItemInHand($heldItem);
|
||||
}
|
||||
|
||||
$this->exhaust(0.3, PlayerExhaustEvent::CAUSE_ATTACK);
|
||||
}
|
||||
|
||||
return true;
|
||||
default:
|
||||
break; //unknown
|
||||
}
|
||||
|
||||
break;
|
||||
case InventoryTransactionPacket::TYPE_RELEASE_ITEM:
|
||||
try{
|
||||
$type = $packet->trData->actionType;
|
||||
switch($type){
|
||||
case InventoryTransactionPacket::RELEASE_ITEM_ACTION_RELEASE:
|
||||
if($this->isUsingItem()){
|
||||
$item = $this->inventory->getItemInHand();
|
||||
if($this->hasItemCooldown($item)){
|
||||
$this->inventory->sendContents($this);
|
||||
return false;
|
||||
}
|
||||
if($item->onReleaseUsing($this)){
|
||||
$this->resetItemCooldown($item);
|
||||
$this->inventory->setItemInHand($item);
|
||||
}
|
||||
}else{
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}finally{
|
||||
$this->setUsingItem(false);
|
||||
}
|
||||
|
||||
$this->inventory->sendContents($this);
|
||||
break;
|
||||
default:
|
||||
$this->inventory->sendContents($this);
|
||||
break;
|
||||
}finally{
|
||||
$this->setUsingItem(false);
|
||||
}
|
||||
|
||||
$this->inventory->sendContents($this);
|
||||
return false;
|
||||
}else{
|
||||
$this->inventory->sendContents($this);
|
||||
return false;
|
||||
}
|
||||
|
||||
return false; //TODO
|
||||
}
|
||||
|
||||
public function handleMobEquipment(MobEquipmentPacket $packet) : bool{
|
||||
@ -2804,8 +2827,8 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
|
||||
$item = $this->inventory->getItem($packet->hotbarSlot);
|
||||
|
||||
if(!$item->equals($packet->item)){
|
||||
$this->server->getLogger()->debug("Tried to equip " . $packet->item . " but have " . $item . " in target slot");
|
||||
if(!$item->equals($packet->item->getItemStack())){
|
||||
$this->server->getLogger()->debug("Tried to equip " . $packet->item->getItemStack() . " but have " . $item . " in target slot");
|
||||
$this->inventory->sendContents($this);
|
||||
return false;
|
||||
}
|
||||
@ -2821,15 +2844,11 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
if(!$this->spawned or !$this->isAlive()){
|
||||
return true;
|
||||
}
|
||||
if($packet->action === InteractPacket::ACTION_MOUSEOVER and $packet->target === 0){
|
||||
//TODO HACK: silence useless spam (MCPE 1.8)
|
||||
//this packet is EXPECTED to only be sent when interacting with an entity, but due to some messy Mojang
|
||||
//hacks, it also sends it when changing the held item now, which causes us to think the inventory was closed
|
||||
//when it wasn't.
|
||||
return true;
|
||||
}
|
||||
|
||||
$this->doCloseInventory();
|
||||
if($packet->action !== InteractPacket::ACTION_MOUSEOVER){
|
||||
//mouseover fires when the player swaps their held itemstack in the inventory menu
|
||||
$this->doCloseInventory();
|
||||
}
|
||||
|
||||
$target = $this->level->getEntity($packet->target);
|
||||
if($target === null){
|
||||
@ -2924,6 +2943,16 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
break;
|
||||
}
|
||||
|
||||
$tile = $this->level->getTile($pos);
|
||||
if($tile instanceof ItemFrame and $tile->hasItem()){
|
||||
if (lcg_value() <= $tile->getItemDropChance()){
|
||||
$this->level->dropItem($tile->getBlock(), $tile->getItem());
|
||||
}
|
||||
$tile->setItem(null);
|
||||
$tile->setItemRotation(0);
|
||||
break;
|
||||
}
|
||||
|
||||
$block = $target->getSide($packet->face);
|
||||
if($block->getId() === Block::FIRE){
|
||||
$this->level->setBlock($block, BlockFactory::get(Block::AIR));
|
||||
@ -2975,7 +3004,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
case PlayerActionPacket::ACTION_START_GLIDE:
|
||||
case PlayerActionPacket::ACTION_STOP_GLIDE:
|
||||
break; //TODO
|
||||
case PlayerActionPacket::ACTION_CONTINUE_BREAK:
|
||||
case PlayerActionPacket::ACTION_CRACK_BREAK:
|
||||
$block = $this->level->getBlock($pos);
|
||||
$this->level->broadcastLevelEvent($pos, LevelEventPacket::EVENT_PARTICLE_PUNCH_BLOCK, $block->getRuntimeId() | ($packet->face << 24));
|
||||
//TODO: destroy-progress level event
|
||||
@ -3093,14 +3122,25 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
}
|
||||
if(isset($this->windowIndex[$packet->windowId])){
|
||||
$this->closingWindowId = $packet->windowId;
|
||||
(new InventoryCloseEvent($this->windowIndex[$packet->windowId], $this))->call();
|
||||
$this->removeWindow($this->windowIndex[$packet->windowId]);
|
||||
$this->closingWindowId = null;
|
||||
//removeWindow handles sending the appropriate
|
||||
return true;
|
||||
}else{
|
||||
/*
|
||||
* TODO: HACK!
|
||||
* If we told the client to remove a window on our own (e.g. a plugin called removeWindow()), our
|
||||
* first ContainerClose tricks the client into behaving as if it itself asked for the window to be closed.
|
||||
* This means that it will send us a ContainerClose of its own, which we must respond to the same way as if
|
||||
* the client closed the window by itself.
|
||||
* If we don't, the client will not be able to open any new windows.
|
||||
*/
|
||||
$pk = new ContainerClosePacket();
|
||||
$pk->windowId = $packet->windowId;
|
||||
$pk->server = false;
|
||||
$this->sendDataPacket($pk);
|
||||
}
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public function handleAdventureSettings(AdventureSettingsPacket $packet) : bool{
|
||||
@ -3111,11 +3151,12 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
$handled = false;
|
||||
|
||||
$isFlying = $packet->getFlag(AdventureSettingsPacket::FLYING);
|
||||
if($isFlying and !$this->allowFlight){
|
||||
$this->kick($this->server->getLanguage()->translateString("kick.reason.cheat", ["%ability.flight"]));
|
||||
return true;
|
||||
}elseif($isFlying !== $this->isFlying()){
|
||||
if($isFlying !== $this->isFlying()){
|
||||
$ev = new PlayerToggleFlightEvent($this, $isFlying);
|
||||
if($isFlying and !$this->allowFlight){
|
||||
$ev->setCancelled();
|
||||
}
|
||||
|
||||
$ev->call();
|
||||
if($ev->isCancelled()){
|
||||
$this->sendSettings();
|
||||
@ -3679,6 +3720,8 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
$this->stopSleep();
|
||||
|
||||
if($this->spawned){
|
||||
$this->doCloseInventory();
|
||||
|
||||
$ev = new PlayerQuitEvent($this, $message, $reason);
|
||||
$ev->call();
|
||||
if($ev->getQuitMessage() != ""){
|
||||
@ -3861,6 +3904,10 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
return;
|
||||
}
|
||||
|
||||
$this->actuallyRespawn();
|
||||
}
|
||||
|
||||
protected function actuallyRespawn() : void{
|
||||
$ev = new PlayerRespawnEvent($this, $this->getSpawn());
|
||||
$ev->call();
|
||||
|
||||
@ -4116,6 +4163,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
}
|
||||
|
||||
if($id !== null){
|
||||
(new InventoryCloseEvent($inventory, $this))->call();
|
||||
$inventory->close($this);
|
||||
unset($this->windows[$hash], $this->windowIndex[$id], $this->permanentWindows[$id]);
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ namespace pocketmine {
|
||||
|
||||
require_once __DIR__ . '/VersionInfo.php';
|
||||
|
||||
const MIN_PHP_VERSION = "7.3.0";
|
||||
const MIN_PHP_VERSION = "8.0.0";
|
||||
|
||||
/**
|
||||
* @param string $message
|
||||
@ -74,6 +74,7 @@ namespace pocketmine {
|
||||
}
|
||||
|
||||
$extensions = [
|
||||
"chunkutils2" => "PocketMine ChunkUtils v2",
|
||||
"curl" => "cURL",
|
||||
"ctype" => "ctype",
|
||||
"date" => "Date",
|
||||
@ -103,8 +104,8 @@ namespace pocketmine {
|
||||
if(substr_count($pthreads_version, ".") < 2){
|
||||
$pthreads_version = "0.$pthreads_version";
|
||||
}
|
||||
if(version_compare($pthreads_version, "3.2.0") < 0){
|
||||
$messages[] = "pthreads >= 3.2.0 is required, while you have $pthreads_version.";
|
||||
if(version_compare($pthreads_version, "4.0.0") < 0 || version_compare($pthreads_version, "5.0.0") > 0){
|
||||
$messages[] = "pthreads ^4.0.0 is required, while you have $pthreads_version.";
|
||||
}
|
||||
}
|
||||
|
||||
@ -115,6 +116,16 @@ namespace pocketmine {
|
||||
}
|
||||
}
|
||||
|
||||
$chunkutils2_version = phpversion("chunkutils2");
|
||||
$wantedVersionLock = "0.3";
|
||||
$wantedVersionMin = "$wantedVersionLock.0";
|
||||
if($chunkutils2_version !== false && (
|
||||
version_compare($chunkutils2_version, $wantedVersionMin) < 0 ||
|
||||
preg_match("/^" . preg_quote($wantedVersionLock, "/") . "\.\d+(?:-dev)?$/", $chunkutils2_version) === 0 //lock in at ^0.2, optionally at a patch release
|
||||
)){
|
||||
$messages[] = "chunkutils2 ^$wantedVersionMin is required, while you have $chunkutils2_version.";
|
||||
}
|
||||
|
||||
if(extension_loaded("pocketmine")){
|
||||
$messages[] = "The native PocketMine extension is no longer supported.";
|
||||
}
|
||||
@ -127,6 +138,9 @@ namespace pocketmine {
|
||||
* @return void
|
||||
*/
|
||||
function emit_performance_warnings(\Logger $logger){
|
||||
if(PHP_DEBUG !== 0){
|
||||
$logger->warning("This PHP binary was compiled in debug mode. This has a major impact on performance.");
|
||||
}
|
||||
if(extension_loaded("xdebug")){
|
||||
$logger->warning("Xdebug extension is enabled. This has a major impact on performance.");
|
||||
}
|
||||
@ -139,6 +153,24 @@ namespace pocketmine {
|
||||
if(\Phar::running(true) === ""){
|
||||
$logger->warning("Non-packaged installation detected. This will degrade autoloading speed and make startup times longer.");
|
||||
}
|
||||
if(function_exists('opcache_get_status') && ($opcacheStatus = opcache_get_status(false)) !== false){
|
||||
$jitEnabled = $opcacheStatus["jit"]["on"] ?? false;
|
||||
if($jitEnabled !== false){
|
||||
$logger->warning(<<<'JIT_WARNING'
|
||||
|
||||
|
||||
--------------------------------------- ! WARNING ! ---------------------------------------
|
||||
You're using PHP 8.0 with JIT enabled. This provides significant performance improvements.
|
||||
HOWEVER, it is EXPERIMENTAL, and has already been seen to cause weird and unexpected bugs.
|
||||
Proceed with caution.
|
||||
If you want to report any bugs, make sure to mention that you are using PHP 8.0 with JIT.
|
||||
To turn off JIT, change `opcache.jit` to `0` in your php.ini file.
|
||||
-------------------------------------------------------------------------------------------
|
||||
|
||||
JIT_WARNING
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -159,10 +191,14 @@ namespace pocketmine {
|
||||
if(count($messages = check_platform_dependencies()) > 0){
|
||||
echo PHP_EOL;
|
||||
$binary = version_compare(PHP_VERSION, "5.4") >= 0 ? PHP_BINARY : "unknown";
|
||||
critical_error("Selected PHP binary ($binary) does not satisfy some requirements.");
|
||||
critical_error("Selected PHP binary does not satisfy some requirements.");
|
||||
foreach($messages as $m){
|
||||
echo " - $m" . PHP_EOL;
|
||||
}
|
||||
critical_error("PHP binary used: " . $binary);
|
||||
critical_error("Loaded php.ini: " . (($file = php_ini_loaded_file()) !== false ? $file : "none"));
|
||||
$phprc = getenv("PHPRC");
|
||||
critical_error("Value of PHPRC environment variable: " . ($phprc === false ? "" : $phprc));
|
||||
critical_error("Please recompile PHP with the needed configuration, or refer to the installation instructions at http://pmmp.rtfd.io/en/rtfd/installation.html.");
|
||||
echo PHP_EOL;
|
||||
exit(1);
|
||||
@ -189,10 +225,8 @@ namespace pocketmine {
|
||||
|
||||
set_error_handler([Utils::class, 'errorExceptionHandler']);
|
||||
|
||||
$version = new VersionString(\pocketmine\BASE_VERSION, \pocketmine\IS_DEVELOPMENT_BUILD, \pocketmine\BUILD_NUMBER);
|
||||
define('pocketmine\VERSION', $version->getFullVersion(true));
|
||||
|
||||
$gitHash = str_repeat("00", 20);
|
||||
$buildNumber = 0;
|
||||
|
||||
if(\Phar::running(true) === ""){
|
||||
$gitHash = Git::getRepositoryStatePretty(\pocketmine\PATH);
|
||||
@ -202,9 +236,16 @@ namespace pocketmine {
|
||||
if(isset($meta["git"])){
|
||||
$gitHash = $meta["git"];
|
||||
}
|
||||
if(isset($meta["build"]) && is_int($meta["build"])){
|
||||
$buildNumber = $meta["build"];
|
||||
}
|
||||
}
|
||||
|
||||
define('pocketmine\GIT_COMMIT', $gitHash);
|
||||
define('pocketmine\BUILD_NUMBER', $buildNumber);
|
||||
|
||||
$version = new VersionString(\pocketmine\BASE_VERSION, \pocketmine\IS_DEVELOPMENT_BUILD, \pocketmine\BUILD_NUMBER);
|
||||
define('pocketmine\VERSION', $version->getFullVersion(true));
|
||||
|
||||
$composerGitHash = InstalledVersions::getReference('pocketmine/pocketmine-mp');
|
||||
if($composerGitHash !== null){
|
||||
|
@ -1461,8 +1461,7 @@ class Server{
|
||||
|
||||
$this->onlineMode = $this->getConfigBool("xbox-auth", true);
|
||||
if($this->onlineMode){
|
||||
$this->logger->notice($this->getLanguage()->translateString("pocketmine.server.auth.enabled"));
|
||||
$this->logger->notice($this->getLanguage()->translateString("pocketmine.server.authProperty.enabled"));
|
||||
$this->logger->info($this->getLanguage()->translateString("pocketmine.server.auth.enabled"));
|
||||
}else{
|
||||
$this->logger->warning($this->getLanguage()->translateString("pocketmine.server.auth.disabled"));
|
||||
$this->logger->warning($this->getLanguage()->translateString("pocketmine.server.authWarning"));
|
||||
@ -1962,7 +1961,7 @@ class Server{
|
||||
$this->network->blockAddress($entry->getName(), -1);
|
||||
}
|
||||
|
||||
if((bool) $this->getProperty("settings.send-usage", true)){
|
||||
if((bool) $this->getProperty("anonymous-statistics.enabled", true)){
|
||||
$this->sendUsageTicker = 6000;
|
||||
$this->sendUsage(SendUsageTask::TYPE_OPEN);
|
||||
}
|
||||
|
@ -33,6 +33,6 @@ if(defined('pocketmine\_VERSION_INFO_INCLUDED')){
|
||||
const _VERSION_INFO_INCLUDED = true;
|
||||
|
||||
const NAME = "PocketMine-MP";
|
||||
const BASE_VERSION = "3.17.5";
|
||||
const BASE_VERSION = "3.26.4";
|
||||
const IS_DEVELOPMENT_BUILD = false;
|
||||
const BUILD_NUMBER = 0;
|
||||
const BUILD_CHANNEL = "pm3";
|
||||
|
@ -95,7 +95,7 @@ abstract class Worker extends \Worker{
|
||||
public function quit(){
|
||||
$this->isKilled = true;
|
||||
|
||||
if($this->isRunning()){
|
||||
if(!$this->isShutdown()){
|
||||
while($this->unstack() !== null);
|
||||
$this->notify();
|
||||
$this->shutdown();
|
||||
|
@ -418,6 +418,9 @@ abstract class Liquid extends Transparent{
|
||||
return $isOptimalFlowDirection;
|
||||
}
|
||||
|
||||
/**
|
||||
* @phpstan-impure This function modifies the adjacent sources count (premature optimisation)
|
||||
*/
|
||||
private function getSmallestFlowDecay(Block $block, int $decay) : int{
|
||||
$blockDecay = $this->getFlowDecay($block);
|
||||
|
||||
|
@ -68,7 +68,10 @@ class SignPost extends Transparent{
|
||||
$this->getLevelNonNull()->setBlock($blockReplace, BlockFactory::get(Block::WALL_SIGN, $this->meta), true);
|
||||
}
|
||||
|
||||
Tile::createTile(Tile::SIGN, $this->getLevelNonNull(), TileSign::createNBT($this, $face, $item, $player));
|
||||
$sign = Tile::createTile(Tile::SIGN, $this->getLevelNonNull(), TileSign::createNBT($this, $face, $item, $player));
|
||||
if($player !== null && $sign instanceof TileSign){
|
||||
$sign->setEditorEntityRuntimeId($player->getId());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -32,7 +32,6 @@ use function fstat;
|
||||
use function is_resource;
|
||||
use function microtime;
|
||||
use function preg_replace;
|
||||
use function readline;
|
||||
use function stream_isatty;
|
||||
use function stream_select;
|
||||
use function trim;
|
||||
@ -116,37 +115,28 @@ class CommandReader extends Thread{
|
||||
* @return bool if the main execution should continue reading lines
|
||||
*/
|
||||
private function readLine() : bool{
|
||||
$line = "";
|
||||
|
||||
if(!is_resource(self::$stdin)){
|
||||
$this->initStdin();
|
||||
}
|
||||
|
||||
switch($this->type){
|
||||
/** @noinspection PhpMissingBreakStatementInspection */
|
||||
case self::TYPE_STREAM:
|
||||
//stream_select doesn't work on piped streams for some reason
|
||||
$r = [self::$stdin];
|
||||
$w = $e = null;
|
||||
if(($count = stream_select($r, $w, $e, 0, 200000)) === 0){ //nothing changed in 200000 microseconds
|
||||
return true;
|
||||
}elseif($count === false){ //stream error
|
||||
$this->initStdin();
|
||||
}
|
||||
|
||||
case self::TYPE_PIPED:
|
||||
if(($raw = fgets(self::$stdin)) === false){ //broken pipe or EOF
|
||||
$this->initStdin();
|
||||
$this->synchronized(function() : void{
|
||||
$this->wait(200000);
|
||||
}); //prevent CPU waste if it's end of pipe
|
||||
return true; //loop back round
|
||||
}
|
||||
|
||||
$line = trim($raw);
|
||||
break;
|
||||
$r = [self::$stdin];
|
||||
$w = $e = null;
|
||||
if(($count = stream_select($r, $w, $e, 0, 200000)) === 0){ //nothing changed in 200000 microseconds
|
||||
return true;
|
||||
}elseif($count === false){ //stream error
|
||||
$this->initStdin();
|
||||
}
|
||||
|
||||
if(($raw = fgets(self::$stdin)) === false){ //broken pipe or EOF
|
||||
$this->initStdin();
|
||||
$this->synchronized(function() : void{
|
||||
$this->wait(200000);
|
||||
}); //prevent CPU waste if it's end of pipe
|
||||
return true; //loop back round
|
||||
}
|
||||
|
||||
$line = trim($raw);
|
||||
|
||||
if($line !== ""){
|
||||
$this->buffer[] = preg_replace("#\\x1b\\x5b([^\\x1b]*\\x7e|[\\x40-\\x50])#", "", $line);
|
||||
if($this->notifier !== null){
|
||||
|
@ -175,56 +175,56 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
|
||||
public const DATA_RIDER_ROTATION_LOCKED = 57; //byte
|
||||
public const DATA_RIDER_MAX_ROTATION = 58; //float
|
||||
public const DATA_RIDER_MIN_ROTATION = 59; //float
|
||||
public const DATA_AREA_EFFECT_CLOUD_RADIUS = 60; //float
|
||||
public const DATA_AREA_EFFECT_CLOUD_WAITING = 61; //int
|
||||
public const DATA_AREA_EFFECT_CLOUD_PARTICLE_ID = 62; //int
|
||||
/* 63 (int) shulker-related */
|
||||
public const DATA_SHULKER_ATTACH_FACE = 64; //byte
|
||||
/* 65 (short) shulker-related */
|
||||
public const DATA_SHULKER_ATTACH_POS = 66; //block coords
|
||||
public const DATA_TRADING_PLAYER_EID = 67; //long
|
||||
public const DATA_AREA_EFFECT_CLOUD_RADIUS = 61; //float
|
||||
public const DATA_AREA_EFFECT_CLOUD_WAITING = 62; //int
|
||||
public const DATA_AREA_EFFECT_CLOUD_PARTICLE_ID = 63; //int
|
||||
/* 64 (int) shulker-related */
|
||||
public const DATA_SHULKER_ATTACH_FACE = 65; //byte
|
||||
/* 66 (short) shulker-related */
|
||||
public const DATA_SHULKER_ATTACH_POS = 67; //block coords
|
||||
public const DATA_TRADING_PLAYER_EID = 68; //long
|
||||
|
||||
/* 69 (byte) command-block */
|
||||
public const DATA_COMMAND_BLOCK_COMMAND = 70; //string
|
||||
public const DATA_COMMAND_BLOCK_LAST_OUTPUT = 71; //string
|
||||
public const DATA_COMMAND_BLOCK_TRACK_OUTPUT = 72; //byte
|
||||
public const DATA_CONTROLLING_RIDER_SEAT_NUMBER = 73; //byte
|
||||
public const DATA_STRENGTH = 74; //int
|
||||
public const DATA_MAX_STRENGTH = 75; //int
|
||||
/* 76 (int) */
|
||||
public const DATA_LIMITED_LIFE = 77;
|
||||
public const DATA_ARMOR_STAND_POSE_INDEX = 78; //int
|
||||
public const DATA_ENDER_CRYSTAL_TIME_OFFSET = 79; //int
|
||||
public const DATA_ALWAYS_SHOW_NAMETAG = 80; //byte: -1 = default, 0 = only when looked at, 1 = always
|
||||
public const DATA_COLOR_2 = 81; //byte
|
||||
/* 82 (unknown) */
|
||||
public const DATA_SCORE_TAG = 83; //string
|
||||
public const DATA_BALLOON_ATTACHED_ENTITY = 84; //int64, entity unique ID of owner
|
||||
public const DATA_PUFFERFISH_SIZE = 85; //byte
|
||||
public const DATA_BOAT_BUBBLE_TIME = 86; //int (time in bubble column)
|
||||
public const DATA_PLAYER_AGENT_EID = 87; //long
|
||||
/* 88 (float) related to panda sitting
|
||||
* 89 (float) related to panda sitting */
|
||||
public const DATA_EAT_COUNTER = 90; //int (used by pandas)
|
||||
public const DATA_FLAGS2 = 91; //long (extended data flags)
|
||||
/* 92 (float) related to panda lying down
|
||||
* 93 (float) related to panda lying down */
|
||||
public const DATA_AREA_EFFECT_CLOUD_DURATION = 94; //int
|
||||
public const DATA_AREA_EFFECT_CLOUD_SPAWN_TIME = 95; //int
|
||||
public const DATA_AREA_EFFECT_CLOUD_RADIUS_PER_TICK = 96; //float, usually negative
|
||||
public const DATA_AREA_EFFECT_CLOUD_RADIUS_CHANGE_ON_PICKUP = 97; //float
|
||||
public const DATA_AREA_EFFECT_CLOUD_PICKUP_COUNT = 98; //int
|
||||
public const DATA_INTERACTIVE_TAG = 99; //string (button text)
|
||||
public const DATA_TRADE_TIER = 100; //int
|
||||
public const DATA_MAX_TRADE_TIER = 101; //int
|
||||
public const DATA_TRADE_XP = 102; //int
|
||||
public const DATA_SKIN_ID = 103; //int ???
|
||||
/* 104 (int) related to wither */
|
||||
public const DATA_COMMAND_BLOCK_TICK_DELAY = 105; //int
|
||||
public const DATA_COMMAND_BLOCK_EXECUTE_ON_FIRST_TICK = 106; //byte
|
||||
public const DATA_AMBIENT_SOUND_INTERVAL_MIN = 107; //float
|
||||
public const DATA_AMBIENT_SOUND_INTERVAL_RANGE = 108; //float
|
||||
public const DATA_AMBIENT_SOUND_EVENT = 109; //string
|
||||
/* 70 (byte) command-block */
|
||||
public const DATA_COMMAND_BLOCK_COMMAND = 71; //string
|
||||
public const DATA_COMMAND_BLOCK_LAST_OUTPUT = 72; //string
|
||||
public const DATA_COMMAND_BLOCK_TRACK_OUTPUT = 73; //byte
|
||||
public const DATA_CONTROLLING_RIDER_SEAT_NUMBER = 74; //byte
|
||||
public const DATA_STRENGTH = 75; //int
|
||||
public const DATA_MAX_STRENGTH = 76; //int
|
||||
/* 77 (int) */
|
||||
public const DATA_LIMITED_LIFE = 78;
|
||||
public const DATA_ARMOR_STAND_POSE_INDEX = 79; //int
|
||||
public const DATA_ENDER_CRYSTAL_TIME_OFFSET = 80; //int
|
||||
public const DATA_ALWAYS_SHOW_NAMETAG = 81; //byte: -1 = default, 0 = only when looked at, 1 = always
|
||||
public const DATA_COLOR_2 = 82; //byte
|
||||
/* 83 (unknown) */
|
||||
public const DATA_SCORE_TAG = 84; //string
|
||||
public const DATA_BALLOON_ATTACHED_ENTITY = 85; //int64, entity unique ID of owner
|
||||
public const DATA_PUFFERFISH_SIZE = 86; //byte
|
||||
public const DATA_BOAT_BUBBLE_TIME = 87; //int (time in bubble column)
|
||||
public const DATA_PLAYER_AGENT_EID = 88; //long
|
||||
/* 89 (float) related to panda sitting
|
||||
* 90 (float) related to panda sitting */
|
||||
public const DATA_EAT_COUNTER = 91; //int (used by pandas)
|
||||
public const DATA_FLAGS2 = 92; //long (extended data flags)
|
||||
/* 93 (float) related to panda lying down
|
||||
* 94 (float) related to panda lying down */
|
||||
public const DATA_AREA_EFFECT_CLOUD_DURATION = 95; //int
|
||||
public const DATA_AREA_EFFECT_CLOUD_SPAWN_TIME = 96; //int
|
||||
public const DATA_AREA_EFFECT_CLOUD_RADIUS_PER_TICK = 97; //float, usually negative
|
||||
public const DATA_AREA_EFFECT_CLOUD_RADIUS_CHANGE_ON_PICKUP = 98; //float
|
||||
public const DATA_AREA_EFFECT_CLOUD_PICKUP_COUNT = 99; //int
|
||||
public const DATA_INTERACTIVE_TAG = 100; //string (button text)
|
||||
public const DATA_TRADE_TIER = 101; //int
|
||||
public const DATA_MAX_TRADE_TIER = 102; //int
|
||||
public const DATA_TRADE_XP = 103; //int
|
||||
public const DATA_SKIN_ID = 104; //int ???
|
||||
/* 105 (int) related to wither */
|
||||
public const DATA_COMMAND_BLOCK_TICK_DELAY = 106; //int
|
||||
public const DATA_COMMAND_BLOCK_EXECUTE_ON_FIRST_TICK = 107; //byte
|
||||
public const DATA_AMBIENT_SOUND_INTERVAL_MIN = 108; //float
|
||||
public const DATA_AMBIENT_SOUND_INTERVAL_RANGE = 109; //float
|
||||
public const DATA_AMBIENT_SOUND_EVENT = 110; //string
|
||||
|
||||
public const DATA_FLAG_ONFIRE = 0;
|
||||
public const DATA_FLAG_SNEAKING = 1;
|
||||
@ -619,6 +619,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
|
||||
$this->propertyManager->setFloat(self::DATA_SCALE, 1);
|
||||
$this->propertyManager->setFloat(self::DATA_BOUNDING_BOX_WIDTH, $this->width);
|
||||
$this->propertyManager->setFloat(self::DATA_BOUNDING_BOX_HEIGHT, $this->height);
|
||||
$this->propertyManager->setFloat(self::DATA_COLOR, 0);
|
||||
|
||||
$this->fireTicks = $this->namedtag->getShort("Fire", 0);
|
||||
if($this->isOnFire()){
|
||||
@ -1229,10 +1230,10 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
|
||||
$diffZ = $z - $floorZ;
|
||||
|
||||
if(BlockFactory::$solid[$this->level->getBlockIdAt($floorX, $floorY, $floorZ)]){
|
||||
$westNonSolid = !BlockFactory::$solid[$this->level->getBlockIdAt($floorX - 1, $floorY, $floorZ)];
|
||||
$eastNonSolid = !BlockFactory::$solid[$this->level->getBlockIdAt($floorX + 1, $floorY, $floorZ)];
|
||||
$downNonSolid = !BlockFactory::$solid[$this->level->getBlockIdAt($floorX, $floorY - 1, $floorZ)];
|
||||
$upNonSolid = !BlockFactory::$solid[$this->level->getBlockIdAt($floorX, $floorY + 1, $floorZ)];
|
||||
$westNonSolid = !BlockFactory::$solid[$this->level->getBlockIdAt($floorX - 1, $floorY, $floorZ)];
|
||||
$eastNonSolid = !BlockFactory::$solid[$this->level->getBlockIdAt($floorX + 1, $floorY, $floorZ)];
|
||||
$downNonSolid = !BlockFactory::$solid[$this->level->getBlockIdAt($floorX, $floorY - 1, $floorZ)];
|
||||
$upNonSolid = !BlockFactory::$solid[$this->level->getBlockIdAt($floorX, $floorY + 1, $floorZ)];
|
||||
$northNonSolid = !BlockFactory::$solid[$this->level->getBlockIdAt($floorX, $floorY, $floorZ - 1)];
|
||||
$southNonSolid = !BlockFactory::$solid[$this->level->getBlockIdAt($floorX, $floorY, $floorZ + 1)];
|
||||
|
||||
@ -1953,6 +1954,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
|
||||
if(
|
||||
!isset($this->hasSpawned[$player->getLoaderId()]) and
|
||||
$this->chunk !== null and
|
||||
$player->getLevelNonNull() === $this->level and
|
||||
isset($player->usedChunks[$chunkHash = Level::chunkHash($this->chunk->getX(), $this->chunk->getZ())]) and
|
||||
$player->usedChunks[$chunkHash] === true
|
||||
){
|
||||
|
@ -51,9 +51,9 @@ use pocketmine\network\mcpe\protocol\ActorEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\AddPlayerPacket;
|
||||
use pocketmine\network\mcpe\protocol\LevelEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\MovePlayerPacket;
|
||||
use pocketmine\network\mcpe\protocol\PlayerListPacket;
|
||||
use pocketmine\network\mcpe\protocol\PlayerSkinPacket;
|
||||
use pocketmine\network\mcpe\protocol\types\inventory\ItemStackWrapper;
|
||||
use pocketmine\network\mcpe\protocol\types\PlayerListEntry;
|
||||
use pocketmine\network\mcpe\protocol\types\SkinAdapterSingleton;
|
||||
use pocketmine\Player;
|
||||
@ -393,7 +393,9 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
|
||||
public function setCurrentTotalXp(int $amount) : bool{
|
||||
$newLevel = ExperienceUtils::getLevelFromXp($amount);
|
||||
|
||||
return $this->setXpAndProgress((int) $newLevel, $newLevel - ((int) $newLevel));
|
||||
$xpLevel = (int) $newLevel;
|
||||
$xpProgress = $newLevel - (int) $newLevel;
|
||||
return $this->setXpAndProgress($xpLevel, $xpProgress);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -403,6 +405,7 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
|
||||
* @param bool $playSound Whether to play level-up and XP gained sounds.
|
||||
*/
|
||||
public function addXp(int $amount, bool $playSound = true) : bool{
|
||||
$amount = min($amount, INT32_MAX - $this->totalXp);
|
||||
$oldLevel = $this->getXpLevel();
|
||||
$oldTotal = $this->getCurrentTotalXp();
|
||||
|
||||
@ -439,24 +442,26 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
|
||||
}
|
||||
|
||||
protected function setXpAndProgress(?int $level, ?float $progress) : bool{
|
||||
$newLevel = $level;
|
||||
$newProgress = $progress;
|
||||
if(!$this->justCreated){
|
||||
$ev = new PlayerExperienceChangeEvent($this, $this->getXpLevel(), $this->getXpProgress(), $level, $progress);
|
||||
$ev = new PlayerExperienceChangeEvent($this, $this->getXpLevel(), $this->getXpProgress(), $newLevel, $newProgress);
|
||||
$ev->call();
|
||||
|
||||
if($ev->isCancelled()){
|
||||
return false;
|
||||
}
|
||||
|
||||
$level = $ev->getNewLevel();
|
||||
$progress = $ev->getNewProgress();
|
||||
$newLevel = $ev->getNewLevel();
|
||||
$newProgress = $ev->getNewProgress();
|
||||
}
|
||||
|
||||
if($level !== null){
|
||||
$this->getAttributeMap()->getAttribute(Attribute::EXPERIENCE_LEVEL)->setValue($level);
|
||||
if($newLevel !== null){
|
||||
$this->getAttributeMap()->getAttribute(Attribute::EXPERIENCE_LEVEL)->setValue($newLevel);
|
||||
}
|
||||
|
||||
if($progress !== null){
|
||||
$this->getAttributeMap()->getAttribute(Attribute::EXPERIENCE)->setValue($progress);
|
||||
if($newProgress !== null){
|
||||
$this->getAttributeMap()->getAttribute(Attribute::EXPERIENCE)->setValue($newProgress);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -475,8 +480,8 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
|
||||
* score when they die. (TODO: add this when MCPE supports it)
|
||||
*/
|
||||
public function setLifetimeTotalXp(int $amount) : void{
|
||||
if($amount < 0){
|
||||
throw new \InvalidArgumentException("XP must be greater than 0");
|
||||
if($amount < 0 || $amount > INT32_MAX){
|
||||
throw new \InvalidArgumentException("XP must be greater than 0 and less than " . INT32_MAX);
|
||||
}
|
||||
|
||||
$this->totalXp = $amount;
|
||||
@ -813,7 +818,7 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
|
||||
$pk->motion = $this->getMotion();
|
||||
$pk->yaw = $this->yaw;
|
||||
$pk->pitch = $this->pitch;
|
||||
$pk->item = $this->getInventory()->getItemInHand();
|
||||
$pk->item = ItemStackWrapper::legacy($this->getInventory()->getItemInHand());
|
||||
$pk->metadata = $this->propertyManager->getAll();
|
||||
$player->dataPacket($pk);
|
||||
|
||||
@ -830,23 +835,6 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
|
||||
}
|
||||
}
|
||||
|
||||
public function broadcastMovement(bool $teleport = false) : void{
|
||||
//TODO: workaround 1.14.30 bug: MoveActor(Absolute|Delta)Packet don't work on players anymore :(
|
||||
$pk = new MovePlayerPacket();
|
||||
$pk->entityRuntimeId = $this->getId();
|
||||
$pk->position = $this->getOffsetPosition($this);
|
||||
$pk->yaw = $this->yaw;
|
||||
$pk->pitch = $this->pitch;
|
||||
$pk->headYaw = $this->yaw;
|
||||
$pk->mode = $teleport ? MovePlayerPacket::MODE_TELEPORT : MovePlayerPacket::MODE_NORMAL;
|
||||
|
||||
//we can't assume that everyone who is using our chunk wants to see this movement,
|
||||
//because this human might be a player who shouldn't be receiving his own movement.
|
||||
//this didn't matter when we were able to use MoveActorPacket because
|
||||
//the client just ignored MoveActor for itself, but it doesn't ignore MovePlayer for itself.
|
||||
$this->server->broadcastPacket($this->hasSpawned, $pk);
|
||||
}
|
||||
|
||||
public function close() : void{
|
||||
if(!$this->closed){
|
||||
if($this->inventory !== null){
|
||||
|
@ -30,6 +30,7 @@ use pocketmine\event\inventory\InventoryPickupItemEvent;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\network\mcpe\protocol\AddItemActorPacket;
|
||||
use pocketmine\network\mcpe\protocol\TakeItemActorPacket;
|
||||
use pocketmine\network\mcpe\protocol\types\inventory\ItemStackWrapper;
|
||||
use pocketmine\Player;
|
||||
use function get_class;
|
||||
|
||||
@ -173,7 +174,7 @@ class ItemEntity extends Entity{
|
||||
$pk->entityRuntimeId = $this->getId();
|
||||
$pk->position = $this->asVector3();
|
||||
$pk->motion = $this->getMotion();
|
||||
$pk->item = $this->getItem();
|
||||
$pk->item = ItemStackWrapper::legacy($this->getItem());
|
||||
$pk->metadata = $this->propertyManager->getAll();
|
||||
|
||||
$player->dataPacket($pk);
|
||||
|
@ -80,33 +80,29 @@ abstract class Projectile extends Entity{
|
||||
$this->setHealth(1);
|
||||
$this->damage = $this->namedtag->getDouble("damage", $this->damage);
|
||||
|
||||
do{
|
||||
$blockHit = null;
|
||||
$blockId = null;
|
||||
$blockData = null;
|
||||
|
||||
(function() : void{
|
||||
if($this->namedtag->hasTag("tileX", IntTag::class) and $this->namedtag->hasTag("tileY", IntTag::class) and $this->namedtag->hasTag("tileZ", IntTag::class)){
|
||||
$blockHit = new Vector3($this->namedtag->getInt("tileX"), $this->namedtag->getInt("tileY"), $this->namedtag->getInt("tileZ"));
|
||||
}else{
|
||||
break;
|
||||
return;
|
||||
}
|
||||
|
||||
if($this->namedtag->hasTag("blockId", IntTag::class)){
|
||||
$blockId = $this->namedtag->getInt("blockId");
|
||||
}else{
|
||||
break;
|
||||
return;
|
||||
}
|
||||
|
||||
if($this->namedtag->hasTag("blockData", ByteTag::class)){
|
||||
$blockData = $this->namedtag->getByte("blockData");
|
||||
}else{
|
||||
break;
|
||||
return;
|
||||
}
|
||||
|
||||
$this->blockHit = $blockHit;
|
||||
$this->blockHitId = $blockId;
|
||||
$this->blockHitData = $blockData;
|
||||
}while(false);
|
||||
})();
|
||||
}
|
||||
|
||||
public function canCollideWith(Entity $entity) : bool{
|
||||
@ -180,7 +176,7 @@ abstract class Projectile extends Entity{
|
||||
Timings::$entityMoveTimer->startTiming();
|
||||
|
||||
$start = $this->asVector3();
|
||||
$end = $start->add($this->motion);
|
||||
$end = $start->add($dx, $dy, $dz);
|
||||
|
||||
$blockHit = null;
|
||||
$entityHit = null;
|
||||
|
@ -36,7 +36,7 @@ use pocketmine\Player;
|
||||
|
||||
class PlayerDeathEvent extends EntityDeathEvent{
|
||||
/** @var Player */
|
||||
protected $entity;
|
||||
protected $player;
|
||||
|
||||
/** @var TextContainer|string */
|
||||
private $deathMessage;
|
||||
@ -49,6 +49,7 @@ class PlayerDeathEvent extends EntityDeathEvent{
|
||||
*/
|
||||
public function __construct(Player $entity, array $drops, $deathMessage = null, int $xp = 0){
|
||||
parent::__construct($entity, $drops, $xp);
|
||||
$this->player = $entity;
|
||||
$this->deathMessage = $deathMessage ?? self::deriveMessage($entity->getDisplayName(), $entity->getLastDamageCause());
|
||||
}
|
||||
|
||||
@ -56,11 +57,11 @@ class PlayerDeathEvent extends EntityDeathEvent{
|
||||
* @return Player
|
||||
*/
|
||||
public function getEntity(){
|
||||
return $this->entity;
|
||||
return $this->player;
|
||||
}
|
||||
|
||||
public function getPlayer() : Player{
|
||||
return $this->entity;
|
||||
return $this->player;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -79,6 +79,9 @@ class PlayerExperienceChangeEvent extends EntityEvent implements Cancellable{
|
||||
}
|
||||
|
||||
public function setNewProgress(?float $newProgress) : void{
|
||||
if($newProgress < 0.0 || $newProgress > 1.0){
|
||||
throw new \InvalidArgumentException("XP progress must be in range 0-1");
|
||||
}
|
||||
$this->newProgress = $newProgress;
|
||||
}
|
||||
}
|
||||
|
@ -98,10 +98,10 @@ class ArmorInventory extends BaseInventory{
|
||||
|
||||
$pk = new MobArmorEquipmentPacket();
|
||||
$pk->entityRuntimeId = $this->getHolder()->getId();
|
||||
$pk->head = $this->getHelmet();
|
||||
$pk->chest = $this->getChestplate();
|
||||
$pk->legs = $this->getLeggings();
|
||||
$pk->feet = $this->getBoots();
|
||||
$pk->head = ItemStackWrapper::legacy($this->getHelmet());
|
||||
$pk->chest = ItemStackWrapper::legacy($this->getChestplate());
|
||||
$pk->legs = ItemStackWrapper::legacy($this->getLeggings());
|
||||
$pk->feet = ItemStackWrapper::legacy($this->getBoots());
|
||||
$pk->encode();
|
||||
|
||||
foreach($target as $player){
|
||||
@ -126,10 +126,10 @@ class ArmorInventory extends BaseInventory{
|
||||
|
||||
$pk = new MobArmorEquipmentPacket();
|
||||
$pk->entityRuntimeId = $this->getHolder()->getId();
|
||||
$pk->head = $this->getHelmet();
|
||||
$pk->chest = $this->getChestplate();
|
||||
$pk->legs = $this->getLeggings();
|
||||
$pk->feet = $this->getBoots();
|
||||
$pk->head = ItemStackWrapper::legacy($this->getHelmet());
|
||||
$pk->chest = ItemStackWrapper::legacy($this->getChestplate());
|
||||
$pk->legs = ItemStackWrapper::legacy($this->getLeggings());
|
||||
$pk->feet = ItemStackWrapper::legacy($this->getBoots());
|
||||
$pk->encode();
|
||||
|
||||
foreach($target as $player){
|
||||
|
@ -53,4 +53,13 @@ class PlayerCursorInventory extends BaseInventory{
|
||||
public function getHolder(){
|
||||
return $this->holder;
|
||||
}
|
||||
|
||||
public function sendContents($target) : void{
|
||||
//TODO: HACK!
|
||||
//Since 1.13, this is now part of a larger "UI inventory", and sending contents for this larger inventory does
|
||||
//not work the way it's intended to. Even if it did, it would be necessary to send all 51 slots just to update
|
||||
//this one, which is just not worth it.
|
||||
//This workaround isn't great, but it's at least simple.
|
||||
$this->sendSlot(0, $target);
|
||||
}
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ use pocketmine\network\mcpe\protocol\CreativeContentPacket;
|
||||
use pocketmine\network\mcpe\protocol\MobEquipmentPacket;
|
||||
use pocketmine\network\mcpe\protocol\types\ContainerIds;
|
||||
use pocketmine\network\mcpe\protocol\types\inventory\CreativeContentEntry;
|
||||
use pocketmine\network\mcpe\protocol\types\inventory\ItemStackWrapper;
|
||||
use pocketmine\Player;
|
||||
use function array_map;
|
||||
use function in_array;
|
||||
@ -165,7 +166,7 @@ class PlayerInventory extends BaseInventory{
|
||||
|
||||
$pk = new MobEquipmentPacket();
|
||||
$pk->entityRuntimeId = $this->getHolder()->getId();
|
||||
$pk->item = $item;
|
||||
$pk->item = ItemStackWrapper::legacy($item);
|
||||
$pk->inventorySlot = $pk->hotbarSlot = $this->getHeldItemIndex();
|
||||
$pk->windowId = ContainerIds::INVENTORY;
|
||||
|
||||
|
@ -339,7 +339,11 @@ class Item implements ItemIds, \JsonSerializable{
|
||||
}
|
||||
}
|
||||
|
||||
$this->setNamedTagEntry($ench);
|
||||
if($ench->getCount() > 0){
|
||||
$this->setNamedTagEntry($ench);
|
||||
}else{
|
||||
$this->removeNamedTagEntry(self::TAG_ENCH);
|
||||
}
|
||||
}
|
||||
|
||||
public function removeEnchantments() : void{
|
||||
|
@ -370,7 +370,7 @@ class Level implements ChunkManager, Metadatable{
|
||||
*/
|
||||
public function __construct(Server $server, string $name, LevelProvider $provider){
|
||||
$this->blockStates = BlockFactory::getBlockStatesArray();
|
||||
$this->levelId = static::$levelIdCounter++;
|
||||
$this->levelId = self::$levelIdCounter++;
|
||||
$this->blockMetadata = new BlockMetadataStore($this);
|
||||
$this->server = $server;
|
||||
$this->autoSave = $server->getAutoSave();
|
||||
|
@ -28,6 +28,7 @@ namespace pocketmine\level\format;
|
||||
|
||||
use pocketmine\block\BlockFactory;
|
||||
use pocketmine\entity\Entity;
|
||||
use pocketmine\level\biome\Biome;
|
||||
use pocketmine\level\Level;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\nbt\tag\IntTag;
|
||||
@ -35,13 +36,20 @@ use pocketmine\nbt\tag\StringTag;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\tile\Spawnable;
|
||||
use pocketmine\tile\Tile;
|
||||
use pocketmine\utils\AssumptionFailedError;
|
||||
use pocketmine\utils\Binary;
|
||||
use pocketmine\utils\BinaryStream;
|
||||
use pocketmine\world\format\PalettedBlockArray;
|
||||
use function array_fill;
|
||||
use function array_filter;
|
||||
use function array_flip;
|
||||
use function array_values;
|
||||
use function assert;
|
||||
use function chr;
|
||||
use function count;
|
||||
use function file_get_contents;
|
||||
use function is_array;
|
||||
use function json_decode;
|
||||
use function ord;
|
||||
use function pack;
|
||||
use function str_repeat;
|
||||
@ -838,15 +846,37 @@ class Chunk{
|
||||
/**
|
||||
* Serializes the chunk for sending to players
|
||||
*/
|
||||
public function networkSerialize() : string{
|
||||
public function networkSerialize(?string $networkSerializedTiles) : string{
|
||||
$result = "";
|
||||
$subChunkCount = $this->getSubChunkSendCount();
|
||||
|
||||
//TODO: HACK! fill in fake subchunks to make up for the new negative space client-side
|
||||
for($y = 0; $y < 4; ++$y){
|
||||
$result .= chr(8); //subchunk version 8
|
||||
$result .= chr(0); //0 layers - client will treat this as all-air
|
||||
}
|
||||
for($y = 0; $y < $subChunkCount; ++$y){
|
||||
$result .= $this->subChunks[$y]->networkSerialize();
|
||||
}
|
||||
$result .= $this->biomeIds . chr(0); //border block array count
|
||||
|
||||
//TODO: right now we don't support 3D natively, so we just 3Dify our 2D biomes so they fill the column
|
||||
$encodedBiomePalette = $this->networkSerializeBiomesAsPalette();
|
||||
$result .= str_repeat($encodedBiomePalette, 25);
|
||||
|
||||
$result .= chr(0); //border block array count
|
||||
//Border block entry format: 1 byte (4 bits X, 4 bits Z). These are however useless since they crash the regular client.
|
||||
|
||||
$result .= $networkSerializedTiles ?? $this->networkSerializeTiles();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes all tiles in network format for chunk sending. This is necessary because fastSerialize() doesn't
|
||||
* include tiles; they have to be encoded on the main thread.
|
||||
*/
|
||||
public function networkSerializeTiles() : string{
|
||||
$result = "";
|
||||
foreach($this->tiles as $tile){
|
||||
if($tile instanceof Spawnable){
|
||||
$result .= $tile->getSerializedSpawnCompound();
|
||||
@ -856,6 +886,49 @@ class Chunk{
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function networkSerializeBiomesAsPalette() : string{
|
||||
/** @var string[]|null $biomeIdMap */
|
||||
static $biomeIdMap = null;
|
||||
if($biomeIdMap === null){
|
||||
$biomeIdMapRaw = file_get_contents(\pocketmine\RESOURCE_PATH . '/vanilla/biome_id_map.json');
|
||||
if($biomeIdMapRaw === false) throw new AssumptionFailedError();
|
||||
$biomeIdMapDecoded = json_decode($biomeIdMapRaw, true);
|
||||
if(!is_array($biomeIdMapDecoded)) throw new AssumptionFailedError();
|
||||
$biomeIdMap = array_flip($biomeIdMapDecoded);
|
||||
}
|
||||
$biomePalette = new PalettedBlockArray($this->getBiomeId(0, 0));
|
||||
for($x = 0; $x < 16; ++$x){
|
||||
for($z = 0; $z < 16; ++$z){
|
||||
$biomeId = $this->getBiomeId($x, $z);
|
||||
if(!isset($biomeIdMap[$biomeId])){
|
||||
//make sure we aren't sending bogus biomes - the 1.18.0 client crashes if we do this
|
||||
$biomeId = Biome::OCEAN;
|
||||
}
|
||||
for($y = 0; $y < 16; ++$y){
|
||||
$biomePalette->set($x, $y, $z, $biomeId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$biomePaletteBitsPerBlock = $biomePalette->getBitsPerBlock();
|
||||
$encodedBiomePalette =
|
||||
chr(($biomePaletteBitsPerBlock << 1) | 1) . //the last bit is non-persistence (like for blocks), though it has no effect on biomes since they always use integer IDs
|
||||
$biomePalette->getWordArray();
|
||||
|
||||
//these LSHIFT by 1 uvarints are optimizations: the client expects zigzag varints here
|
||||
//but since we know they are always unsigned, we can avoid the extra fcall overhead of
|
||||
//zigzag and just shift directly.
|
||||
$biomePaletteArray = $biomePalette->getPalette();
|
||||
if($biomePaletteBitsPerBlock !== 0){
|
||||
$encodedBiomePalette .= Binary::writeUnsignedVarInt(count($biomePaletteArray) << 1);
|
||||
}
|
||||
foreach($biomePaletteArray as $p){
|
||||
$encodedBiomePalette .= Binary::writeUnsignedVarInt($p << 1);
|
||||
}
|
||||
|
||||
return $encodedBiomePalette;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fast-serializes the chunk for passing between threads
|
||||
* TODO: tiles and entities
|
||||
|
@ -39,6 +39,7 @@ class ChunkRequestTask extends AsyncTask{
|
||||
|
||||
/** @var string */
|
||||
protected $chunk;
|
||||
private string $tiles;
|
||||
/** @var int */
|
||||
protected $chunkX;
|
||||
/** @var int */
|
||||
@ -47,21 +48,20 @@ class ChunkRequestTask extends AsyncTask{
|
||||
/** @var int */
|
||||
protected $compressionLevel;
|
||||
|
||||
/** @var int */
|
||||
private $subChunkCount;
|
||||
|
||||
public function __construct(Level $level, int $chunkX, int $chunkZ, Chunk $chunk){
|
||||
$this->levelId = $level->getId();
|
||||
$this->compressionLevel = $level->getServer()->networkCompressionLevel;
|
||||
|
||||
$this->chunk = $chunk->networkSerialize();
|
||||
$this->chunk = $chunk->fastSerialize();
|
||||
$this->tiles = $chunk->networkSerializeTiles();
|
||||
|
||||
$this->chunkX = $chunkX;
|
||||
$this->chunkZ = $chunkZ;
|
||||
$this->subChunkCount = $chunk->getSubChunkSendCount();
|
||||
}
|
||||
|
||||
public function onRun(){
|
||||
$pk = LevelChunkPacket::withoutCache($this->chunkX, $this->chunkZ, $this->subChunkCount, $this->chunk);
|
||||
$chunk = Chunk::fastDeserialize($this->chunk);
|
||||
$pk = LevelChunkPacket::withoutCache($this->chunkX, $this->chunkZ, $chunk->getSubChunkSendCount() + 4, $chunk->networkSerialize($this->tiles));
|
||||
|
||||
$batch = new BatchPacket();
|
||||
$batch->addPacket($pk);
|
||||
|
@ -81,7 +81,7 @@ if(!extension_loaded('pocketmine_chunkutils')){
|
||||
}else{
|
||||
$i1 = ord($array[$j]);
|
||||
$i2 = ord($array[$j80]);
|
||||
$result[$i] = chr(($i2 << 4) | ($i1 & 0x0f));
|
||||
$result[$i] = chr(($i2 << 4) | ($i1 & 0x0f));
|
||||
$result[$i | 0x80] = chr(($i1 >> 4) | ($i2 & 0xf0));
|
||||
}
|
||||
$i++;
|
||||
|
@ -545,10 +545,6 @@ class LevelDB extends BaseLevelProvider{
|
||||
return Binary::writeLInt($chunkX) . Binary::writeLInt($chunkZ);
|
||||
}
|
||||
|
||||
private function chunkExists(int $chunkX, int $chunkZ) : bool{
|
||||
return $this->db->get(LevelDB::chunkIndex($chunkX, $chunkZ) . self::TAG_VERSION) !== false;
|
||||
}
|
||||
|
||||
public function close(){
|
||||
unset($this->db);
|
||||
}
|
||||
|
@ -135,6 +135,7 @@ class Anvil extends McRegion{
|
||||
$result->setLightPopulated($chunk->getByte("LightPopulated", 0) !== 0);
|
||||
$result->setPopulated($chunk->getByte("TerrainPopulated", 0) !== 0);
|
||||
$result->setGenerated();
|
||||
$result->setChanged(false);
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
@ -201,6 +201,7 @@ class McRegion extends BaseLevelProvider{
|
||||
$result->setLightPopulated($chunk->getByte("LightPopulated", 0) !== 0);
|
||||
$result->setPopulated($chunk->getByte("TerrainPopulated", 0) !== 0);
|
||||
$result->setGenerated(true);
|
||||
$result->setChanged(false);
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
@ -144,16 +144,9 @@ class Normal extends Generator{
|
||||
return Biome::BIRCH_FOREST;
|
||||
}
|
||||
}else{
|
||||
//FIXME: This will always cause River to be used since the rainfall is always greater than 0.8 if we
|
||||
//reached this branch. However I don't think that substituting temperature for rainfall is correct given
|
||||
//that mountain biomes are supposed to be pretty cold.
|
||||
if($rainfall < 0.25){
|
||||
return Biome::MOUNTAINS;
|
||||
}elseif($rainfall < 0.70){
|
||||
return Biome::SMALL_MOUNTAINS;
|
||||
}else{
|
||||
return Biome::RIVER;
|
||||
}
|
||||
//Previously here, we had a (broken) condition to generate mountains, but fixing it would have
|
||||
//caused generation changes on a patch release, so we can't keep it here for now.
|
||||
return Biome::RIVER;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -31,6 +31,7 @@ use pocketmine\math\Vector3;
|
||||
use pocketmine\network\mcpe\protocol\AddPlayerPacket;
|
||||
use pocketmine\network\mcpe\protocol\PlayerListPacket;
|
||||
use pocketmine\network\mcpe\protocol\RemoveActorPacket;
|
||||
use pocketmine\network\mcpe\protocol\types\inventory\ItemStackWrapper;
|
||||
use pocketmine\network\mcpe\protocol\types\PlayerListEntry;
|
||||
use pocketmine\network\mcpe\protocol\types\SkinAdapterSingleton;
|
||||
use pocketmine\utils\UUID;
|
||||
@ -104,7 +105,7 @@ class FloatingTextParticle extends Particle{
|
||||
$pk->username = $name;
|
||||
$pk->entityRuntimeId = $this->entityId;
|
||||
$pk->position = $this->asVector3(); //TODO: check offset
|
||||
$pk->item = ItemFactory::get(Item::AIR, 0, 0);
|
||||
$pk->item = ItemStackWrapper::legacy(ItemFactory::get(Item::AIR, 0, 0));
|
||||
|
||||
$flags = (
|
||||
1 << Entity::DATA_FLAG_IMMOBILE
|
||||
|
@ -36,65 +36,79 @@ abstract class Particle extends Vector3{
|
||||
public const TYPE_EXPLODE = 6;
|
||||
public const TYPE_EVAPORATION = 7;
|
||||
public const TYPE_FLAME = 8;
|
||||
public const TYPE_LAVA = 9;
|
||||
public const TYPE_LARGE_SMOKE = 10;
|
||||
public const TYPE_REDSTONE = 11;
|
||||
public const TYPE_RISING_RED_DUST = 12;
|
||||
public const TYPE_ITEM_BREAK = 13;
|
||||
public const TYPE_SNOWBALL_POOF = 14;
|
||||
public const TYPE_HUGE_EXPLODE = 15;
|
||||
public const TYPE_HUGE_EXPLODE_SEED = 16;
|
||||
public const TYPE_MOB_FLAME = 17;
|
||||
public const TYPE_HEART = 18;
|
||||
public const TYPE_TERRAIN = 19;
|
||||
public const TYPE_SUSPENDED_TOWN = 20, TYPE_TOWN_AURA = 20;
|
||||
public const TYPE_PORTAL = 21;
|
||||
//22 same as 21
|
||||
public const TYPE_SPLASH = 23, TYPE_WATER_SPLASH = 23;
|
||||
public const TYPE_WATER_SPLASH_MANUAL = 24;
|
||||
public const TYPE_WATER_WAKE = 25;
|
||||
public const TYPE_DRIP_WATER = 26;
|
||||
public const TYPE_DRIP_LAVA = 27;
|
||||
public const TYPE_DRIP_HONEY = 28;
|
||||
public const TYPE_FALLING_DUST = 29, TYPE_DUST = 29;
|
||||
public const TYPE_MOB_SPELL = 30;
|
||||
public const TYPE_MOB_SPELL_AMBIENT = 31;
|
||||
public const TYPE_MOB_SPELL_INSTANTANEOUS = 32;
|
||||
public const TYPE_INK = 33;
|
||||
public const TYPE_SLIME = 34;
|
||||
public const TYPE_RAIN_SPLASH = 35;
|
||||
public const TYPE_VILLAGER_ANGRY = 36;
|
||||
public const TYPE_VILLAGER_HAPPY = 37;
|
||||
public const TYPE_ENCHANTMENT_TABLE = 38;
|
||||
public const TYPE_TRACKING_EMITTER = 39;
|
||||
public const TYPE_NOTE = 40;
|
||||
public const TYPE_WITCH_SPELL = 41;
|
||||
public const TYPE_CARROT = 42;
|
||||
public const TYPE_MOB_APPEARANCE = 43;
|
||||
public const TYPE_END_ROD = 44;
|
||||
public const TYPE_DRAGONS_BREATH = 45;
|
||||
public const TYPE_SPIT = 46;
|
||||
public const TYPE_TOTEM = 47;
|
||||
public const TYPE_FOOD = 48;
|
||||
public const TYPE_FIREWORKS_STARTER = 49;
|
||||
public const TYPE_FIREWORKS_SPARK = 50;
|
||||
public const TYPE_FIREWORKS_OVERLAY = 51;
|
||||
public const TYPE_BALLOON_GAS = 52;
|
||||
public const TYPE_COLORED_FLAME = 53;
|
||||
public const TYPE_SPARKLER = 54;
|
||||
public const TYPE_CONDUIT = 55;
|
||||
public const TYPE_BUBBLE_COLUMN_UP = 56;
|
||||
public const TYPE_BUBBLE_COLUMN_DOWN = 57;
|
||||
public const TYPE_SNEEZE = 58;
|
||||
public const TYPE_SHULKER_BULLET = 59;
|
||||
public const TYPE_BLEACH = 60;
|
||||
public const TYPE_DRAGON_DESTROY_BLOCK = 61;
|
||||
public const TYPE_MYCELIUM_DUST = 62;
|
||||
public const TYPE_FALLING_RED_DUST = 63;
|
||||
public const TYPE_CAMPFIRE_SMOKE = 64;
|
||||
public const TYPE_TALL_CAMPFIRE_SMOKE = 65;
|
||||
public const TYPE_DRAGON_BREATH_FIRE = 66;
|
||||
public const TYPE_DRAGON_BREATH_TRAIL = 67;
|
||||
public const TYPE_CANDLE_FLAME = 9;
|
||||
public const TYPE_LAVA = 10;
|
||||
public const TYPE_LARGE_SMOKE = 11;
|
||||
public const TYPE_REDSTONE = 12;
|
||||
public const TYPE_RISING_RED_DUST = 13;
|
||||
public const TYPE_ITEM_BREAK = 14;
|
||||
public const TYPE_SNOWBALL_POOF = 15;
|
||||
public const TYPE_HUGE_EXPLODE = 16;
|
||||
public const TYPE_HUGE_EXPLODE_SEED = 17;
|
||||
public const TYPE_MOB_FLAME = 18;
|
||||
public const TYPE_HEART = 19;
|
||||
public const TYPE_TERRAIN = 20;
|
||||
public const TYPE_SUSPENDED_TOWN = 21, TYPE_TOWN_AURA = 21;
|
||||
public const TYPE_PORTAL = 22;
|
||||
//23 same as 22
|
||||
public const TYPE_SPLASH = 24, TYPE_WATER_SPLASH = 24;
|
||||
public const TYPE_WATER_SPLASH_MANUAL = 25;
|
||||
public const TYPE_WATER_WAKE = 26;
|
||||
public const TYPE_DRIP_WATER = 27;
|
||||
public const TYPE_DRIP_LAVA = 28;
|
||||
public const TYPE_DRIP_HONEY = 29;
|
||||
public const TYPE_STALACTITE_DRIP_WATER = 30;
|
||||
public const TYPE_STALACTITE_DRIP_LAVA = 31;
|
||||
public const TYPE_FALLING_DUST = 32, TYPE_DUST = 32;
|
||||
public const TYPE_MOB_SPELL = 33;
|
||||
public const TYPE_MOB_SPELL_AMBIENT = 34;
|
||||
public const TYPE_MOB_SPELL_INSTANTANEOUS = 35;
|
||||
public const TYPE_INK = 36;
|
||||
public const TYPE_SLIME = 37;
|
||||
public const TYPE_RAIN_SPLASH = 38;
|
||||
public const TYPE_VILLAGER_ANGRY = 39;
|
||||
public const TYPE_VILLAGER_HAPPY = 40;
|
||||
public const TYPE_ENCHANTMENT_TABLE = 41;
|
||||
public const TYPE_TRACKING_EMITTER = 42;
|
||||
public const TYPE_NOTE = 43;
|
||||
public const TYPE_WITCH_SPELL = 44;
|
||||
public const TYPE_CARROT = 45;
|
||||
public const TYPE_MOB_APPEARANCE = 46;
|
||||
public const TYPE_END_ROD = 47;
|
||||
public const TYPE_DRAGONS_BREATH = 48;
|
||||
public const TYPE_SPIT = 49;
|
||||
public const TYPE_TOTEM = 50;
|
||||
public const TYPE_FOOD = 51;
|
||||
public const TYPE_FIREWORKS_STARTER = 52;
|
||||
public const TYPE_FIREWORKS_SPARK = 53;
|
||||
public const TYPE_FIREWORKS_OVERLAY = 54;
|
||||
public const TYPE_BALLOON_GAS = 55;
|
||||
public const TYPE_COLORED_FLAME = 56;
|
||||
public const TYPE_SPARKLER = 57;
|
||||
public const TYPE_CONDUIT = 58;
|
||||
public const TYPE_BUBBLE_COLUMN_UP = 59;
|
||||
public const TYPE_BUBBLE_COLUMN_DOWN = 60;
|
||||
public const TYPE_SNEEZE = 61;
|
||||
public const TYPE_SHULKER_BULLET = 62;
|
||||
public const TYPE_BLEACH = 63;
|
||||
public const TYPE_DRAGON_DESTROY_BLOCK = 64;
|
||||
public const TYPE_MYCELIUM_DUST = 65;
|
||||
public const TYPE_FALLING_RED_DUST = 66;
|
||||
public const TYPE_CAMPFIRE_SMOKE = 67;
|
||||
public const TYPE_TALL_CAMPFIRE_SMOKE = 68;
|
||||
public const TYPE_DRAGON_BREATH_FIRE = 69;
|
||||
public const TYPE_DRAGON_BREATH_TRAIL = 70;
|
||||
public const TYPE_BLUE_FLAME = 71;
|
||||
public const TYPE_SOUL = 72;
|
||||
public const TYPE_OBSIDIAN_TEAR = 73;
|
||||
public const TYPE_PORTAL_REVERSE = 74;
|
||||
public const TYPE_SNOWFLAKE = 75;
|
||||
public const TYPE_VIBRATION_SIGNAL = 76;
|
||||
public const TYPE_SCULK_SENSOR_REDSTONE = 77;
|
||||
public const TYPE_SPORE_BLOSSOM_SHOWER = 78;
|
||||
public const TYPE_SPORE_BLOSSOM_AMBIENT = 79;
|
||||
public const TYPE_WAX = 80;
|
||||
public const TYPE_ELECTRIC_SPARK = 81;
|
||||
|
||||
/**
|
||||
* @return DataPacket|DataPacket[]
|
||||
|
@ -25,6 +25,7 @@ namespace pocketmine\network\mcpe;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\block\BlockIds;
|
||||
use pocketmine\entity\Attribute;
|
||||
use pocketmine\entity\Entity;
|
||||
use pocketmine\item\Durable;
|
||||
@ -32,12 +33,14 @@ use pocketmine\item\Item;
|
||||
use pocketmine\item\ItemFactory;
|
||||
use pocketmine\item\ItemIds;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\nbt\LittleEndianNBTStream;
|
||||
use pocketmine\nbt\NetworkLittleEndianNBTStream;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\nbt\tag\IntTag;
|
||||
use pocketmine\nbt\tag\NamedTag;
|
||||
use pocketmine\network\mcpe\convert\ItemTranslator;
|
||||
use pocketmine\network\mcpe\convert\ItemTypeDictionary;
|
||||
use pocketmine\network\mcpe\convert\RuntimeBlockMapping;
|
||||
use pocketmine\network\mcpe\protocol\types\CommandOriginData;
|
||||
use pocketmine\network\mcpe\protocol\types\EntityLink;
|
||||
use pocketmine\network\mcpe\protocol\types\GameRuleType;
|
||||
@ -58,6 +61,7 @@ class NetworkBinaryStream extends BinaryStream{
|
||||
|
||||
private const DAMAGE_TAG = "Damage"; //TAG_Int
|
||||
private const DAMAGE_TAG_CONFLICT_RESOLUTION = "___Damage_ProtocolCollisionResolution___";
|
||||
private const PM_META_TAG = "___Meta___";
|
||||
|
||||
public function getString() : string{
|
||||
return $this->get($this->getUnsignedVarInt());
|
||||
@ -87,6 +91,7 @@ class NetworkBinaryStream extends BinaryStream{
|
||||
|
||||
public function getSkin() : SkinData{
|
||||
$skinId = $this->getString();
|
||||
$skinPlayFabId = $this->getString();
|
||||
$skinResourcePatch = $this->getString();
|
||||
$skinData = $this->getSkinImage();
|
||||
$animationCount = $this->getLInt();
|
||||
@ -100,10 +105,8 @@ class NetworkBinaryStream extends BinaryStream{
|
||||
}
|
||||
$capeData = $this->getSkinImage();
|
||||
$geometryData = $this->getString();
|
||||
$geometryDataVersion = $this->getString();
|
||||
$animationData = $this->getString();
|
||||
$premium = $this->getBool();
|
||||
$persona = $this->getBool();
|
||||
$capeOnClassic = $this->getBool();
|
||||
$capeId = $this->getString();
|
||||
$fullSkinId = $this->getString();
|
||||
$armSize = $this->getString();
|
||||
@ -132,8 +135,12 @@ class NetworkBinaryStream extends BinaryStream{
|
||||
$colors
|
||||
);
|
||||
}
|
||||
$premium = $this->getBool();
|
||||
$persona = $this->getBool();
|
||||
$capeOnClassic = $this->getBool();
|
||||
$isPrimaryUser = $this->getBool();
|
||||
|
||||
return new SkinData($skinId, $skinResourcePatch, $skinData, $animations, $capeData, $geometryData, $animationData, $premium, $persona, $capeOnClassic, $capeId, $fullSkinId, $armSize, $skinColor, $personaPieces, $pieceTintColors);
|
||||
return new SkinData($skinId, $skinPlayFabId, $skinResourcePatch, $skinData, $animations, $capeData, $geometryData, $geometryDataVersion, $animationData, $capeId, $fullSkinId, $armSize, $skinColor, $personaPieces, $pieceTintColors, true, $premium, $persona, $capeOnClassic, $isPrimaryUser);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -141,6 +148,7 @@ class NetworkBinaryStream extends BinaryStream{
|
||||
*/
|
||||
public function putSkin(SkinData $skin){
|
||||
$this->putString($skin->getSkinId());
|
||||
$this->putString($skin->getPlayFabId());
|
||||
$this->putString($skin->getResourcePatch());
|
||||
$this->putSkinImage($skin->getSkinImage());
|
||||
$this->putLInt(count($skin->getAnimations()));
|
||||
@ -152,10 +160,8 @@ class NetworkBinaryStream extends BinaryStream{
|
||||
}
|
||||
$this->putSkinImage($skin->getCapeImage());
|
||||
$this->putString($skin->getGeometryData());
|
||||
$this->putString($skin->getGeometryDataEngineVersion());
|
||||
$this->putString($skin->getAnimationData());
|
||||
$this->putBool($skin->isPremium());
|
||||
$this->putBool($skin->isPersona());
|
||||
$this->putBool($skin->isPersonaCapeOnClassic());
|
||||
$this->putString($skin->getCapeId());
|
||||
$this->putString($skin->getFullSkinId());
|
||||
$this->putString($skin->getArmSize());
|
||||
@ -176,6 +182,10 @@ class NetworkBinaryStream extends BinaryStream{
|
||||
$this->putString($color);
|
||||
}
|
||||
}
|
||||
$this->putBool($skin->isPremium());
|
||||
$this->putBool($skin->isPersona());
|
||||
$this->putBool($skin->isPersonaCapeOnClassic());
|
||||
$this->putBool($skin->isPrimaryUser());
|
||||
}
|
||||
|
||||
private function getSkinImage() : SkinImage{
|
||||
@ -191,83 +201,134 @@ class NetworkBinaryStream extends BinaryStream{
|
||||
$this->putString($image->getData());
|
||||
}
|
||||
|
||||
public function getSlot() : Item{
|
||||
public function getItemStackWithoutStackId() : Item{
|
||||
return $this->getItemStack(function() : void{
|
||||
//NOOP
|
||||
});
|
||||
}
|
||||
|
||||
public function putItemStackWithoutStackId(Item $item) : void{
|
||||
$this->putItemStack($item, function() : void{
|
||||
//NOOP
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @phpstan-param \Closure(NetworkBinaryStream) : void $readExtraCrapInTheMiddle
|
||||
*/
|
||||
public function getItemStack(\Closure $readExtraCrapInTheMiddle) : Item{
|
||||
$netId = $this->getVarInt();
|
||||
if($netId === 0){
|
||||
return ItemFactory::get(0, 0, 0);
|
||||
}
|
||||
|
||||
$auxValue = $this->getVarInt();
|
||||
$netData = $auxValue >> 8;
|
||||
$cnt = $auxValue & 0xff;
|
||||
$cnt = $this->getLShort();
|
||||
$netData = $this->getUnsignedVarInt();
|
||||
|
||||
[$id, $meta] = ItemTranslator::getInstance()->fromNetworkId($netId, $netData);
|
||||
|
||||
$nbtLen = $this->getLShort();
|
||||
$readExtraCrapInTheMiddle($this);
|
||||
|
||||
/** @var CompoundTag|null $nbt */
|
||||
$nbt = null;
|
||||
if($nbtLen === 0xffff){
|
||||
$nbtDataVersion = $this->getByte();
|
||||
if($nbtDataVersion !== 1){
|
||||
throw new \UnexpectedValueException("Unexpected NBT data version $nbtDataVersion");
|
||||
$this->getVarInt();
|
||||
|
||||
$extraData = new NetworkBinaryStream($this->getString());
|
||||
return (static function() use ($extraData, $netId, $id, $meta, $cnt) : Item{
|
||||
$nbtLen = $extraData->getLShort();
|
||||
|
||||
/** @var CompoundTag|null $nbt */
|
||||
$nbt = null;
|
||||
if($nbtLen === 0xffff){
|
||||
$nbtDataVersion = $extraData->getByte();
|
||||
if($nbtDataVersion !== 1){
|
||||
throw new \UnexpectedValueException("Unexpected NBT data version $nbtDataVersion");
|
||||
}
|
||||
$decodedNBT = (new LittleEndianNBTStream())->read($extraData->buffer, false, $extraData->offset, 512);
|
||||
if(!($decodedNBT instanceof CompoundTag)){
|
||||
throw new \UnexpectedValueException("Unexpected root tag type for itemstack");
|
||||
}
|
||||
$nbt = $decodedNBT;
|
||||
}elseif($nbtLen !== 0){
|
||||
throw new \UnexpectedValueException("Unexpected fake NBT length $nbtLen");
|
||||
}
|
||||
$decodedNBT = (new NetworkLittleEndianNBTStream())->read($this->buffer, false, $this->offset, 512);
|
||||
if(!($decodedNBT instanceof CompoundTag)){
|
||||
throw new \UnexpectedValueException("Unexpected root tag type for itemstack");
|
||||
|
||||
//TODO
|
||||
for($i = 0, $canPlaceOn = $extraData->getLInt(); $i < $canPlaceOn; ++$i){
|
||||
$extraData->get($extraData->getLShort());
|
||||
}
|
||||
$nbt = $decodedNBT;
|
||||
}elseif($nbtLen !== 0){
|
||||
throw new \UnexpectedValueException("Unexpected fake NBT length $nbtLen");
|
||||
}
|
||||
|
||||
//TODO
|
||||
for($i = 0, $canPlaceOn = $this->getVarInt(); $i < $canPlaceOn; ++$i){
|
||||
$this->getString();
|
||||
}
|
||||
//TODO
|
||||
for($i = 0, $canDestroy = $extraData->getLInt(); $i < $canDestroy; ++$i){
|
||||
$extraData->get($extraData->getLShort());
|
||||
}
|
||||
|
||||
//TODO
|
||||
for($i = 0, $canDestroy = $this->getVarInt(); $i < $canDestroy; ++$i){
|
||||
$this->getString();
|
||||
}
|
||||
if($netId === ItemTypeDictionary::getInstance()->fromStringId("minecraft:shield")){
|
||||
$extraData->getLLong(); //"blocking tick" (ffs mojang)
|
||||
}
|
||||
|
||||
if($netId === ItemTypeDictionary::getInstance()->fromStringId("minecraft:shield")){
|
||||
$this->getVarLong(); //"blocking tick" (ffs mojang)
|
||||
}
|
||||
if($nbt !== null){
|
||||
if($nbt->hasTag(self::DAMAGE_TAG, IntTag::class)){
|
||||
$meta = $nbt->getInt(self::DAMAGE_TAG);
|
||||
$nbt->removeTag(self::DAMAGE_TAG);
|
||||
if(($conflicted = $nbt->getTag(self::DAMAGE_TAG_CONFLICT_RESOLUTION)) !== null){
|
||||
$nbt->removeTag(self::DAMAGE_TAG_CONFLICT_RESOLUTION);
|
||||
$conflicted->setName(self::DAMAGE_TAG);
|
||||
$nbt->setTag($conflicted);
|
||||
}elseif($nbt->count() === 0){
|
||||
$nbt = null;
|
||||
if(!$extraData->feof()){
|
||||
throw new \UnexpectedValueException("Unexpected trailing extradata for network item $netId");
|
||||
}
|
||||
|
||||
if($nbt !== null){
|
||||
if($nbt->hasTag(self::DAMAGE_TAG, IntTag::class)){
|
||||
$meta = $nbt->getInt(self::DAMAGE_TAG);
|
||||
$nbt->removeTag(self::DAMAGE_TAG);
|
||||
if(($conflicted = $nbt->getTag(self::DAMAGE_TAG_CONFLICT_RESOLUTION)) !== null){
|
||||
$nbt->removeTag(self::DAMAGE_TAG_CONFLICT_RESOLUTION);
|
||||
$conflicted->setName(self::DAMAGE_TAG);
|
||||
$nbt->setTag($conflicted);
|
||||
}elseif($nbt->count() === 0){
|
||||
$nbt = null;
|
||||
}
|
||||
}elseif(($metaTag = $nbt->getTag(self::PM_META_TAG)) instanceof IntTag){
|
||||
//TODO HACK: This foul-smelling code ensures that we can correctly deserialize an item when the
|
||||
//client sends it back to us, because as of 1.16.220, blockitems quietly discard their metadata
|
||||
//client-side. Aside from being very annoying, this also breaks various server-side behaviours.
|
||||
$meta = $metaTag->getValue();
|
||||
$nbt->removeTag(self::PM_META_TAG);
|
||||
if($nbt->count() === 0){
|
||||
$nbt = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ItemFactory::get($id, $meta, $cnt, $nbt);
|
||||
return ItemFactory::get($id, $meta, $cnt, $nbt);
|
||||
})();
|
||||
}
|
||||
|
||||
public function putSlot(Item $item) : void{
|
||||
/**
|
||||
* @phpstan-param \Closure(NetworkBinaryStream) : void $writeExtraCrapInTheMiddle
|
||||
*/
|
||||
public function putItemStack(Item $item, \Closure $writeExtraCrapInTheMiddle) : void{
|
||||
if($item->getId() === 0){
|
||||
$this->putVarInt(0);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
[$netId, $netData] = ItemTranslator::getInstance()->toNetworkId($item->getId(), $item->getDamage());
|
||||
$coreData = $item->getDamage();
|
||||
[$netId, $netData] = ItemTranslator::getInstance()->toNetworkId($item->getId(), $coreData);
|
||||
|
||||
$this->putVarInt($netId);
|
||||
$auxValue = (($netData & 0x7fff) << 8) | $item->getCount();
|
||||
$this->putVarInt($auxValue);
|
||||
$this->putLShort($item->getCount());
|
||||
$this->putUnsignedVarInt($netData);
|
||||
|
||||
$writeExtraCrapInTheMiddle($this);
|
||||
|
||||
$blockRuntimeId = 0;
|
||||
$isBlockItem = $item->getId() < 256;
|
||||
if($isBlockItem){
|
||||
$block = $item->getBlock();
|
||||
if($block->getId() !== BlockIds::AIR){
|
||||
$blockRuntimeId = RuntimeBlockMapping::toStaticRuntimeId($block->getId(), $block->getDamage());
|
||||
}
|
||||
}
|
||||
$this->putVarInt($blockRuntimeId);
|
||||
|
||||
$nbt = null;
|
||||
if($item->hasCompoundTag()){
|
||||
$nbt = clone $item->getNamedTag();
|
||||
}
|
||||
if($item instanceof Durable and $item->getDamage() > 0){
|
||||
if($item instanceof Durable and $coreData > 0){
|
||||
if($nbt !== null){
|
||||
if(($existing = $nbt->getTag(self::DAMAGE_TAG)) !== null){
|
||||
$nbt->removeTag(self::DAMAGE_TAG);
|
||||
@ -277,23 +338,37 @@ class NetworkBinaryStream extends BinaryStream{
|
||||
}else{
|
||||
$nbt = new CompoundTag();
|
||||
}
|
||||
$nbt->setInt(self::DAMAGE_TAG, $item->getDamage());
|
||||
$nbt->setInt(self::DAMAGE_TAG, $coreData);
|
||||
}elseif($isBlockItem && $coreData !== 0){
|
||||
//TODO HACK: This foul-smelling code ensures that we can correctly deserialize an item when the
|
||||
//client sends it back to us, because as of 1.16.220, blockitems quietly discard their metadata
|
||||
//client-side. Aside from being very annoying, this also breaks various server-side behaviours.
|
||||
if($nbt === null){
|
||||
$nbt = new CompoundTag();
|
||||
}
|
||||
$nbt->setInt(self::PM_META_TAG, $coreData);
|
||||
}
|
||||
|
||||
if($nbt !== null){
|
||||
$this->putLShort(0xffff);
|
||||
$this->putByte(1); //TODO: NBT data version (?)
|
||||
$this->put((new NetworkLittleEndianNBTStream())->write($nbt));
|
||||
}else{
|
||||
$this->putLShort(0);
|
||||
}
|
||||
$this->putString(
|
||||
(static function() use ($nbt, $netId) : string{
|
||||
$extraData = new NetworkBinaryStream();
|
||||
|
||||
$this->putVarInt(0); //CanPlaceOn entry count (TODO)
|
||||
$this->putVarInt(0); //CanDestroy entry count (TODO)
|
||||
if($nbt !== null){
|
||||
$extraData->putLShort(0xffff);
|
||||
$extraData->putByte(1); //TODO: NBT data version (?)
|
||||
$extraData->put((new LittleEndianNBTStream())->write($nbt));
|
||||
}else{
|
||||
$extraData->putLShort(0);
|
||||
}
|
||||
|
||||
if($netId === ItemTypeDictionary::getInstance()->fromStringId("minecraft:shield")){
|
||||
$this->putVarLong(0); //"blocking tick" (ffs mojang)
|
||||
}
|
||||
$extraData->putLInt(0); //CanPlaceOn entry count (TODO)
|
||||
$extraData->putLInt(0); //CanDestroy entry count (TODO)
|
||||
|
||||
if($netId === ItemTypeDictionary::getInstance()->fromStringId("minecraft:shield")){
|
||||
$extraData->putLLong(0); //"blocking tick" (ffs mojang)
|
||||
}
|
||||
return $extraData->getBuffer();
|
||||
})());
|
||||
}
|
||||
|
||||
public function getRecipeIngredient() : Item{
|
||||
@ -600,14 +675,15 @@ class NetworkBinaryStream extends BinaryStream{
|
||||
* Reads gamerules
|
||||
* TODO: implement this properly
|
||||
*
|
||||
* @return mixed[][], members are in the structure [name => [type, value]]
|
||||
* @phpstan-return array<string, array{0: int, 1: bool|int|float}>
|
||||
* @return mixed[][], members are in the structure [name => [type, value, isPlayerModifiable]]
|
||||
* @phpstan-return array<string, array{0: int, 1: bool|int|float, 2: bool}>
|
||||
*/
|
||||
public function getGameRules() : array{
|
||||
$count = $this->getUnsignedVarInt();
|
||||
$rules = [];
|
||||
for($i = 0; $i < $count; ++$i){
|
||||
$name = $this->getString();
|
||||
$isPlayerModifiable = $this->getBool();
|
||||
$type = $this->getUnsignedVarInt();
|
||||
$value = null;
|
||||
switch($type){
|
||||
@ -622,23 +698,24 @@ class NetworkBinaryStream extends BinaryStream{
|
||||
break;
|
||||
}
|
||||
|
||||
$rules[$name] = [$type, $value];
|
||||
$rules[$name] = [$type, $value, $isPlayerModifiable];
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a gamerule array, members should be in the structure [name => [type, value]]
|
||||
* Writes a gamerule array, members should be in the structure [name => [type, value, isPlayerModifiable]]
|
||||
* TODO: implement this properly
|
||||
*
|
||||
* @param mixed[][] $rules
|
||||
* @phpstan-param array<string, array{0: int, 1: bool|int|float}> $rules
|
||||
* @phpstan-param array<string, array{0: int, 1: bool|int|float, 2: bool}> $rules
|
||||
*/
|
||||
public function putGameRules(array $rules) : void{
|
||||
$this->putUnsignedVarInt(count($rules));
|
||||
foreach($rules as $name => $rule){
|
||||
$this->putString($name);
|
||||
$this->putBool($rule[2]);
|
||||
$this->putUnsignedVarInt($rule[0]);
|
||||
switch($rule[0]){
|
||||
case GameRuleType::BOOL:
|
||||
@ -709,8 +786,10 @@ class NetworkBinaryStream extends BinaryStream{
|
||||
$result->lastTouchedByPlayerID = $this->getEntityUniqueId();
|
||||
$result->rotation = $this->getByte();
|
||||
$result->mirror = $this->getByte();
|
||||
$result->integrityValue = $this->getFloat();
|
||||
$result->integritySeed = $this->getInt();
|
||||
$result->animationMode = $this->getByte();
|
||||
$result->animationSeconds = $this->getLFloat();
|
||||
$result->integrityValue = $this->getLFloat();
|
||||
$result->integritySeed = $this->getLInt();
|
||||
$result->pivot = $this->getVector3();
|
||||
|
||||
return $result;
|
||||
@ -728,8 +807,10 @@ class NetworkBinaryStream extends BinaryStream{
|
||||
$this->putEntityUniqueId($structureSettings->lastTouchedByPlayerID);
|
||||
$this->putByte($structureSettings->rotation);
|
||||
$this->putByte($structureSettings->mirror);
|
||||
$this->putFloat($structureSettings->integrityValue);
|
||||
$this->putInt($structureSettings->integritySeed);
|
||||
$this->putByte($structureSettings->animationMode);
|
||||
$this->putLFloat($structureSettings->animationSeconds);
|
||||
$this->putLFloat($structureSettings->integrityValue);
|
||||
$this->putLInt($structureSettings->integritySeed);
|
||||
$this->putVector3($structureSettings->pivot);
|
||||
}
|
||||
|
||||
|
@ -31,6 +31,7 @@ use pocketmine\network\mcpe\protocol\AddEntityPacket;
|
||||
use pocketmine\network\mcpe\protocol\AddItemActorPacket;
|
||||
use pocketmine\network\mcpe\protocol\AddPaintingPacket;
|
||||
use pocketmine\network\mcpe\protocol\AddPlayerPacket;
|
||||
use pocketmine\network\mcpe\protocol\AddVolumeEntityPacket;
|
||||
use pocketmine\network\mcpe\protocol\AdventureSettingsPacket;
|
||||
use pocketmine\network\mcpe\protocol\AnimateEntityPacket;
|
||||
use pocketmine\network\mcpe\protocol\AnimatePacket;
|
||||
@ -48,6 +49,7 @@ use pocketmine\network\mcpe\protocol\CameraPacket;
|
||||
use pocketmine\network\mcpe\protocol\CameraShakePacket;
|
||||
use pocketmine\network\mcpe\protocol\ChangeDimensionPacket;
|
||||
use pocketmine\network\mcpe\protocol\ChunkRadiusUpdatedPacket;
|
||||
use pocketmine\network\mcpe\protocol\ClientboundDebugRendererPacket;
|
||||
use pocketmine\network\mcpe\protocol\ClientboundMapItemDataPacket;
|
||||
use pocketmine\network\mcpe\protocol\ClientCacheBlobStatusPacket;
|
||||
use pocketmine\network\mcpe\protocol\ClientCacheMissResponsePacket;
|
||||
@ -64,11 +66,13 @@ use pocketmine\network\mcpe\protocol\ContainerSetDataPacket;
|
||||
use pocketmine\network\mcpe\protocol\CorrectPlayerMovePredictionPacket;
|
||||
use pocketmine\network\mcpe\protocol\CraftingDataPacket;
|
||||
use pocketmine\network\mcpe\protocol\CraftingEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\CreatePhotoPacket;
|
||||
use pocketmine\network\mcpe\protocol\CreativeContentPacket;
|
||||
use pocketmine\network\mcpe\protocol\DataPacket;
|
||||
use pocketmine\network\mcpe\protocol\DebugInfoPacket;
|
||||
use pocketmine\network\mcpe\protocol\DisconnectPacket;
|
||||
use pocketmine\network\mcpe\protocol\EducationSettingsPacket;
|
||||
use pocketmine\network\mcpe\protocol\EduUriResourcePacket;
|
||||
use pocketmine\network\mcpe\protocol\EmoteListPacket;
|
||||
use pocketmine\network\mcpe\protocol\EmotePacket;
|
||||
use pocketmine\network\mcpe\protocol\EventPacket;
|
||||
@ -108,9 +112,12 @@ use pocketmine\network\mcpe\protocol\MultiplayerSettingsPacket;
|
||||
use pocketmine\network\mcpe\protocol\NetworkChunkPublisherUpdatePacket;
|
||||
use pocketmine\network\mcpe\protocol\NetworkSettingsPacket;
|
||||
use pocketmine\network\mcpe\protocol\NetworkStackLatencyPacket;
|
||||
use pocketmine\network\mcpe\protocol\NpcDialoguePacket;
|
||||
use pocketmine\network\mcpe\protocol\NpcRequestPacket;
|
||||
use pocketmine\network\mcpe\protocol\OnScreenTextureAnimationPacket;
|
||||
use pocketmine\network\mcpe\protocol\PacketViolationWarningPacket;
|
||||
use pocketmine\network\mcpe\protocol\PassengerJumpPacket;
|
||||
use pocketmine\network\mcpe\protocol\PhotoInfoRequestPacket;
|
||||
use pocketmine\network\mcpe\protocol\PhotoTransferPacket;
|
||||
use pocketmine\network\mcpe\protocol\PlayerActionPacket;
|
||||
use pocketmine\network\mcpe\protocol\PlayerArmorDamagePacket;
|
||||
@ -129,6 +136,7 @@ use pocketmine\network\mcpe\protocol\PurchaseReceiptPacket;
|
||||
use pocketmine\network\mcpe\protocol\RemoveActorPacket;
|
||||
use pocketmine\network\mcpe\protocol\RemoveEntityPacket;
|
||||
use pocketmine\network\mcpe\protocol\RemoveObjectivePacket;
|
||||
use pocketmine\network\mcpe\protocol\RemoveVolumeEntityPacket;
|
||||
use pocketmine\network\mcpe\protocol\RequestChunkRadiusPacket;
|
||||
use pocketmine\network\mcpe\protocol\ResourcePackChunkDataPacket;
|
||||
use pocketmine\network\mcpe\protocol\ResourcePackChunkRequestPacket;
|
||||
@ -137,7 +145,6 @@ use pocketmine\network\mcpe\protocol\ResourcePackDataInfoPacket;
|
||||
use pocketmine\network\mcpe\protocol\ResourcePacksInfoPacket;
|
||||
use pocketmine\network\mcpe\protocol\ResourcePackStackPacket;
|
||||
use pocketmine\network\mcpe\protocol\RespawnPacket;
|
||||
use pocketmine\network\mcpe\protocol\RiderJumpPacket;
|
||||
use pocketmine\network\mcpe\protocol\ScriptCustomEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\ServerSettingsRequestPacket;
|
||||
use pocketmine\network\mcpe\protocol\ServerSettingsResponsePacket;
|
||||
@ -163,6 +170,7 @@ use pocketmine\network\mcpe\protocol\ShowCreditsPacket;
|
||||
use pocketmine\network\mcpe\protocol\ShowProfilePacket;
|
||||
use pocketmine\network\mcpe\protocol\ShowStoreOfferPacket;
|
||||
use pocketmine\network\mcpe\protocol\SimpleEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\SimulationTypePacket;
|
||||
use pocketmine\network\mcpe\protocol\SpawnExperienceOrbPacket;
|
||||
use pocketmine\network\mcpe\protocol\SpawnParticleEffectPacket;
|
||||
use pocketmine\network\mcpe\protocol\StartGamePacket;
|
||||
@ -170,7 +178,10 @@ use pocketmine\network\mcpe\protocol\StopSoundPacket;
|
||||
use pocketmine\network\mcpe\protocol\StructureBlockUpdatePacket;
|
||||
use pocketmine\network\mcpe\protocol\StructureTemplateDataRequestPacket;
|
||||
use pocketmine\network\mcpe\protocol\StructureTemplateDataResponsePacket;
|
||||
use pocketmine\network\mcpe\protocol\SubChunkPacket;
|
||||
use pocketmine\network\mcpe\protocol\SubChunkRequestPacket;
|
||||
use pocketmine\network\mcpe\protocol\SubClientLoginPacket;
|
||||
use pocketmine\network\mcpe\protocol\SyncActorPropertyPacket;
|
||||
use pocketmine\network\mcpe\protocol\TakeItemActorPacket;
|
||||
use pocketmine\network\mcpe\protocol\TextPacket;
|
||||
use pocketmine\network\mcpe\protocol\TickSyncPacket;
|
||||
@ -181,6 +192,7 @@ use pocketmine\network\mcpe\protocol\UpdateBlockSyncedPacket;
|
||||
use pocketmine\network\mcpe\protocol\UpdateEquipPacket;
|
||||
use pocketmine\network\mcpe\protocol\UpdatePlayerGameTypePacket;
|
||||
use pocketmine\network\mcpe\protocol\UpdateSoftEnumPacket;
|
||||
use pocketmine\network\mcpe\protocol\UpdateSubChunkBlocksPacket;
|
||||
use pocketmine\network\mcpe\protocol\UpdateTradePacket;
|
||||
|
||||
abstract class NetworkSession{
|
||||
@ -262,7 +274,7 @@ abstract class NetworkSession{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleRiderJump(RiderJumpPacket $packet) : bool{
|
||||
public function handlePassengerJump(PassengerJumpPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -821,4 +833,52 @@ abstract class NetworkSession{
|
||||
public function handleFilterText(FilterTextPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleClientboundDebugRenderer(ClientboundDebugRendererPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSyncActorProperty(SyncActorPropertyPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleAddVolumeEntity(AddVolumeEntityPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleRemoveVolumeEntity(RemoveVolumeEntityPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSimulationType(SimulationTypePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleNpcDialogue(NpcDialoguePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleEduUriResource(EduUriResourcePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleCreatePhoto(CreatePhotoPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleUpdateSubChunkBlocks(UpdateSubChunkBlocksPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handlePhotoInfoRequest(PhotoInfoRequestPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSubChunk(SubChunkPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSubChunkRequest(SubChunkRequestPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -212,7 +212,7 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{
|
||||
$info->getMaxPlayerCount(),
|
||||
$this->rakLib->getServerId(),
|
||||
$this->server->getName(),
|
||||
Server::getGamemodeName($this->server->getGamemode())
|
||||
Server::getGamemodeName(Player::getClientFriendlyGamemode($this->server->getGamemode()))
|
||||
]) . ";"
|
||||
);
|
||||
}
|
||||
|
@ -85,6 +85,10 @@ final class ItemTranslator{
|
||||
if(!is_string($oldId) || !is_string($newId)){
|
||||
throw new AssumptionFailedError("Invalid item table format");
|
||||
}
|
||||
if(!isset($legacyStringToIntMap[$oldId])){
|
||||
//new item without a fixed legacy ID - we can't handle this right now
|
||||
continue;
|
||||
}
|
||||
$simpleMappings[$newId] = $legacyStringToIntMap[$oldId];
|
||||
}
|
||||
foreach($legacyStringToIntMap as $stringId => $intId){
|
||||
@ -128,8 +132,9 @@ final class ItemTranslator{
|
||||
}elseif(isset($simpleMappings[$stringId])){
|
||||
$this->simpleCoreToNetMapping[$simpleMappings[$stringId]] = $netId;
|
||||
$this->simpleNetToCoreMapping[$netId] = $simpleMappings[$stringId];
|
||||
}elseif($stringId !== "minecraft:unknown"){
|
||||
throw new \InvalidArgumentException("Unmapped entry " . $stringId);
|
||||
}else{
|
||||
//not all items have a legacy mapping - for now, we only support the ones that do
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -139,6 +144,9 @@ final class ItemTranslator{
|
||||
* @phpstan-return array{int, int}
|
||||
*/
|
||||
public function toNetworkId(int $internalId, int $internalMeta) : array{
|
||||
if($internalMeta === -1){
|
||||
$internalMeta = 0x7fff;
|
||||
}
|
||||
if(isset($this->complexCoreToNetMapping[$internalId][$internalMeta])){
|
||||
return [$this->complexCoreToNetMapping[$internalId][$internalMeta], 0];
|
||||
}
|
||||
|
@ -34,15 +34,19 @@ class ActorPickRequestPacket extends DataPacket{
|
||||
public $entityUniqueId;
|
||||
/** @var int */
|
||||
public $hotbarSlot;
|
||||
/** @var bool */
|
||||
public $addUserData;
|
||||
|
||||
protected function decodePayload(){
|
||||
$this->entityUniqueId = $this->getLLong();
|
||||
$this->hotbarSlot = $this->getByte();
|
||||
$this->addUserData = $this->getBool();
|
||||
}
|
||||
|
||||
protected function encodePayload(){
|
||||
$this->putLLong($this->entityUniqueId);
|
||||
$this->putByte($this->hotbarSlot);
|
||||
$this->putBool($this->addUserData);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
|
@ -31,24 +31,24 @@ class AddEntityPacket extends DataPacket/* implements ClientboundPacket*/{
|
||||
public const NETWORK_ID = ProtocolInfo::ADD_ENTITY_PACKET;
|
||||
|
||||
/** @var int */
|
||||
private $uvarint1;
|
||||
private $entityNetId;
|
||||
|
||||
public static function create(int $uvarint1) : self{
|
||||
public static function create(int $entityNetId) : self{
|
||||
$result = new self;
|
||||
$result->uvarint1 = $uvarint1;
|
||||
$result->entityNetId = $entityNetId;
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getUvarint1() : int{
|
||||
return $this->uvarint1;
|
||||
public function getEntityNetId() : int{
|
||||
return $this->entityNetId;
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->uvarint1 = $this->getUnsignedVarInt();
|
||||
$this->entityNetId = $this->getUnsignedVarInt();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putUnsignedVarInt($this->uvarint1);
|
||||
$this->putUnsignedVarInt($this->entityNetId);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $handler) : bool{
|
||||
|
@ -25,9 +25,9 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\protocol\types\inventory\ItemStackWrapper;
|
||||
|
||||
class AddItemActorPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::ADD_ITEM_ACTOR_PACKET;
|
||||
@ -36,7 +36,7 @@ class AddItemActorPacket extends DataPacket{
|
||||
public $entityUniqueId = null; //TODO
|
||||
/** @var int */
|
||||
public $entityRuntimeId;
|
||||
/** @var Item */
|
||||
/** @var ItemStackWrapper */
|
||||
public $item;
|
||||
/** @var Vector3 */
|
||||
public $position;
|
||||
@ -53,7 +53,7 @@ class AddItemActorPacket extends DataPacket{
|
||||
protected function decodePayload(){
|
||||
$this->entityUniqueId = $this->getEntityUniqueId();
|
||||
$this->entityRuntimeId = $this->getEntityRuntimeId();
|
||||
$this->item = $this->getSlot();
|
||||
$this->item = ItemStackWrapper::read($this);
|
||||
$this->position = $this->getVector3();
|
||||
$this->motion = $this->getVector3();
|
||||
$this->metadata = $this->getEntityMetadata();
|
||||
@ -63,7 +63,7 @@ class AddItemActorPacket extends DataPacket{
|
||||
protected function encodePayload(){
|
||||
$this->putEntityUniqueId($this->entityUniqueId ?? $this->entityRuntimeId);
|
||||
$this->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->putSlot($this->item);
|
||||
$this->item->write($this);
|
||||
$this->putVector3($this->position);
|
||||
$this->putVector3Nullable($this->motion);
|
||||
$this->putEntityMetadata($this->metadata);
|
||||
|
@ -25,11 +25,11 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\protocol\types\DeviceOS;
|
||||
use pocketmine\network\mcpe\protocol\types\EntityLink;
|
||||
use pocketmine\network\mcpe\protocol\types\inventory\ItemStackWrapper;
|
||||
use pocketmine\utils\UUID;
|
||||
use function count;
|
||||
|
||||
@ -56,7 +56,7 @@ class AddPlayerPacket extends DataPacket{
|
||||
public $yaw = 0.0;
|
||||
/** @var float|null */
|
||||
public $headYaw = null; //TODO
|
||||
/** @var Item */
|
||||
/** @var ItemStackWrapper */
|
||||
public $item;
|
||||
/**
|
||||
* @var mixed[][]
|
||||
@ -98,7 +98,7 @@ class AddPlayerPacket extends DataPacket{
|
||||
$this->pitch = $this->getLFloat();
|
||||
$this->yaw = $this->getLFloat();
|
||||
$this->headYaw = $this->getLFloat();
|
||||
$this->item = $this->getSlot();
|
||||
$this->item = ItemStackWrapper::read($this);
|
||||
$this->metadata = $this->getEntityMetadata();
|
||||
|
||||
$this->uvarint1 = $this->getUnsignedVarInt();
|
||||
@ -129,7 +129,7 @@ class AddPlayerPacket extends DataPacket{
|
||||
$this->putLFloat($this->pitch);
|
||||
$this->putLFloat($this->yaw);
|
||||
$this->putLFloat($this->headYaw ?? $this->yaw);
|
||||
$this->putSlot($this->item);
|
||||
$this->item->write($this);
|
||||
$this->putEntityMetadata($this->metadata);
|
||||
|
||||
$this->putUnsignedVarInt($this->uvarint1);
|
||||
|
@ -0,0 +1,71 @@
|
||||
<?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\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\nbt\NetworkLittleEndianNBTStream;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class AddVolumeEntityPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::ADD_VOLUME_ENTITY_PACKET;
|
||||
|
||||
/** @var int */
|
||||
private $entityNetId;
|
||||
/** @var CompoundTag */
|
||||
private $data;
|
||||
/** @var string */
|
||||
private $engineVersion;
|
||||
|
||||
public static function create(int $entityNetId, CompoundTag $data, string $engineVersion) : self{
|
||||
$result = new self;
|
||||
$result->entityNetId = $entityNetId;
|
||||
$result->data = $data;
|
||||
$result->engineVersion = $engineVersion;
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getEntityNetId() : int{ return $this->entityNetId; }
|
||||
|
||||
public function getData() : CompoundTag{ return $this->data; }
|
||||
|
||||
public function getEngineVersion() : string{ return $this->engineVersion; }
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->entityNetId = $this->getUnsignedVarInt();
|
||||
$this->data = $this->getNbtCompoundRoot();
|
||||
$this->engineVersion = $this->getString();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putUnsignedVarInt($this->entityNetId);
|
||||
$this->put((new NetworkLittleEndianNBTStream())->write($this->data));
|
||||
$this->putString($this->engineVersion);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $handler) : bool{
|
||||
return $handler->handleAddVolumeEntity($this);
|
||||
}
|
||||
}
|
@ -54,13 +54,15 @@ class AdventureSettingsPacket extends DataPacket{
|
||||
public const FLYING = 0x200;
|
||||
public const MUTED = 0x400;
|
||||
|
||||
public const BUILD_AND_MINE = 0x01 | self::BITFLAG_SECOND_SET;
|
||||
public const MINE = 0x01 | self::BITFLAG_SECOND_SET;
|
||||
public const DOORS_AND_SWITCHES = 0x02 | self::BITFLAG_SECOND_SET;
|
||||
public const OPEN_CONTAINERS = 0x04 | self::BITFLAG_SECOND_SET;
|
||||
public const ATTACK_PLAYERS = 0x08 | self::BITFLAG_SECOND_SET;
|
||||
public const ATTACK_MOBS = 0x10 | self::BITFLAG_SECOND_SET;
|
||||
public const OPERATOR = 0x20 | self::BITFLAG_SECOND_SET;
|
||||
public const TELEPORT = 0x80 | self::BITFLAG_SECOND_SET;
|
||||
public const BUILD = 0x100 | self::BITFLAG_SECOND_SET;
|
||||
public const DEFAULT = 0x200 | self::BITFLAG_SECOND_SET;
|
||||
|
||||
/** @var int */
|
||||
public $flags = 0;
|
||||
@ -106,9 +108,9 @@ class AdventureSettingsPacket extends DataPacket{
|
||||
*/
|
||||
public function setFlag(int $flag, bool $value){
|
||||
if(($flag & self::BITFLAG_SECOND_SET) !== 0){
|
||||
$flagSet =& $this->flags2;
|
||||
$flagSet = &$this->flags2;
|
||||
}else{
|
||||
$flagSet =& $this->flags;
|
||||
$flagSet = &$this->flags;
|
||||
}
|
||||
|
||||
if($value){
|
||||
|
@ -37,6 +37,8 @@ class AnimateEntityPacket extends DataPacket/* implements ClientboundPacket*/{
|
||||
private $nextState;
|
||||
/** @var string */
|
||||
private $stopExpression;
|
||||
/** @var int */
|
||||
private $stopExpressionVersion;
|
||||
/** @var string */
|
||||
private $controller;
|
||||
/** @var float */
|
||||
@ -51,11 +53,12 @@ class AnimateEntityPacket extends DataPacket/* implements ClientboundPacket*/{
|
||||
* @param int[] $actorRuntimeIds
|
||||
* @phpstan-param list<int> $actorRuntimeIds
|
||||
*/
|
||||
public static function create(string $animation, string $nextState, string $stopExpression, string $controller, float $blendOutTime, array $actorRuntimeIds) : self{
|
||||
public static function create(string $animation, string $nextState, string $stopExpression, int $stopExpressionVersion, string $controller, float $blendOutTime, array $actorRuntimeIds) : self{
|
||||
$result = new self;
|
||||
$result->animation = $animation;
|
||||
$result->nextState = $nextState;
|
||||
$result->stopExpression = $stopExpression;
|
||||
$result->stopExpressionVersion = $stopExpressionVersion;
|
||||
$result->controller = $controller;
|
||||
$result->blendOutTime = $blendOutTime;
|
||||
$result->actorRuntimeIds = $actorRuntimeIds;
|
||||
@ -68,6 +71,8 @@ class AnimateEntityPacket extends DataPacket/* implements ClientboundPacket*/{
|
||||
|
||||
public function getStopExpression() : string{ return $this->stopExpression; }
|
||||
|
||||
public function getStopExpressionVersion() : int{ return $this->stopExpressionVersion; }
|
||||
|
||||
public function getController() : string{ return $this->controller; }
|
||||
|
||||
public function getBlendOutTime() : float{ return $this->blendOutTime; }
|
||||
@ -82,6 +87,7 @@ class AnimateEntityPacket extends DataPacket/* implements ClientboundPacket*/{
|
||||
$this->animation = $this->getString();
|
||||
$this->nextState = $this->getString();
|
||||
$this->stopExpression = $this->getString();
|
||||
$this->stopExpressionVersion = $this->getLInt();
|
||||
$this->controller = $this->getString();
|
||||
$this->blendOutTime = $this->getLFloat();
|
||||
$this->actorRuntimeIds = [];
|
||||
@ -94,6 +100,7 @@ class AnimateEntityPacket extends DataPacket/* implements ClientboundPacket*/{
|
||||
$this->putString($this->animation);
|
||||
$this->putString($this->nextState);
|
||||
$this->putString($this->stopExpression);
|
||||
$this->putLInt($this->stopExpressionVersion);
|
||||
$this->putString($this->controller);
|
||||
$this->putLFloat($this->blendOutTime);
|
||||
$this->putUnsignedVarInt(count($this->actorRuntimeIds));
|
||||
|
@ -48,26 +48,27 @@ class AvailableCommandsPacket extends DataPacket{
|
||||
* Basic parameter types. These must be combined with the ARG_FLAG_VALID constant.
|
||||
* ARG_FLAG_VALID | (type const)
|
||||
*/
|
||||
public const ARG_TYPE_INT = 0x01;
|
||||
public const ARG_TYPE_FLOAT = 0x02;
|
||||
public const ARG_TYPE_VALUE = 0x03;
|
||||
public const ARG_TYPE_WILDCARD_INT = 0x04;
|
||||
public const ARG_TYPE_OPERATOR = 0x05;
|
||||
public const ARG_TYPE_TARGET = 0x06;
|
||||
public const ARG_TYPE_INT = 0x01;
|
||||
public const ARG_TYPE_FLOAT = 0x03;
|
||||
public const ARG_TYPE_VALUE = 0x04;
|
||||
public const ARG_TYPE_WILDCARD_INT = 0x05;
|
||||
public const ARG_TYPE_OPERATOR = 0x06;
|
||||
public const ARG_TYPE_TARGET = 0x07;
|
||||
public const ARG_TYPE_WILDCARD_TARGET = 0x08;
|
||||
|
||||
public const ARG_TYPE_FILEPATH = 0x0e;
|
||||
public const ARG_TYPE_FILEPATH = 0x10;
|
||||
|
||||
public const ARG_TYPE_STRING = 0x1d;
|
||||
public const ARG_TYPE_STRING = 0x20;
|
||||
|
||||
public const ARG_TYPE_POSITION = 0x25;
|
||||
public const ARG_TYPE_POSITION = 0x28;
|
||||
|
||||
public const ARG_TYPE_MESSAGE = 0x29;
|
||||
public const ARG_TYPE_MESSAGE = 0x2c;
|
||||
|
||||
public const ARG_TYPE_RAWTEXT = 0x2b;
|
||||
public const ARG_TYPE_RAWTEXT = 0x2e;
|
||||
|
||||
public const ARG_TYPE_JSON = 0x2f;
|
||||
public const ARG_TYPE_JSON = 0x32;
|
||||
|
||||
public const ARG_TYPE_COMMAND = 0x36;
|
||||
public const ARG_TYPE_COMMAND = 0x3f;
|
||||
|
||||
/**
|
||||
* Enums are a little different: they are composed as follows:
|
||||
@ -280,7 +281,7 @@ class AvailableCommandsPacket extends DataPacket{
|
||||
$retval = new CommandData();
|
||||
$retval->commandName = $this->getString();
|
||||
$retval->commandDescription = $this->getString();
|
||||
$retval->flags = $this->getByte();
|
||||
$retval->flags = $this->getLShort();
|
||||
$retval->permission = $this->getByte();
|
||||
$retval->aliases = $enums[$this->getLInt()] ?? null;
|
||||
|
||||
@ -323,7 +324,7 @@ class AvailableCommandsPacket extends DataPacket{
|
||||
protected function putCommandData(CommandData $data, array $enumIndexes, array $postfixIndexes) : void{
|
||||
$this->putString($data->commandName);
|
||||
$this->putString($data->commandDescription);
|
||||
$this->putByte($data->flags);
|
||||
$this->putLShort($data->flags);
|
||||
$this->putByte($data->permission);
|
||||
|
||||
if($data->aliases !== null){
|
||||
@ -358,49 +359,6 @@ class AvailableCommandsPacket extends DataPacket{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string[] $postfixes
|
||||
* @phpstan-param array<int, string> $postfixes
|
||||
*/
|
||||
private function argTypeToString(int $argtype, array $postfixes) : string{
|
||||
if(($argtype & self::ARG_FLAG_VALID) !== 0){
|
||||
if(($argtype & self::ARG_FLAG_ENUM) !== 0){
|
||||
return "stringenum (" . ($argtype & 0xffff) . ")";
|
||||
}
|
||||
|
||||
switch($argtype & 0xffff){
|
||||
case self::ARG_TYPE_INT:
|
||||
return "int";
|
||||
case self::ARG_TYPE_FLOAT:
|
||||
return "float";
|
||||
case self::ARG_TYPE_VALUE:
|
||||
return "mixed";
|
||||
case self::ARG_TYPE_TARGET:
|
||||
return "target";
|
||||
case self::ARG_TYPE_STRING:
|
||||
return "string";
|
||||
case self::ARG_TYPE_POSITION:
|
||||
return "xyz";
|
||||
case self::ARG_TYPE_MESSAGE:
|
||||
return "message";
|
||||
case self::ARG_TYPE_RAWTEXT:
|
||||
return "text";
|
||||
case self::ARG_TYPE_JSON:
|
||||
return "json";
|
||||
case self::ARG_TYPE_COMMAND:
|
||||
return "command";
|
||||
}
|
||||
}elseif(($argtype & self::ARG_FLAG_POSTFIX) !== 0){
|
||||
$postfix = $postfixes[$argtype & 0xffff];
|
||||
|
||||
return "int (postfix $postfix)";
|
||||
}else{
|
||||
throw new \UnexpectedValueException("Unknown arg type 0x" . dechex($argtype));
|
||||
}
|
||||
|
||||
return "unknown ($argtype)";
|
||||
}
|
||||
|
||||
protected function encodePayload(){
|
||||
/** @var int[] $enumValueIndexes */
|
||||
$enumValueIndexes = [];
|
||||
|
@ -33,18 +33,24 @@ class CameraShakePacket extends DataPacket/* implements ClientboundPacket*/{
|
||||
public const TYPE_POSITIONAL = 0;
|
||||
public const TYPE_ROTATIONAL = 1;
|
||||
|
||||
public const ACTION_ADD = 0;
|
||||
public const ACTION_STOP = 1;
|
||||
|
||||
/** @var float */
|
||||
private $intensity;
|
||||
/** @var float */
|
||||
private $duration;
|
||||
/** @var int */
|
||||
private $shakeType;
|
||||
/** @var int */
|
||||
private $shakeAction;
|
||||
|
||||
public static function create(float $intensity, float $duration, int $shakeType) : self{
|
||||
public static function create(float $intensity, float $duration, int $shakeType, int $shakeAction) : self{
|
||||
$result = new self;
|
||||
$result->intensity = $intensity;
|
||||
$result->duration = $duration;
|
||||
$result->shakeType = $shakeType;
|
||||
$result->shakeAction = $shakeAction;
|
||||
return $result;
|
||||
}
|
||||
|
||||
@ -54,16 +60,20 @@ class CameraShakePacket extends DataPacket/* implements ClientboundPacket*/{
|
||||
|
||||
public function getShakeType() : int{ return $this->shakeType; }
|
||||
|
||||
public function getShakeAction() : int{ return $this->shakeAction; }
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->intensity = $this->getLFloat();
|
||||
$this->duration = $this->getLFloat();
|
||||
$this->shakeType = $this->getByte();
|
||||
$this->shakeAction = $this->getByte();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putLFloat($this->intensity);
|
||||
$this->putLFloat($this->duration);
|
||||
$this->putByte($this->shakeType);
|
||||
$this->putByte($this->shakeAction);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $handler) : bool{
|
||||
|
@ -66,23 +66,23 @@ class ClientCacheBlobStatusPacket extends DataPacket/* implements ServerboundPac
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$hitCount = $this->getUnsignedVarInt();
|
||||
$missCount = $this->getUnsignedVarInt();
|
||||
for($i = 0; $i < $hitCount; ++$i){
|
||||
$this->hitHashes[] = $this->getLLong();
|
||||
}
|
||||
$hitCount = $this->getUnsignedVarInt();
|
||||
for($i = 0; $i < $missCount; ++$i){
|
||||
$this->missHashes[] = $this->getLLong();
|
||||
}
|
||||
for($i = 0; $i < $hitCount; ++$i){
|
||||
$this->hitHashes[] = $this->getLLong();
|
||||
}
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putUnsignedVarInt(count($this->hitHashes));
|
||||
$this->putUnsignedVarInt(count($this->missHashes));
|
||||
foreach($this->hitHashes as $hash){
|
||||
$this->putUnsignedVarInt(count($this->hitHashes));
|
||||
foreach($this->missHashes as $hash){
|
||||
$this->putLLong($hash);
|
||||
}
|
||||
foreach($this->missHashes as $hash){
|
||||
foreach($this->hitHashes as $hash){
|
||||
$this->putLLong($hash);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,137 @@
|
||||
<?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\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class ClientboundDebugRendererPacket extends DataPacket/* implements ClientboundPacket*/{
|
||||
public const NETWORK_ID = ProtocolInfo::CLIENTBOUND_DEBUG_RENDERER_PACKET;
|
||||
|
||||
public const TYPE_CLEAR = 1;
|
||||
public const TYPE_ADD_CUBE = 2;
|
||||
|
||||
/** @var int */
|
||||
private $type;
|
||||
|
||||
//TODO: if more types are added, we'll probably want to make a separate data type and interfaces
|
||||
/** @var string */
|
||||
private $text;
|
||||
/** @var Vector3 */
|
||||
private $position;
|
||||
/** @var float */
|
||||
private $red;
|
||||
/** @var float */
|
||||
private $green;
|
||||
/** @var float */
|
||||
private $blue;
|
||||
/** @var float */
|
||||
private $alpha;
|
||||
/** @var int */
|
||||
private $durationMillis;
|
||||
|
||||
private static function base(int $type) : self{
|
||||
$result = new self;
|
||||
$result->type = $type;
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function clear() : self{ return self::base(self::TYPE_CLEAR); }
|
||||
|
||||
public static function addCube(string $text, Vector3 $position, float $red, float $green, float $blue, float $alpha, int $durationMillis) : self{
|
||||
$result = self::base(self::TYPE_ADD_CUBE);
|
||||
$result->text = $text;
|
||||
$result->position = $position;
|
||||
$result->red = $red;
|
||||
$result->green = $green;
|
||||
$result->blue = $blue;
|
||||
$result->alpha = $alpha;
|
||||
$result->durationMillis = $durationMillis;
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getType() : int{ return $this->type; }
|
||||
|
||||
public function getText() : string{ return $this->text; }
|
||||
|
||||
public function getPosition() : Vector3{ return $this->position; }
|
||||
|
||||
public function getRed() : float{ return $this->red; }
|
||||
|
||||
public function getGreen() : float{ return $this->green; }
|
||||
|
||||
public function getBlue() : float{ return $this->blue; }
|
||||
|
||||
public function getAlpha() : float{ return $this->alpha; }
|
||||
|
||||
public function getDurationMillis() : int{ return $this->durationMillis; }
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->type = $this->getLInt();
|
||||
|
||||
switch($this->type){
|
||||
case self::TYPE_CLEAR:
|
||||
//NOOP
|
||||
break;
|
||||
case self::TYPE_ADD_CUBE:
|
||||
$this->text = $this->getString();
|
||||
$this->position = $this->getVector3();
|
||||
$this->red = $this->getLFloat();
|
||||
$this->green = $this->getLFloat();
|
||||
$this->blue = $this->getLFloat();
|
||||
$this->alpha = $this->getLFloat();
|
||||
$this->durationMillis = $this->getLLong();
|
||||
break;
|
||||
default:
|
||||
throw new \UnexpectedValueException("Unknown type " . $this->type);
|
||||
}
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putLInt($this->type);
|
||||
|
||||
switch($this->type){
|
||||
case self::TYPE_CLEAR:
|
||||
//NOOP
|
||||
break;
|
||||
case self::TYPE_ADD_CUBE:
|
||||
$this->putString($this->text);
|
||||
$this->putVector3($this->position);
|
||||
$this->putLFloat($this->red);
|
||||
$this->putLFloat($this->green);
|
||||
$this->putLFloat($this->blue);
|
||||
$this->putLFloat($this->alpha);
|
||||
$this->putLLong($this->durationMillis);
|
||||
break;
|
||||
default:
|
||||
throw new \InvalidArgumentException("Unknown type " . $this->type);
|
||||
}
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleClientboundDebugRenderer($this);
|
||||
}
|
||||
}
|
@ -33,6 +33,11 @@ use function count;
|
||||
class CommandOutputPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::COMMAND_OUTPUT_PACKET;
|
||||
|
||||
public const TYPE_LAST = 1;
|
||||
public const TYPE_SILENT = 2;
|
||||
public const TYPE_ALL = 3;
|
||||
public const TYPE_DATA_SET = 4;
|
||||
|
||||
/** @var CommandOriginData */
|
||||
public $originData;
|
||||
/** @var int */
|
||||
@ -53,7 +58,7 @@ class CommandOutputPacket extends DataPacket{
|
||||
$this->messages[] = $this->getCommandMessage();
|
||||
}
|
||||
|
||||
if($this->outputType === 4){
|
||||
if($this->outputType === self::TYPE_DATA_SET){
|
||||
$this->unknownString = $this->getString();
|
||||
}
|
||||
}
|
||||
@ -81,7 +86,7 @@ class CommandOutputPacket extends DataPacket{
|
||||
$this->putCommandMessage($message);
|
||||
}
|
||||
|
||||
if($this->outputType === 4){
|
||||
if($this->outputType === self::TYPE_DATA_SET){
|
||||
$this->putString($this->unknownString);
|
||||
}
|
||||
}
|
||||
|
@ -28,11 +28,12 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
use pocketmine\inventory\FurnaceRecipe;
|
||||
use pocketmine\inventory\ShapedRecipe;
|
||||
use pocketmine\inventory\ShapelessRecipe;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\ItemFactory;
|
||||
use pocketmine\network\mcpe\convert\ItemTranslator;
|
||||
use pocketmine\network\mcpe\NetworkBinaryStream;
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\protocol\types\MaterialReducerRecipe;
|
||||
use pocketmine\network\mcpe\protocol\types\MaterialReducerRecipeOutput;
|
||||
use pocketmine\network\mcpe\protocol\types\PotionContainerChangeRecipe;
|
||||
use pocketmine\network\mcpe\protocol\types\PotionTypeRecipe;
|
||||
#ifndef COMPILE
|
||||
@ -59,6 +60,8 @@ class CraftingDataPacket extends DataPacket{
|
||||
public $potionTypeRecipes = [];
|
||||
/** @var PotionContainerChangeRecipe[] */
|
||||
public $potionContainerRecipes = [];
|
||||
/** @var MaterialReducerRecipe[] */
|
||||
public $materialReducerRecipes = [];
|
||||
/** @var bool */
|
||||
public $cleanRecipes = false;
|
||||
|
||||
@ -92,7 +95,7 @@ class CraftingDataPacket extends DataPacket{
|
||||
$resultCount = $this->getUnsignedVarInt();
|
||||
$entry["output"] = [];
|
||||
for($k = 0; $k < $resultCount; ++$k){
|
||||
$entry["output"][] = $this->getSlot();
|
||||
$entry["output"][] = $this->getItemStackWithoutStackId();
|
||||
}
|
||||
$entry["uuid"] = $this->getUUID()->toString();
|
||||
$entry["block"] = $this->getString();
|
||||
@ -114,7 +117,7 @@ class CraftingDataPacket extends DataPacket{
|
||||
$resultCount = $this->getUnsignedVarInt();
|
||||
$entry["output"] = [];
|
||||
for($k = 0; $k < $resultCount; ++$k){
|
||||
$entry["output"][] = $this->getSlot();
|
||||
$entry["output"][] = $this->getItemStackWithoutStackId();
|
||||
}
|
||||
$entry["uuid"] = $this->getUUID()->toString();
|
||||
$entry["block"] = $this->getString();
|
||||
@ -132,7 +135,7 @@ class CraftingDataPacket extends DataPacket{
|
||||
[$inputId, $inputData] = ItemTranslator::getInstance()->fromNetworkIdWithWildcardHandling($inputIdNet, $inputMetaNet);
|
||||
}
|
||||
$entry["input"] = ItemFactory::get($inputId, $inputData);
|
||||
$entry["output"] = $out = $this->getSlot();
|
||||
$entry["output"] = $out = $this->getItemStackWithoutStackId();
|
||||
if($out->getDamage() === 0x7fff){
|
||||
$out->setDamage(0); //TODO HACK: some 1.12 furnace recipe outputs have wildcard damage values
|
||||
}
|
||||
@ -170,6 +173,17 @@ class CraftingDataPacket extends DataPacket{
|
||||
[$output, ] = ItemTranslator::getInstance()->fromNetworkId($outputIdNet, 0);
|
||||
$this->potionContainerRecipes[] = new PotionContainerChangeRecipe($input, $ingredient, $output);
|
||||
}
|
||||
for($i = 0, $count = $this->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
$inputIdAndData = $this->getVarInt();
|
||||
[$inputId, $inputMeta] = [$inputIdAndData >> 16, $inputIdAndData & 0x7fff];
|
||||
$outputs = [];
|
||||
for($j = 0, $outputCount = $this->getUnsignedVarInt(); $j < $outputCount; ++$j){
|
||||
$outputItemId = $this->getVarInt();
|
||||
$outputItemCount = $this->getVarInt();
|
||||
$outputs[] = new MaterialReducerRecipeOutput($outputItemId, $outputItemCount);
|
||||
}
|
||||
$this->materialReducerRecipes[] = new MaterialReducerRecipe($inputId, $inputMeta, $outputs);
|
||||
}
|
||||
$this->cleanRecipes = $this->getBool();
|
||||
}
|
||||
|
||||
@ -199,7 +213,7 @@ class CraftingDataPacket extends DataPacket{
|
||||
$results = $recipe->getResults();
|
||||
$stream->putUnsignedVarInt(count($results));
|
||||
foreach($results as $item){
|
||||
$stream->putSlot($item);
|
||||
$stream->putItemStackWithoutStackId($item);
|
||||
}
|
||||
|
||||
$stream->put(str_repeat("\x00", 16)); //Null UUID
|
||||
@ -224,7 +238,7 @@ class CraftingDataPacket extends DataPacket{
|
||||
$results = $recipe->getResults();
|
||||
$stream->putUnsignedVarInt(count($results));
|
||||
foreach($results as $item){
|
||||
$stream->putSlot($item);
|
||||
$stream->putItemStackWithoutStackId($item);
|
||||
}
|
||||
|
||||
$stream->put(str_repeat("\x00", 16)); //Null UUID
|
||||
@ -245,7 +259,7 @@ class CraftingDataPacket extends DataPacket{
|
||||
}
|
||||
$stream->putVarInt($netId);
|
||||
$stream->putVarInt($netData);
|
||||
$stream->putSlot($recipe->getResult());
|
||||
$stream->putItemStackWithoutStackId($recipe->getResult());
|
||||
$stream->putString("furnace"); //TODO: blocktype (no prefix) (this might require internal API breaks)
|
||||
return CraftingDataPacket::ENTRY_FURNACE_DATA;
|
||||
}
|
||||
@ -277,7 +291,7 @@ class CraftingDataPacket extends DataPacket{
|
||||
$writer = new NetworkBinaryStream();
|
||||
$counter = 0;
|
||||
foreach($this->entries as $d){
|
||||
$entryType = self::writeEntry($d, $writer, $counter++);
|
||||
$entryType = self::writeEntry($d, $writer, ++$counter);
|
||||
if($entryType >= 0){
|
||||
$this->putVarInt($entryType);
|
||||
$this->put($writer->getBuffer());
|
||||
@ -302,6 +316,15 @@ class CraftingDataPacket extends DataPacket{
|
||||
$this->putVarInt($recipe->getIngredientItemId());
|
||||
$this->putVarInt($recipe->getOutputItemId());
|
||||
}
|
||||
$this->putUnsignedVarInt(count($this->materialReducerRecipes));
|
||||
foreach($this->materialReducerRecipes as $recipe){
|
||||
$this->putVarInt(($recipe->getInputItemId() << 16) | $recipe->getInputItemMeta());
|
||||
$this->putUnsignedVarInt(count($recipe->getOutputs()));
|
||||
foreach($recipe->getOutputs() as $output){
|
||||
$this->putVarInt($output->getItemId());
|
||||
$this->putVarInt($output->getCount());
|
||||
}
|
||||
}
|
||||
|
||||
$this->putBool($this->cleanRecipes);
|
||||
}
|
||||
|
@ -25,8 +25,8 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\protocol\types\inventory\ItemStackWrapper;
|
||||
use pocketmine\utils\UUID;
|
||||
use function count;
|
||||
|
||||
@ -39,9 +39,9 @@ class CraftingEventPacket extends DataPacket{
|
||||
public $type;
|
||||
/** @var UUID */
|
||||
public $id;
|
||||
/** @var Item[] */
|
||||
/** @var ItemStackWrapper[] */
|
||||
public $input = [];
|
||||
/** @var Item[] */
|
||||
/** @var ItemStackWrapper[] */
|
||||
public $output = [];
|
||||
|
||||
public function clean(){
|
||||
@ -57,12 +57,12 @@ class CraftingEventPacket extends DataPacket{
|
||||
|
||||
$size = $this->getUnsignedVarInt();
|
||||
for($i = 0; $i < $size and $i < 128; ++$i){
|
||||
$this->input[] = $this->getSlot();
|
||||
$this->input[] = ItemStackWrapper::read($this);
|
||||
}
|
||||
|
||||
$size = $this->getUnsignedVarInt();
|
||||
for($i = 0; $i < $size and $i < 128; ++$i){
|
||||
$this->output[] = $this->getSlot();
|
||||
$this->output[] = ItemStackWrapper::read($this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -73,12 +73,12 @@ class CraftingEventPacket extends DataPacket{
|
||||
|
||||
$this->putUnsignedVarInt(count($this->input));
|
||||
foreach($this->input as $item){
|
||||
$this->putSlot($item);
|
||||
$item->write($this);
|
||||
}
|
||||
|
||||
$this->putUnsignedVarInt(count($this->output));
|
||||
foreach($this->output as $item){
|
||||
$this->putSlot($item);
|
||||
$item->write($this);
|
||||
}
|
||||
}
|
||||
|
||||
|
69
src/pocketmine/network/mcpe/protocol/CreatePhotoPacket.php
Normal file
69
src/pocketmine/network/mcpe/protocol/CreatePhotoPacket.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\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class CreatePhotoPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::CREATE_PHOTO_PACKET;
|
||||
|
||||
private int $entityUniqueId;
|
||||
private string $photoName;
|
||||
private string $photoItemName;
|
||||
|
||||
public static function create(int $actorUniqueId, string $photoName, string $photoItemName) : self{
|
||||
$result = new self;
|
||||
$result->entityUniqueId = $actorUniqueId;
|
||||
$result->photoName = $photoName;
|
||||
$result->photoItemName = $photoItemName;
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: rename this to getEntityUniqueId() on PM4 (shit architecture, thanks shoghi)
|
||||
*/
|
||||
public function getEntityUniqueIdField() : int{ return $this->entityUniqueId; }
|
||||
|
||||
public function getPhotoName() : string{ return $this->photoName; }
|
||||
|
||||
public function getPhotoItemName() : string{ return $this->photoItemName; }
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->entityUniqueId = $this->getLLong(); //why be consistent mojang ?????
|
||||
$this->photoName = $this->getString();
|
||||
$this->photoItemName = $this->getString();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putLLong($this->entityUniqueId);
|
||||
$this->putString($this->photoName);
|
||||
$this->putString($this->photoItemName);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $handler) : bool{
|
||||
return $handler->handleCreatePhoto($this);
|
||||
}
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\protocol\types\EducationUriResource;
|
||||
|
||||
class EduUriResourcePacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::EDU_URI_RESOURCE_PACKET;
|
||||
|
||||
private EducationUriResource $resource;
|
||||
|
||||
public static function create(EducationUriResource $resource) : self{
|
||||
$result = new self;
|
||||
$result->resource = $resource;
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getResource() : EducationUriResource{ return $this->resource; }
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->resource = EducationUriResource::read($this);
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->resource->write($this);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $handler) : bool{
|
||||
return $handler->handleEduUriResource($this);
|
||||
}
|
||||
}
|
@ -26,6 +26,8 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\protocol\types\EducationSettingsAgentCapabilities;
|
||||
use pocketmine\network\mcpe\protocol\types\EducationSettingsExternalLinkSettings;
|
||||
|
||||
class EducationSettingsPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::EDUCATION_SETTINGS_PACKET;
|
||||
@ -36,18 +38,44 @@ class EducationSettingsPacket extends DataPacket{
|
||||
private $codeBuilderTitle;
|
||||
/** @var bool */
|
||||
private $canResizeCodeBuilder;
|
||||
/** @var bool */
|
||||
private $disableLegacyTitleBar;
|
||||
/** @var string */
|
||||
private $postProcessFilter;
|
||||
/** @var string */
|
||||
private $screenshotBorderResourcePath;
|
||||
/** @var EducationSettingsAgentCapabilities|null */
|
||||
private $agentCapabilities;
|
||||
/** @var string|null */
|
||||
private $codeBuilderOverrideUri;
|
||||
/** @var bool */
|
||||
private $hasQuiz;
|
||||
/** @var EducationSettingsExternalLinkSettings|null */
|
||||
private $linkSettings;
|
||||
|
||||
public static function create(string $codeBuilderDefaultUri, string $codeBuilderTitle, bool $canResizeCodeBuilder, ?string $codeBuilderOverrideUri, bool $hasQuiz) : self{
|
||||
public static function create(
|
||||
string $codeBuilderDefaultUri,
|
||||
string $codeBuilderTitle,
|
||||
bool $canResizeCodeBuilder,
|
||||
bool $disableLegacyTitleBar,
|
||||
string $postProcessFilter,
|
||||
string $screenshotBorderResourcePath,
|
||||
?EducationSettingsAgentCapabilities $agentCapabilities,
|
||||
?string $codeBuilderOverrideUri,
|
||||
bool $hasQuiz,
|
||||
?EducationSettingsExternalLinkSettings $linkSettings
|
||||
) : self{
|
||||
$result = new self;
|
||||
$result->codeBuilderDefaultUri = $codeBuilderDefaultUri;
|
||||
$result->codeBuilderTitle = $codeBuilderTitle;
|
||||
$result->canResizeCodeBuilder = $canResizeCodeBuilder;
|
||||
$result->disableLegacyTitleBar = $disableLegacyTitleBar;
|
||||
$result->postProcessFilter = $postProcessFilter;
|
||||
$result->screenshotBorderResourcePath = $screenshotBorderResourcePath;
|
||||
$result->agentCapabilities = $agentCapabilities;
|
||||
$result->codeBuilderOverrideUri = $codeBuilderOverrideUri;
|
||||
$result->hasQuiz = $hasQuiz;
|
||||
$result->linkSettings = $linkSettings;
|
||||
return $result;
|
||||
}
|
||||
|
||||
@ -63,6 +91,14 @@ class EducationSettingsPacket extends DataPacket{
|
||||
return $this->canResizeCodeBuilder;
|
||||
}
|
||||
|
||||
public function disableLegacyTitleBar() : bool{ return $this->disableLegacyTitleBar; }
|
||||
|
||||
public function getPostProcessFilter() : string{ return $this->postProcessFilter; }
|
||||
|
||||
public function getScreenshotBorderResourcePath() : string{ return $this->screenshotBorderResourcePath; }
|
||||
|
||||
public function getAgentCapabilities() : ?EducationSettingsAgentCapabilities{ return $this->agentCapabilities; }
|
||||
|
||||
public function getCodeBuilderOverrideUri() : ?string{
|
||||
return $this->codeBuilderOverrideUri;
|
||||
}
|
||||
@ -71,27 +107,51 @@ class EducationSettingsPacket extends DataPacket{
|
||||
return $this->hasQuiz;
|
||||
}
|
||||
|
||||
public function getLinkSettings() : ?EducationSettingsExternalLinkSettings{ return $this->linkSettings; }
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->codeBuilderDefaultUri = $this->getString();
|
||||
$this->codeBuilderTitle = $this->getString();
|
||||
$this->canResizeCodeBuilder = $this->getBool();
|
||||
$this->disableLegacyTitleBar = $this->getBool();
|
||||
$this->postProcessFilter = $this->getString();
|
||||
$this->screenshotBorderResourcePath = $this->getString();
|
||||
$this->agentCapabilities = $this->getBool() ? EducationSettingsAgentCapabilities::read($this) : null;
|
||||
if($this->getBool()){
|
||||
$this->codeBuilderOverrideUri = $this->getString();
|
||||
}else{
|
||||
$this->codeBuilderOverrideUri = null;
|
||||
}
|
||||
$this->hasQuiz = $this->getBool();
|
||||
$this->linkSettings = $this->getBool() ? EducationSettingsExternalLinkSettings::read($this) : null;
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putString($this->codeBuilderDefaultUri);
|
||||
$this->putString($this->codeBuilderTitle);
|
||||
$this->putBool($this->canResizeCodeBuilder);
|
||||
$this->putBool($this->disableLegacyTitleBar);
|
||||
$this->putString($this->postProcessFilter);
|
||||
$this->putString($this->screenshotBorderResourcePath);
|
||||
$agentCapabilities = $this->agentCapabilities;
|
||||
if($agentCapabilities !== null){
|
||||
$this->putBool(true);
|
||||
$agentCapabilities->write($this);
|
||||
}else{
|
||||
$this->putBool(false);
|
||||
}
|
||||
$this->putBool($this->codeBuilderOverrideUri !== null);
|
||||
if($this->codeBuilderOverrideUri !== null){
|
||||
$this->putString($this->codeBuilderOverrideUri);
|
||||
}
|
||||
$this->putBool($this->hasQuiz);
|
||||
$linkSettings = $this->linkSettings;
|
||||
if($linkSettings !== null){
|
||||
$this->putBool(true);
|
||||
$linkSettings->write($this);
|
||||
}else{
|
||||
$this->putBool(false);
|
||||
}
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $handler) : bool{
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user