Compare commits

..

135 Commits

Author SHA1 Message Date
a7cd081002 Release 3.19.1 2021-04-25 20:34:13 +01:00
361be8fe36 Normal: drop MOUNTAINS and SMALL_MOUNTAINS from biome selection
this would cause disruption to generation on a patch release, which is unacceptable.
This would be better for 3.20 or 4.0.
2021-04-25 20:27:19 +01:00
b01e4ab417 Bump phpstan/phpstan from 0.12.83 to 0.12.84 (#4189) 2021-04-21 18:49:08 +00:00
177b963d8e TaskScheduler: do not push cancelled repeating tasks back onto the queue 2021-04-19 13:23:31 +01:00
8d1a1628de Item: Remove "ench" tag when all enchantments are removed from an item (#4184)
fixes #4144
2021-04-18 20:56:07 +01:00
6f80b8979d Particle: added some missing IDs 2021-04-16 18:20:47 +01:00
3c8eb29d4e Limit blockitem metadata hack to just blockitems
for some reason putting NBT on some items makes the creative inventory go haywire. Sadly, we currently need this hack, so I limit it to only stuff which actually needs it (blockitems).
closes #4159
2021-04-16 00:41:19 +01:00
b94bbf6f5e Merge branch 'stable' of github.com:pmmp/PocketMine-MP into stable 2021-04-16 00:11:01 +01:00
314a8a1297 protocol: updated particle type constants
closes #4173
2021-04-16 00:10:48 +01:00
547503e8f4 Normal: Fixed bug that never lets mountainous terrain generate (#4170) 2021-04-13 17:56:57 +01:00
f74ff1fcd4 Bump adhocore/json-comment from 1.1.0 to 1.1.2 (#4158)
Bumps [adhocore/json-comment](https://github.com/adhocore/php-json-comment) from 1.1.0 to 1.1.2.
- [Release notes](https://github.com/adhocore/php-json-comment/releases)
- [Changelog](https://github.com/adhocore/php-json-comment/blob/main/CHANGELOG.md)
- [Commits](https://github.com/adhocore/php-json-comment/compare/1.1.0...1.1.2)

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

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
2021-04-11 16:03:41 +01:00
6c351357ab NetworkBinaryStream: bail if finding unexpected trailing data on item extradata
this may help to discover additional bugs and/or missing data on items that we don't know about yet.
2021-04-11 16:02:41 +01:00
3433406cff 3.19.1 is next 2021-04-07 19:03:36 +01:00
b307cd0aa1 Release 3.19.0 2021-04-07 19:03:36 +01:00
c9b83d7276 Protocol changes for 1.16.220 2021-04-07 18:59:01 +01:00
e22b6ff566 Revert "Revert "Backport InventoryTransactionPacket impl from PM4""
This reverts commit c7cdaeae85.
2021-04-07 18:42:07 +01:00
af88f49a21 3.18.3 is next 2021-04-07 18:32:14 +01:00
599d5253db Release 3.18.2 2021-04-07 18:32:10 +01:00
54cb5ee0fa ItemTranslator: ensure that the correct meta value is returned after translation
-1 is a PM-specific thing. Right now there is a hack in the NetworkBinaryStream which prevents this from becoming a problem, but that might not be the case in future.
2021-04-07 13:10:29 +01:00
cdae8b42eb Bump adhocore/json-comment to ^1.1.0, new version strips trailing comma as well (#4146) 2021-04-06 11:58:23 +01:00
Ali
a45a4a91ae Call InventoryCloseEvent in Player::removeWindow() (#4142)
closes #4130
2021-04-04 01:07:58 +01:00
21378b7f27 Regenerate PHPStan baselines
this should be the last time we get baselines randomly rearranging themselves on changes ...
2021-04-03 22:36:15 +01:00
502aed41b0 phpstan 0.12.83 2021-04-03 22:34:48 +01:00
125837324f Player: don't dump cursor contents on mouseover interaction
this can fire while the player has the inventory window open, because it also gets sent when the player swaps their held itemstack for something new.

We already had a special-case for mouseover with entity ID 0, but since
this isn't just a zero problem, a more general fix suits better
(particularly since we might need to handle the 0 case anyway).

closes #4140
closes #4141
2021-04-02 21:35:38 +01:00
Ali
609dff1aae Player: Revert invalid attempts to toggle flight, instead of kicking (#4139)
If allowFlight was toggled by the server (e.g. due to gamemode change), a race could occur due to network latency where the client could try to enable flight, and then get kicked for cheating.

Since this can happen in legitimate, non-cheating cases, we can't make any assumptions about whether a player is cheating, so instead we just revert it, like we do with every other bad input.
2021-04-01 17:57:26 +01:00
b03212053c 3.18.2 is next 2021-03-28 21:24:07 +01:00
fd4ac885bb Release 3.18.1 2021-03-28 21:24:03 +01:00
f35886f18a Updated composer dependencies 2021-03-28 21:14:02 +01:00
a9eaa55427 actions: added a php-cs-fixer run 2021-03-28 20:38:56 +01:00
5c41f79be4 Added php-cs-fixer configuration
this is by no means a complete code style guide, but it fixes a lot of common issues that show up, particularly in PRs.
2021-03-28 19:21:41 +01:00
34c2b62ffe Remove unused import 2021-03-28 19:12:18 +01:00
e42a691da9 Strip trailing whitespace 2021-03-28 19:02:51 +01:00
Ali
3b3fb5e662 fix ItemFrames (#4101)
removing items from item frames was broken due to behavioural changes in 1.16.210.
2021-03-28 18:53:46 +01:00
01ffe8bf57 Updated build/php submodule to pmmp/php-build-scripts@c64baa0f1c 2021-03-28 18:14:40 +01:00
4abf4aecad MainLogger: fixed potential deadlock during syncFlushBuffer()
the notify() to flush the buffer might arrive in between the writeLogStream() and synchronized() calls in the thread body, resulting in a deadlock if the logger thread managed to call wait() before the main thread did.
2021-03-28 18:10:23 +01:00
b29f83ee99 Added preprocessor test build job to Actions
this should catch problems like the one that broke 3.17.6 at the root.
2021-03-25 01:25:04 +00:00
4bc57f00b8 Updated LevelSoundEventPacket constants 2021-03-23 23:36:48 +00:00
ff61e1e018 ClientCacheBlobStatusPacket: fixed field order
miss comes first, not hit.
2021-03-23 19:52:25 +00:00
fb20bb3832 Don't handle NAN/INF in movements 2021-03-23 14:54:39 +00:00
3333df31df Bump phpunit/phpunit from 9.5.3 to 9.5.4 (#4104)
Bumps [phpunit/phpunit](https://github.com/sebastianbergmann/phpunit) from 9.5.3 to 9.5.4.
- [Release notes](https://github.com/sebastianbergmann/phpunit/releases)
- [Changelog](https://github.com/sebastianbergmann/phpunit/blob/master/ChangeLog-9.5.md)
- [Commits](https://github.com/sebastianbergmann/phpunit/compare/9.5.3...9.5.4)

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

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
2021-03-23 13:53:45 +00:00
c09fcb2df2 Merge branch 'stable' of github.com:pmmp/PocketMine-MP into stable 2021-03-22 21:22:56 +00:00
c7cdaeae85 Revert "Backport InventoryTransactionPacket impl from PM4"
This reverts commit cb06be615a.

we can't push this to stable because it would break plugins without any
way to know (no protocol or API change).

At most, this should have been wrapped into a protocol change.
2021-03-22 21:21:11 +00:00
4416cd5a28 Bump phpstan/phpstan from 0.12.81 to 0.12.82 (#4088)
Bumps [phpstan/phpstan](https://github.com/phpstan/phpstan) from 0.12.81 to 0.12.82.
- [Release notes](https://github.com/phpstan/phpstan/releases)
- [Commits](https://github.com/phpstan/phpstan/compare/0.12.81...0.12.82)

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

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
2021-03-22 13:26:07 +00:00
cb93095857 [ci skip] readme: added link to devdoc.pmmp.io 2021-03-21 16:59:58 +00:00
c8f396ecbc [ci skip] doxygen: link to devdoc.pmmp.io instead of the github repo 2021-03-21 16:56:23 +00:00
cb06be615a Backport InventoryTransactionPacket impl from PM4
this version is far better, and we're going to need it to deal with the PlayerAuthInputPacket bullshit.
2021-03-19 22:16:30 +00:00
0d3c11699c Clean up PHPStan baselines 2021-03-19 22:14:07 +00:00
3667e95ff6 Added PlayerAuthInputFlags 2021-03-19 21:41:22 +00:00
0e2dc51ec8 added some missing things to the protocol 2021-03-19 21:09:53 +00:00
eaf85b028a fix prebuilt binaries link (#4090) 2021-03-19 20:42:21 +00:00
9479a1a0ab Bump phpunit/phpunit from 9.5.2 to 9.5.3 (#4084)
Bumps [phpunit/phpunit](https://github.com/sebastianbergmann/phpunit) from 9.5.2 to 9.5.3.
- [Release notes](https://github.com/sebastianbergmann/phpunit/releases)
- [Changelog](https://github.com/sebastianbergmann/phpunit/blob/master/ChangeLog-9.5.md)
- [Commits](https://github.com/sebastianbergmann/phpunit/compare/9.5.2...9.5.3)

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

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
2021-03-17 14:08:44 +00:00
1bb2d162ab Simplify CommandReader
while stream_select() doesn't work on pipes, if it ever starts working properly in the future, we'll need this code. In the meantime, it's harmless (it just immediately returns 1 anyway).
2021-03-16 21:42:35 +00:00
ee868bcccc update argument type constants (#4082) 2021-03-15 18:22:01 +00:00
cbc8576d4a Implement UPnP support without dotNET (#3378)
UPnP forwarding is now available on all supported platforms.
com_dotnet is no longer required for UPnP forwarding to work.

Closes #3216 .
2021-03-14 22:50:33 +00:00
edcf296086 RakLibInterface: fixed server being unjoinable if gamemode is Spectator
closes #4069
this happens because the client bans any server that has an invalid pong, which is very stupid in this case because the gamemode isn't even shown on the UI anyway ...
2021-03-14 20:35:17 +00:00
9e27c47116 Merge branch 'stable' of github.com:pmmp/PocketMine-MP into stable 2021-03-12 22:08:20 +00:00
a0368a843e 3.18.1 is next 2021-03-12 22:07:01 +00:00
3f64906263 Release 3.18.0 2021-03-12 22:07:01 +00:00
19bb8a00df Updated PHPStan baselines 2021-03-12 22:05:15 +00:00
4816a66fb8 Baseline protocol changes for 1.16.210
this is not a complete changeset, but it's sufficient to get servers back online.
There are additional changes to PlayerAuthInputPacket which need to be reversed.
2021-03-12 21:41:48 +00:00
06f4e1e4c2 Bump phpstan/phpstan from 0.12.80 to 0.12.81 (#4063) 2021-03-11 00:33:05 +00:00
5b8166c1f0 3.17.8 is next 2021-03-11 00:22:17 +00:00
30c5cad5b3 Release 3.17.7 2021-03-11 00:22:17 +00:00
a7a7fe3895 Merge branch 'stable' of github.com:pmmp/PocketMine-MP into stable 2021-03-11 00:15:48 +00:00
55ac2f07dc Updated PreProcessor submodule to pmmp/PreProcessor@1b9304de61 2021-03-11 00:15:33 +00:00
0660888029 Updated NBT dependency (again) 2021-03-11 00:15:00 +00:00
0476e6bcfc Updated PreProcessor submodule to pmmp/PreProcessor@934f92d388 2021-03-10 23:33:45 +00:00
72bd37e442 Updated PreProcessor submodule to pmmp/PreProcessor@652c6d8b4c 2021-03-10 23:02:47 +00:00
f95fcecb5b 3.17.7 is next 2021-03-10 20:49:10 +00:00
61391b6e23 Release 3.17.6 2021-03-10 20:48:57 +00:00
fbb6f1f81c Workaround for cursor sync in 1.13+, closes #4059 2021-03-07 21:17:52 +00:00
712df04bc4 Updated NBT dependency to 0.2.17 2021-03-07 21:06:08 +00:00
1563e25378 Updated composer dependencies 2021-03-07 19:57:16 +00:00
ed84252942 Player: Improved XUID verification
we check if an existing player is online with a matching XUID first; if there isn't, we don't bother loading the playerdata, since that other player couldn't have joined unless they had a match or were allowed to bypass.
2021-03-07 19:53:19 +00:00
3d90625020 Revert "Revert "Use PHP 7.4.16 for Actions""
This reverts commit 9f6b914925.
2021-03-07 16:37:33 +00:00
9f6b914925 Revert "Use PHP 7.4.16 for Actions"
This reverts commit 0e614ea8fd.

apparently php-build doesn't have 7.4.16 yet ...
2021-03-06 00:41:19 +00:00
0e614ea8fd Use PHP 7.4.16 for Actions 2021-03-06 00:32:56 +00:00
401bd09d60 Bump phpstan/phpstan from 0.12.79 to 0.12.80 (#4054) 2021-03-01 16:56:23 +00:00
649671cc69 Bump phpstan/phpstan from 0.12.78 to 0.12.79 (#4051) 2021-02-27 17:42:19 +00:00
e755e1dc23 ResourcePackClientResponsePacket: fixed non-deterministic decoding 2021-02-27 01:08:18 +00:00
e34a444dde Bump phpstan/phpstan from 0.12.77 to 0.12.78 (#4046) 2021-02-26 00:34:38 +00:00
78f9985377 Player: fixed PlayerMoveEvent->getFrom() returning unexpected results on movement reversion
fixes #4043
2021-02-26 00:30:42 +00:00
fac2bd3379 Liquid: mark getSmallestFlowDecay() as impure
this fixes two bogus PHPStan warnings.
2021-02-25 22:41:07 +00:00
fcfd51dfc7 CrashDump: do not put FALSE into crashdumps in case file_get_contents() failed 2021-02-23 19:39:21 +00:00
ccc76cf338 Make less noise about XBL being enabled
this has been in force for years now, it's expected by now.
2021-02-23 19:25:22 +00:00
10a73488ed Merge branch 'stable' of https://github.com/pmmp/pocketmine-mp into stable 2021-02-22 16:43:51 +00:00
9c5114084b Updated Snooze to fix race conditions 2021-02-22 16:42:54 +00:00
11630ab1aa Bump phpstan/phpstan from 0.12.76 to 0.12.77 (#4041) 2021-02-18 11:34:42 +00:00
a3068b39a2 Update composer dependencies 2021-02-16 22:31:01 +00:00
edbc73a72c 3.17.6 is next 2021-02-16 22:13:05 +00:00
3a0c8dd594 Release 3.17.5 2021-02-16 22:13:05 +00:00
16fa26405a Remove remaining usages of LevelDB::close()
this is handled by the object destructor.

closes #4035
2021-02-15 20:10:11 +00:00
57423540f0 BUILDING.md: Document server-phar.php's compression bug (#4037)
This bug is not fixable on PM's side because the fault lies with php-src. It was fixed recently in 1bb2a4f91c.
2021-02-15 19:53:44 +00:00
8f8821c904 Bump phpstan/phpstan from 0.12.75 to 0.12.76 (#4038) 2021-02-15 11:25:36 +00:00
094102fe92 fopen() might return FALSE if permission was denied to read/write the file 2021-02-12 16:16:36 +00:00
2aef83e7d7 MainLogger: fix type ambiguity 2021-02-12 15:05:24 +00:00
5c3e78e1d3 Bump phpstan/phpstan from 0.12.74 to 0.12.75 (#4033) 2021-02-12 14:58:01 +00:00
18666e5a60 Be compatible with newest versions of php-leveldb 2021-02-11 22:33:29 +00:00
f72163c173 Fixed build not failing when PHP build gets borked 2021-02-11 17:06:03 +00:00
7407e504b6 actions: bump PHP versions to 7.3.27 and 7.4.15 2021-02-11 16:35:19 +00:00
0e396dc47d actions: update PHP extension versions 2021-02-11 16:24:09 +00:00
d2204da1d5 [ci skip] center the build badges 2021-02-11 16:05:55 +00:00
2a51269305 Merge branch 'stable' of https://github.com/pmmp/pocketmine-mp into stable 2021-02-11 16:05:24 +00:00
928041ddf1 Bump phpstan/phpstan from 0.12.71 to 0.12.74 (#4028)
Bumps [phpstan/phpstan](https://github.com/phpstan/phpstan) from 0.12.71 to 0.12.74.
- [Release notes](https://github.com/phpstan/phpstan/releases)
- [Commits](https://github.com/phpstan/phpstan/compare/0.12.71...0.12.74)

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

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
2021-02-08 21:42:08 +00:00
007f4f9350 CraftingDataPacket: Remove useless @var comment 2021-02-08 11:53:50 +00:00
46e9f0cec6 Player: fixed verify-xuid not kicking in by default on old configs 2021-02-07 21:10:23 +00:00
606d56b55d Composer: lock in PHP at ^7.3 || ^8.0, don't leave it unbounded 2021-02-07 17:31:32 +00:00
78a62a8b27 Remember and verify player XUIDs (controlled by player.verify-xuid in pocketmine.yml) 2021-02-05 14:42:57 +00:00
c5bdd7dd64 Added a unit test to ensure valid format of MINECRAFT_VERSION_NETWORK 2021-02-04 22:36:40 +00:00
8ee37a3033 Bump phpunit/phpunit from 9.5.1 to 9.5.2 (#4023) 2021-02-04 16:46:22 +00:00
7e3e63f342 Fixed race condition in MainLogger shutdown
this resulted in a deadlock in https://github.com/pmmp/PocketMine-MP/runs/1831812620?check_suite_focus=true because the notify() arrived while writeLogStream() was executing.
This ensures that either:
- the notification will occur before the sleep, and therefore no sleeping will occur (this->shutdown = true before the wait)
- the notification will arrive during the sleep.
2021-02-04 16:40:10 +00:00
8ef1e54e20 MainLogger: fixing CPU waste on logger thread
this doesn't need to keep spinning every 25ms; it can just wake up when there's actually log messages to write into the buffer.
2021-02-04 15:07:40 +00:00
eaf3a86981 MainLogger: fixed UB in writeLogStream()
notify() has to be used inside a synchronized block.
2021-02-04 15:03:14 +00:00
317a48d9b0 ItemStackRequest: expose filterStrings 2021-02-03 23:40:34 +00:00
bc14660e55 Added missing ItemStackRequest protocol changes 2021-02-03 23:37:41 +00:00
b1bb9fbd1c Reinstall PHP deps on cache hit
the 20.04 actions image doesn't have libzip5 and who knows what else is missing ...
2021-02-03 17:42:11 +00:00
96181f8cf5 Version PHP build caches by image version
we can't safely use `ubuntu-latest` because the build caches will break if they were built for 18.04 and used on 20.04, or vice versa. Instead, we pin the images (and caches) to a specific version.
2021-02-03 17:24:50 +00:00
4771e3dc28 3.17.5 is next 2021-02-02 14:04:51 +00:00
2e9117d102 Release 3.17.4 2021-02-02 14:04:50 +00:00
06493da7d9 Imports cleanup 2021-02-02 13:58:07 +00:00
bd303b1062 RegionLoader: fixed flaky region header validation since 3.17.3 2021-02-02 13:43:52 +00:00
fe731b9018 Added failing test case for region header validation
fucking PHP... what genius thought it was a good idea to cache file stats without even an attempt at keeping the cache up to date on modifications?
2021-02-02 13:43:12 +00:00
1a24afc6d1 InventoryTransaction: Fixed indexes persisting from balance calculation in crafting input/outputs
fixes #4019
the order of the actual items may not be the same across runs, but index 0 will at least be sure to exist.
2021-02-02 00:13:58 +00:00
bef906b0f0 phpstan 0.12.71 2021-02-02 00:05:53 +00:00
37e8dd6444 Fix PHP 8 optional before required parameters deprecation warnings (#4016) 2021-01-31 12:08:47 +00:00
02ee0f23c0 Removed old support requests configuration 2021-01-27 22:53:37 +00:00
cda472333c Add workflow for dessant/support-requests
we're using the legacy github app right now.
2021-01-27 22:47:33 +00:00
47cf58be8a phpstan 0.12.70 2021-01-27 20:11:37 +00:00
ccf9691927 Bump phpunit/phpunit from 9.5.0 to 9.5.1 (#4010) 2021-01-27 19:28:36 +00:00
16fa958416 phpstan: better hack for any-callable parameters
variadics are a bad fit for this because what we really need is to accept callable with any number of arguments. LSP requires that the provided number of arguments must be >= than the required number of arguments.
2021-01-27 19:25:28 +00:00
bac57c159f Player: fix bridging, towering and various other fast building bugs
clickPos is relative to the base block position, so if you keep aiming at the same spot on the block and jump, it thinks you're still spamming.
closes #2730
2021-01-27 00:11:14 +00:00
38b2d83799 MemoryManager: fixed protected properties being dumped multiple times
we don't need to scan the parent classes for anything other than private properties, because protected and public properties will appear on the main reflection as if they were declared directly as such.
2021-01-26 20:32:23 +00:00
c134b1cd8a [ci skip] README: add some badges 2021-01-26 17:34:05 +00:00
62deafda48 CommandReader: removed readline support
readline has been borked for a long time and it's not thread safe.
2021-01-25 17:53:25 +00:00
31b6df4376 3.17.4 is next 2021-01-25 17:15:43 +00:00
103 changed files with 3547 additions and 1987 deletions

16
.github/support.yml vendored
View File

@ -1,16 +0,0 @@
# Configuration for support-requests - https://github.com/dessant/support-requests
# Label used to mark issues as support requests
supportLabel: "Support request"
# Comment to post on issues marked as support requests. Add a link
# to a support page, or set to `false` to disable
supportComment: >
Thanks, but this issue tracker is not intended for support requests. Please read the guidelines on [submitting an issue](https://github.com/pmmp/PocketMine-MP/blob/master/CONTRIBUTING.md#creating-an-issue).
[Docs](https://pmmp.rtfd.io) | [Discord](https://discord.gg/bmSAZBG) | [Forums](https://forums.pmmp.io)
# Whether to close issues marked as support requests
close: true
# Whether to lock issues marked as support requests
lock: false

View File

@ -8,11 +8,12 @@ on:
jobs:
build-php:
name: Prepare PHP
runs-on: ubuntu-latest
runs-on: ${{ matrix.image }}
strategy:
matrix:
php: [7.3.25, 7.4.13]
image: [ubuntu-20.04]
php: [7.3.27, 7.4.16]
steps:
- uses: actions/checkout@v2 #needed for build.sh
@ -21,7 +22,7 @@ jobs:
uses: actions/cache@v2
with:
path: "./bin"
key: "php-build-generic-${{ matrix.php }}-${{ hashFiles('./tests/gh-actions/build.sh') }}"
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'
@ -30,12 +31,13 @@ jobs:
phpstan:
name: PHPStan analysis
needs: build-php
runs-on: ubuntu-latest
runs-on: ${{ matrix.image }}
strategy:
fail-fast: false
matrix:
php: [7.3.25, 7.4.13]
image: [ubuntu-20.04]
php: [7.3.27, 7.4.16]
steps:
- uses: actions/checkout@v2
@ -45,12 +47,16 @@ jobs:
uses: actions/cache@v2
with:
path: "./bin"
key: "php-build-generic-${{ matrix.php }}-${{ hashFiles('./tests/gh-actions/build.sh') }}"
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
@ -76,11 +82,12 @@ jobs:
phpunit:
name: PHPUnit tests
needs: build-php
runs-on: ubuntu-latest
runs-on: ${{ matrix.image }}
strategy:
fail-fast: false
matrix:
php: [7.3.25, 7.4.13]
image: [ubuntu-20.04]
php: [7.3.27, 7.4.16]
steps:
- uses: actions/checkout@v2
@ -90,12 +97,16 @@ jobs:
uses: actions/cache@v2
with:
path: "./bin"
key: "php-build-generic-${{ matrix.php }}-${{ hashFiles('./tests/gh-actions/build.sh') }}"
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
@ -121,11 +132,12 @@ jobs:
integration:
name: Integration tests
needs: build-php
runs-on: ubuntu-latest
runs-on: ${{ matrix.image }}
strategy:
fail-fast: false
matrix:
php: [7.3.25, 7.4.13]
image: [ubuntu-20.04]
php: [7.3.27, 7.4.16]
steps:
- uses: actions/checkout@v2
@ -137,12 +149,16 @@ jobs:
uses: actions/cache@v2
with:
path: "./bin"
key: "php-build-generic-${{ matrix.php }}-${{ hashFiles('./tests/gh-actions/build.sh') }}"
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
@ -164,3 +180,102 @@ 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: [7.3.27, 7.4.16]
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Restore PHP build cache
id: php-build-cache
uses: actions/cache@v2
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
- 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" --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.9.0
with:
php-version: 7.4
tools: php-cs-fixer
- name: Run PHP-CS-Fixer
run: php-cs-fixer fix --dry-run --diff --diff-format=udiff

22
.github/workflows/support.yml vendored Normal file
View File

@ -0,0 +1,22 @@
name: 'Manage support request issues'
on:
issues:
types: [labeled, unlabeled, reopened]
jobs:
support:
runs-on: ubuntu-latest
steps:
- uses: dessant/support-requests@v2
with:
github-token: ${{ github.token }}
support-label: "Support request"
issue-comment: >
Thanks, but this issue tracker is not intended for support requests. Please read the guidelines on [submitting an issue](https://github.com/pmmp/PocketMine-MP/blob/master/CONTRIBUTING.md#creating-an-issue).
[Docs](https://pmmp.rtfd.io) | [Discord](https://discord.gg/bmSAZBG) | [Forums](https://forums.pmmp.io)
close-issue: true
lock-issue: false

71
.php_cs Normal file
View File

@ -0,0 +1,71 @@
<?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 PhpCsFixer\Config::create()
->setRiskyAllowed(true)
->setRules([
'align_multiline_comment' => [
'comment_type' => 'phpdocs_only'
],
'array_indentation' => true,
'array_syntax' => [
'syntax' => 'short'
],
'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'
],
'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_trim' => true,
'phpdoc_trim_consecutive_blank_line_separation' => true,
'single_import_per_statement' => true,
'strict_param' => true,
])
->setFinder($finder)
->setIndent("\t")
->setLineEnding("\n");

View File

@ -8,7 +8,7 @@
## 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-7.4-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`.
@ -34,5 +34,11 @@ Run `composer make-server` using your preferred PHP binary. It'll drop a `Pocket
You can also use the `--out` option to change the output filename.
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.
## Running PocketMine-MP from source code
Run `src/pocketmine/PocketMine.php` using your preferred PHP binary.

View File

@ -3,7 +3,12 @@
<b>A highly customisable, open source server software for Minecraft: Bedrock Edition written in PHP</b>
</p>
![CI](https://github.com/pmmp/PocketMine-MP/workflows/CI/badge.svg)
<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>
<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>
## Getting started
- [Documentation](http://pmmp.readthedocs.org/)
@ -18,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

View File

@ -71,7 +71,7 @@ function main(array $argv) : void{
$versionInfoPath = dirname(__DIR__) . '/src/pocketmine/VersionInfo.php';
replaceVersion($versionInfoPath, $currentVer->getBaseVersion(), false);
echo "please add appropriate notes to the changelog and press enter...";
fgets(STDIN);
system('git add "' . dirname(__DIR__) . '/changelogs"');

View File

@ -32,3 +32,32 @@ Plugin developers should **only** update their required API to this version if y
- Improved performance of region header validation in Region-based worlds (indirect improvement to chunk loading performance).
- Fixed some PHP 8.0 language-level compatibility issues.
- Source installations will now exit with an error when Composer dependencies are not in sync with the current Git revision. Now, it's required to run `composer install` after every git pull to make sure the correct dependency versions are installed.
# 3.17.4
- Removed `readline` support. This hasn't been maintained for many years, never worked correctly, and isn't thread-safe in any case.
- Fixed false-positives of region corruption in Region-based worlds (outdated file stat cache).
- Fixed more deprecation warnings on PHP 8.0 (optional parameter before required).
- `CraftItemEvent->getInputs()` now returns a list starting at offset 0, instead of random offsets. (Note that the contents still won't be ordered.)
- `CraftItemEvent->getOutputs()` now returns a list starting at offset 0, instead of random offsets. (Note that the contents still won't be ordered.)
- Fixed a bug that broke synchronized building, bridging, towering and more.
- Objects in memory dumps no longer show inherited properties multiple times.
# 3.17.5
- Reduced CPU wastage by the logger thread.
- Fixed LevelDB deprecation errors on PHP 8.0.
- 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
View 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.

23
changelogs/3.19.md Normal file
View File

@ -0,0 +1,23 @@
**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).

View File

@ -5,10 +5,10 @@
"homepage": "https://pmmp.io",
"license": "LGPL-3.0",
"require": {
"php": ">=7.3.0",
"php": "^7.3 || ^8.0",
"php-64bit": "*",
"ext-curl": "*",
"ext-ctype": "*",
"ext-curl": "*",
"ext-date": "*",
"ext-hash": "*",
"ext-json": "*",
@ -18,26 +18,27 @@
"ext-phar": "*",
"ext-pthreads": "~3.2.0",
"ext-reflection": "*",
"ext-simplexml": "*",
"ext-sockets": "*",
"ext-spl": "*",
"ext-yaml": ">=2.0.0",
"ext-zip": "*",
"ext-zlib": ">=1.2.11",
"pocketmine/raklib": "^0.12.7",
"pocketmine/spl": "^0.4.0",
"composer-runtime-api": "^2.0",
"adhocore/json-comment": "^1.1",
"pocketmine/binaryutils": "^0.1.9",
"pocketmine/nbt": "^0.2.10",
"pocketmine/math": "^0.2.0",
"pocketmine/snooze": "^0.1.0",
"pocketmine/callback-validator": "^1.0.2",
"pocketmine/classloader": "^0.1.0",
"pocketmine/log": "^0.2.0",
"pocketmine/log-pthreads": "^0.1.0",
"pocketmine/callback-validator": "^1.0.2",
"adhocore/json-comment": "^0.1.0",
"composer-runtime-api": "^2.0"
"pocketmine/math": "^0.2.0",
"pocketmine/nbt": "^0.2.18",
"pocketmine/raklib": "^0.12.7",
"pocketmine/snooze": "^0.1.0",
"pocketmine/spl": "^0.4.0"
},
"require-dev": {
"phpstan/phpstan": "0.12.69",
"phpstan/phpstan": "0.12.84",
"phpstan/phpstan-phpunit": "^0.12.6",
"phpstan/phpstan-strict-rules": "^0.12.2",
"phpunit/phpunit": "^9.2"

175
composer.lock generated
View File

@ -4,27 +4,28 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "5466cbf8934081309e4c8ad5c2781f65",
"content-hash": "8c9701fdb696fe1cd1952aa273f1bfa6",
"packages": [
{
"name": "adhocore/json-comment",
"version": "0.1.0",
"version": "1.1.2",
"source": {
"type": "git",
"url": "https://github.com/adhocore/php-json-comment.git",
"reference": "8448076039389f558f39ad0553aab87db3f81614"
"reference": "fc2f76979f0a44a5f5bc2a2b600d0762fe0e78e7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/adhocore/php-json-comment/zipball/8448076039389f558f39ad0553aab87db3f81614",
"reference": "8448076039389f558f39ad0553aab87db3f81614",
"url": "https://api.github.com/repos/adhocore/php-json-comment/zipball/fc2f76979f0a44a5f5bc2a2b600d0762fe0e78e7",
"reference": "fc2f76979f0a44a5f5bc2a2b600d0762fe0e78e7",
"shasum": ""
},
"require": {
"php": ">=5.4"
"ext-ctype": "*",
"php": ">=7.0"
},
"require-dev": {
"phpunit/phpunit": "^6.5 || ^7.5"
"phpunit/phpunit": "^6.5 || ^7.5 || ^8.5"
},
"type": "library",
"autoload": {
@ -50,9 +51,15 @@
],
"support": {
"issues": "https://github.com/adhocore/php-json-comment/issues",
"source": "https://github.com/adhocore/php-json-comment/tree/0.1.0"
"source": "https://github.com/adhocore/php-json-comment/tree/1.1.2"
},
"time": "2020-01-03T13:51:23+00:00"
"funding": [
{
"url": "https://paypal.me/ji10",
"type": "custom"
}
],
"time": "2021-04-09T03:06:06+00:00"
},
{
"name": "pocketmine/binaryutils",
@ -315,16 +322,16 @@
},
{
"name": "pocketmine/nbt",
"version": "0.2.16",
"version": "0.2.18",
"source": {
"type": "git",
"url": "https://github.com/pmmp/NBT.git",
"reference": "be6d54a8a314967d938b501eee49d4641e2ab07d"
"reference": "9f82ca4d7f97fcd9a566e44b63c4f18a7657ae82"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pmmp/NBT/zipball/be6d54a8a314967d938b501eee49d4641e2ab07d",
"reference": "be6d54a8a314967d938b501eee49d4641e2ab07d",
"url": "https://api.github.com/repos/pmmp/NBT/zipball/9f82ca4d7f97fcd9a566e44b63c4f18a7657ae82",
"reference": "9f82ca4d7f97fcd9a566e44b63c4f18a7657ae82",
"shasum": ""
},
"require": {
@ -336,7 +343,7 @@
"require-dev": {
"irstea/phpunit-shim": "^7.5 || ^8.0",
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "0.12.67",
"phpstan/phpstan": "0.12.80",
"phpstan/phpstan-strict-rules": "^0.12.4"
},
"type": "library",
@ -352,22 +359,22 @@
"description": "PHP library for working with Named Binary Tags",
"support": {
"issues": "https://github.com/pmmp/NBT/issues",
"source": "https://github.com/pmmp/NBT/tree/0.2.16"
"source": "https://github.com/pmmp/NBT/tree/0.2.18"
},
"time": "2021-01-15T15:27:28+00:00"
"time": "2021-03-11T00:09:04+00:00"
},
{
"name": "pocketmine/raklib",
"version": "0.12.10",
"version": "0.12.11",
"source": {
"type": "git",
"url": "https://github.com/pmmp/RakLib.git",
"reference": "48e70551cca6f2409115d3468bed94c2edd08f31"
"reference": "9cce458b8bfde3e4dfdbf70c659fc7b7fe26b5c4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pmmp/RakLib/zipball/48e70551cca6f2409115d3468bed94c2edd08f31",
"reference": "48e70551cca6f2409115d3468bed94c2edd08f31",
"url": "https://api.github.com/repos/pmmp/RakLib/zipball/9cce458b8bfde3e4dfdbf70c659fc7b7fe26b5c4",
"reference": "9cce458b8bfde3e4dfdbf70c659fc7b7fe26b5c4",
"shasum": ""
},
"require": {
@ -382,7 +389,7 @@
"pocketmine/snooze": "^0.1.0"
},
"require-dev": {
"phpstan/phpstan": "0.12.67",
"phpstan/phpstan": "0.12.76",
"phpstan/phpstan-strict-rules": "^0.12.2"
},
"type": "library",
@ -398,22 +405,22 @@
"description": "A RakNet server implementation written in PHP",
"support": {
"issues": "https://github.com/pmmp/RakLib/issues",
"source": "https://github.com/pmmp/RakLib/tree/0.12.10"
"source": "https://github.com/pmmp/RakLib/tree/0.12.11"
},
"time": "2021-01-15T16:19:15+00:00"
"time": "2021-02-15T11:21:05+00:00"
},
{
"name": "pocketmine/snooze",
"version": "0.1.4",
"version": "0.1.5",
"source": {
"type": "git",
"url": "https://github.com/pmmp/Snooze.git",
"reference": "382ab149f01ecca0a57f999ff5d7fc9e271c3268"
"reference": "70b5e7937a06878dd321a3182ceb76d56298f2cd"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pmmp/Snooze/zipball/382ab149f01ecca0a57f999ff5d7fc9e271c3268",
"reference": "382ab149f01ecca0a57f999ff5d7fc9e271c3268",
"url": "https://api.github.com/repos/pmmp/Snooze/zipball/70b5e7937a06878dd321a3182ceb76d56298f2cd",
"reference": "70b5e7937a06878dd321a3182ceb76d56298f2cd",
"shasum": ""
},
"require": {
@ -422,7 +429,7 @@
},
"require-dev": {
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "0.12.67",
"phpstan/phpstan": "0.12.76",
"phpstan/phpstan-strict-rules": "^0.12.4"
},
"type": "library",
@ -438,9 +445,9 @@
"description": "Thread notification management library for code using the pthreads extension",
"support": {
"issues": "https://github.com/pmmp/Snooze/issues",
"source": "https://github.com/pmmp/Snooze/tree/0.1.4"
"source": "https://github.com/pmmp/Snooze/tree/0.1.5"
},
"time": "2021-01-15T14:44:16+00:00"
"time": "2021-02-22T16:16:12+00:00"
},
{
"name": "pocketmine/spl",
@ -726,16 +733,16 @@
},
{
"name": "phar-io/version",
"version": "3.0.4",
"version": "3.1.0",
"source": {
"type": "git",
"url": "https://github.com/phar-io/version.git",
"reference": "e4782611070e50613683d2b9a57730e9a3ba5451"
"reference": "bae7c545bef187884426f042434e561ab1ddb182"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phar-io/version/zipball/e4782611070e50613683d2b9a57730e9a3ba5451",
"reference": "e4782611070e50613683d2b9a57730e9a3ba5451",
"url": "https://api.github.com/repos/phar-io/version/zipball/bae7c545bef187884426f042434e561ab1ddb182",
"reference": "bae7c545bef187884426f042434e561ab1ddb182",
"shasum": ""
},
"require": {
@ -771,9 +778,9 @@
"description": "Library for handling version information and constraints",
"support": {
"issues": "https://github.com/phar-io/version/issues",
"source": "https://github.com/phar-io/version/tree/3.0.4"
"source": "https://github.com/phar-io/version/tree/3.1.0"
},
"time": "2020-12-13T23:18:30+00:00"
"time": "2021-02-23T14:00:09+00:00"
},
{
"name": "phpdocumentor/reflection-common",
@ -935,16 +942,16 @@
},
{
"name": "phpspec/prophecy",
"version": "1.12.2",
"version": "1.13.0",
"source": {
"type": "git",
"url": "https://github.com/phpspec/prophecy.git",
"reference": "245710e971a030f42e08f4912863805570f23d39"
"reference": "be1996ed8adc35c3fd795488a653f4b518be70ea"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpspec/prophecy/zipball/245710e971a030f42e08f4912863805570f23d39",
"reference": "245710e971a030f42e08f4912863805570f23d39",
"url": "https://api.github.com/repos/phpspec/prophecy/zipball/be1996ed8adc35c3fd795488a653f4b518be70ea",
"reference": "be1996ed8adc35c3fd795488a653f4b518be70ea",
"shasum": ""
},
"require": {
@ -996,22 +1003,22 @@
],
"support": {
"issues": "https://github.com/phpspec/prophecy/issues",
"source": "https://github.com/phpspec/prophecy/tree/1.12.2"
"source": "https://github.com/phpspec/prophecy/tree/1.13.0"
},
"time": "2020-12-19T10:15:11+00:00"
"time": "2021-03-17T13:42:18+00:00"
},
{
"name": "phpstan/phpstan",
"version": "0.12.69",
"version": "0.12.84",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan.git",
"reference": "8f436ea35241da33487fd0d38b4bc3e6dfe30ea8"
"reference": "9c43f15da8798c8f30a4b099e6a94530a558cfd5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/8f436ea35241da33487fd0d38b4bc3e6dfe30ea8",
"reference": "8f436ea35241da33487fd0d38b4bc3e6dfe30ea8",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/9c43f15da8798c8f30a4b099e6a94530a558cfd5",
"reference": "9c43f15da8798c8f30a4b099e6a94530a558cfd5",
"shasum": ""
},
"require": {
@ -1042,7 +1049,7 @@
"description": "PHPStan - PHP Static Analysis Tool",
"support": {
"issues": "https://github.com/phpstan/phpstan/issues",
"source": "https://github.com/phpstan/phpstan/tree/0.12.69"
"source": "https://github.com/phpstan/phpstan/tree/0.12.84"
},
"funding": [
{
@ -1058,20 +1065,20 @@
"type": "tidelift"
}
],
"time": "2021-01-24T14:55:37+00:00"
"time": "2021-04-19T17:10:54+00:00"
},
{
"name": "phpstan/phpstan-phpunit",
"version": "0.12.17",
"version": "0.12.18",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan-phpunit.git",
"reference": "432575b41cf2d4f44e460234acaf56119ed97d36"
"reference": "ab44aec7cfb5cb267b8bc30a8caea86dd50d1f72"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/432575b41cf2d4f44e460234acaf56119ed97d36",
"reference": "432575b41cf2d4f44e460234acaf56119ed97d36",
"url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/ab44aec7cfb5cb267b8bc30a8caea86dd50d1f72",
"reference": "ab44aec7cfb5cb267b8bc30a8caea86dd50d1f72",
"shasum": ""
},
"require": {
@ -1111,9 +1118,9 @@
"description": "PHPUnit extensions and rules for PHPStan",
"support": {
"issues": "https://github.com/phpstan/phpstan-phpunit/issues",
"source": "https://github.com/phpstan/phpstan-phpunit/tree/0.12.17"
"source": "https://github.com/phpstan/phpstan-phpunit/tree/0.12.18"
},
"time": "2020-12-13T12:12:51+00:00"
"time": "2021-03-06T11:51:27+00:00"
},
{
"name": "phpstan/phpstan-strict-rules",
@ -1168,16 +1175,16 @@
},
{
"name": "phpunit/php-code-coverage",
"version": "9.2.5",
"version": "9.2.6",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
"reference": "f3e026641cc91909d421802dd3ac7827ebfd97e1"
"reference": "f6293e1b30a2354e8428e004689671b83871edde"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/f3e026641cc91909d421802dd3ac7827ebfd97e1",
"reference": "f3e026641cc91909d421802dd3ac7827ebfd97e1",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/f6293e1b30a2354e8428e004689671b83871edde",
"reference": "f6293e1b30a2354e8428e004689671b83871edde",
"shasum": ""
},
"require": {
@ -1233,7 +1240,7 @@
],
"support": {
"issues": "https://github.com/sebastianbergmann/php-code-coverage/issues",
"source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.5"
"source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.6"
},
"funding": [
{
@ -1241,7 +1248,7 @@
"type": "github"
}
],
"time": "2020-11-28T06:44:49+00:00"
"time": "2021-03-28T07:26:59+00:00"
},
{
"name": "phpunit/php-file-iterator",
@ -1486,16 +1493,16 @@
},
{
"name": "phpunit/phpunit",
"version": "9.5.0",
"version": "9.5.4",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "8e16c225d57c3d6808014df6b1dd7598d0a5bbbe"
"reference": "c73c6737305e779771147af66c96ca6a7ed8a741"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/8e16c225d57c3d6808014df6b1dd7598d0a5bbbe",
"reference": "8e16c225d57c3d6808014df6b1dd7598d0a5bbbe",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/c73c6737305e779771147af66c96ca6a7ed8a741",
"reference": "c73c6737305e779771147af66c96ca6a7ed8a741",
"shasum": ""
},
"require": {
@ -1573,7 +1580,7 @@
],
"support": {
"issues": "https://github.com/sebastianbergmann/phpunit/issues",
"source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.0"
"source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.4"
},
"funding": [
{
@ -1585,7 +1592,7 @@
"type": "github"
}
],
"time": "2020-12-04T05:05:53+00:00"
"time": "2021-03-23T07:16:29+00:00"
},
{
"name": "sebastian/cli-parser",
@ -2553,7 +2560,7 @@
},
{
"name": "symfony/polyfill-ctype",
"version": "v1.22.0",
"version": "v1.22.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-ctype.git",
@ -2612,7 +2619,7 @@
"portable"
],
"support": {
"source": "https://github.com/symfony/polyfill-ctype/tree/v1.22.0"
"source": "https://github.com/symfony/polyfill-ctype/tree/v1.22.1"
},
"funding": [
{
@ -2682,30 +2689,35 @@
},
{
"name": "webmozart/assert",
"version": "1.9.1",
"version": "1.10.0",
"source": {
"type": "git",
"url": "https://github.com/webmozart/assert.git",
"reference": "bafc69caeb4d49c39fd0779086c03a3738cbb389"
"url": "https://github.com/webmozarts/assert.git",
"reference": "6964c76c7804814a842473e0c8fd15bab0f18e25"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/webmozart/assert/zipball/bafc69caeb4d49c39fd0779086c03a3738cbb389",
"reference": "bafc69caeb4d49c39fd0779086c03a3738cbb389",
"url": "https://api.github.com/repos/webmozarts/assert/zipball/6964c76c7804814a842473e0c8fd15bab0f18e25",
"reference": "6964c76c7804814a842473e0c8fd15bab0f18e25",
"shasum": ""
},
"require": {
"php": "^5.3.3 || ^7.0 || ^8.0",
"php": "^7.2 || ^8.0",
"symfony/polyfill-ctype": "^1.8"
},
"conflict": {
"phpstan/phpstan": "<0.12.20",
"vimeo/psalm": "<3.9.1"
"vimeo/psalm": "<4.6.1 || 4.6.2"
},
"require-dev": {
"phpunit/phpunit": "^4.8.36 || ^7.5.13"
"phpunit/phpunit": "^8.5.13"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.10-dev"
}
},
"autoload": {
"psr-4": {
"Webmozart\\Assert\\": "src/"
@ -2728,10 +2740,10 @@
"validate"
],
"support": {
"issues": "https://github.com/webmozart/assert/issues",
"source": "https://github.com/webmozart/assert/tree/master"
"issues": "https://github.com/webmozarts/assert/issues",
"source": "https://github.com/webmozarts/assert/tree/1.10.0"
},
"time": "2020-07-08T17:02:28+00:00"
"time": "2021-03-09T10:59:23+00:00"
}
],
"aliases": [],
@ -2740,10 +2752,10 @@
"prefer-stable": false,
"prefer-lowest": false,
"platform": {
"php": ">=7.3.0",
"php": "^7.3 || ^8.0",
"php-64bit": "*",
"ext-curl": "*",
"ext-ctype": "*",
"ext-curl": "*",
"ext-date": "*",
"ext-hash": "*",
"ext-json": "*",
@ -2753,6 +2765,7 @@
"ext-phar": "*",
"ext-pthreads": "~3.2.0",
"ext-reflection": "*",
"ext-simplexml": "*",
"ext-sockets": "*",
"ext-spl": "*",
"ext-yaml": ">=2.0.0",

View File

@ -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

View File

@ -1,7 +1,6 @@
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
@ -42,3 +41,9 @@ parameters:
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'

View File

@ -206,9 +206,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"] = "";

View File

@ -423,8 +423,12 @@ class MemoryManager{
}
$name = $property->getName();
if($reflection !== $original and !$property->isPublic()){
$name = $reflection->getName() . ":" . $name;
if($reflection !== $original){
if($property->isPrivate()){
$name = $reflection->getName() . ":" . $name;
}else{
continue;
}
}
if(!$property->isPublic()){
$property->setAccessible(true);

View File

@ -100,6 +100,7 @@ use pocketmine\nbt\tag\ByteTag;
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\DoubleTag;
use pocketmine\nbt\tag\ListTag;
use pocketmine\nbt\tag\StringTag;
use pocketmine\network\mcpe\convert\ItemTypeDictionary;
use pocketmine\network\mcpe\PlayerNetworkSessionAdapter;
use pocketmine\network\mcpe\protocol\ActorEventPacket;
@ -151,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;
@ -193,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;
@ -408,8 +418,8 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
/** @var float */
protected $lastRightClickTime = 0.0;
/** @var Vector3|null */
protected $lastRightClickPos = null;
/** @var UseItemTransactionData|null */
protected $lastRightClickData = null;
/**
* @return TranslationContainer|string
@ -1652,13 +1662,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();
@ -1673,6 +1676,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));
@ -1695,13 +1704,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);
}
@ -1964,6 +1966,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"],
@ -2080,17 +2083,42 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
* @return void
*/
protected function processLogin(){
$checkXUID = (bool) $this->server->getProperty("player.verify-xuid", true);
$kickForXUIDMismatch = function(string $xuid) use ($checkXUID) : bool{
if($checkXUID && $this->xuid !== $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 true;
}
$this->server->getLogger()->debug("XUID mismatch for " . $this->getName() . ", but plugin cancelled event allowing them to join anyway");
}
return false;
};
foreach($this->server->getLoggedInPlayers() as $p){
if($p !== $this and ($p->iusername === $this->iusername or $this->getUniqueId()->equals($p->getUniqueId()))){
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());
}
}
$this->playedBefore = ($this->getLastPlayed() - $this->getFirstPlayed()) > 1; // microtime(true) - microtime(true) may have less than one millisecond difference
$this->namedtag->setString("NameTag", $this->username);
@ -2250,6 +2278,7 @@ 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);
$this->dataPacket($pk);
$this->sendDataPacket(new AvailableActorIdentifiersPacket());
@ -2335,8 +2364,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
@ -2404,14 +2440,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
@ -2462,317 +2498,313 @@ 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->lastRightClickPos !== null and
microtime(true) - $this->lastRightClickTime < 0.1 and //100ms
$this->lastRightClickPos->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->lastRightClickPos = clone $packet->trData->clickPos;
$this->lastRightClickTime = microtime(true);
if($spamBug){
return true;
}
//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->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);
$blockVector = $packet->trData->getBlockPos();
$face = $packet->trData->getFace();
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;
}
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){
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{
@ -2782,8 +2814,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;
}
@ -2799,15 +2831,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){
@ -2902,6 +2930,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));
@ -2953,7 +2991,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
@ -3071,7 +3109,6 @@ 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
@ -3089,11 +3126,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();
@ -3752,6 +3790,8 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
parent::saveNBT();
$this->namedtag->setString("LastKnownXUID", $this->xuid);
if($this->isValid()){
$this->namedtag->setString("Level", $this->level->getFolderName());
}
@ -4092,6 +4132,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]);
}

View File

@ -228,7 +228,12 @@ namespace pocketmine {
mkdir(\pocketmine\DATA, 0777, true);
}
define('pocketmine\LOCK_FILE', fopen(\pocketmine\DATA . 'server.lock', "a+b"));
$lockFile = fopen(\pocketmine\DATA . 'server.lock', "a+b");
if($lockFile === false){
critical_error("Unable to open server.lock file. Please check that the current user has read/write permissions to it.");
exit(1);
}
define('pocketmine\LOCK_FILE', $lockFile);
if(!flock(\pocketmine\LOCK_FILE, LOCK_EX | LOCK_NB)){
//wait for a shared lock to avoid race conditions if two servers started at the same time - this makes sure the
//other server wrote its PID and released exclusive lock before we get our lock

View File

@ -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"));

View File

@ -33,6 +33,6 @@ if(defined('pocketmine\_VERSION_INFO_INCLUDED')){
const _VERSION_INFO_INCLUDED = true;
const NAME = "PocketMine-MP";
const BASE_VERSION = "3.17.3";
const BASE_VERSION = "3.19.1";
const IS_DEVELOPMENT_BUILD = false;
const BUILD_NUMBER = 0;

View File

@ -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);

View File

@ -25,23 +25,18 @@ namespace pocketmine\command;
use pocketmine\snooze\SleeperNotifier;
use pocketmine\Thread;
use pocketmine\utils\Utils;
use function extension_loaded;
use function fclose;
use function fgets;
use function fopen;
use function fstat;
use function getopt;
use function is_resource;
use function microtime;
use function preg_replace;
use function readline;
use function readline_add_history;
use function stream_isatty;
use function stream_select;
use function trim;
use function usleep;
use const STDIN;
class CommandReader extends Thread{
@ -65,12 +60,6 @@ class CommandReader extends Thread{
public function __construct(?SleeperNotifier $notifier = null){
$this->buffer = new \Threaded;
$this->notifier = $notifier;
$opts = getopt("", ["disable-readline", "enable-readline"]);
if(extension_loaded("readline") and (Utils::getOS() === Utils::OS_WINDOWS ? isset($opts["enable-readline"]) : !isset($opts["disable-readline"])) and !$this->isPipe(STDIN)){
$this->type = self::TYPE_READLINE;
}
}
/**
@ -127,44 +116,28 @@ class CommandReader extends Thread{
* @return bool if the main execution should continue reading lines
*/
private function readLine() : bool{
$line = "";
if($this->type === self::TYPE_READLINE){
if(($raw = readline("> ")) !== false and ($line = trim($raw)) !== ""){
readline_add_history($line);
}else{
return true;
}
}else{
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;
}
if(!is_resource(self::$stdin)){
$this->initStdin();
}
$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){
@ -193,17 +166,11 @@ class CommandReader extends Thread{
*/
public function run(){
$this->registerClassLoader();
if($this->type !== self::TYPE_READLINE){
$this->initStdin();
}
$this->initStdin();
while(!$this->shutdown and $this->readLine());
if($this->type !== self::TYPE_READLINE){
fclose(self::$stdin);
}
fclose(self::$stdin);
}
public function getThreadName() : string{

View File

@ -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;

View File

@ -54,6 +54,7 @@ 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;
@ -813,7 +814,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);

View File

@ -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);

View File

@ -48,7 +48,7 @@ class BlockBreakEvent extends BlockEvent implements Cancellable{
/**
* @param Item[] $drops
*/
public function __construct(Player $player, Block $block, Item $item, bool $instaBreak = false, array $drops, int $xpDrops = 0){
public function __construct(Player $player, Block $block, Item $item, bool $instaBreak = false, array $drops = [], int $xpDrops = 0){
parent::__construct($block);
$this->item = $item;
$this->player = $player;

View File

@ -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){

View File

@ -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);
}
}

View File

@ -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;

View File

@ -30,6 +30,7 @@ use pocketmine\inventory\transaction\action\SlotChangeAction;
use pocketmine\item\Item;
use pocketmine\Player;
use function array_keys;
use function array_values;
use function assert;
use function count;
use function get_class;
@ -168,6 +169,8 @@ class InventoryTransaction{
}
}
}
$needItems = array_values($needItems);
$haveItems = array_values($haveItems);
}
/**

View File

@ -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{

View File

@ -183,8 +183,6 @@ class LevelDB extends BaseLevelProvider{
if(!$this->levelData->hasTag("generatorOptions", StringTag::class)){
$this->levelData->setString("generatorOptions", "");
}
$db->close();
}
public static function getProviderName() : string{
@ -269,9 +267,6 @@ class LevelDB extends BaseLevelProvider{
$db->put(self::ENTRY_FLAT_WORLD_LAYERS, $out); //Add vanilla flatworld layers to allow terrain generation by MCPE to continue seamlessly
}
}
$db->close();
}
public function saveLevelData(){
@ -555,6 +550,6 @@ class LevelDB extends BaseLevelProvider{
}
public function close(){
$this->db->close();
unset($this->db);
}
}

View File

@ -32,8 +32,8 @@ use pocketmine\utils\BinaryStream;
use function assert;
use function ceil;
use function chr;
use function clearstatcache;
use function fclose;
use function feof;
use function file_exists;
use function filesize;
use function fopen;
@ -44,14 +44,12 @@ use function fwrite;
use function is_resource;
use function ksort;
use function max;
use function ord;
use function pack;
use function str_pad;
use function str_repeat;
use function stream_set_read_buffer;
use function stream_set_write_buffer;
use function strlen;
use function substr;
use function time;
use function touch;
use function unpack;
@ -100,6 +98,7 @@ class RegionLoader{
* @throws CorruptedRegionException
*/
public function open(){
clearstatcache(false, $this->filePath);
$exists = file_exists($this->filePath);
if(!$exists){
touch($this->filePath);
@ -409,6 +408,7 @@ class RegionLoader{
fwrite($this->filePointer, Binary::writeInt($entry !== null ? ($entry->getFirstSector() << 8) | $entry->getSectorCount() : 0), 4);
fseek($this->filePointer, 4096 + ($index << 2));
fwrite($this->filePointer, Binary::writeInt($entry !== null ? $entry->getTimestamp() : 0), 4);
clearstatcache(false, $this->filePath);
}
/**

View File

@ -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;
}
}
};

View File

@ -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

View File

@ -56,45 +56,58 @@ abstract class Particle extends Vector3{
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_STALACTITE_DRIP_WATER = 29;
public const TYPE_STALACTITE_DRIP_LAVA = 30;
public const TYPE_FALLING_DUST = 31, TYPE_DUST = 31;
public const TYPE_MOB_SPELL = 32;
public const TYPE_MOB_SPELL_AMBIENT = 33;
public const TYPE_MOB_SPELL_INSTANTANEOUS = 34;
public const TYPE_INK = 35;
public const TYPE_SLIME = 36;
public const TYPE_RAIN_SPLASH = 37;
public const TYPE_VILLAGER_ANGRY = 38;
public const TYPE_VILLAGER_HAPPY = 39;
public const TYPE_ENCHANTMENT_TABLE = 40;
public const TYPE_TRACKING_EMITTER = 41;
public const TYPE_NOTE = 42;
public const TYPE_WITCH_SPELL = 43;
public const TYPE_CARROT = 44;
public const TYPE_MOB_APPEARANCE = 45;
public const TYPE_END_ROD = 46;
public const TYPE_DRAGONS_BREATH = 47;
public const TYPE_SPIT = 48;
public const TYPE_TOTEM = 49;
public const TYPE_FOOD = 50;
public const TYPE_FIREWORKS_STARTER = 51;
public const TYPE_FIREWORKS_SPARK = 52;
public const TYPE_FIREWORKS_OVERLAY = 53;
public const TYPE_BALLOON_GAS = 54;
public const TYPE_COLORED_FLAME = 55;
public const TYPE_SPARKLER = 56;
public const TYPE_CONDUIT = 57;
public const TYPE_BUBBLE_COLUMN_UP = 58;
public const TYPE_BUBBLE_COLUMN_DOWN = 59;
public const TYPE_SNEEZE = 60;
public const TYPE_SHULKER_BULLET = 61;
public const TYPE_BLEACH = 62;
public const TYPE_DRAGON_DESTROY_BLOCK = 63;
public const TYPE_MYCELIUM_DUST = 64;
public const TYPE_FALLING_RED_DUST = 65;
public const TYPE_CAMPFIRE_SMOKE = 66;
public const TYPE_TALL_CAMPFIRE_SMOKE = 67;
public const TYPE_DRAGON_BREATH_FIRE = 68;
public const TYPE_DRAGON_BREATH_TRAIL = 69;
public const TYPE_BLUE_FLAME = 70;
public const TYPE_SOUL = 71;
public const TYPE_OBSIDIAN_TEAR = 72;
public const TYPE_PORTAL_REVERSE = 73;
public const TYPE_SNOWFLAKE = 74;
public const TYPE_VIBRATION_SIGNAL = 75;
public const TYPE_SCULK_SENSOR_REDSTONE = 76;
public const TYPE_SPORE_BLOSSOM_SHOWER = 77;
public const TYPE_SPORE_BLOSSOM_AMBIENT = 78;
public const TYPE_WAX = 79;
public const TYPE_ELECTRIC_SPARK = 80;
/**
* @return DataPacket|DataPacket[]

View File

@ -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();
@ -133,7 +138,7 @@ class NetworkBinaryStream extends BinaryStream{
);
}
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, $animationData, $premium, $persona, $capeOnClassic, $capeId, $fullSkinId, $armSize, $skinColor, $personaPieces, $pieceTintColors);
}
/**
@ -141,6 +146,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()));
@ -191,83 +197,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 +334,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{

View File

@ -48,6 +48,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;
@ -821,4 +822,8 @@ abstract class NetworkSession{
public function handleFilterText(FilterTextPacket $packet) : bool{
return false;
}
public function handleClientboundDebugRenderer(ClientboundDebugRendererPacket $packet) : bool{
return false;
}
}

View File

@ -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()))
]) . ";"
);
}

View File

@ -139,6 +139,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];
}

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -49,25 +49,26 @@ class AvailableCommandsPacket extends DataPacket{
* 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_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:

View File

@ -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{

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -28,7 +28,6 @@ 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;
@ -84,7 +83,6 @@ class CraftingDataPacket extends DataPacket{
case self::ENTRY_SHAPELESS_CHEMISTRY:
$entry["recipe_id"] = $this->getString();
$ingredientCount = $this->getUnsignedVarInt();
/** @var Item */
$entry["input"] = [];
for($j = 0; $j < $ingredientCount; ++$j){
$entry["input"][] = $in = $this->getRecipeIngredient();
@ -93,7 +91,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();
@ -115,7 +113,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();
@ -133,7 +131,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
}
@ -200,7 +198,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
@ -225,7 +223,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
@ -246,7 +244,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;
}

View File

@ -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);
}
}

View File

@ -48,6 +48,13 @@ class EventPacket extends DataPacket{
public const TYPE_CAULDRON_BLOCK_USED = 15;
public const TYPE_COMPOSTER_BLOCK_USED = 16;
public const TYPE_BELL_BLOCK_USED = 17;
public const TYPE_ACTOR_DEFINITION = 18;
public const TYPE_RAID_UPDATE = 19;
public const TYPE_PLAYER_MOVEMENT_ANOMALY = 20; //anti cheat
public const TYPE_PLAYER_MOVEMENT_CORRECTED = 21;
public const TYPE_HONEY_HARVESTED = 22;
public const TYPE_TARGET_BLOCK_HIT = 23;
public const TYPE_PIGLIN_BARTER = 24;
/** @var int */
public $playerRuntimeId;

View File

@ -25,9 +25,15 @@ namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\NetworkSession;
use pocketmine\network\mcpe\NetworkSession as PacketHandlerInterface;
use pocketmine\network\mcpe\protocol\types\inventory\InventoryTransactionChangedSlotsHack;
use pocketmine\network\mcpe\protocol\types\NetworkInventoryAction;
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\TransactionData;
use pocketmine\network\mcpe\protocol\types\inventory\UseItemOnEntityTransactionData;
use pocketmine\network\mcpe\protocol\types\inventory\UseItemTransactionData;
use UnexpectedValueException as PacketDecodeException;
use function count;
class InventoryTransactionPacket extends DataPacket{
@ -39,137 +45,64 @@ class InventoryTransactionPacket extends DataPacket{
public const TYPE_USE_ITEM_ON_ENTITY = 3;
public const TYPE_RELEASE_ITEM = 4;
public const USE_ITEM_ACTION_CLICK_BLOCK = 0;
public const USE_ITEM_ACTION_CLICK_AIR = 1;
public const USE_ITEM_ACTION_BREAK_BLOCK = 2;
public const RELEASE_ITEM_ACTION_RELEASE = 0; //bow shoot
public const RELEASE_ITEM_ACTION_CONSUME = 1; //eat food, drink potion
public const USE_ITEM_ON_ENTITY_ACTION_INTERACT = 0;
public const USE_ITEM_ON_ENTITY_ACTION_ATTACK = 1;
/** @var int */
public $requestId;
/** @var InventoryTransactionChangedSlotsHack[] */
public $requestChangedSlots;
/** @var int */
public $transactionType;
/** @var bool */
public $hasItemStackIds;
/** @var NetworkInventoryAction[] */
public $actions = [];
/** @var \stdClass */
/** @var TransactionData */
public $trData;
protected function decodePayload(){
$this->requestId = $this->readGenericTypeNetworkId();
protected function decodePayload() : void{
$in = $this;
$this->requestId = $in->readGenericTypeNetworkId();
$this->requestChangedSlots = [];
if($this->requestId !== 0){
for($i = 0, $len = $this->getUnsignedVarInt(); $i < $len; ++$i){
$this->requestChangedSlots[] = InventoryTransactionChangedSlotsHack::read($this);
for($i = 0, $len = $in->getUnsignedVarInt(); $i < $len; ++$i){
$this->requestChangedSlots[] = InventoryTransactionChangedSlotsHack::read($in);
}
}
$this->transactionType = $this->getUnsignedVarInt();
$transactionType = $in->getUnsignedVarInt();
$this->hasItemStackIds = $this->getBool();
for($i = 0, $count = $this->getUnsignedVarInt(); $i < $count; ++$i){
$this->actions[] = $action = (new NetworkInventoryAction())->read($this, $this->hasItemStackIds);
}
$this->trData = new \stdClass();
switch($this->transactionType){
switch($transactionType){
case self::TYPE_NORMAL:
$this->trData = new NormalTransactionData();
break;
case self::TYPE_MISMATCH:
//Regular ComplexInventoryTransaction doesn't read any extra data
$this->trData = new MismatchTransactionData();
break;
case self::TYPE_USE_ITEM:
$this->trData->actionType = $this->getUnsignedVarInt();
$this->getBlockPosition($this->trData->x, $this->trData->y, $this->trData->z);
$this->trData->face = $this->getVarInt();
$this->trData->hotbarSlot = $this->getVarInt();
$this->trData->itemInHand = $this->getSlot();
$this->trData->playerPos = $this->getVector3();
$this->trData->clickPos = $this->getVector3();
$this->trData->blockRuntimeId = $this->getUnsignedVarInt();
$this->trData = new UseItemTransactionData();
break;
case self::TYPE_USE_ITEM_ON_ENTITY:
$this->trData->entityRuntimeId = $this->getEntityRuntimeId();
$this->trData->actionType = $this->getUnsignedVarInt();
$this->trData->hotbarSlot = $this->getVarInt();
$this->trData->itemInHand = $this->getSlot();
$this->trData->playerPos = $this->getVector3();
$this->trData->clickPos = $this->getVector3();
$this->trData = new UseItemOnEntityTransactionData();
break;
case self::TYPE_RELEASE_ITEM:
$this->trData->actionType = $this->getUnsignedVarInt();
$this->trData->hotbarSlot = $this->getVarInt();
$this->trData->itemInHand = $this->getSlot();
$this->trData->headPos = $this->getVector3();
$this->trData = new ReleaseItemTransactionData();
break;
default:
throw new \UnexpectedValueException("Unknown transaction type $this->transactionType");
throw new PacketDecodeException("Unknown transaction type $transactionType");
}
$this->trData->decode($in);
}
protected function encodePayload(){
$this->writeGenericTypeNetworkId($this->requestId);
protected function encodePayload() : void{
$out = $this;
$out->writeGenericTypeNetworkId($this->requestId);
if($this->requestId !== 0){
$this->putUnsignedVarInt(count($this->requestChangedSlots));
$out->putUnsignedVarInt(count($this->requestChangedSlots));
foreach($this->requestChangedSlots as $changedSlots){
$changedSlots->write($this);
$changedSlots->write($out);
}
}
$this->putUnsignedVarInt($this->transactionType);
$out->putUnsignedVarInt($this->trData->getTypeId());
$this->putBool($this->hasItemStackIds);
$this->putUnsignedVarInt(count($this->actions));
foreach($this->actions as $action){
$action->write($this, $this->hasItemStackIds);
}
switch($this->transactionType){
case self::TYPE_NORMAL:
case self::TYPE_MISMATCH:
break;
case self::TYPE_USE_ITEM:
$this->putUnsignedVarInt($this->trData->actionType);
$this->putBlockPosition($this->trData->x, $this->trData->y, $this->trData->z);
$this->putVarInt($this->trData->face);
$this->putVarInt($this->trData->hotbarSlot);
$this->putSlot($this->trData->itemInHand);
$this->putVector3($this->trData->playerPos);
$this->putVector3($this->trData->clickPos);
$this->putUnsignedVarInt($this->trData->blockRuntimeId);
break;
case self::TYPE_USE_ITEM_ON_ENTITY:
$this->putEntityRuntimeId($this->trData->entityRuntimeId);
$this->putUnsignedVarInt($this->trData->actionType);
$this->putVarInt($this->trData->hotbarSlot);
$this->putSlot($this->trData->itemInHand);
$this->putVector3($this->trData->playerPos);
$this->putVector3($this->trData->clickPos);
break;
case self::TYPE_RELEASE_ITEM:
$this->putUnsignedVarInt($this->trData->actionType);
$this->putVarInt($this->trData->hotbarSlot);
$this->putSlot($this->trData->itemInHand);
$this->putVector3($this->trData->headPos);
break;
default:
throw new \InvalidArgumentException("Unknown transaction type $this->transactionType");
}
$this->trData->encode($out);
}
public function handle(NetworkSession $session) : bool{
return $session->handleInventoryTransaction($this);
public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleInventoryTransaction($this);
}
}

View File

@ -255,7 +255,7 @@ class LevelSoundEventPacket extends DataPacket{
public const SOUND_BLOCK_TURTLE_EGG_BREAK = 224;
public const SOUND_BLOCK_TURTLE_EGG_CRACK = 225;
public const SOUND_BLOCK_TURTLE_EGG_HATCH = 226;
public const SOUND_LAY_EGG = 227;
public const SOUND_BLOCK_TURTLE_EGG_ATTACK = 228;
public const SOUND_BEACON_ACTIVATE = 229;
public const SOUND_BEACON_AMBIENT = 230;
@ -309,7 +309,56 @@ class LevelSoundEventPacket extends DataPacket{
public const SOUND_BLOCK_SMOKER_SMOKE = 278;
public const SOUND_BLOCK_BLASTFURNACE_FIRE_CRACKLE = 279;
public const SOUND_BLOCK_SMITHING_TABLE_USE = 280;
public const SOUND_UNDEFINED = 281;
public const SOUND_SCREECH = 281;
public const SOUND_SLEEP = 282;
public const SOUND_BLOCK_FURNACE_LIT = 283;
public const SOUND_CONVERT_MOOSHROOM = 284;
public const SOUND_MILK_SUSPICIOUSLY = 285;
public const SOUND_CELEBRATE = 286;
public const SOUND_JUMP_PREVENT = 287;
public const SOUND_AMBIENT_POLLINATE = 288;
public const SOUND_BLOCK_BEEHIVE_DRIP = 289;
public const SOUND_BLOCK_BEEHIVE_ENTER = 290;
public const SOUND_BLOCK_BEEHIVE_EXIT = 291;
public const SOUND_BLOCK_BEEHIVE_WORK = 292;
public const SOUND_BLOCK_BEEHIVE_SHEAR = 293;
public const SOUND_DRINK_HONEY = 294;
public const SOUND_AMBIENT_CAVE = 295;
public const SOUND_RETREAT = 296;
public const SOUND_CONVERTED_TO_ZOMBIFIED = 297;
public const SOUND_ADMIRE = 298;
public const SOUND_STEP_LAVA = 299;
public const SOUND_TEMPT = 300;
public const SOUND_PANIC = 301;
public const SOUND_ANGRY = 302;
public const SOUND_AMBIENT_WARPED_FOREST_MOOD = 303;
public const SOUND_AMBIENT_SOULSAND_VALLEY_MOOD = 304;
public const SOUND_AMBIENT_NETHER_WASTES_MOOD = 305;
public const SOUND_RESPAWN_ANCHOR_BASALT_DELTAS_MOOD = 306;
public const SOUND_AMBIENT_CRIMSON_FOREST_MOOD = 307;
public const SOUND_RESPAWN_ANCHOR_CHARGE = 308;
public const SOUND_RESPAWN_ANCHOR_DEPLETE = 309;
public const SOUND_RESPAWN_ANCHOR_SET_SPAWN = 310;
public const SOUND_RESPAWN_ANCHOR_AMBIENT = 311;
public const SOUND_PARTICLE_SOUL_ESCAPE_QUIET = 312;
public const SOUND_PARTICLE_SOUL_ESCAPE_LOUD = 313;
public const SOUND_RECORD_PIGSTEP = 314;
public const SOUND_LODESTONE_COMPASS_LINK_COMPASS_TO_LODESTONE = 315;
public const SOUND_SMITHING_TABLE_USE = 316;
public const SOUND_ARMOR_EQUIP_NETHERITE = 317;
public const SOUND_AMBIENT_WARPED_FOREST_LOOP = 318;
public const SOUND_AMBIENT_SOULSAND_VALLEY_LOOP = 319;
public const SOUND_AMBIENT_NETHER_WASTES_LOOP = 320;
public const SOUND_AMBIENT_BASALT_DELTAS_LOOP = 321;
public const SOUND_AMBIENT_CRIMSON_FOREST_LOOP = 322;
public const SOUND_AMBIENT_WARPED_FOREST_ADDITIONS = 323;
public const SOUND_AMBIENT_SOULSAND_VALLEY_ADDITIONS = 324;
public const SOUND_AMBIENT_NETHER_WASTES_ADDITIONS = 325;
public const SOUND_AMBIENT_BASALT_DELTAS_ADDITIONS = 326;
public const SOUND_AMBIENT_CRIMSON_FOREST_ADDITIONS = 327;
public const SOUND_BUCKET_FILL_POWDER_SNOW = 328;
public const SOUND_BUCKET_EMPTY_POWDER_SNOW = 329;
public const SOUND_UNDEFINED = 330;
/** @var int */
public $sound;

View File

@ -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;
class MobArmorEquipmentPacket extends DataPacket{
public const NETWORK_ID = ProtocolInfo::MOB_ARMOR_EQUIPMENT_PACKET;
@ -36,29 +36,29 @@ class MobArmorEquipmentPacket extends DataPacket{
//this intentionally doesn't use an array because we don't want any implicit dependencies on internal order
/** @var Item */
/** @var ItemStackWrapper */
public $head;
/** @var Item */
/** @var ItemStackWrapper */
public $chest;
/** @var Item */
/** @var ItemStackWrapper */
public $legs;
/** @var Item */
/** @var ItemStackWrapper */
public $feet;
protected function decodePayload(){
$this->entityRuntimeId = $this->getEntityRuntimeId();
$this->head = $this->getSlot();
$this->chest = $this->getSlot();
$this->legs = $this->getSlot();
$this->feet = $this->getSlot();
$this->head = ItemStackWrapper::read($this);
$this->chest = ItemStackWrapper::read($this);
$this->legs = ItemStackWrapper::read($this);
$this->feet = ItemStackWrapper::read($this);
}
protected function encodePayload(){
$this->putEntityRuntimeId($this->entityRuntimeId);
$this->putSlot($this->head);
$this->putSlot($this->chest);
$this->putSlot($this->legs);
$this->putSlot($this->feet);
$this->head->write($this);
$this->chest->write($this);
$this->legs->write($this);
$this->feet->write($this);
}
public function handle(NetworkSession $session) : bool{

View File

@ -25,15 +25,15 @@ 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;
class MobEquipmentPacket extends DataPacket{
public const NETWORK_ID = ProtocolInfo::MOB_EQUIPMENT_PACKET;
/** @var int */
public $entityRuntimeId;
/** @var Item */
/** @var ItemStackWrapper */
public $item;
/** @var int */
public $inventorySlot;
@ -44,7 +44,7 @@ class MobEquipmentPacket extends DataPacket{
protected function decodePayload(){
$this->entityRuntimeId = $this->getEntityRuntimeId();
$this->item = $this->getSlot();
$this->item = ItemStackWrapper::read($this);
$this->inventorySlot = $this->getByte();
$this->hotbarSlot = $this->getByte();
$this->windowId = $this->getByte();
@ -52,7 +52,7 @@ class MobEquipmentPacket extends DataPacket{
protected function encodePayload(){
$this->putEntityRuntimeId($this->entityRuntimeId);
$this->putSlot($this->item);
$this->item->write($this);
$this->putByte($this->inventorySlot);
$this->putByte($this->hotbarSlot);
$this->putByte($this->windowId);

View File

@ -194,6 +194,7 @@ class PacketPool{
static::registerPacket(new CorrectPlayerMovePredictionPacket());
static::registerPacket(new ItemComponentPacket());
static::registerPacket(new FilterTextPacket());
static::registerPacket(new ClientboundDebugRendererPacket());
}
/**

View File

@ -48,7 +48,7 @@ class PlayerActionPacket extends DataPacket{
public const ACTION_START_GLIDE = 15;
public const ACTION_STOP_GLIDE = 16;
public const ACTION_BUILD_DENIED = 17;
public const ACTION_CONTINUE_BREAK = 18;
public const ACTION_CRACK_BREAK = 18;
public const ACTION_CHANGE_SKIN = 19;
public const ACTION_SET_ENCHANTMENT_SEED = 20; //no longer used
public const ACTION_START_SWIMMING = 21;
@ -56,6 +56,8 @@ class PlayerActionPacket extends DataPacket{
public const ACTION_START_SPIN_ATTACK = 23;
public const ACTION_STOP_SPIN_ATTACK = 24;
public const ACTION_INTERACT_BLOCK = 25;
public const ACTION_PREDICT_DESTROY_BLOCK = 26;
public const ACTION_CONTINUE_DESTROY_BLOCK = 27;
/** @var int */
public $entityRuntimeId;

View File

@ -28,6 +28,7 @@ namespace pocketmine\network\mcpe\protocol;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\NetworkSession;
use pocketmine\network\mcpe\protocol\types\InputMode;
use pocketmine\network\mcpe\protocol\types\PlayerAuthInputFlags;
use pocketmine\network\mcpe\protocol\types\PlayMode;
use function assert;
@ -60,6 +61,7 @@ class PlayerAuthInputPacket extends DataPacket/* implements ServerboundPacket*/{
private $delta;
/**
* @param int $inputFlags @see InputFlags
* @param int $inputMode @see InputMode
* @param int $playMode @see PlayMode
* @param Vector3|null $vrGazeDirection only used when PlayMode::VR
@ -111,6 +113,9 @@ class PlayerAuthInputPacket extends DataPacket/* implements ServerboundPacket*/{
return $this->moveVecZ;
}
/**
* @see PlayerAuthInputFlags
*/
public function getInputFlags() : int{
return $this->inputFlags;
}

View File

@ -37,11 +37,11 @@ interface ProtocolInfo{
*/
/** Actual Minecraft: PE protocol version */
public const CURRENT_PROTOCOL = 422;
public const CURRENT_PROTOCOL = 431;
/** Current Minecraft PE version reported by the server. This is usually the earliest currently supported version. */
public const MINECRAFT_VERSION = 'v1.16.200';
public const MINECRAFT_VERSION = 'v1.16.220';
/** Version number sent to clients in ping responses. */
public const MINECRAFT_VERSION_NETWORK = '1.16.200';
public const MINECRAFT_VERSION_NETWORK = '1.16.220';
public const LOGIN_PACKET = 0x01;
public const PLAY_STATUS_PACKET = 0x02;
@ -206,5 +206,6 @@ interface ProtocolInfo{
public const CORRECT_PLAYER_MOVE_PREDICTION_PACKET = 0xa1;
public const ITEM_COMPONENT_PACKET = 0xa2;
public const FILTER_TEXT_PACKET = 0xa3;
public const CLIENTBOUND_DEBUG_RENDERER_PACKET = 0xa4;
}

View File

@ -44,6 +44,7 @@ class ResourcePackClientResponsePacket extends DataPacket{
protected function decodePayload(){
$this->status = $this->getByte();
$entryCount = $this->getLShort();
$this->packIds = [];
while($entryCount-- > 0){
$this->packIds[] = $this->getString();
}

View File

@ -36,6 +36,9 @@ class SetTitlePacket extends DataPacket{
public const TYPE_SET_SUBTITLE = 3;
public const TYPE_SET_ACTIONBAR_MESSAGE = 4;
public const TYPE_SET_ANIMATION_TIMES = 5;
public const TYPE_SET_TITLE_JSON = 6;
public const TYPE_SET_SUBTITLE_JSON = 7;
public const TYPE_SET_ACTIONBAR_MESSAGE_JSON = 8;
/** @var int */
public $type;

View File

@ -35,7 +35,7 @@ use pocketmine\network\mcpe\protocol\types\GameRuleType;
use pocketmine\network\mcpe\protocol\types\GeneratorType;
use pocketmine\network\mcpe\protocol\types\ItemTypeEntry;
use pocketmine\network\mcpe\protocol\types\MultiplayerGameVisibility;
use pocketmine\network\mcpe\protocol\types\PlayerMovementType;
use pocketmine\network\mcpe\protocol\types\PlayerMovementSettings;
use pocketmine\network\mcpe\protocol\types\PlayerPermissions;
use pocketmine\network\mcpe\protocol\types\SpawnSettings;
use function count;
@ -154,8 +154,8 @@ class StartGamePacket extends DataPacket{
public $premiumWorldTemplateId = "";
/** @var bool */
public $isTrial = false;
/** @var int */
public $playerMovementType = PlayerMovementType::LEGACY;
/** @var PlayerMovementSettings */
public $playerMovementSettings;
/** @var int */
public $currentTick = 0; //only used if isTrial is true
/** @var int */
@ -235,7 +235,7 @@ class StartGamePacket extends DataPacket{
$this->worldName = $this->getString();
$this->premiumWorldTemplateId = $this->getString();
$this->isTrial = $this->getBool();
$this->playerMovementType = $this->getVarInt();
$this->playerMovementSettings = PlayerMovementSettings::read($this);
$this->currentTick = $this->getLLong();
$this->enchantmentSeed = $this->getVarInt();
@ -317,7 +317,7 @@ class StartGamePacket extends DataPacket{
$this->putString($this->worldName);
$this->putString($this->premiumWorldTemplateId);
$this->putBool($this->isTrial);
$this->putVarInt($this->playerMovementType);
$this->playerMovementSettings->write($this);
$this->putLLong($this->currentTick);
$this->putVarInt($this->enchantmentSeed);

View File

@ -44,6 +44,7 @@ class LegacySkinAdapter implements SkinAdapter{
}
return new SkinData(
$skin->getSkinId(),
"", //TODO: playfab ID
json_encode(["geometry" => ["default" => $geometryName]]),
SkinImage::fromLegacy($skin->getSkinData()), [],
$capeImage,

View File

@ -30,6 +30,7 @@ use pocketmine\inventory\transaction\action\InventoryAction;
use pocketmine\inventory\transaction\action\SlotChangeAction;
use pocketmine\item\Item;
use pocketmine\network\mcpe\NetworkBinaryStream;
use pocketmine\network\mcpe\protocol\types\inventory\ItemStackWrapper;
use pocketmine\network\mcpe\protocol\types\inventory\UIInventorySlotOffset;
use pocketmine\Player;
use function array_key_exists;
@ -79,17 +80,15 @@ class NetworkInventoryAction{
public $sourceFlags = 0;
/** @var int */
public $inventorySlot;
/** @var Item */
/** @var ItemStackWrapper */
public $oldItem;
/** @var Item */
/** @var ItemStackWrapper */
public $newItem;
/** @var int|null */
public $newItemStackId = null;
/**
* @return $this
*/
public function read(NetworkBinaryStream $packet, bool $hasItemStackIds){
public function read(NetworkBinaryStream $packet){
$this->sourceType = $packet->getUnsignedVarInt();
switch($this->sourceType){
@ -109,11 +108,8 @@ class NetworkInventoryAction{
}
$this->inventorySlot = $packet->getUnsignedVarInt();
$this->oldItem = $packet->getSlot();
$this->newItem = $packet->getSlot();
if($hasItemStackIds){
$this->newItemStackId = $packet->readGenericTypeNetworkId();
}
$this->oldItem = ItemStackWrapper::read($packet);
$this->newItem = ItemStackWrapper::read($packet);
return $this;
}
@ -121,7 +117,7 @@ class NetworkInventoryAction{
/**
* @return void
*/
public function write(NetworkBinaryStream $packet, bool $hasItemStackIds){
public function write(NetworkBinaryStream $packet){
$packet->putUnsignedVarInt($this->sourceType);
switch($this->sourceType){
@ -141,14 +137,8 @@ class NetworkInventoryAction{
}
$packet->putUnsignedVarInt($this->inventorySlot);
$packet->putSlot($this->oldItem);
$packet->putSlot($this->newItem);
if($hasItemStackIds){
if($this->newItemStackId === null){
throw new \InvalidStateException("Item stack ID for newItem must be provided");
}
$packet->writeGenericTypeNetworkId($this->newItemStackId);
}
$this->oldItem->write($packet);
$this->newItem->write($packet);
}
/**
@ -157,7 +147,9 @@ class NetworkInventoryAction{
* @throws \UnexpectedValueException
*/
public function createInventoryAction(Player $player){
if($this->oldItem->equalsExact($this->newItem)){
$oldItem = $this->oldItem->getItemStack();
$newItem = $this->newItem->getItemStack();
if($oldItem->equalsExact($newItem)){
//filter out useless noise in 1.13
return null;
}
@ -187,7 +179,7 @@ class NetworkInventoryAction{
$slot = $this->inventorySlot;
}
if($window !== null){
return new SlotChangeAction($window, $slot, $this->oldItem, $this->newItem);
return new SlotChangeAction($window, $slot, $oldItem, $newItem);
}
throw new \UnexpectedValueException("Player " . $player->getName() . " has no open container with window ID $this->windowId");
@ -196,7 +188,7 @@ class NetworkInventoryAction{
throw new \UnexpectedValueException("Only expecting drop-item world actions from the client!");
}
return new DropItemAction($this->newItem);
return new DropItemAction($newItem);
case self::SOURCE_CREATIVE:
switch($this->inventorySlot){
case self::ACTION_MAGIC_SLOT_CREATIVE_DELETE_ITEM:
@ -210,7 +202,7 @@ class NetworkInventoryAction{
}
return new CreativeInventoryAction($this->oldItem, $this->newItem, $type);
return new CreativeInventoryAction($oldItem, $newItem, $type);
case self::SOURCE_TODO:
//These types need special handling.
switch($this->windowId){

View File

@ -0,0 +1,75 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol\types;
use pocketmine\network\mcpe\protocol\PlayerAuthInputPacket;
/**
* These flags are used in PlayerAuthInputPacket's inputFlags field.
* The flags should be written as
* `flags |= (1 << flag)`
* and read as
* `(flags & (1 & flag)) !== 0`
*
* @see PlayerAuthInputPacket
*/
final class PlayerAuthInputFlags{
public const ASCEND = 0;
public const DESCEND = 1;
public const NORTH_JUMP = 2;
public const JUMP_DOWN = 3;
public const SPRINT_DOWN = 4;
public const CHANGE_HEIGHT = 5;
public const JUMPING = 6;
public const AUTO_JUMPING_IN_WATER = 7;
public const SNEAKING = 8;
public const SNEAK_DOWN = 9;
public const UP = 10;
public const DOWN = 11;
public const LEFT = 12;
public const RIGHT = 13;
public const UP_LEFT = 14;
public const UP_RIGHT = 15;
public const WANT_UP = 16;
public const WANT_DOWN = 17;
public const WANT_DOWN_SLOW = 18;
public const WANT_UP_SLOW = 19;
public const SPRINTING = 20;
public const ASCEND_SCAFFOLDING = 21;
public const DESCEND_SCAFFOLDING = 22;
public const SNEAK_TOGGLE_DOWN = 23;
public const PERSIST_SNEAK = 24;
public const START_SPRINTING = 25;
public const STOP_SPRINTING = 26;
public const START_SNEAKING = 27;
public const STOP_SNEAKING = 28;
public const START_SWIMMING = 29;
public const STOP_SWIMMING = 30;
public const START_JUMPING = 31;
public const START_GLIDING = 32;
public const STOP_GLIDING = 33;
public const PERFORM_ITEM_INTERACTION = 34;
public const PERFORM_BLOCK_ACTIONS = 35;
public const PERFORM_ITEM_STACK_REQUEST = 36;
}

View File

@ -0,0 +1,61 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol\types;
use pocketmine\network\mcpe\NetworkBinaryStream;
final class PlayerMovementSettings{
/** @var int */
private $movementType;
/** @var int */
private $rewindHistorySize;
/** @var bool */
private $serverAuthoritativeBlockBreaking;
public function __construct(int $movementType, int $rewindHistorySize, bool $serverAuthoritativeBlockBreaking){
$this->movementType = $movementType;
$this->rewindHistorySize = $rewindHistorySize;
//do not ask me what the F this is doing here
$this->serverAuthoritativeBlockBreaking = $serverAuthoritativeBlockBreaking;
}
public function getMovementType() : int{ return $this->movementType; }
public function getRewindHistorySize() : int{ return $this->rewindHistorySize; }
public function isServerAuthoritativeBlockBreaking() : bool{ return $this->serverAuthoritativeBlockBreaking; }
public static function read(NetworkBinaryStream $in) : self{
$movementType = $in->getVarInt();
$rewindHistorySize = $in->getVarInt();
$serverAuthBlockBreaking = $in->getBool();
return new self($movementType, $rewindHistorySize, $serverAuthBlockBreaking);
}
public function write(NetworkBinaryStream $out) : void{
$out->putVarInt($this->movementType);
$out->putVarInt($this->rewindHistorySize);
$out->putBool($this->serverAuthoritativeBlockBreaking);
}
}

View File

@ -33,6 +33,8 @@ class SkinData{
/** @var string */
private $skinId;
/** @var string */
private $playFabId;
/** @var string */
private $resourcePatch;
/** @var SkinImage */
private $skinImage;
@ -70,8 +72,9 @@ class SkinData{
* @param PersonaSkinPiece[] $personaPieces
* @param PersonaPieceTintColor[] $pieceTintColors
*/
public function __construct(string $skinId, string $resourcePatch, SkinImage $skinImage, array $animations = [], SkinImage $capeImage = null, string $geometryData = "", string $animationData = "", bool $premium = false, bool $persona = false, bool $personaCapeOnClassic = false, string $capeId = "", ?string $fullSkinId = null, string $armSize = self::ARM_SIZE_WIDE, string $skinColor = "", array $personaPieces = [], array $pieceTintColors = [], bool $isVerified = true){
public function __construct(string $skinId, string $playFabId, string $resourcePatch, SkinImage $skinImage, array $animations = [], SkinImage $capeImage = null, string $geometryData = "", string $animationData = "", bool $premium = false, bool $persona = false, bool $personaCapeOnClassic = false, string $capeId = "", ?string $fullSkinId = null, string $armSize = self::ARM_SIZE_WIDE, string $skinColor = "", array $personaPieces = [], array $pieceTintColors = [], bool $isVerified = true){
$this->skinId = $skinId;
$this->playFabId = $playFabId;
$this->resourcePatch = $resourcePatch;
$this->skinImage = $skinImage;
$this->animations = $animations;
@ -95,6 +98,8 @@ class SkinData{
return $this->skinId;
}
public function getPlayFabId() : string{ return $this->playFabId; }
public function getResourcePatch() : string{
return $this->resourcePatch;
}

View File

@ -44,12 +44,12 @@ final class CreativeContentEntry{
public static function read(NetworkBinaryStream $in) : self{
$entryId = $in->readGenericTypeNetworkId();
$item = $in->getSlot();
$item = $in->getItemStackWithoutStackId();
return new self($entryId, $item);
}
public function write(NetworkBinaryStream $out) : void{
$out->writeGenericTypeNetworkId($this->entryId);
$out->putSlot($this->item);
$out->putItemStackWithoutStackId($this->item);
}
}

View File

@ -47,13 +47,22 @@ final class ItemStackWrapper{
public function getItemStack() : Item{ return $this->itemStack; }
public static function read(NetworkBinaryStream $in) : self{
$stackId = $in->readGenericTypeNetworkId();
$stack = $in->getSlot();
$stackId = 0;
$stack = $in->getItemStack(function(NetworkBinaryStream $in) use (&$stackId) : void{
$hasNetId = $in->getBool();
if($hasNetId){
$stackId = $in->readGenericTypeNetworkId();
}
});
return new self($stackId, $stack);
}
public function write(NetworkBinaryStream $out) : void{
$out->writeGenericTypeNetworkId($this->stackId);
$out->putSlot($this->itemStack);
$out->putItemStack($this->itemStack, function(NetworkBinaryStream $out) : void{
$out->putBool($this->stackId !== 0);
if($this->stackId !== 0){
$out->writeGenericTypeNetworkId($this->stackId);
}
});
}
}

View File

@ -0,0 +1,50 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol\types\inventory;
use pocketmine\network\mcpe\NetworkBinaryStream as PacketSerializer;
use pocketmine\network\mcpe\protocol\InventoryTransactionPacket;
use UnexpectedValueException as PacketDecodeException;
use function count;
class MismatchTransactionData extends TransactionData{
public function getTypeId() : int{
return InventoryTransactionPacket::TYPE_MISMATCH;
}
protected function decodeData(PacketSerializer $stream) : void{
if(count($this->actions) > 0){
throw new PacketDecodeException("Mismatch transaction type should not have any actions associated with it, but got " . count($this->actions));
}
}
protected function encodeData(PacketSerializer $stream) : void{
}
public static function new() : self{
return new self; //no arguments
}
}

View File

@ -0,0 +1,54 @@
<?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\types\inventory;
use pocketmine\network\mcpe\NetworkBinaryStream as PacketSerializer;
use pocketmine\network\mcpe\protocol\InventoryTransactionPacket;
use pocketmine\network\mcpe\protocol\types\NetworkInventoryAction;
class NormalTransactionData extends TransactionData{
public function getTypeId() : int{
return InventoryTransactionPacket::TYPE_NORMAL;
}
protected function decodeData(PacketSerializer $stream) : void{
}
protected function encodeData(PacketSerializer $stream) : void{
}
/**
* @param NetworkInventoryAction[] $actions
*
* @return NormalTransactionData
*/
public static function new(array $actions) : self{
$result = new self();
$result->actions = $actions;
return $result;
}
}

View File

@ -0,0 +1,91 @@
<?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\types\inventory;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\NetworkBinaryStream as PacketSerializer;
use pocketmine\network\mcpe\protocol\InventoryTransactionPacket;
use pocketmine\network\mcpe\protocol\types\NetworkInventoryAction;
class ReleaseItemTransactionData extends TransactionData{
public const ACTION_RELEASE = 0; //bow shoot
public const ACTION_CONSUME = 1; //eat food, drink potion
/** @var int */
private $actionType;
/** @var int */
private $hotbarSlot;
/** @var ItemStackWrapper */
private $itemInHand;
/** @var Vector3 */
private $headPos;
public function getActionType() : int{
return $this->actionType;
}
public function getHotbarSlot() : int{
return $this->hotbarSlot;
}
public function getItemInHand() : ItemStackWrapper{
return $this->itemInHand;
}
public function getHeadPos() : Vector3{
return $this->headPos;
}
public function getTypeId() : int{
return InventoryTransactionPacket::TYPE_RELEASE_ITEM;
}
protected function decodeData(PacketSerializer $stream) : void{
$this->actionType = $stream->getUnsignedVarInt();
$this->hotbarSlot = $stream->getVarInt();
$this->itemInHand = ItemStackWrapper::read($stream);
$this->headPos = $stream->getVector3();
}
protected function encodeData(PacketSerializer $stream) : void{
$stream->putUnsignedVarInt($this->actionType);
$stream->putVarInt($this->hotbarSlot);
$this->itemInHand->write($stream);
$stream->putVector3($this->headPos);
}
/**
* @param NetworkInventoryAction[] $actions
*/
public static function new(array $actions, int $actionType, int $hotbarSlot, ItemStackWrapper $itemInHand, Vector3 $headPos) : self{
$result = new self;
$result->actions = $actions;
$result->actionType = $actionType;
$result->hotbarSlot = $hotbarSlot;
$result->itemInHand = $itemInHand;
$result->headPos = $headPos;
return $result;
}
}

View File

@ -0,0 +1,72 @@
<?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\types\inventory;
use pocketmine\network\mcpe\NetworkBinaryStream as PacketSerializer;
use pocketmine\network\mcpe\protocol\types\NetworkInventoryAction;
use pocketmine\utils\BinaryDataException;
use UnexpectedValueException as PacketDecodeException;
use function count;
abstract class TransactionData{
/** @var NetworkInventoryAction[] */
protected $actions = [];
/**
* @return NetworkInventoryAction[]
*/
final public function getActions() : array{
return $this->actions;
}
abstract public function getTypeId() : int;
/**
* @throws BinaryDataException
* @throws PacketDecodeException
*/
final public function decode(PacketSerializer $stream) : void{
$actionCount = $stream->getUnsignedVarInt();
for($i = 0; $i < $actionCount; ++$i){
$this->actions[] = (new NetworkInventoryAction())->read($stream);
}
$this->decodeData($stream);
}
/**
* @throws BinaryDataException
* @throws PacketDecodeException
*/
abstract protected function decodeData(PacketSerializer $stream) : void;
final public function encode(PacketSerializer $stream) : void{
$stream->putUnsignedVarInt(count($this->actions));
foreach($this->actions as $action){
$action->write($stream);
}
$this->encodeData($stream);
}
abstract protected function encodeData(PacketSerializer $stream) : void;
}

View File

@ -0,0 +1,108 @@
<?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\types\inventory;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\NetworkBinaryStream as PacketSerializer;
use pocketmine\network\mcpe\protocol\InventoryTransactionPacket;
use pocketmine\network\mcpe\protocol\types\NetworkInventoryAction;
class UseItemOnEntityTransactionData extends TransactionData{
public const ACTION_INTERACT = 0;
public const ACTION_ATTACK = 1;
/** @var int */
private $entityRuntimeId;
/** @var int */
private $actionType;
/** @var int */
private $hotbarSlot;
/** @var ItemStackWrapper */
private $itemInHand;
/** @var Vector3 */
private $playerPos;
/** @var Vector3 */
private $clickPos;
public function getEntityRuntimeId() : int{
return $this->entityRuntimeId;
}
public function getActionType() : int{
return $this->actionType;
}
public function getHotbarSlot() : int{
return $this->hotbarSlot;
}
public function getItemInHand() : ItemStackWrapper{
return $this->itemInHand;
}
public function getPlayerPos() : Vector3{
return $this->playerPos;
}
public function getClickPos() : Vector3{
return $this->clickPos;
}
public function getTypeId() : int{
return InventoryTransactionPacket::TYPE_USE_ITEM_ON_ENTITY;
}
protected function decodeData(PacketSerializer $stream) : void{
$this->entityRuntimeId = $stream->getEntityRuntimeId();
$this->actionType = $stream->getUnsignedVarInt();
$this->hotbarSlot = $stream->getVarInt();
$this->itemInHand = ItemStackWrapper::read($stream);
$this->playerPos = $stream->getVector3();
$this->clickPos = $stream->getVector3();
}
protected function encodeData(PacketSerializer $stream) : void{
$stream->putEntityRuntimeId($this->entityRuntimeId);
$stream->putUnsignedVarInt($this->actionType);
$stream->putVarInt($this->hotbarSlot);
$this->itemInHand->write($stream);
$stream->putVector3($this->playerPos);
$stream->putVector3($this->clickPos);
}
/**
* @param NetworkInventoryAction[] $actions
*/
public static function new(array $actions, int $entityRuntimeId, int $actionType, int $hotbarSlot, ItemStackWrapper $itemInHand, Vector3 $playerPos, Vector3 $clickPos) : self{
$result = new self;
$result->actions = $actions;
$result->entityRuntimeId = $entityRuntimeId;
$result->actionType = $actionType;
$result->hotbarSlot = $hotbarSlot;
$result->itemInHand = $itemInHand;
$result->playerPos = $playerPos;
$result->clickPos = $clickPos;
return $result;
}
}

View File

@ -0,0 +1,129 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol\types\inventory;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\NetworkBinaryStream as PacketSerializer;
use pocketmine\network\mcpe\protocol\InventoryTransactionPacket;
use pocketmine\network\mcpe\protocol\types\NetworkInventoryAction;
class UseItemTransactionData extends TransactionData{
public const ACTION_CLICK_BLOCK = 0;
public const ACTION_CLICK_AIR = 1;
public const ACTION_BREAK_BLOCK = 2;
/** @var int */
private $actionType;
/** @var Vector3 */
private $blockPos;
/** @var int */
private $face;
/** @var int */
private $hotbarSlot;
/** @var ItemStackWrapper */
private $itemInHand;
/** @var Vector3 */
private $playerPos;
/** @var Vector3 */
private $clickPos;
/** @var int */
private $blockRuntimeId;
public function getActionType() : int{
return $this->actionType;
}
public function getBlockPos() : Vector3{
return $this->blockPos;
}
public function getFace() : int{
return $this->face;
}
public function getHotbarSlot() : int{
return $this->hotbarSlot;
}
public function getItemInHand() : ItemStackWrapper{
return $this->itemInHand;
}
public function getPlayerPos() : Vector3{
return $this->playerPos;
}
public function getClickPos() : Vector3{
return $this->clickPos;
}
public function getBlockRuntimeId() : int{
return $this->blockRuntimeId;
}
public function getTypeId() : int{
return InventoryTransactionPacket::TYPE_USE_ITEM;
}
protected function decodeData(PacketSerializer $stream) : void{
$this->actionType = $stream->getUnsignedVarInt();
$x = $y = $z = 0;
$stream->getBlockPosition($x, $y, $z);
$this->blockPos = new Vector3($x, $y, $z);
$this->face = $stream->getVarInt();
$this->hotbarSlot = $stream->getVarInt();
$this->itemInHand = ItemStackWrapper::read($stream);
$this->playerPos = $stream->getVector3();
$this->clickPos = $stream->getVector3();
$this->blockRuntimeId = $stream->getUnsignedVarInt();
}
protected function encodeData(PacketSerializer $stream) : void{
$stream->putUnsignedVarInt($this->actionType);
$stream->putBlockPosition($this->blockPos->x, $this->blockPos->y, $this->blockPos->z);
$stream->putVarInt($this->face);
$stream->putVarInt($this->hotbarSlot);
$this->itemInHand->write($stream);
$stream->putVector3($this->playerPos);
$stream->putVector3($this->clickPos);
$stream->putUnsignedVarInt($this->blockRuntimeId);
}
/**
* @param NetworkInventoryAction[] $actions
*/
public static function new(array $actions, int $actionType, Vector3 $blockPos, int $face, int $hotbarSlot, ItemStackWrapper $itemInHand, Vector3 $playerPos, Vector3 $clickPos, int $blockRuntimeId) : self{
$result = new self;
$result->actions = $actions;
$result->actionType = $actionType;
$result->blockPos = $blockPos;
$result->face = $face;
$result->hotbarSlot = $hotbarSlot;
$result->itemInHand = $itemInHand;
$result->playerPos = $playerPos;
$result->clickPos = $clickPos;
$result->blockRuntimeId = $blockRuntimeId;
return $result;
}
}

View File

@ -0,0 +1,59 @@
<?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\types\inventory\stackrequest;
use pocketmine\network\mcpe\NetworkBinaryStream;
/**
* Renames an item in an anvil, or map on a cartography table.
*/
final class CraftRecipeOptionalStackRequestAction extends ItemStackRequestAction{
/** @var int */
private $recipeId;
/** @var int */
private $filterStringIndex;
public function __construct(int $type, int $filterStringIndex){
$this->recipeId = $type;
$this->filterStringIndex = $filterStringIndex;
}
public function getRecipeId() : int{ return $this->recipeId; }
public function getFilterStringIndex() : int{ return $this->filterStringIndex; }
public static function getTypeId() : int{ return ItemStackRequestActionType::CRAFTING_RECIPE_OPTIONAL; }
public static function read(NetworkBinaryStream $in) : self{
$recipeId = $in->readGenericTypeNetworkId();
$filterStringIndex = $in->getLInt();
return new self($recipeId, $filterStringIndex);
}
public function write(NetworkBinaryStream $out) : void{
$out->writeGenericTypeNetworkId($this->recipeId);
$out->putLInt($this->filterStringIndex);
}
}

View File

@ -58,7 +58,7 @@ final class DeprecatedCraftingResultsStackRequestAction extends ItemStackRequest
public static function read(NetworkBinaryStream $in) : self{
$results = [];
for($i = 0, $len = $in->getUnsignedVarInt(); $i < $len; ++$i){
$results[] = $in->getSlot();
$results[] = $in->getItemStackWithoutStackId();
}
$iterations = $in->getByte();
return new self($results, $iterations);
@ -67,7 +67,7 @@ final class DeprecatedCraftingResultsStackRequestAction extends ItemStackRequest
public function write(NetworkBinaryStream $out) : void{
$out->putUnsignedVarInt(count($this->results));
foreach($this->results as $result){
$out->putSlot($result);
$out->putItemStackWithoutStackId($result);
}
$out->putByte($this->iterations);
}

View File

@ -32,13 +32,21 @@ final class ItemStackRequest{
private $requestId;
/** @var ItemStackRequestAction[] */
private $actions;
/**
* @var string[]
* @phpstan-var list<string>
*/
private $filterStrings;
/**
* @param ItemStackRequestAction[] $actions
* @param string[] $filterStrings
* @phpstan-param list<string> $filterStrings
*/
public function __construct(int $requestId, array $actions){
public function __construct(int $requestId, array $actions, array $filterStrings){
$this->requestId = $requestId;
$this->actions = $actions;
$this->filterStrings = $filterStrings;
}
public function getRequestId() : int{ return $this->requestId; }
@ -46,6 +54,12 @@ final class ItemStackRequest{
/** @return ItemStackRequestAction[] */
public function getActions() : array{ return $this->actions; }
/**
* @return string[]
* @phpstan-return list<string>
*/
public function getFilterStrings() : array{ return $this->filterStrings; }
private static function readAction(NetworkBinaryStream $in, int $typeId) : ItemStackRequestAction{
switch($typeId){
case TakeStackRequestAction::getTypeId(): return TakeStackRequestAction::read($in);
@ -57,9 +71,11 @@ final class ItemStackRequest{
case CraftingMarkSecondaryResultStackRequestAction::getTypeId(): return CraftingMarkSecondaryResultStackRequestAction::read($in);
case LabTableCombineStackRequestAction::getTypeId(): return LabTableCombineStackRequestAction::read($in);
case BeaconPaymentStackRequestAction::getTypeId(): return BeaconPaymentStackRequestAction::read($in);
case MineBlockStackRequestAction::getTypeId(): return MineBlockStackRequestAction::read($in);
case CraftRecipeStackRequestAction::getTypeId(): return CraftRecipeStackRequestAction::read($in);
case CraftRecipeAutoStackRequestAction::getTypeId(): return CraftRecipeAutoStackRequestAction::read($in);
case CreativeCreateStackRequestAction::getTypeId(): return CreativeCreateStackRequestAction::read($in);
case CraftRecipeOptionalStackRequestAction::getTypeId(): return CraftRecipeOptionalStackRequestAction::read($in);
case DeprecatedCraftingNonImplementedStackRequestAction::getTypeId(): return DeprecatedCraftingNonImplementedStackRequestAction::read($in);
case DeprecatedCraftingResultsStackRequestAction::getTypeId(): return DeprecatedCraftingResultsStackRequestAction::read($in);
}
@ -73,7 +89,11 @@ final class ItemStackRequest{
$typeId = $in->getByte();
$actions[] = self::readAction($in, $typeId);
}
return new self($requestId, $actions);
$filterStrings = [];
for($i = 0, $len = $in->getUnsignedVarInt(); $i < $len; ++$i){
$filterStrings[] = $in->getString();
}
return new self($requestId, $actions, $filterStrings);
}
public function write(NetworkBinaryStream $out) : void{
@ -83,5 +103,9 @@ final class ItemStackRequest{
$out->putByte($action::getTypeId());
$action->write($out);
}
$out->putUnsignedVarInt(count($this->filterStrings));
foreach($this->filterStrings as $string){
$out->putString($string);
}
}
}

View File

@ -38,9 +38,11 @@ final class ItemStackRequestActionType{
public const CRAFTING_MARK_SECONDARY_RESULT_SLOT = 6;
public const LAB_TABLE_COMBINE = 7;
public const BEACON_PAYMENT = 8;
public const CRAFTING_RECIPE = 9;
public const CRAFTING_RECIPE_AUTO = 10; //recipe book?
public const CREATIVE_CREATE = 11;
public const CRAFTING_NON_IMPLEMENTED_DEPRECATED_ASK_TY_LAING = 12; //anvils aren't fully implemented yet
public const CRAFTING_RESULTS_DEPRECATED_ASK_TY_LAING = 13; //no idea what this is for
public const MINE_BLOCK = 9;
public const CRAFTING_RECIPE = 10;
public const CRAFTING_RECIPE_AUTO = 11; //recipe book?
public const CREATIVE_CREATE = 12;
public const CRAFTING_RECIPE_OPTIONAL = 13; //anvil/cartography table rename
public const CRAFTING_NON_IMPLEMENTED_DEPRECATED_ASK_TY_LAING = 14;
public const CRAFTING_RESULTS_DEPRECATED_ASK_TY_LAING = 15; //no idea what this is for
}

View File

@ -0,0 +1,63 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol\types\inventory\stackrequest;
use pocketmine\network\mcpe\NetworkBinaryStream;
final class MineBlockStackRequestAction extends ItemStackRequestAction{
/** @var int */
private $unknown1;
/** @var int */
private $predictedDurability;
/** @var int */
private $stackId;
public function __construct(int $unknown1, int $predictedDurability, int $stackId){
$this->unknown1 = $unknown1;
$this->predictedDurability = $predictedDurability;
$this->stackId = $stackId;
}
public function getUnknown1() : int{ return $this->unknown1; }
public function getPredictedDurability() : int{ return $this->predictedDurability; }
public function getStackId() : int{ return $this->stackId; }
public static function getTypeId() : int{ return ItemStackRequestActionType::MINE_BLOCK; }
public static function read(NetworkBinaryStream $in) : self{
$unknown1 = $in->getVarInt();
$predictedDurability = $in->getVarInt();
$stackId = $in->readGenericTypeNetworkId();
return new self($unknown1, $predictedDurability, $stackId);
}
public function write(NetworkBinaryStream $out) : void{
$out->putVarInt($this->unknown1);
$out->putVarInt($this->predictedDurability);
$out->writeGenericTypeNetworkId($this->stackId);
}
}

View File

@ -37,13 +37,16 @@ final class ItemStackResponseSlotInfo{
private $itemStackId;
/** @var string */
private $customName;
/** @var int */
private $durabilityCorrection;
public function __construct(int $slot, int $hotbarSlot, int $count, int $itemStackId, string $customName){
public function __construct(int $slot, int $hotbarSlot, int $count, int $itemStackId, string $customName, int $durabilityCorrection){
$this->slot = $slot;
$this->hotbarSlot = $hotbarSlot;
$this->count = $count;
$this->itemStackId = $itemStackId;
$this->customName = $customName;
$this->durabilityCorrection = $durabilityCorrection;
}
public function getSlot() : int{ return $this->slot; }
@ -56,13 +59,16 @@ final class ItemStackResponseSlotInfo{
public function getCustomName() : string{ return $this->customName; }
public function getDurabilityCorrection() : int{ return $this->durabilityCorrection; }
public static function read(NetworkBinaryStream $in) : self{
$slot = $in->getByte();
$hotbarSlot = $in->getByte();
$count = $in->getByte();
$itemStackId = $in->readGenericTypeNetworkId();
$customName = $in->getString();
return new self($slot, $hotbarSlot, $count, $itemStackId, $customName);
$durabilityCorrection = $in->getVarInt();
return new self($slot, $hotbarSlot, $count, $itemStackId, $customName, $durabilityCorrection);
}
public function write(NetworkBinaryStream $out) : void{
@ -71,5 +77,6 @@ final class ItemStackResponseSlotInfo{
$out->putByte($this->count);
$out->writeGenericTypeNetworkId($this->itemStackId);
$out->putString($this->customName);
$out->putVarInt($this->durabilityCorrection);
}
}

View File

@ -77,7 +77,7 @@ class RCONInstance extends Thread{
* @param resource $socket
* @param resource $ipcSocket
*/
public function __construct($socket, string $password, int $maxClients = 50, \ThreadedLogger $logger, $ipcSocket, ?SleeperNotifier $notifier){
public function __construct($socket, string $password, int $maxClients, \ThreadedLogger $logger, $ipcSocket, ?SleeperNotifier $notifier){
$this->stop = false;
$this->cmd = "";
$this->response = "";

View File

@ -19,63 +19,238 @@
*
*/
// This code is based on a Go implementation and its license is below:
// Copyright (c) 2010 Jack Palevich. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
declare(strict_types=1);
/**
* UPnP port forwarding support. Only for Windows
* UPnP port forwarding support.
*/
namespace pocketmine\network\upnp;
use pocketmine\utils\AssumptionFailedError;
use pocketmine\utils\Internet;
use pocketmine\utils\Utils;
use function class_exists;
use function is_object;
use function count;
use function libxml_use_internal_errors;
use function parse_url;
use function preg_last_error;
use function preg_match;
use function socket_close;
use function socket_create;
use function socket_last_error;
use function socket_recvfrom;
use function socket_sendto;
use function socket_set_option;
use function socket_strerror;
use function sprintf;
use function strlen;
use function trim;
use const AF_INET;
use const SO_RCVTIMEO;
use const SOCK_DGRAM;
use const SOCKET_ETIMEDOUT;
use const SOL_SOCKET;
use const SOL_UDP;
abstract class UPnP{
private const MAX_DISCOVERY_ATTEMPTS = 3;
/** @var string|null */
private static $serviceURL = null;
private static function makePcreError() : \RuntimeException{
$errorCode = preg_last_error();
$message = [
PREG_INTERNAL_ERROR => "Internal error",
PREG_BACKTRACK_LIMIT_ERROR => "Backtrack limit reached",
PREG_RECURSION_LIMIT_ERROR => "Recursion limit reached",
PREG_BAD_UTF8_ERROR => "Malformed UTF-8",
PREG_BAD_UTF8_OFFSET_ERROR => "Bad UTF-8 offset",
PREG_JIT_STACKLIMIT_ERROR => "PCRE JIT stack limit reached"
][$errorCode] ?? "Unknown (code $errorCode)";
throw new \RuntimeException("PCRE error: $message");
}
public static function getServiceUrl() : string{
$socket = @socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
if($socket === false){
throw new \RuntimeException("Socket error: " . trim(socket_strerror(socket_last_error())));
}
if(!@socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, ["sec" => 3, "usec" => 0])){
throw new \RuntimeException("Socket error: " . trim(socket_strerror(socket_last_error($socket))));
}
$contents =
"M-SEARCH * HTTP/1.1\r\n" .
"MX: 2\r\n" .
"HOST: 239.255.255.250:1900\r\n" .
"MAN: \"ssdp:discover\"\r\n" .
"ST: upnp:rootdevice\r\n\r\n";
$location = null;
for($i = 0; $i < self::MAX_DISCOVERY_ATTEMPTS; ++$i){
$sendbyte = @socket_sendto($socket, $contents, strlen($contents), 0, "239.255.255.250", 1900);
if($sendbyte === false){
throw new \RuntimeException("Socket error: " . trim(socket_strerror(socket_last_error($socket))));
}
if($sendbyte !== strlen($contents)){
throw new \RuntimeException("Socket error: Unable to send the entire contents.");
}
while(true){
if(@socket_recvfrom($socket, $buffer, 1024, 0, $responseHost, $responsePort) === false){
if(socket_last_error($socket) === SOCKET_ETIMEDOUT){
continue 2;
}
throw new \RuntimeException("Socket error: " . trim(socket_strerror(socket_last_error($socket))));
}
$pregResult = preg_match('/location\s*:\s*(.+)\n/i', $buffer, $matches);
if($pregResult === false){
//TODO: replace with preg_last_error_msg() in PHP 8.
throw self::makePcreError();
}
if($pregResult !== 0){ //this might be garbage from somewhere other than the router
$location = trim($matches[1]);
break 2;
}
}
}
socket_close($socket);
if($location === null){
throw new \RuntimeException("Unable to find the router. Ensure that network discovery is enabled in Control Panel.");
}
$url = parse_url($location);
if($url === false){
throw new \RuntimeException("Failed to parse the router's url: {$location}");
}
if(!isset($url['host'])){
throw new \RuntimeException("Failed to recognize the host name from the router's url: {$location}");
}
$urlHost = $url['host'];
if(!isset($url['port'])){
throw new \RuntimeException("Failed to recognize the port number from the router's url: {$location}");
}
$urlPort = $url['port'];
$response = Internet::getURL($location, 3, [], $err, $headers, $httpCode);
if($response === false){
throw new \RuntimeException("Unable to access XML: {$err}");
}
if($httpCode !== 200){
throw new \RuntimeException("Unable to access XML: {$response}");
}
$defaultInternalError = libxml_use_internal_errors(true);
try{
$root = new \SimpleXMLElement($response);
}catch(\Exception $e){
throw new \RuntimeException("Broken XML.");
}
libxml_use_internal_errors($defaultInternalError);
$root->registerXPathNamespace("upnp", "urn:schemas-upnp-org:device-1-0");
$xpathResult = $root->xpath(
'//upnp:device[upnp:deviceType="urn:schemas-upnp-org:device:InternetGatewayDevice:1"]' .
'/upnp:deviceList/upnp:device[upnp:deviceType="urn:schemas-upnp-org:device:WANDevice:1"]' .
'/upnp:deviceList/upnp:device[upnp:deviceType="urn:schemas-upnp-org:device:WANConnectionDevice:1"]' .
'/upnp:serviceList/upnp:service[upnp:serviceType="urn:schemas-upnp-org:service:WANIPConnection:1"]' .
'/upnp:controlURL'
);
if($xpathResult === false){
//this should be an array of 0 if there is no matching elements; false indicates a problem with the query itself
throw new AssumptionFailedError("xpath query should not error here");
}
if(count($xpathResult) === 0){
throw new \RuntimeException("Your router does not support portforwarding");
}
$controlURL = (string) $xpathResult[0];
$serviceURL = sprintf("%s:%d/%s", $urlHost, $urlPort, $controlURL);
return $serviceURL;
}
public static function PortForward(int $port) : void{
if(!Internet::$online){
throw new \RuntimeException("Server is offline");
}
if(Utils::getOS() !== Utils::OS_WINDOWS){
throw new \RuntimeException("UPnP is only supported on Windows");
if(self::$serviceURL === null){
self::$serviceURL = self::getServiceUrl();
}
if(!class_exists("COM")){
throw new \RuntimeException("UPnP requires the com_dotnet extension");
$body =
'<u:AddPortMapping xmlns:u="urn:schemas-upnp-org:service:WANIPConnection:1">' .
'<NewRemoteHost></NewRemoteHost>' .
'<NewExternalPort>' . $port . '</NewExternalPort>' .
'<NewProtocol>UDP</NewProtocol>' .
'<NewInternalPort>' . $port . '</NewInternalPort>' .
'<NewInternalClient>' . Internet::getInternalIP() . '</NewInternalClient>' .
'<NewEnabled>1</NewEnabled>' .
'<NewPortMappingDescription>PocketMine-MP</NewPortMappingDescription>' .
'<NewLeaseDuration>0</NewLeaseDuration>' .
'</u:AddPortMapping>';
$contents =
'<?xml version="1.0"?>' .
'<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">' .
'<s:Body>' . $body . '</s:Body></s:Envelope>';
$headers = [
'Content-Type: text/xml',
'SOAPAction: "urn:schemas-upnp-org:service:WANIPConnection:1#AddPortMapping"'
];
if(Internet::postURL(self::$serviceURL, $contents, 3, $headers, $err) === false){
throw new \RuntimeException("Failed to portforward using UPnP: " . $err);
}
$myLocalIP = Internet::getInternalIP();
/** @noinspection PhpUndefinedClassInspection */
$com = new \COM("HNetCfg.NATUPnP");
/** @noinspection PhpUndefinedFieldInspection */
if(!is_object($com->StaticPortMappingCollection)){
throw new \RuntimeException("Failed to portforward using UPnP. Ensure that network discovery is enabled in Control Panel.");
}
/** @noinspection PhpUndefinedFieldInspection */
$com->StaticPortMappingCollection->Add($port, "UDP", $port, $myLocalIP, true, "PocketMine-MP");
}
public static function RemovePortForward(int $port) : bool{
if(!Internet::$online){
return false;
}
if(Utils::getOS() !== Utils::OS_WINDOWS or !class_exists("COM")){
if(self::$serviceURL === null){
return false;
}
try{
/** @noinspection PhpUndefinedClassInspection */
$com = new \COM("HNetCfg.NATUPnP");
/** @noinspection PhpUndefinedFieldInspection */
if(!is_object($com->StaticPortMappingCollection)){
return false;
}
/** @noinspection PhpUndefinedFieldInspection */
$com->StaticPortMappingCollection->Remove($port, "UDP");
}catch(\Throwable $e){
$body =
'<u:DeletePortMapping xmlns:u="urn:schemas-upnp-org:service:WANIPConnection:1">' .
'<NewRemoteHost></NewRemoteHost>' .
'<NewExternalPort>' . $port . '</NewExternalPort>' .
'<NewProtocol>UDP</NewProtocol>' .
'</u:DeletePortMapping>';
$contents =
'<?xml version="1.0"?>' .
'<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">' .
'<s:Body>' . $body . '</s:Body></s:Envelope>';
$headers = [
'Content-Type: text/xml',
'SOAPAction: "urn:schemas-upnp-org:service:WANIPConnection:1#DeletePortMapping"'
];
if(Internet::postURL(self::$serviceURL, $contents, 3, $headers) === false){
return false;
}

View File

@ -87,7 +87,7 @@ network:
compression-level: 6
#Use AsyncTasks for compression. Adds half/one tick delay, less CPU load on main thread
async-compression: false
#Experimental, only for Windows. Tries to use UPnP to automatically port forward
#Experimental. Use UPnP to automatically port forward
upnp-forwarding: false
#Maximum size in bytes of packets sent over the network (default 1492 bytes). Packets larger than this will be
#fragmented or split into smaller parts. Clients can request MTU sizes up to but not more than this number.
@ -100,6 +100,9 @@ debug:
player:
#Choose whether to enable player data saving.
save-player-data: true
#If true, checks that joining players' Xbox user ID (XUID) match what was previously recorded.
#This also prevents non-XBL players using XBL players' usernames to steal their data on servers with xbox-auth=off.
verify-xuid: true
anti-cheat:
#If false, will try to prevent speed and noclip cheats. May cause movement issues.
allow-movement-cheats: true

View File

@ -177,7 +177,7 @@ class TaskScheduler{
continue;
}
$task->run($this->currentTick);
if($task->isRepeating()){
if(!$task->isCancelled() && $task->isRepeating()){
$task->setNextRun($this->currentTick + $task->getPeriod());
$this->queue->insert($task, $this->currentTick + $task->getPeriod());
}else{

View File

@ -278,8 +278,10 @@ class MainLogger extends \AttachableThreadedLogger{
* @return void
*/
public function shutdown(){
$this->shutdown = true;
$this->notify();
$this->synchronized(function() : void{
$this->shutdown = true;
$this->notify();
});
}
/**
@ -321,6 +323,7 @@ class MainLogger extends \AttachableThreadedLogger{
}
$this->logStream[] = $time->format("Y-m-d") . " " . TextFormat::clean($message) . PHP_EOL;
$this->notify();
});
}
@ -328,10 +331,11 @@ class MainLogger extends \AttachableThreadedLogger{
* @return void
*/
public function syncFlushBuffer(){
$this->syncFlush = true;
$this->synchronized(function() : void{
$this->syncFlush = true;
$this->notify(); //write immediately
});
$this->synchronized(function() : void{
while($this->syncFlush){
$this->wait(); //block until it's all been written to disk
}
@ -343,14 +347,17 @@ class MainLogger extends \AttachableThreadedLogger{
*/
private function writeLogStream($logResource) : void{
while($this->logStream->count() > 0){
/** @var string $chunk */
$chunk = $this->logStream->shift();
fwrite($logResource, $chunk);
}
if($this->syncFlush){
$this->syncFlush = false;
$this->notify(); //if this was due to a sync flush, tell the caller to stop waiting
}
$this->synchronized(function() : void{
if($this->syncFlush){
$this->syncFlush = false;
$this->notify(); //if this was due to a sync flush, tell the caller to stop waiting
}
});
}
/**
@ -365,7 +372,9 @@ class MainLogger extends \AttachableThreadedLogger{
while(!$this->shutdown){
$this->writeLogStream($logResource);
$this->synchronized(function() : void{
$this->wait(25000);
if(!$this->shutdown && !$this->syncFlush){
$this->wait();
}
});
}

View File

@ -117,7 +117,7 @@ class Utils{
/**
* Generates an unique identifier to a callable
*
* @phpstan-param callable(mixed...) : mixed $variable
* @phpstan-param anyCallable $variable
*
* @return string
*/
@ -134,7 +134,7 @@ class Utils{
/**
* Returns a readable identifier for the given Closure, including file and line.
*
* @phpstan-param \Closure(mixed...) : mixed $closure
* @phpstan-param anyClosure $closure
* @throws \ReflectionException
*/
public static function getNiceClosureName(\Closure $closure) : string{
@ -688,8 +688,8 @@ class Utils{
*
* @param callable $signature Dummy callable with the required parameters and return type
* @param callable $subject Callable to check the signature of
* @phpstan-param callable(mixed...) : mixed $signature
* @phpstan-param callable(mixed...) : mixed $subject
* @phpstan-param anyCallable $signature
* @phpstan-param anyCallable $subject
*
* @throws \DaveRandom\CallbackValidator\InvalidCallbackException
* @throws \TypeError

View File

@ -221,7 +221,7 @@ LICENSE;
$config->save();
}
private function printIpDetails() : void{
$this->message($this->lang->get("ip_get"));

View File

@ -21,5 +21,6 @@ git clone https://github.com/php-build/php-build.git
cd php-build
./install-dependencies.sh
echo '"pthreads",,"https://github.com/pmmp/pthreads.git",,,"extension",' >> share/php-build/extension/definition
PHP_BUILD_INSTALL_EXTENSION='pthreads=@2bcd8b8c10395d58b8a9bc013e3a5328080c867f yaml=2.2.0' PHP_BUILD_ZTS_ENABLE=on ./bin/php-build "$VERSION" "$INSTALL_DIR"
PHP_BUILD_INSTALL_EXTENSION='pthreads=@acc6e52b2144c61c434b62a3cb680d537e06828e yaml=2.2.1' PHP_BUILD_ZTS_ENABLE=on ./bin/php-build "$VERSION" "$INSTALL_DIR" || exit 1
rm "$INSTALL_DIR/etc/conf.d/xdebug.ini" || true
cp install-dependencies.sh "$INSTALL_DIR"

View File

@ -11,7 +11,12 @@ parameters:
path: ../../../src/pocketmine/Player.php
-
message: "#^Cannot instantiate interface pocketmine\\\\level\\\\format\\\\io\\\\LevelProvider\\.$#"
message: "#^Instanceof between pocketmine\\\\command\\\\CommandReader and pocketmine\\\\command\\\\CommandReader will always evaluate to true\\.$#"
count: 1
path: ../../../src/pocketmine/Server.php
-
message: "#^Instanceof between pocketmine\\\\network\\\\Network and pocketmine\\\\network\\\\Network will always evaluate to true\\.$#"
count: 1
path: ../../../src/pocketmine/Server.php
@ -25,16 +30,6 @@ parameters:
count: 1
path: ../../../src/pocketmine/Server.php
-
message: "#^Instanceof between pocketmine\\\\command\\\\CommandReader and pocketmine\\\\command\\\\CommandReader will always evaluate to true\\.$#"
count: 1
path: ../../../src/pocketmine/Server.php
-
message: "#^Instanceof between pocketmine\\\\network\\\\Network and pocketmine\\\\network\\\\Network will always evaluate to true\\.$#"
count: 1
path: ../../../src/pocketmine/Server.php
-
message: "#^pocketmine\\\\block\\\\Air\\:\\:__construct\\(\\) does not call parent constructor from pocketmine\\\\block\\\\Block\\.$#"
count: 1

View File

@ -1,43 +1,38 @@
parameters:
ignoreErrors:
-
message: "#^Cannot access offset string on mixed\\.$#"
count: 1
path: ../../../src/pocketmine/CrashDump.php
-
message: "#^Parameter \\#3 \\$subject of function preg_replace expects array\\|string, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/CrashDump.php
-
message: "#^Cannot access offset float\\|int on mixed\\.$#"
count: 1
path: ../../../src/pocketmine/CrashDump.php
-
message: "#^Cannot access offset string on mixed\\.$#"
count: 1
path: ../../../src/pocketmine/CrashDump.php
-
message: "#^Parameter \\#1 \\$path of static method pocketmine\\\\utils\\\\Utils\\:\\:cleanPath\\(\\) expects string, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/CrashDump.php
-
message: "#^Cannot access offset 'name' on mixed\\.$#"
count: 1
path: ../../../src/pocketmine/CrashDump.php
-
message: "#^Cannot cast mixed to int\\.$#"
count: 7
path: ../../../src/pocketmine/MemoryManager.php
-
message: "#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\\.$#"
count: 3
path: ../../../src/pocketmine/Player.php
-
message: "#^Cannot cast mixed to int\\.$#"
count: 1
path: ../../../src/pocketmine/Player.php
-
message: "#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\\.$#"
count: 3
message: "#^Parameter \\#1 \\$height of class pocketmine\\\\network\\\\mcpe\\\\protocol\\\\types\\\\SkinImage constructor expects int, mixed given\\.$#"
count: 2
path: ../../../src/pocketmine/Player.php
-
@ -51,8 +46,38 @@ parameters:
path: ../../../src/pocketmine/Player.php
-
message: "#^Parameter \\#1 \\$height of class pocketmine\\\\network\\\\mcpe\\\\protocol\\\\types\\\\SkinImage constructor expects int, mixed given\\.$#"
count: 2
message: "#^Parameter \\#1 \\.\\.\\.\\$slots of method pocketmine\\\\inventory\\\\BaseInventory\\:\\:addItem\\(\\) expects pocketmine\\\\item\\\\Item, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/Player.php
-
message: "#^Parameter \\#10 \\$persona of class pocketmine\\\\network\\\\mcpe\\\\protocol\\\\types\\\\SkinData constructor expects bool, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/Player.php
-
message: "#^Parameter \\#11 \\$personaCapeOnClassic of class pocketmine\\\\network\\\\mcpe\\\\protocol\\\\types\\\\SkinData constructor expects bool, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/Player.php
-
message: "#^Parameter \\#12 \\$capeId of class pocketmine\\\\network\\\\mcpe\\\\protocol\\\\types\\\\SkinData constructor expects string, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/Player.php
-
message: "#^Parameter \\#14 \\$armSize of class pocketmine\\\\network\\\\mcpe\\\\protocol\\\\types\\\\SkinData constructor expects string, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/Player.php
-
message: "#^Parameter \\#15 \\$skinColor of class pocketmine\\\\network\\\\mcpe\\\\protocol\\\\types\\\\SkinData constructor expects string, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/Player.php
-
message: "#^Parameter \\#2 \\$playFabId of class pocketmine\\\\network\\\\mcpe\\\\protocol\\\\types\\\\SkinData constructor expects string, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/Player.php
-
@ -61,37 +86,7 @@ parameters:
path: ../../../src/pocketmine/Player.php
-
message: "#^Parameter \\#8 \\$premium of class pocketmine\\\\network\\\\mcpe\\\\protocol\\\\types\\\\SkinData constructor expects bool, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/Player.php
-
message: "#^Parameter \\#9 \\$persona of class pocketmine\\\\network\\\\mcpe\\\\protocol\\\\types\\\\SkinData constructor expects bool, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/Player.php
-
message: "#^Parameter \\#10 \\$personaCapeOnClassic of class pocketmine\\\\network\\\\mcpe\\\\protocol\\\\types\\\\SkinData constructor expects bool, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/Player.php
-
message: "#^Parameter \\#11 \\$capeId of class pocketmine\\\\network\\\\mcpe\\\\protocol\\\\types\\\\SkinData constructor expects string, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/Player.php
-
message: "#^Parameter \\#13 \\$armSize of class pocketmine\\\\network\\\\mcpe\\\\protocol\\\\types\\\\SkinData constructor expects string, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/Player.php
-
message: "#^Parameter \\#14 \\$skinColor of class pocketmine\\\\network\\\\mcpe\\\\protocol\\\\types\\\\SkinData constructor expects string, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/Player.php
-
message: "#^Parameter \\#1 \\.\\.\\.\\$slots of method pocketmine\\\\inventory\\\\BaseInventory\\:\\:addItem\\(\\) expects pocketmine\\\\item\\\\Item, mixed given\\.$#"
message: "#^Parameter \\#9 \\$premium of class pocketmine\\\\network\\\\mcpe\\\\protocol\\\\types\\\\SkinData constructor expects bool, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/Player.php
@ -101,18 +96,28 @@ parameters:
path: ../../../src/pocketmine/PocketMine.php
-
message: "#^Parameter \\#1 \\$name of static method pocketmine\\\\level\\\\format\\\\io\\\\LevelProviderManager\\:\\:getProviderByName\\(\\) expects string, mixed given\\.$#"
message: "#^Cannot access offset 'type' on mixed\\.$#"
count: 1
path: ../../../src/pocketmine/Server.php
-
message: "#^Cannot cast mixed to float\\.$#"
count: 1
path: ../../../src/pocketmine/Server.php
-
message: "#^Cannot cast mixed to int\\.$#"
count: 7
path: ../../../src/pocketmine/Server.php
-
message: "#^Cannot cast mixed to string\\.$#"
count: 1
path: ../../../src/pocketmine/Server.php
-
message: "#^Cannot cast mixed to int\\.$#"
count: 7
message: "#^Parameter \\#1 \\$name of static method pocketmine\\\\level\\\\format\\\\io\\\\LevelProviderManager\\:\\:getProviderByName\\(\\) expects string, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/Server.php
-
@ -125,11 +130,6 @@ parameters:
count: 1
path: ../../../src/pocketmine/Server.php
-
message: "#^Cannot cast mixed to float\\.$#"
count: 1
path: ../../../src/pocketmine/Server.php
-
message: "#^Parameter \\#2 \\$endpoint of class pocketmine\\\\updater\\\\AutoUpdater constructor expects string, mixed given\\.$#"
count: 1
@ -140,11 +140,6 @@ parameters:
count: 1
path: ../../../src/pocketmine/Server.php
-
message: "#^Cannot access offset 'type' on mixed\\.$#"
count: 1
path: ../../../src/pocketmine/Server.php
-
message: "#^Method pocketmine\\\\ThreadManager\\:\\:getAll\\(\\) should return array\\<pocketmine\\\\Thread\\|pocketmine\\\\Worker\\> but returns array\\.$#"
count: 1
@ -160,23 +155,23 @@ parameters:
count: 1
path: ../../../src/pocketmine/command/defaults/StatusCommand.php
-
message: "#^Parameter \\#2 \\$host of class class@anonymous/src/pocketmine/command/defaults/TimingsCommand\\.php\\:126 constructor expects string, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/command/defaults/TimingsCommand.php
-
message: "#^Cannot access offset 0 on mixed\\.$#"
count: 1
path: ../../../src/pocketmine/command/defaults/TimingsCommand.php
-
message: "#^Cannot cast mixed to int\\.$#"
message: "#^Parameter \\#2 \\$host of class class@anonymous/src/pocketmine/command/defaults/TimingsCommand\\.php\\:126 constructor expects string, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/command/defaults/TimingsCommand.php
-
message: "#^Cannot cast mixed to float\\.$#"
count: 1
path: ../../../src/pocketmine/command/defaults/VanillaCommand.php
-
message: "#^Cannot cast mixed to float\\.$#"
message: "#^Cannot cast mixed to int\\.$#"
count: 1
path: ../../../src/pocketmine/command/defaults/VanillaCommand.php
@ -236,12 +231,12 @@ parameters:
path: ../../../src/pocketmine/level/format/io/leveldb/LevelDB.php
-
message: "#^Parameter \\#2 \\$value of class pocketmine\\\\nbt\\\\tag\\\\StringTag constructor expects string, mixed given\\.$#"
message: "#^Parameter \\#2 \\$str of function explode expects string, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/level/format/io/leveldb/LevelDB.php
-
message: "#^Parameter \\#2 \\$str of function explode expects string, mixed given\\.$#"
message: "#^Parameter \\#2 \\$value of class pocketmine\\\\nbt\\\\tag\\\\StringTag constructor expects string, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/level/format/io/leveldb/LevelDB.php
@ -260,56 +255,11 @@ parameters:
count: 1
path: ../../../src/pocketmine/level/generator/Flat.php
-
message: "#^Parameter \\#4 \\$q0 of static method pocketmine\\\\level\\\\generator\\\\noise\\\\Noise\\:\\:linearLerp\\(\\) expects float, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/level/generator/noise/Noise.php
-
message: "#^Parameter \\#5 \\$q1 of static method pocketmine\\\\level\\\\generator\\\\noise\\\\Noise\\:\\:linearLerp\\(\\) expects float, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/level/generator/noise/Noise.php
-
message: "#^Cannot access offset int on mixed\\.$#"
count: 6
path: ../../../src/pocketmine/level/generator/noise/Noise.php
-
message: "#^Parameter \\#1 \\$buffer of class pocketmine\\\\network\\\\mcpe\\\\protocol\\\\BatchPacket constructor expects string, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/network/CompressBatchedTask.php
-
message: "#^Parameter \\#1 \\$v of method pocketmine\\\\utils\\\\BinaryStream\\:\\:putByte\\(\\) expects int, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/network/mcpe/NetworkBinaryStream.php
-
message: "#^Parameter \\#1 \\$v of method pocketmine\\\\utils\\\\BinaryStream\\:\\:putLShort\\(\\) expects int, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/network/mcpe/NetworkBinaryStream.php
-
message: "#^Parameter \\#1 \\$v of method pocketmine\\\\utils\\\\BinaryStream\\:\\:putVarInt\\(\\) expects int, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/network/mcpe/NetworkBinaryStream.php
-
message: "#^Parameter \\#1 \\$v of method pocketmine\\\\utils\\\\BinaryStream\\:\\:putLFloat\\(\\) expects float, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/network/mcpe/NetworkBinaryStream.php
-
message: "#^Parameter \\#1 \\$v of method pocketmine\\\\network\\\\mcpe\\\\NetworkBinaryStream\\:\\:putString\\(\\) expects string, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/network/mcpe/NetworkBinaryStream.php
-
message: "#^Parameter \\#1 \\$data of method pocketmine\\\\nbt\\\\NBTStream\\:\\:write\\(\\) expects array\\<pocketmine\\\\nbt\\\\tag\\\\NamedTag\\>\\|pocketmine\\\\nbt\\\\tag\\\\NamedTag, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/network/mcpe/NetworkBinaryStream.php
-
message: "#^Cannot access property \\$x on mixed\\.$#"
count: 1
@ -325,6 +275,36 @@ parameters:
count: 1
path: ../../../src/pocketmine/network/mcpe/NetworkBinaryStream.php
-
message: "#^Parameter \\#1 \\$data of method pocketmine\\\\nbt\\\\NBTStream\\:\\:write\\(\\) expects array\\<pocketmine\\\\nbt\\\\tag\\\\NamedTag\\>\\|pocketmine\\\\nbt\\\\tag\\\\NamedTag, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/network/mcpe/NetworkBinaryStream.php
-
message: "#^Parameter \\#1 \\$v of method pocketmine\\\\network\\\\mcpe\\\\NetworkBinaryStream\\:\\:putString\\(\\) expects string, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/network/mcpe/NetworkBinaryStream.php
-
message: "#^Parameter \\#1 \\$v of method pocketmine\\\\utils\\\\BinaryStream\\:\\:putByte\\(\\) expects int, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/network/mcpe/NetworkBinaryStream.php
-
message: "#^Parameter \\#1 \\$v of method pocketmine\\\\utils\\\\BinaryStream\\:\\:putLFloat\\(\\) expects float, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/network/mcpe/NetworkBinaryStream.php
-
message: "#^Parameter \\#1 \\$v of method pocketmine\\\\utils\\\\BinaryStream\\:\\:putLShort\\(\\) expects int, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/network/mcpe/NetworkBinaryStream.php
-
message: "#^Parameter \\#1 \\$v of method pocketmine\\\\utils\\\\BinaryStream\\:\\:putVarInt\\(\\) expects int, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/network/mcpe/NetworkBinaryStream.php
-
message: "#^Parameter \\#1 \\$v of method pocketmine\\\\utils\\\\BinaryStream\\:\\:putVarLong\\(\\) expects int, mixed given\\.$#"
count: 1
@ -335,11 +315,6 @@ parameters:
count: 1
path: ../../../src/pocketmine/network/mcpe/NetworkBinaryStream.php
-
message: "#^Cannot cast mixed to int\\.$#"
count: 1
path: ../../../src/pocketmine/network/mcpe/RakLibInterface.php
-
message: "#^Cannot access offset 'down' on mixed\\.$#"
count: 1
@ -351,14 +326,9 @@ parameters:
path: ../../../src/pocketmine/network/mcpe/RakLibInterface.php
-
message: "#^Cannot access offset 'x5u' on mixed\\.$#"
count: 2
path: ../../../src/pocketmine/network/mcpe/VerifyLoginTask.php
-
message: "#^Cannot access offset 'nbf' on mixed\\.$#"
count: 2
path: ../../../src/pocketmine/network/mcpe/VerifyLoginTask.php
message: "#^Cannot cast mixed to int\\.$#"
count: 1
path: ../../../src/pocketmine/network/mcpe/RakLibInterface.php
-
message: "#^Cannot access offset 'exp' on mixed\\.$#"
@ -370,6 +340,16 @@ parameters:
count: 1
path: ../../../src/pocketmine/network/mcpe/VerifyLoginTask.php
-
message: "#^Cannot access offset 'nbf' on mixed\\.$#"
count: 2
path: ../../../src/pocketmine/network/mcpe/VerifyLoginTask.php
-
message: "#^Cannot access offset 'x5u' on mixed\\.$#"
count: 2
path: ../../../src/pocketmine/network/mcpe/VerifyLoginTask.php
-
message: "#^Cannot access offset string on mixed\\.$#"
count: 1
@ -396,8 +376,8 @@ parameters:
path: ../../../src/pocketmine/network/mcpe/protocol/AddPlayerPacket.php
-
message: "#^Property pocketmine\\\\network\\\\mcpe\\\\protocol\\\\LoginPacket\\:\\:\\$chainData \\(array\\(\\?'chain' \\=\\> array\\<int, string\\>\\)\\) does not accept mixed\\.$#"
count: 1
message: "#^Cannot access offset 'XUID' on mixed\\.$#"
count: 2
path: ../../../src/pocketmine/network/mcpe/protocol/LoginPacket.php
-
@ -416,12 +396,7 @@ parameters:
path: ../../../src/pocketmine/network/mcpe/protocol/LoginPacket.php
-
message: "#^Cannot access offset 'XUID' on mixed\\.$#"
count: 2
path: ../../../src/pocketmine/network/mcpe/protocol/LoginPacket.php
-
message: "#^Property pocketmine\\\\network\\\\mcpe\\\\protocol\\\\LoginPacket\\:\\:\\$identityPublicKey \\(string\\) does not accept mixed\\.$#"
message: "#^Property pocketmine\\\\network\\\\mcpe\\\\protocol\\\\LoginPacket\\:\\:\\$chainData \\(array\\(\\?'chain' \\=\\> array\\<int, string\\>\\)\\) does not accept mixed\\.$#"
count: 1
path: ../../../src/pocketmine/network/mcpe/protocol/LoginPacket.php
@ -431,7 +406,7 @@ parameters:
path: ../../../src/pocketmine/network/mcpe/protocol/LoginPacket.php
-
message: "#^Property pocketmine\\\\network\\\\mcpe\\\\protocol\\\\LoginPacket\\:\\:\\$serverAddress \\(string\\) does not accept mixed\\.$#"
message: "#^Property pocketmine\\\\network\\\\mcpe\\\\protocol\\\\LoginPacket\\:\\:\\$identityPublicKey \\(string\\) does not accept mixed\\.$#"
count: 1
path: ../../../src/pocketmine/network/mcpe/protocol/LoginPacket.php
@ -440,6 +415,11 @@ parameters:
count: 1
path: ../../../src/pocketmine/network/mcpe/protocol/LoginPacket.php
-
message: "#^Property pocketmine\\\\network\\\\mcpe\\\\protocol\\\\LoginPacket\\:\\:\\$serverAddress \\(string\\) does not accept mixed\\.$#"
count: 1
path: ../../../src/pocketmine/network/mcpe/protocol/LoginPacket.php
-
message: "#^Property pocketmine\\\\network\\\\mcpe\\\\protocol\\\\SetActorDataPacket\\:\\:\\$metadata \\(array\\<int, array\\(int, mixed\\)\\>\\) does not accept array\\<int, mixed\\>\\.$#"
count: 1
@ -455,13 +435,38 @@ parameters:
count: 1
path: ../../../src/pocketmine/permission/Permission.php
-
message: "#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\\.$#"
count: 1
path: ../../../src/pocketmine/plugin/PluginDescription.php
-
message: "#^Array \\(array\\<string\\>\\) does not accept mixed\\.$#"
count: 1
path: ../../../src/pocketmine/plugin/PluginDescription.php
-
message: "#^Cannot cast mixed to string\\.$#"
count: 4
path: ../../../src/pocketmine/plugin/PluginDescription.php
-
message: "#^Parameter \\#1 \\$data of static method pocketmine\\\\permission\\\\Permission\\:\\:loadPermissions\\(\\) expects array\\<string, array\\<string, mixed\\>\\>, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/plugin/PluginDescription.php
-
message: "#^Parameter \\#1 \\$haystack of function stripos expects string, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/plugin/PluginDescription.php
-
message: "#^Parameter \\#1 \\$plugin of method pocketmine\\\\plugin\\\\PluginDescription\\:\\:loadMap\\(\\) expects array, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/plugin/PluginDescription.php
-
message: "#^Property pocketmine\\\\plugin\\\\PluginDescription\\:\\:\\$name \\(string\\) does not accept mixed\\.$#"
message: "#^Parameter \\#1 \\$str of function mb_strtoupper expects string, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/plugin/PluginDescription.php
@ -475,23 +480,13 @@ parameters:
count: 1
path: ../../../src/pocketmine/plugin/PluginDescription.php
-
message: "#^Cannot cast mixed to string\\.$#"
count: 4
path: ../../../src/pocketmine/plugin/PluginDescription.php
-
message: "#^Property pocketmine\\\\plugin\\\\PluginDescription\\:\\:\\$main \\(string\\) does not accept mixed\\.$#"
count: 1
path: ../../../src/pocketmine/plugin/PluginDescription.php
-
message: "#^Parameter \\#1 \\$haystack of function stripos expects string, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/plugin/PluginDescription.php
-
message: "#^Parameter \\#1 \\$str of function mb_strtoupper expects string, mixed given\\.$#"
message: "#^Property pocketmine\\\\plugin\\\\PluginDescription\\:\\:\\$name \\(string\\) does not accept mixed\\.$#"
count: 1
path: ../../../src/pocketmine/plugin/PluginDescription.php
@ -500,80 +495,60 @@ parameters:
count: 1
path: ../../../src/pocketmine/plugin/PluginDescription.php
-
message: "#^Array \\(array\\<string\\>\\) does not accept mixed\\.$#"
count: 1
path: ../../../src/pocketmine/plugin/PluginDescription.php
-
message: "#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\\.$#"
count: 1
path: ../../../src/pocketmine/plugin/PluginDescription.php
-
message: "#^Parameter \\#1 \\$data of static method pocketmine\\\\permission\\\\Permission\\:\\:loadPermissions\\(\\) expects array\\<string, array\\<string, mixed\\>\\>, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/plugin/PluginDescription.php
-
message: "#^Parameter \\#1 \\$description of method pocketmine\\\\command\\\\Command\\:\\:setDescription\\(\\) expects string, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/plugin/PluginManager.php
-
message: "#^Parameter \\#1 \\$usage of method pocketmine\\\\command\\\\Command\\:\\:setUsage\\(\\) expects string, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/plugin/PluginManager.php
-
message: "#^Parameter \\#1 \\$permissionMessage of method pocketmine\\\\command\\\\Command\\:\\:setPermissionMessage\\(\\) expects string, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/plugin/PluginManager.php
-
message: "#^Parameter \\#1 \\$usage of method pocketmine\\\\command\\\\Command\\:\\:setUsage\\(\\) expects string, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/plugin/PluginManager.php
-
message: "#^Parameter \\#2 \\$code of class pocketmine\\\\resourcepacks\\\\ResourcePackException constructor expects int, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/resourcepacks/ZippedResourcePack.php
-
message: "#^Property pocketmine\\\\scheduler\\\\AsyncTask\\:\\:\\$result \\(bool\\|float\\|int\\|string\\|null\\) does not accept mixed\\.$#"
count: 1
path: ../../../src/pocketmine/scheduler/AsyncTask.php
-
message: "#^Parameter \\#1 \\$variable_representation of function unserialize expects string, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/scheduler/AsyncTask.php
-
message: "#^Parameter \\#2 \\$timestamp of function date expects int, mixed given\\.$#"
message: "#^Property pocketmine\\\\scheduler\\\\AsyncTask\\:\\:\\$result \\(bool\\|float\\|int\\|string\\|null\\) does not accept mixed\\.$#"
count: 1
path: ../../../src/pocketmine/updater/AutoUpdater.php
path: ../../../src/pocketmine/scheduler/AsyncTask.php
-
message: "#^Parameter \\#1 \\$baseVersion of class pocketmine\\\\utils\\\\VersionString constructor expects string, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/updater/AutoUpdater.php
-
message: "#^Parameter \\#2 \\$isDevBuild of class pocketmine\\\\utils\\\\VersionString constructor expects bool, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/updater/AutoUpdater.php
-
message: "#^Parameter \\#3 \\$buildNumber of class pocketmine\\\\utils\\\\VersionString constructor expects int, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/updater/AutoUpdater.php
-
message: "#^Parameter \\#1 \\$str of function strtolower expects string, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/updater/AutoUpdater.php
-
message: "#^Parameter \\#3 \\$length of function substr expects int, mixed given\\.$#"
message: "#^Parameter \\#2 \\$isDevBuild of class pocketmine\\\\utils\\\\VersionString constructor expects bool, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/utils/Internet.php
path: ../../../src/pocketmine/updater/AutoUpdater.php
-
message: "#^Parameter \\#2 \\$timestamp of function date expects int, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/updater/AutoUpdater.php
-
message: "#^Parameter \\#3 \\$buildNumber of class pocketmine\\\\utils\\\\VersionString constructor expects int, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/updater/AutoUpdater.php
-
message: "#^Parameter \\#2 \\$start of function substr expects int, mixed given\\.$#"
@ -581,9 +556,9 @@ parameters:
path: ../../../src/pocketmine/utils/Internet.php
-
message: "#^Parameter \\#2 \\$str of function fwrite expects string, mixed given\\.$#"
message: "#^Parameter \\#3 \\$length of function substr expects int, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/utils/MainLogger.php
path: ../../../src/pocketmine/utils/Internet.php
-
message: "#^Cannot access offset 'status' on mixed\\.$#"
@ -595,13 +570,13 @@ parameters:
count: 2
path: ../../../src/pocketmine/utils/Timezone.php
-
message: "#^Parameter \\#2 \\$input1 of function array_map expects array, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/utils/Utils.php
-
message: "#^Parameter \\#1 \\$path of static method pocketmine\\\\utils\\\\Utils\\:\\:cleanPath\\(\\) expects string, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/utils/Utils.php
-
message: "#^Parameter \\#2 \\$input1 of function array_map expects array, mixed given\\.$#"
count: 1
path: ../../../src/pocketmine/utils/Utils.php

View File

@ -1,7 +0,0 @@
parameters:
ignoreErrors:
-
message: "#^Access to an undefined property COM\\:\\:\\$StaticPortMappingCollection\\.$#"
count: 2
path: ../../../src/pocketmine/network/upnp/UPnP.php

View File

@ -1,7 +1,7 @@
parameters:
ignoreErrors:
-
message: "#^Property pocketmine\\\\Player\\:\\:\\$sessionAdapter \\(pocketmine\\\\network\\\\mcpe\\\\PlayerNetworkSessionAdapter\\) does not accept null\\.$#"
message: "#^Property pocketmine\\\\Player\\:\\:\\$craftingGrid \\(pocketmine\\\\inventory\\\\CraftingGrid\\) does not accept null\\.$#"
count: 1
path: ../../../src/pocketmine/Player.php
@ -11,12 +11,12 @@ parameters:
path: ../../../src/pocketmine/Player.php
-
message: "#^Property pocketmine\\\\Player\\:\\:\\$craftingGrid \\(pocketmine\\\\inventory\\\\CraftingGrid\\) does not accept null\\.$#"
message: "#^Property pocketmine\\\\Player\\:\\:\\$perm \\(pocketmine\\\\permission\\\\PermissibleBase\\) does not accept null\\.$#"
count: 1
path: ../../../src/pocketmine/Player.php
-
message: "#^Property pocketmine\\\\Player\\:\\:\\$perm \\(pocketmine\\\\permission\\\\PermissibleBase\\) does not accept null\\.$#"
message: "#^Property pocketmine\\\\Player\\:\\:\\$sessionAdapter \\(pocketmine\\\\network\\\\mcpe\\\\PlayerNetworkSessionAdapter\\) does not accept null\\.$#"
count: 1
path: ../../../src/pocketmine/Player.php
@ -26,12 +26,12 @@ parameters:
path: ../../../src/pocketmine/entity/Entity.php
-
message: "#^Property pocketmine\\\\entity\\\\Human\\:\\:\\$inventory \\(pocketmine\\\\inventory\\\\PlayerInventory\\) does not accept null\\.$#"
message: "#^Property pocketmine\\\\entity\\\\Human\\:\\:\\$enderChestInventory \\(pocketmine\\\\inventory\\\\EnderChestInventory\\) does not accept null\\.$#"
count: 1
path: ../../../src/pocketmine/entity/Human.php
-
message: "#^Property pocketmine\\\\entity\\\\Human\\:\\:\\$enderChestInventory \\(pocketmine\\\\inventory\\\\EnderChestInventory\\) does not accept null\\.$#"
message: "#^Property pocketmine\\\\entity\\\\Human\\:\\:\\$inventory \\(pocketmine\\\\inventory\\\\PlayerInventory\\) does not accept null\\.$#"
count: 1
path: ../../../src/pocketmine/entity/Human.php
@ -51,12 +51,12 @@ parameters:
path: ../../../src/pocketmine/inventory/DoubleChestInventory.php
-
message: "#^Property pocketmine\\\\level\\\\Level\\:\\:\\$provider \\(pocketmine\\\\level\\\\format\\\\io\\\\LevelProvider\\) does not accept null\\.$#"
message: "#^Property pocketmine\\\\level\\\\Level\\:\\:\\$blockMetadata \\(pocketmine\\\\metadata\\\\BlockMetadataStore\\) does not accept null\\.$#"
count: 1
path: ../../../src/pocketmine/level/Level.php
-
message: "#^Property pocketmine\\\\level\\\\Level\\:\\:\\$blockMetadata \\(pocketmine\\\\metadata\\\\BlockMetadataStore\\) does not accept null\\.$#"
message: "#^Property pocketmine\\\\level\\\\Level\\:\\:\\$provider \\(pocketmine\\\\level\\\\format\\\\io\\\\LevelProvider\\) does not accept null\\.$#"
count: 1
path: ../../../src/pocketmine/level/Level.php

View File

@ -5,23 +5,23 @@ parameters:
count: 1
path: ../../../build/make-release.php
-
message: "#^Parameter \\#1 \\$strings of function pocketmine\\\\build\\\\server_phar\\\\preg_quote_array expects array\\<string\\>, array\\<int, string\\|false\\> given\\.$#"
count: 1
path: ../../../build/server-phar.php
-
message: "#^Parameter \\#1 \\$pharPath of function pocketmine\\\\build\\\\server_phar\\\\buildPhar expects string, array\\<int, mixed\\>\\|string\\|false given\\.$#"
count: 1
path: ../../../build/server-phar.php
-
message: "#^Parameter \\#1 \\$fp of function fwrite expects resource, resource\\|false given\\.$#"
message: "#^Parameter \\#1 \\$strings of function pocketmine\\\\build\\\\server_phar\\\\preg_quote_array expects array\\<string\\>, array\\<int, string\\|false\\> given\\.$#"
count: 1
path: ../../../build/server-phar.php
-
message: "#^Parameter \\#1 \\$fp of function fclose expects resource, resource\\|false given\\.$#"
count: 1
path: ../../../src/pocketmine/MemoryManager.php
-
message: "#^Parameter \\#1 \\$fp of function fclose expects resource, resource\\|false given\\.$#"
message: "#^Parameter \\#1 \\$fp of function fwrite expects resource, resource\\|false given\\.$#"
count: 1
path: ../../../src/pocketmine/MemoryManager.php
@ -31,74 +31,59 @@ parameters:
path: ../../../src/pocketmine/Player.php
-
message: "#^Parameter \\#2 \\$resourcePatch of class pocketmine\\\\network\\\\mcpe\\\\protocol\\\\types\\\\SkinData constructor expects string, string\\|false given\\.$#"
message: "#^Parameter \\#3 \\$resourcePatch of class pocketmine\\\\network\\\\mcpe\\\\protocol\\\\types\\\\SkinData constructor expects string, string\\|false given\\.$#"
count: 1
path: ../../../src/pocketmine/Player.php
-
message: "#^Parameter \\#6 \\$geometryData of class pocketmine\\\\network\\\\mcpe\\\\protocol\\\\types\\\\SkinData constructor expects string, string\\|false given\\.$#"
message: "#^Parameter \\#7 \\$geometryData of class pocketmine\\\\network\\\\mcpe\\\\protocol\\\\types\\\\SkinData constructor expects string, string\\|false given\\.$#"
count: 1
path: ../../../src/pocketmine/Player.php
-
message: "#^Parameter \\#7 \\$animationData of class pocketmine\\\\network\\\\mcpe\\\\protocol\\\\types\\\\SkinData constructor expects string, string\\|false given\\.$#"
message: "#^Parameter \\#8 \\$animationData of class pocketmine\\\\network\\\\mcpe\\\\protocol\\\\types\\\\SkinData constructor expects string, string\\|false given\\.$#"
count: 1
path: ../../../src/pocketmine/Player.php
-
message: "#^Binary operation \"\\.\" between array\\<int, mixed\\>\\|string\\|false and '/'\\|'\\\\\\\\' results in an error\\.$#"
count: 2
path: ../../../src/pocketmine/PocketMine.php
-
message: "#^Parameter \\#1 \\$haystack of function substr_count expects string, string\\|false given\\.$#"
count: 1
path: ../../../src/pocketmine/PocketMine.php
-
message: "#^Parameter \\#1 \\$version1 of function version_compare expects string, string\\|false given\\.$#"
count: 2
path: ../../../src/pocketmine/PocketMine.php
-
message: "#^Parameter \\#1 \\$path of function realpath expects string, array\\<int, mixed\\>\\|string\\|false given\\.$#"
count: 1
path: ../../../src/pocketmine/PocketMine.php
-
message: "#^Binary operation \"\\.\" between array\\<int, mixed\\>\\|string\\|false and '/'\\|'\\\\\\\\' results in an error\\.$#"
count: 2
path: ../../../src/pocketmine/PocketMine.php
-
message: "#^Parameter \\#1 \\$path of function realpath expects string, string\\|false given\\.$#"
count: 2
path: ../../../src/pocketmine/PocketMine.php
-
message: "#^Parameter \\#1 \\$fp of function flock expects resource, resource\\|false given\\.$#"
count: 4
message: "#^Parameter \\#1 \\$version1 of function version_compare expects string, string\\|false given\\.$#"
count: 2
path: ../../../src/pocketmine/PocketMine.php
-
message: "#^Parameter \\#1 \\$source of function stream_get_contents expects resource, resource\\|false given\\.$#"
message: "#^Cannot cast array\\<int, mixed\\>\\|string\\|false to int\\.$#"
count: 1
path: ../../../src/pocketmine/PocketMine.php
path: ../../../src/pocketmine/Server.php
-
message: "#^Parameter \\#1 \\$fp of function ftruncate expects resource, resource\\|false given\\.$#"
message: "#^Cannot cast array\\<int, mixed\\>\\|string\\|false to string\\.$#"
count: 1
path: ../../../src/pocketmine/PocketMine.php
path: ../../../src/pocketmine/Server.php
-
message: "#^Parameter \\#1 \\$fp of function fwrite expects resource, resource\\|false given\\.$#"
message: "#^Only numeric types are allowed in \\+, int\\|false given on the left side\\.$#"
count: 1
path: ../../../src/pocketmine/PocketMine.php
-
message: "#^Parameter \\#1 \\$fp of function fflush expects resource, resource\\|false given\\.$#"
count: 1
path: ../../../src/pocketmine/PocketMine.php
-
message: "#^Parameter \\#1 \\$fp of function fclose expects resource, resource\\|false given\\.$#"
count: 1
path: ../../../src/pocketmine/PocketMine.php
path: ../../../src/pocketmine/Server.php
-
message: "#^Parameter \\#1 \\$buffer of method pocketmine\\\\nbt\\\\NBTStream\\:\\:readCompressed\\(\\) expects string, string\\|false given\\.$#"
@ -110,26 +95,11 @@ parameters:
count: 1
path: ../../../src/pocketmine/Server.php
-
message: "#^Cannot cast array\\<int, mixed\\>\\|string\\|false to string\\.$#"
count: 1
path: ../../../src/pocketmine/Server.php
-
message: "#^Cannot cast array\\<int, mixed\\>\\|string\\|false to int\\.$#"
count: 1
path: ../../../src/pocketmine/Server.php
-
message: "#^Parameter \\#3 \\$subject of function str_replace expects array\\|string, string\\|false given\\.$#"
count: 1
path: ../../../src/pocketmine/Server.php
-
message: "#^Only numeric types are allowed in \\+, int\\|false given on the left side\\.$#"
count: 1
path: ../../../src/pocketmine/Server.php
-
message: "#^Parameter \\#1 \\$x of method pocketmine\\\\level\\\\Level\\:\\:getBlockAt\\(\\) expects int, float\\|int given\\.$#"
count: 1
@ -155,36 +125,36 @@ parameters:
count: 3
path: ../../../src/pocketmine/block/Grass.php
-
message: "#^Parameter \\#1 \\$x of static method pocketmine\\\\level\\\\Level\\:\\:blockHash\\(\\) expects int, float\\|int given\\.$#"
count: 3
path: ../../../src/pocketmine/block/Liquid.php
-
message: "#^Parameter \\#2 \\$y of static method pocketmine\\\\level\\\\Level\\:\\:blockHash\\(\\) expects int, float\\|int given\\.$#"
count: 3
path: ../../../src/pocketmine/block/Liquid.php
-
message: "#^Parameter \\#3 \\$z of static method pocketmine\\\\level\\\\Level\\:\\:blockHash\\(\\) expects int, float\\|int given\\.$#"
count: 3
path: ../../../src/pocketmine/block/Liquid.php
-
message: "#^Parameter \\#1 \\$blockX of method pocketmine\\\\block\\\\Liquid\\:\\:calculateFlowCost\\(\\) expects int, float\\|int given\\.$#"
count: 1
path: ../../../src/pocketmine/block/Liquid.php
-
message: "#^Parameter \\#1 \\$x of static method pocketmine\\\\level\\\\Level\\:\\:blockHash\\(\\) expects int, float\\|int given\\.$#"
count: 3
path: ../../../src/pocketmine/block/Liquid.php
-
message: "#^Parameter \\#2 \\$blockY of method pocketmine\\\\block\\\\Liquid\\:\\:calculateFlowCost\\(\\) expects int, float\\|int given\\.$#"
count: 1
path: ../../../src/pocketmine/block/Liquid.php
-
message: "#^Parameter \\#2 \\$y of static method pocketmine\\\\level\\\\Level\\:\\:blockHash\\(\\) expects int, float\\|int given\\.$#"
count: 3
path: ../../../src/pocketmine/block/Liquid.php
-
message: "#^Parameter \\#3 \\$blockZ of method pocketmine\\\\block\\\\Liquid\\:\\:calculateFlowCost\\(\\) expects int, float\\|int given\\.$#"
count: 1
path: ../../../src/pocketmine/block/Liquid.php
-
message: "#^Parameter \\#3 \\$z of static method pocketmine\\\\level\\\\Level\\:\\:blockHash\\(\\) expects int, float\\|int given\\.$#"
count: 3
path: ../../../src/pocketmine/block/Liquid.php
-
message: "#^Parameter \\#1 \\$min of function mt_rand expects int, float\\|int given\\.$#"
count: 3
@ -226,7 +196,7 @@ parameters:
path: ../../../src/pocketmine/block/Sugarcane.php
-
message: "#^Static property pocketmine\\\\command\\\\CommandReader\\:\\:\\$stdin \\(resource\\) does not accept resource\\|false\\.$#"
message: "#^Cannot access offset 'mode' on array\\(0 \\=\\> int, 1 \\=\\> int, 2 \\=\\> int, 3 \\=\\> int, 4 \\=\\> int, 5 \\=\\> int, 6 \\=\\> int, 7 \\=\\> int, \\.\\.\\.\\)\\|false\\.$#"
count: 1
path: ../../../src/pocketmine/command/CommandReader.php
@ -236,7 +206,7 @@ parameters:
path: ../../../src/pocketmine/command/CommandReader.php
-
message: "#^Cannot access offset 'mode' on array\\(0 \\=\\> int, 1 \\=\\> int, 2 \\=\\> int, 3 \\=\\> int, 4 \\=\\> int, 5 \\=\\> int, 6 \\=\\> int, 7 \\=\\> int, \\.\\.\\.\\)\\|false\\.$#"
message: "#^Static property pocketmine\\\\command\\\\CommandReader\\:\\:\\$stdin \\(resource\\) does not accept resource\\|false\\.$#"
count: 1
path: ../../../src/pocketmine/command/CommandReader.php
@ -251,8 +221,8 @@ parameters:
path: ../../../src/pocketmine/command/defaults/PardonIpCommand.php
-
message: "#^Parameter \\#1 \\$fp of static method pocketmine\\\\timings\\\\TimingsHandler\\:\\:printTimings\\(\\) expects resource, resource\\|false given\\.$#"
count: 1
message: "#^Parameter \\#1 \\$fp of function fclose expects resource, resource\\|false given\\.$#"
count: 2
path: ../../../src/pocketmine/command/defaults/TimingsCommand.php
-
@ -261,13 +231,13 @@ parameters:
path: ../../../src/pocketmine/command/defaults/TimingsCommand.php
-
message: "#^Parameter \\#1 \\$source of function stream_get_contents expects resource, resource\\|false given\\.$#"
message: "#^Parameter \\#1 \\$fp of static method pocketmine\\\\timings\\\\TimingsHandler\\:\\:printTimings\\(\\) expects resource, resource\\|false given\\.$#"
count: 1
path: ../../../src/pocketmine/command/defaults/TimingsCommand.php
-
message: "#^Parameter \\#1 \\$fp of function fclose expects resource, resource\\|false given\\.$#"
count: 2
message: "#^Parameter \\#1 \\$source of function stream_get_contents expects resource, resource\\|false given\\.$#"
count: 1
path: ../../../src/pocketmine/command/defaults/TimingsCommand.php
-
@ -311,12 +281,12 @@ parameters:
path: ../../../src/pocketmine/event/HandlerList.php
-
message: "#^Parameter \\#1 \\$json of function json_decode expects string, string\\|false given\\.$#"
message: "#^Method pocketmine\\\\inventory\\\\CraftingManager\\:\\:hashOutputs\\(\\) should return string but returns string\\|false\\.$#"
count: 1
path: ../../../src/pocketmine/inventory/CraftingManager.php
-
message: "#^Method pocketmine\\\\inventory\\\\CraftingManager\\:\\:hashOutputs\\(\\) should return string but returns string\\|false\\.$#"
message: "#^Parameter \\#1 \\$json of function json_decode expects string, string\\|false given\\.$#"
count: 1
path: ../../../src/pocketmine/inventory/CraftingManager.php
@ -336,47 +306,7 @@ parameters:
path: ../../../src/pocketmine/lang/BaseLang.php
-
message: "#^Parameter \\#1 \\$x of static method pocketmine\\\\level\\\\Level\\:\\:blockHash\\(\\) expects int, float\\|int given\\.$#"
count: 2
path: ../../../src/pocketmine/level/Explosion.php
-
message: "#^Parameter \\#2 \\$y of static method pocketmine\\\\level\\\\Level\\:\\:blockHash\\(\\) expects int, float\\|int given\\.$#"
count: 2
path: ../../../src/pocketmine/level/Explosion.php
-
message: "#^Parameter \\#3 \\$z of static method pocketmine\\\\level\\\\Level\\:\\:blockHash\\(\\) expects int, float\\|int given\\.$#"
count: 2
path: ../../../src/pocketmine/level/Explosion.php
-
message: "#^Parameter \\#1 \\$x of method pocketmine\\\\level\\\\Level\\:\\:setBlockIdAt\\(\\) expects int, float\\|int given\\.$#"
count: 1
path: ../../../src/pocketmine/level/Explosion.php
-
message: "#^Parameter \\#2 \\$y of method pocketmine\\\\level\\\\Level\\:\\:setBlockIdAt\\(\\) expects int, float\\|int given\\.$#"
count: 1
path: ../../../src/pocketmine/level/Explosion.php
-
message: "#^Parameter \\#3 \\$z of method pocketmine\\\\level\\\\Level\\:\\:setBlockIdAt\\(\\) expects int, float\\|int given\\.$#"
count: 1
path: ../../../src/pocketmine/level/Explosion.php
-
message: "#^Parameter \\#1 \\$x of method pocketmine\\\\level\\\\Level\\:\\:setBlockDataAt\\(\\) expects int, float\\|int given\\.$#"
count: 1
path: ../../../src/pocketmine/level/Explosion.php
-
message: "#^Parameter \\#2 \\$y of method pocketmine\\\\level\\\\Level\\:\\:setBlockDataAt\\(\\) expects int, float\\|int given\\.$#"
count: 1
path: ../../../src/pocketmine/level/Explosion.php
-
message: "#^Parameter \\#3 \\$z of method pocketmine\\\\level\\\\Level\\:\\:setBlockDataAt\\(\\) expects int, float\\|int given\\.$#"
message: "#^Parameter \\#1 \\$x of method pocketmine\\\\level\\\\Level\\:\\:getBlockAt\\(\\) expects int, float\\|int given\\.$#"
count: 1
path: ../../../src/pocketmine/level/Explosion.php
@ -385,39 +315,54 @@ parameters:
count: 1
path: ../../../src/pocketmine/level/Explosion.php
-
message: "#^Parameter \\#2 \\$y of method pocketmine\\\\level\\\\Level\\:\\:getTileAt\\(\\) expects int, float\\|int given\\.$#"
count: 1
path: ../../../src/pocketmine/level/Explosion.php
-
message: "#^Parameter \\#3 \\$z of method pocketmine\\\\level\\\\Level\\:\\:getTileAt\\(\\) expects int, float\\|int given\\.$#"
count: 1
path: ../../../src/pocketmine/level/Explosion.php
-
message: "#^Parameter \\#1 \\$x of method pocketmine\\\\level\\\\Level\\:\\:isInWorld\\(\\) expects int, float\\|int given\\.$#"
count: 1
path: ../../../src/pocketmine/level/Explosion.php
-
message: "#^Parameter \\#1 \\$x of method pocketmine\\\\level\\\\Level\\:\\:setBlockDataAt\\(\\) expects int, float\\|int given\\.$#"
count: 1
path: ../../../src/pocketmine/level/Explosion.php
-
message: "#^Parameter \\#1 \\$x of method pocketmine\\\\level\\\\Level\\:\\:setBlockIdAt\\(\\) expects int, float\\|int given\\.$#"
count: 1
path: ../../../src/pocketmine/level/Explosion.php
-
message: "#^Parameter \\#1 \\$x of static method pocketmine\\\\level\\\\Level\\:\\:blockHash\\(\\) expects int, float\\|int given\\.$#"
count: 2
path: ../../../src/pocketmine/level/Explosion.php
-
message: "#^Parameter \\#2 \\$y of method pocketmine\\\\level\\\\Level\\:\\:getBlockAt\\(\\) expects int, float\\|int given\\.$#"
count: 1
path: ../../../src/pocketmine/level/Explosion.php
-
message: "#^Parameter \\#2 \\$y of method pocketmine\\\\level\\\\Level\\:\\:getTileAt\\(\\) expects int, float\\|int given\\.$#"
count: 1
path: ../../../src/pocketmine/level/Explosion.php
-
message: "#^Parameter \\#2 \\$y of method pocketmine\\\\level\\\\Level\\:\\:isInWorld\\(\\) expects int, float\\|int given\\.$#"
count: 1
path: ../../../src/pocketmine/level/Explosion.php
-
message: "#^Parameter \\#3 \\$z of method pocketmine\\\\level\\\\Level\\:\\:isInWorld\\(\\) expects int, float\\|int given\\.$#"
message: "#^Parameter \\#2 \\$y of method pocketmine\\\\level\\\\Level\\:\\:setBlockDataAt\\(\\) expects int, float\\|int given\\.$#"
count: 1
path: ../../../src/pocketmine/level/Explosion.php
-
message: "#^Parameter \\#1 \\$x of method pocketmine\\\\level\\\\Level\\:\\:getBlockAt\\(\\) expects int, float\\|int given\\.$#"
message: "#^Parameter \\#2 \\$y of method pocketmine\\\\level\\\\Level\\:\\:setBlockIdAt\\(\\) expects int, float\\|int given\\.$#"
count: 1
path: ../../../src/pocketmine/level/Explosion.php
-
message: "#^Parameter \\#2 \\$y of method pocketmine\\\\level\\\\Level\\:\\:getBlockAt\\(\\) expects int, float\\|int given\\.$#"
count: 1
message: "#^Parameter \\#2 \\$y of static method pocketmine\\\\level\\\\Level\\:\\:blockHash\\(\\) expects int, float\\|int given\\.$#"
count: 2
path: ../../../src/pocketmine/level/Explosion.php
-
@ -425,13 +370,63 @@ parameters:
count: 1
path: ../../../src/pocketmine/level/Explosion.php
-
message: "#^Parameter \\#3 \\$z of method pocketmine\\\\level\\\\Level\\:\\:getTileAt\\(\\) expects int, float\\|int given\\.$#"
count: 1
path: ../../../src/pocketmine/level/Explosion.php
-
message: "#^Parameter \\#3 \\$z of method pocketmine\\\\level\\\\Level\\:\\:isInWorld\\(\\) expects int, float\\|int given\\.$#"
count: 1
path: ../../../src/pocketmine/level/Explosion.php
-
message: "#^Parameter \\#3 \\$z of method pocketmine\\\\level\\\\Level\\:\\:setBlockDataAt\\(\\) expects int, float\\|int given\\.$#"
count: 1
path: ../../../src/pocketmine/level/Explosion.php
-
message: "#^Parameter \\#3 \\$z of method pocketmine\\\\level\\\\Level\\:\\:setBlockIdAt\\(\\) expects int, float\\|int given\\.$#"
count: 1
path: ../../../src/pocketmine/level/Explosion.php
-
message: "#^Parameter \\#3 \\$z of static method pocketmine\\\\level\\\\Level\\:\\:blockHash\\(\\) expects int, float\\|int given\\.$#"
count: 2
path: ../../../src/pocketmine/level/Explosion.php
-
message: "#^Cannot access offset 'data' on array\\('priority' \\=\\> int, 'data' \\=\\> pocketmine\\\\math\\\\Vector3\\)\\|int\\|pocketmine\\\\math\\\\Vector3\\.$#"
count: 1
path: ../../../src/pocketmine/level/Level.php
-
message: "#^Cannot access offset 'priority' on array\\('priority' \\=\\> int, 'data' \\=\\> pocketmine\\\\math\\\\Vector3\\)\\|int\\|pocketmine\\\\math\\\\Vector3\\.$#"
count: 1
path: ../../../src/pocketmine/level/Level.php
-
message: "#^Cannot access offset 'data' on array\\('priority' \\=\\> int, 'data' \\=\\> pocketmine\\\\math\\\\Vector3\\)\\|int\\|pocketmine\\\\math\\\\Vector3\\.$#"
message: "#^Parameter \\#1 \\$x of method pocketmine\\\\level\\\\Level\\:\\:getFullBlock\\(\\) expects int, float\\|int given\\.$#"
count: 2
path: ../../../src/pocketmine/level/Level.php
-
message: "#^Parameter \\#1 \\$x of method pocketmine\\\\level\\\\Level\\:\\:getFullLightAt\\(\\) expects int, float\\|int given\\.$#"
count: 1
path: ../../../src/pocketmine/level/Level.php
-
message: "#^Parameter \\#1 \\$x of method pocketmine\\\\level\\\\Level\\:\\:isInWorld\\(\\) expects int, float\\|int given\\.$#"
count: 4
path: ../../../src/pocketmine/level/Level.php
-
message: "#^Parameter \\#1 \\$x of method pocketmine\\\\level\\\\Level\\:\\:updateBlockLight\\(\\) expects int, float\\|int given\\.$#"
count: 1
path: ../../../src/pocketmine/level/Level.php
-
message: "#^Parameter \\#1 \\$x of method pocketmine\\\\level\\\\Level\\:\\:updateBlockSkyLight\\(\\) expects int, float\\|int given\\.$#"
count: 1
path: ../../../src/pocketmine/level/Level.php
@ -440,16 +435,81 @@ parameters:
count: 3
path: ../../../src/pocketmine/level/Level.php
-
message: "#^Parameter \\#1 \\$x of static method pocketmine\\\\level\\\\Level\\:\\:chunkBlockHash\\(\\) expects int, float\\|int given\\.$#"
count: 1
path: ../../../src/pocketmine/level/Level.php
-
message: "#^Parameter \\#2 \\$y of method pocketmine\\\\level\\\\Level\\:\\:getFullBlock\\(\\) expects int, float\\|int given\\.$#"
count: 2
path: ../../../src/pocketmine/level/Level.php
-
message: "#^Parameter \\#2 \\$y of method pocketmine\\\\level\\\\Level\\:\\:getFullLightAt\\(\\) expects int, float\\|int given\\.$#"
count: 1
path: ../../../src/pocketmine/level/Level.php
-
message: "#^Parameter \\#2 \\$y of method pocketmine\\\\level\\\\Level\\:\\:isInWorld\\(\\) expects int, float\\|int given\\.$#"
count: 4
path: ../../../src/pocketmine/level/Level.php
-
message: "#^Parameter \\#2 \\$y of method pocketmine\\\\level\\\\Level\\:\\:updateBlockLight\\(\\) expects int, float\\|int given\\.$#"
count: 1
path: ../../../src/pocketmine/level/Level.php
-
message: "#^Parameter \\#2 \\$y of method pocketmine\\\\level\\\\Level\\:\\:updateBlockSkyLight\\(\\) expects int, float\\|int given\\.$#"
count: 1
path: ../../../src/pocketmine/level/Level.php
-
message: "#^Parameter \\#2 \\$y of static method pocketmine\\\\level\\\\Level\\:\\:blockHash\\(\\) expects int, float\\|int given\\.$#"
count: 3
path: ../../../src/pocketmine/level/Level.php
-
message: "#^Parameter \\#2 \\$y of static method pocketmine\\\\level\\\\Level\\:\\:chunkBlockHash\\(\\) expects int, float\\|int given\\.$#"
count: 1
path: ../../../src/pocketmine/level/Level.php
-
message: "#^Parameter \\#3 \\$z of method pocketmine\\\\level\\\\Level\\:\\:getFullBlock\\(\\) expects int, float\\|int given\\.$#"
count: 2
path: ../../../src/pocketmine/level/Level.php
-
message: "#^Parameter \\#3 \\$z of method pocketmine\\\\level\\\\Level\\:\\:getFullLightAt\\(\\) expects int, float\\|int given\\.$#"
count: 1
path: ../../../src/pocketmine/level/Level.php
-
message: "#^Parameter \\#3 \\$z of method pocketmine\\\\level\\\\Level\\:\\:isInWorld\\(\\) expects int, float\\|int given\\.$#"
count: 4
path: ../../../src/pocketmine/level/Level.php
-
message: "#^Parameter \\#3 \\$z of method pocketmine\\\\level\\\\Level\\:\\:updateBlockLight\\(\\) expects int, float\\|int given\\.$#"
count: 1
path: ../../../src/pocketmine/level/Level.php
-
message: "#^Parameter \\#3 \\$z of method pocketmine\\\\level\\\\Level\\:\\:updateBlockSkyLight\\(\\) expects int, float\\|int given\\.$#"
count: 1
path: ../../../src/pocketmine/level/Level.php
-
message: "#^Parameter \\#3 \\$z of static method pocketmine\\\\level\\\\Level\\:\\:blockHash\\(\\) expects int, float\\|int given\\.$#"
count: 3
path: ../../../src/pocketmine/level/Level.php
-
message: "#^Parameter \\#3 \\$z of static method pocketmine\\\\level\\\\Level\\:\\:chunkBlockHash\\(\\) expects int, float\\|int given\\.$#"
count: 1
path: ../../../src/pocketmine/level/Level.php
-
message: "#^Property pocketmine\\\\network\\\\mcpe\\\\protocol\\\\UpdateBlockPacket\\:\\:\\$x \\(int\\) does not accept float\\|int\\.$#"
count: 2
@ -465,106 +525,6 @@ parameters:
count: 2
path: ../../../src/pocketmine/level/Level.php
-
message: "#^Parameter \\#1 \\$x of method pocketmine\\\\level\\\\Level\\:\\:getFullBlock\\(\\) expects int, float\\|int given\\.$#"
count: 2
path: ../../../src/pocketmine/level/Level.php
-
message: "#^Parameter \\#2 \\$y of method pocketmine\\\\level\\\\Level\\:\\:getFullBlock\\(\\) expects int, float\\|int given\\.$#"
count: 2
path: ../../../src/pocketmine/level/Level.php
-
message: "#^Parameter \\#3 \\$z of method pocketmine\\\\level\\\\Level\\:\\:getFullBlock\\(\\) expects int, float\\|int given\\.$#"
count: 2
path: ../../../src/pocketmine/level/Level.php
-
message: "#^Parameter \\#1 \\$x of method pocketmine\\\\level\\\\Level\\:\\:isInWorld\\(\\) expects int, float\\|int given\\.$#"
count: 4
path: ../../../src/pocketmine/level/Level.php
-
message: "#^Parameter \\#2 \\$y of method pocketmine\\\\level\\\\Level\\:\\:isInWorld\\(\\) expects int, float\\|int given\\.$#"
count: 4
path: ../../../src/pocketmine/level/Level.php
-
message: "#^Parameter \\#3 \\$z of method pocketmine\\\\level\\\\Level\\:\\:isInWorld\\(\\) expects int, float\\|int given\\.$#"
count: 4
path: ../../../src/pocketmine/level/Level.php
-
message: "#^Parameter \\#1 \\$x of method pocketmine\\\\level\\\\Level\\:\\:getFullLightAt\\(\\) expects int, float\\|int given\\.$#"
count: 1
path: ../../../src/pocketmine/level/Level.php
-
message: "#^Parameter \\#2 \\$y of method pocketmine\\\\level\\\\Level\\:\\:getFullLightAt\\(\\) expects int, float\\|int given\\.$#"
count: 1
path: ../../../src/pocketmine/level/Level.php
-
message: "#^Parameter \\#3 \\$z of method pocketmine\\\\level\\\\Level\\:\\:getFullLightAt\\(\\) expects int, float\\|int given\\.$#"
count: 1
path: ../../../src/pocketmine/level/Level.php
-
message: "#^Parameter \\#1 \\$x of method pocketmine\\\\level\\\\Level\\:\\:updateBlockSkyLight\\(\\) expects int, float\\|int given\\.$#"
count: 1
path: ../../../src/pocketmine/level/Level.php
-
message: "#^Parameter \\#2 \\$y of method pocketmine\\\\level\\\\Level\\:\\:updateBlockSkyLight\\(\\) expects int, float\\|int given\\.$#"
count: 1
path: ../../../src/pocketmine/level/Level.php
-
message: "#^Parameter \\#3 \\$z of method pocketmine\\\\level\\\\Level\\:\\:updateBlockSkyLight\\(\\) expects int, float\\|int given\\.$#"
count: 1
path: ../../../src/pocketmine/level/Level.php
-
message: "#^Parameter \\#1 \\$x of method pocketmine\\\\level\\\\Level\\:\\:updateBlockLight\\(\\) expects int, float\\|int given\\.$#"
count: 1
path: ../../../src/pocketmine/level/Level.php
-
message: "#^Parameter \\#2 \\$y of method pocketmine\\\\level\\\\Level\\:\\:updateBlockLight\\(\\) expects int, float\\|int given\\.$#"
count: 1
path: ../../../src/pocketmine/level/Level.php
-
message: "#^Parameter \\#3 \\$z of method pocketmine\\\\level\\\\Level\\:\\:updateBlockLight\\(\\) expects int, float\\|int given\\.$#"
count: 1
path: ../../../src/pocketmine/level/Level.php
-
message: "#^Parameter \\#1 \\$x of static method pocketmine\\\\level\\\\Level\\:\\:chunkBlockHash\\(\\) expects int, float\\|int given\\.$#"
count: 1
path: ../../../src/pocketmine/level/Level.php
-
message: "#^Parameter \\#2 \\$y of static method pocketmine\\\\level\\\\Level\\:\\:chunkBlockHash\\(\\) expects int, float\\|int given\\.$#"
count: 1
path: ../../../src/pocketmine/level/Level.php
-
message: "#^Parameter \\#3 \\$z of static method pocketmine\\\\level\\\\Level\\:\\:chunkBlockHash\\(\\) expects int, float\\|int given\\.$#"
count: 1
path: ../../../src/pocketmine/level/Level.php
-
message: "#^Parameter \\#6 \\$xpDrops of class pocketmine\\\\event\\\\block\\\\BlockBreakEvent constructor expects int, float\\|int given\\.$#"
count: 1
path: ../../../src/pocketmine/level/Level.php
-
message: "#^Parameter \\#2 \\$amount of method pocketmine\\\\level\\\\Level\\:\\:dropExperience\\(\\) expects int, float\\|int\\<1, max\\> given\\.$#"
count: 1
path: ../../../src/pocketmine/level/Level.php
-
message: "#^Parameter \\#1 \\$string of function strlen expects string, string\\|false given\\.$#"
count: 2
@ -610,38 +570,38 @@ parameters:
count: 2
path: ../../../src/pocketmine/level/generator/object/TallGrass.php
-
message: "#^Parameter \\#2 \\$y of method pocketmine\\\\level\\\\ChunkManager\\:\\:setBlockIdAt\\(\\) expects int, float\\|int given\\.$#"
count: 1
path: ../../../src/pocketmine/level/generator/object/TallGrass.php
-
message: "#^Parameter \\#2 \\$y of method pocketmine\\\\level\\\\ChunkManager\\:\\:setBlockDataAt\\(\\) expects int, float\\|int given\\.$#"
count: 1
path: ../../../src/pocketmine/level/generator/object/TallGrass.php
-
message: "#^Parameter \\#1 \\$str of method pocketmine\\\\utils\\\\BinaryStream\\:\\:put\\(\\) expects string, string\\|false given\\.$#"
count: 2
path: ../../../src/pocketmine/network/mcpe/NetworkBinaryStream.php
message: "#^Parameter \\#2 \\$y of method pocketmine\\\\level\\\\ChunkManager\\:\\:setBlockIdAt\\(\\) expects int, float\\|int given\\.$#"
count: 1
path: ../../../src/pocketmine/level/generator/object/TallGrass.php
-
message: "#^Method pocketmine\\\\network\\\\mcpe\\\\NetworkBinaryStream\\:\\:getGameRules\\(\\) should return array\\<string, array\\(int, bool\\|float\\|int\\)\\> but returns array\\<string, array\\(int, bool\\|float\\|int\\|null\\)\\>\\.$#"
count: 1
path: ../../../src/pocketmine/network/mcpe/NetworkBinaryStream.php
-
message: "#^Parameter \\#1 \\$str of method pocketmine\\\\utils\\\\BinaryStream\\:\\:put\\(\\) expects string, string\\|false given\\.$#"
count: 2
path: ../../../src/pocketmine/network/mcpe/NetworkBinaryStream.php
-
message: "#^Parameter \\#1 \\$v of method pocketmine\\\\utils\\\\BinaryStream\\:\\:putBool\\(\\) expects bool, bool\\|float\\|int given\\.$#"
count: 1
path: ../../../src/pocketmine/network/mcpe/NetworkBinaryStream.php
-
message: "#^Parameter \\#1 \\$v of method pocketmine\\\\utils\\\\BinaryStream\\:\\:putUnsignedVarInt\\(\\) expects int, bool\\|float\\|int given\\.$#"
message: "#^Parameter \\#1 \\$v of method pocketmine\\\\utils\\\\BinaryStream\\:\\:putLFloat\\(\\) expects float, bool\\|float\\|int given\\.$#"
count: 1
path: ../../../src/pocketmine/network/mcpe/NetworkBinaryStream.php
-
message: "#^Parameter \\#1 \\$v of method pocketmine\\\\utils\\\\BinaryStream\\:\\:putLFloat\\(\\) expects float, bool\\|float\\|int given\\.$#"
message: "#^Parameter \\#1 \\$v of method pocketmine\\\\utils\\\\BinaryStream\\:\\:putUnsignedVarInt\\(\\) expects int, bool\\|float\\|int given\\.$#"
count: 1
path: ../../../src/pocketmine/network/mcpe/NetworkBinaryStream.php
@ -655,23 +615,23 @@ parameters:
count: 2
path: ../../../src/pocketmine/network/mcpe/VerifyLoginTask.php
-
message: "#^Parameter \\#1 \\$string of function strlen expects string, string\\|false given\\.$#"
count: 2
path: ../../../src/pocketmine/network/mcpe/VerifyLoginTask.php
-
message: "#^Parameter \\#1 \\$str of function str_split expects string, string\\|false given\\.$#"
count: 1
path: ../../../src/pocketmine/network/mcpe/VerifyLoginTask.php
-
message: "#^Parameter \\#1 \\$json of function json_decode expects string, string\\|false given\\.$#"
message: "#^Parameter \\#1 \\$string of function strlen expects string, string\\|false given\\.$#"
count: 2
path: ../../../src/pocketmine/network/mcpe/VerifyLoginTask.php
-
message: "#^Parameter \\#1 \\$buffer of class pocketmine\\\\network\\\\mcpe\\\\NetworkBinaryStream constructor expects string, string\\|false given\\.$#"
count: 1
path: ../../../src/pocketmine/network/mcpe/convert/RuntimeBlockMapping.php
-
message: "#^Parameter \\#1 \\$buffer of class pocketmine\\\\network\\\\mcpe\\\\NetworkBinaryStream constructor expects string, string\\|false given\\.$#"
message: "#^Parameter \\#1 \\$json of function json_decode expects string, string\\|false given\\.$#"
count: 1
path: ../../../src/pocketmine/network/mcpe/convert/RuntimeBlockMapping.php
@ -721,24 +681,39 @@ parameters:
path: ../../../src/pocketmine/network/mcpe/protocol/StartGamePacket.php
-
message: "#^Parameter \\#2 \\$resourcePatch of class pocketmine\\\\network\\\\mcpe\\\\protocol\\\\types\\\\SkinData constructor expects string, string\\|false given\\.$#"
message: "#^Parameter \\#3 \\$resourcePatch of class pocketmine\\\\network\\\\mcpe\\\\protocol\\\\types\\\\SkinData constructor expects string, string\\|false given\\.$#"
count: 1
path: ../../../src/pocketmine/network/mcpe/protocol/types/LegacySkinAdapter.php
-
message: "#^Call to an undefined method object\\:\\:Add\\(\\)\\.$#"
message: "#^Parameter \\#1 \\$x of method pocketmine\\\\network\\\\mcpe\\\\NetworkBinaryStream\\:\\:putBlockPosition\\(\\) expects int, float\\|int given\\.$#"
count: 1
path: ../../../src/pocketmine/network/upnp/UPnP.php
path: ../../../src/pocketmine/network/mcpe/protocol/types/inventory/UseItemTransactionData.php
-
message: "#^Call to an undefined method object\\:\\:Remove\\(\\)\\.$#"
message: "#^Parameter \\#2 \\$y of method pocketmine\\\\network\\\\mcpe\\\\NetworkBinaryStream\\:\\:putBlockPosition\\(\\) expects int, float\\|int given\\.$#"
count: 1
path: ../../../src/pocketmine/network/upnp/UPnP.php
path: ../../../src/pocketmine/network/mcpe/protocol/types/inventory/UseItemTransactionData.php
-
message: "#^Parameter \\#1 \\$event of method pocketmine\\\\plugin\\\\PluginManager\\:\\:registerEvent\\(\\) expects class\\-string\\<pocketmine\\\\event\\\\Event\\>, class\\-string\\<object\\> given\\.$#"
message: "#^Parameter \\#3 \\$z of method pocketmine\\\\network\\\\mcpe\\\\NetworkBinaryStream\\:\\:putBlockPosition\\(\\) expects int, float\\|int given\\.$#"
count: 1
path: ../../../src/pocketmine/plugin/PluginManager.php
path: ../../../src/pocketmine/network/mcpe/protocol/types/inventory/UseItemTransactionData.php
-
message: "#^Method pocketmine\\\\resourcepacks\\\\ZippedResourcePack\\:\\:getPackChunk\\(\\) should return string but returns string\\|false\\.$#"
count: 1
path: ../../../src/pocketmine/resourcepacks/ZippedResourcePack.php
-
message: "#^Method pocketmine\\\\resourcepacks\\\\ZippedResourcePack\\:\\:getPackSize\\(\\) should return int but returns int\\|false\\.$#"
count: 1
path: ../../../src/pocketmine/resourcepacks/ZippedResourcePack.php
-
message: "#^Method pocketmine\\\\resourcepacks\\\\ZippedResourcePack\\:\\:getSha256\\(\\) should return string but returns string\\|false\\.$#"
count: 1
path: ../../../src/pocketmine/resourcepacks/ZippedResourcePack.php
-
message: "#^Parameter \\#1 \\$string of function strlen expects string, string\\|false given\\.$#"
@ -755,26 +730,11 @@ parameters:
count: 1
path: ../../../src/pocketmine/resourcepacks/ZippedResourcePack.php
-
message: "#^Method pocketmine\\\\resourcepacks\\\\ZippedResourcePack\\:\\:getPackSize\\(\\) should return int but returns int\\|false\\.$#"
count: 1
path: ../../../src/pocketmine/resourcepacks/ZippedResourcePack.php
-
message: "#^Property pocketmine\\\\resourcepacks\\\\ZippedResourcePack\\:\\:\\$sha256 \\(string\\|null\\) does not accept string\\|false\\.$#"
count: 1
path: ../../../src/pocketmine/resourcepacks/ZippedResourcePack.php
-
message: "#^Method pocketmine\\\\resourcepacks\\\\ZippedResourcePack\\:\\:getSha256\\(\\) should return string but returns string\\|false\\.$#"
count: 1
path: ../../../src/pocketmine/resourcepacks/ZippedResourcePack.php
-
message: "#^Method pocketmine\\\\resourcepacks\\\\ZippedResourcePack\\:\\:getPackChunk\\(\\) should return string but returns string\\|false\\.$#"
count: 1
path: ../../../src/pocketmine/resourcepacks/ZippedResourcePack.php
-
message: "#^Cannot call method getNextRun\\(\\) on array\\<string, int\\|pocketmine\\\\scheduler\\\\TaskHandler\\>\\|int\\|pocketmine\\\\scheduler\\\\TaskHandler\\.$#"
count: 1
@ -795,6 +755,11 @@ parameters:
count: 2
path: ../../../src/pocketmine/tile/Chest.php
-
message: "#^Parameter \\#2 \\$value of class pocketmine\\\\nbt\\\\tag\\\\IntTag constructor expects int, float\\|int given\\.$#"
count: 3
path: ../../../src/pocketmine/tile/Spawnable.php
-
message: "#^Property pocketmine\\\\network\\\\mcpe\\\\protocol\\\\BlockActorDataPacket\\:\\:\\$x \\(int\\) does not accept float\\|int\\.$#"
count: 1
@ -810,11 +775,6 @@ parameters:
count: 1
path: ../../../src/pocketmine/tile/Spawnable.php
-
message: "#^Parameter \\#2 \\$value of class pocketmine\\\\nbt\\\\tag\\\\IntTag constructor expects int, float\\|int given\\.$#"
count: 3
path: ../../../src/pocketmine/tile/Spawnable.php
-
message: "#^Array \\(array\\<class\\-string\\<pocketmine\\\\tile\\\\Tile\\>, string\\>\\) does not accept string\\|false\\.$#"
count: 1

File diff suppressed because it is too large Load Diff

View File

@ -1,15 +1,5 @@
parameters:
ignoreErrors:
-
message: "#^Comparison operation \"\\>\\=\" between 0 and 2 is always false\\.$#"
count: 1
path: ../../../src/pocketmine/block/Liquid.php
-
message: "#^If condition is always false\\.$#"
count: 1
path: ../../../src/pocketmine/block/Liquid.php
-
message: "#^Call to function is_resource\\(\\) with resource will always evaluate to true\\.$#"
count: 3
@ -31,12 +21,12 @@ parameters:
path: ../../../src/pocketmine/network/mcpe/protocol/DataPacket.php
-
message: "#^Strict comparison using \\=\\=\\= between string and false will always evaluate to false\\.$#"
message: "#^Parameter \\#1 \\$ of closure expects TMemberType, TMemberType given\\.$#"
count: 1
path: ../../../src/pocketmine/utils/Utils.php
-
message: "#^Parameter \\#1 \\$ of closure expects TMemberType, TMemberType given\\.$#"
message: "#^Strict comparison using \\=\\=\\= between string and false will always evaluate to false\\.$#"
count: 1
path: ../../../src/pocketmine/utils/Utils.php

View File

@ -25,6 +25,16 @@ parameters:
count: 3
path: ../../../src/pocketmine/item/Item.php
-
message: "#^Call to function is_object\\(\\) with \\*NEVER\\* will always evaluate to true\\.$#"
count: 1
path: ../../../src/pocketmine/item/ItemFactory.php
-
message: "#^Else branch is unreachable because ternary operator condition is always true\\.$#"
count: 1
path: ../../../src/pocketmine/item/ItemFactory.php
-
message: "#^If condition is always false\\.$#"
count: 1
@ -37,29 +47,19 @@ parameters:
-
message: "#^Call to function is_object\\(\\) with \\*NEVER\\* will always evaluate to true\\.$#"
count: 1
path: ../../../src/pocketmine/item/ItemFactory.php
count: 2
path: ../../../src/pocketmine/level/Level.php
-
message: "#^Else branch is unreachable because ternary operator condition is always true\\.$#"
count: 1
path: ../../../src/pocketmine/item/ItemFactory.php
count: 2
path: ../../../src/pocketmine/level/Level.php
-
message: "#^Instanceof between pocketmine\\\\math\\\\Vector3 and pocketmine\\\\math\\\\Vector3 will always evaluate to true\\.$#"
count: 2
path: ../../../src/pocketmine/level/Level.php
-
message: "#^Call to function is_object\\(\\) with \\*NEVER\\* will always evaluate to true\\.$#"
count: 2
path: ../../../src/pocketmine/level/Level.php
-
message: "#^Else branch is unreachable because ternary operator condition is always true\\.$#"
count: 2
path: ../../../src/pocketmine/level/Level.php
-
message: "#^Call to function is_subclass_of\\(\\) with class\\-string\\<pocketmine\\\\level\\\\generator\\\\Generator\\> and 'pocketmine\\\\\\\\level\\\\\\\\generator\\\\\\\\Generator' will always evaluate to true\\.$#"
count: 1

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