mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-09 11:16:57 +00:00
Compare commits
158 Commits
Author | SHA1 | Date | |
---|---|---|---|
d1b70bd400 | |||
29f002b32c | |||
da17ade575 | |||
f0c36f3413 | |||
77d8f133f1 | |||
43ebb23085 | |||
e198c8fa8b | |||
cc3285c8fe | |||
305c63ba4d | |||
acaa0e33b0 | |||
f63857deed | |||
eda3d9b5e4 | |||
c3872619cd | |||
39cc590829 | |||
f347345bb3 | |||
bb05cfb36c | |||
7d5c3c9b46 | |||
cff2d37add | |||
447477c5fb | |||
abdbb2bf0e | |||
783c13926f | |||
45329ddf67 | |||
20af789963 | |||
93cb9390e0 | |||
0aed7f86f5 | |||
bf44bd016d | |||
04e4a36653 | |||
7439e1971d | |||
b961b4e003 | |||
d9eac8fc0a | |||
aeeee5eb53 | |||
13994055d9 | |||
247875e3d5 | |||
ee60a7bc36 | |||
348c2a599b | |||
562b47a1e5 | |||
4e060bc13f | |||
2807f14fcd | |||
f0539f4898 | |||
63d7e7b811 | |||
4da06078ed | |||
8a6381c3fa | |||
d0d61597c7 | |||
7a2a4e2aa3 | |||
e41a2c0792 | |||
11a6e04a28 | |||
70b1ac856d | |||
d724374d1a | |||
a19143cae7 | |||
1be6783c34 | |||
092edc9d43 | |||
2ba8eac27f | |||
25ff90b2c6 | |||
b912ae78bc | |||
677d43028a | |||
7bfb55ec9a | |||
2f61d42518 | |||
dbb669b156 | |||
4d0e8741fe | |||
53dc6e2050 | |||
807b860cfe | |||
d756500928 | |||
7ef27a1a21 | |||
6b4d8b91c6 | |||
8f5eb7ef37 | |||
0ea9a08963 | |||
18a1bfe4dd | |||
2d3562c687 | |||
cb40484a2e | |||
e75a08a5a3 | |||
95dfff727e | |||
d55889d85f | |||
99f65f19ac | |||
581eeee01d | |||
17341d7406 | |||
04c0cd142d | |||
7a747d6f93 | |||
e93d034a4e | |||
5a08a10448 | |||
622f93df45 | |||
b788982d60 | |||
26faf4a952 | |||
670bf2b9d1 | |||
f5491346ce | |||
73d3f9f7f7 | |||
d874be99a6 | |||
1767cbe80d | |||
64fbf5025a | |||
aaa01bb6f8 | |||
50d71809e1 | |||
6839712394 | |||
9b5ae7ec75 | |||
94eb64c2be | |||
3fae57508b | |||
a883c35fd0 | |||
740398282f | |||
9d14bc54d6 | |||
bd69c66d03 | |||
c58a1bf9b7 | |||
59c310b914 | |||
790fcc4ebb | |||
5430f19e7a | |||
1cf4cf8614 | |||
55cccff850 | |||
03e70e68f4 | |||
7c52b4c93d | |||
3f31dbde57 | |||
1bfd6f2a90 | |||
c7a5b8b0b4 | |||
11fc16617a | |||
77a4393c7b | |||
f714ed6e90 | |||
7fc45bc5c3 | |||
ab4b1be363 | |||
3c7f68dc1e | |||
15fa1056b7 | |||
feac2df088 | |||
4c2015fd0f | |||
16482e6a95 | |||
ae9115ad0d | |||
6b090d653c | |||
012f015e7d | |||
6925451f3f | |||
46054803d5 | |||
a9f99240b5 | |||
a16b44ea12 | |||
cd48d8272c | |||
6d09460abc | |||
0ca07ad075 | |||
60b183b0d9 | |||
dbf4054b1f | |||
82e4ef6d48 | |||
d0d300a6f8 | |||
6161155660 | |||
2a5561fcd1 | |||
5d531b56db | |||
3568c7b1c7 | |||
862c844759 | |||
42954c1d72 | |||
4c5f6eb1b7 | |||
02bc43b440 | |||
5832f42783 | |||
7c1f038f20 | |||
a42f68d3cf | |||
b6f3f6120b | |||
96d3f4f78b | |||
6756203aec | |||
adb78679c5 | |||
b60731607d | |||
0058bfcd23 | |||
9f31b479e1 | |||
eb161f8e1c | |||
80f8a27094 | |||
341c480e13 | |||
971ad04299 | |||
025b72e2f2 | |||
cf538afb84 | |||
7ff91337ad |
2
.github/ISSUE_TEMPLATE/help---support.md
vendored
2
.github/ISSUE_TEMPLATE/help---support.md
vendored
@ -11,4 +11,4 @@ We don't accept support requests on the issue tracker. Please try the following
|
||||
|
||||
Documentation: http://pmmp.rtfd.io
|
||||
Forums: https://forums.pmmp.io
|
||||
Discord: https://discord.gg/bge7dYQ
|
||||
Discord: https://discord.gg/bmSAZBG
|
||||
|
4
.github/support.yml
vendored
4
.github/support.yml
vendored
@ -5,10 +5,10 @@ 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 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).
|
||||
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/bge7dYQ) | [Forums](https://forums.pmmp.io)
|
||||
[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
|
||||
|
5
.gitmodules
vendored
5
.gitmodules
vendored
@ -2,7 +2,7 @@
|
||||
path = src/pocketmine/lang/locale
|
||||
url = https://github.com/pmmp/PocketMine-Language.git
|
||||
[submodule "tests/preprocessor"]
|
||||
path = tests/preprocessor
|
||||
path = build/preprocessor
|
||||
url = https://github.com/pmmp/preprocessor.git
|
||||
[submodule "tests/plugins/PocketMine-DevTools"]
|
||||
path = tests/plugins/PocketMine-DevTools
|
||||
@ -10,3 +10,6 @@
|
||||
[submodule "src/pocketmine/resources/vanilla"]
|
||||
path = src/pocketmine/resources/vanilla
|
||||
url = https://github.com/pmmp/BedrockData.git
|
||||
[submodule "build/php"]
|
||||
path = build/php
|
||||
url = https://github.com/pmmp/php-build-scripts.git
|
||||
|
56
README.md
56
README.md
@ -1,53 +1,33 @@
|
||||
# [](https://pmmp.io)
|
||||
|
||||
__A highly customisable, open source server software for Minecraft: Bedrock Edition written in PHP__
|
||||
<p align="center">
|
||||
<a href="https://pmmp.io"><img src="http://cdn.pocketmine.net/img/PocketMine-MP-h.png"></img></a><br>
|
||||
<b>A highly customisable, open source server software for Minecraft: Bedrock Edition written in PHP</b>
|
||||
</p>
|
||||
|
||||
[](https://travis-ci.org/pmmp/PocketMine-MP)
|
||||
|
||||
### Setup, help & support, FAQs
|
||||
Head over to the [documentation site](http://pmmp.readthedocs.org/).
|
||||
If you don't find what you're looking for there, [talk to a human](#discussion). Please do not use our issue tracker for support requests.
|
||||
## Getting started
|
||||
- [Documentation](http://pmmp.readthedocs.org/)
|
||||
- [Installation instructions](https://pmmp.readthedocs.io/en/rtfd/installation.html)
|
||||
- [Docker image](https://hub.docker.com/r/pmmp/pocketmine-mp)
|
||||
- [Plugin repository](https://poggit.pmmp.io/plugins)
|
||||
|
||||
### Discussion
|
||||
## Discussion/Help
|
||||
- [Forums](https://forums.pmmp.io/)
|
||||
- [Community Discord](https://discord.gg/bge7dYQ)
|
||||
- [Community Discord](https://discord.gg/bmSAZBG)
|
||||
- [StackOverflow](https://stackoverflow.com/tags/pocketmine)
|
||||
|
||||
### Plugins
|
||||
There are a very wide range of already-written plugins available which you can use to customise your server. Check out [Poggit](https://poggit.pmmp.io), or just search GitHub.
|
||||
|
||||
### For developers
|
||||
## For developers
|
||||
* [Latest API documentation](https://jenkins.pmmp.io/job/PocketMine-MP-doc/doxygen/) - Doxygen documentation generated from development
|
||||
* [DevTools](https://github.com/pmmp/PocketMine-DevTools/) - Development tools plugin for creating plugins
|
||||
* [ExamplePlugin](https://github.com/pmmp/ExamplePlugin/) - Example plugin demonstrating some basic API features
|
||||
* [Contributing Guidelines](CONTRIBUTING.md)
|
||||
|
||||
### Can I contribute?
|
||||
Yes you can! Contributions are welcomed provided that they comply with our [Contributing Guidelines](CONTRIBUTING.md). Please ensure you read the relevant sections of the guidelines carefully before making a Pull Request or opening an Issue.
|
||||
|
||||
### Where can I get the latest .phar?
|
||||
- Latest release builds can be found in our [GitHub releases](https://github.com/pmmp/PocketMine-MP/releases).
|
||||
- Latest bleeding-edge development builds (and other builds in the build job channels) can be found on our [Jenkins server](https://jenkins.pmmp.io/).
|
||||
|
||||
**Note: Please avoid development builds unless there is no other alternative for what you need.** Development builds are subject to changes at any time without notice, and it is likely that your server or plugins might break without warning.
|
||||
|
||||
### Donate
|
||||
Donations help support the development of the project and pay for our expenses.
|
||||
- Bitcoin Cash (BCH): `qz9p8dqkv0r7aahdatu5uewqfkvstrglv58f8yle07`
|
||||
- Bitcoin (BTC): `1PVAyDJ2g7kcjCxAC3C89oxpV2ZYcLad8T`
|
||||
## Donate
|
||||
- Bitcoin Cash (BCH): `qq3r46hn6ljnhnqnfwxt5pg3g447eq9jhvw5ddfear`
|
||||
- Bitcoin (BTC): `171u8K9e4FtU6j3e5sqNoxKUgEw9qWQdRV`
|
||||
- [Patreon](https://www.patreon.com/pocketminemp)
|
||||
|
||||
## Licensing information
|
||||
|
||||
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.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
This project is licensed under LGPL-3.0. Please see the [LICENSE](/LICENSE) file for details.
|
||||
|
||||
pmmp/PocketMine are not affiliated with Mojang. All brands and trademarks belong to their respective owners. PocketMine-MP is not a Mojang-approved software, nor is it associated with Mojang.
|
||||
|
81
build/make-release.php
Normal file
81
build/make-release.php
Normal file
@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\build_script;
|
||||
|
||||
use pocketmine\utils\VersionString;
|
||||
use function dirname;
|
||||
use function fgets;
|
||||
use function file_get_contents;
|
||||
use function file_put_contents;
|
||||
use function preg_quote;
|
||||
use function preg_replace;
|
||||
use function sleep;
|
||||
use function sprintf;
|
||||
use function system;
|
||||
use const pocketmine\BASE_VERSION;
|
||||
use const STDIN;
|
||||
|
||||
require_once dirname(__DIR__) . '/src/pocketmine/VersionInfo.php';
|
||||
require_once dirname(__DIR__) . '/vendor/autoload.php';
|
||||
|
||||
if(isset($argv[1])){
|
||||
$currentVer = new VersionString($argv[1]);
|
||||
}else{
|
||||
$currentVer = new VersionString(BASE_VERSION);
|
||||
}
|
||||
$nextVer = new VersionString(sprintf(
|
||||
"%u.%u.%u",
|
||||
$currentVer->getMajor(),
|
||||
$currentVer->getMinor(),
|
||||
$currentVer->getPatch() + 1
|
||||
));
|
||||
|
||||
function replaceVersion(string $versionInfoPath, string $newVersion, bool $isDev) : void{
|
||||
$versionInfo = file_get_contents($versionInfoPath);
|
||||
$versionInfo = preg_replace(
|
||||
$pattern = '/^const BASE_VERSION = "(\d+)\.(\d+)\.(\d+)(?:-(.*))?";$/m',
|
||||
'const BASE_VERSION = "' . $newVersion . '";',
|
||||
$versionInfo
|
||||
);
|
||||
$versionInfo = preg_replace(
|
||||
'/^const IS_DEVELOPMENT_BUILD = (?:true|false);$/m',
|
||||
'const IS_DEVELOPMENT_BUILD = ' . ($isDev ? 'true' : 'false'). ';',
|
||||
$versionInfo
|
||||
);
|
||||
file_put_contents($versionInfoPath, $versionInfo);
|
||||
}
|
||||
$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"');
|
||||
system('git commit -m "Release ' . $currentVer->getBaseVersion() . '" --include "' . $versionInfoPath . '"');
|
||||
system('git tag ' . $currentVer->getBaseVersion());
|
||||
replaceVersion($versionInfoPath, $nextVer->getBaseVersion(), true);
|
||||
system('git add "' . $versionInfoPath . '"');
|
||||
system('git commit -m "' . $nextVer->getBaseVersion() . ' is next" --include "' . $versionInfoPath . '"');
|
||||
echo "pushing changes in 10 seconds\n";
|
||||
sleep(10);
|
||||
system('git push origin HEAD ' . $currentVer->getBaseVersion());
|
1
build/php
Submodule
1
build/php
Submodule
Submodule build/php added at 1b3fe3120c
182
changelogs/1.3.md
Normal file
182
changelogs/1.3.md
Normal file
@ -0,0 +1,182 @@
|
||||
# 1.3.3
|
||||
- Minecraft: Pocket Edition alpha 0.7.2 compatible!
|
||||
- Unicode support
|
||||
- Fixed /difficulty command
|
||||
- Fixed a few flying kicks
|
||||
- Fixed async. operations thread
|
||||
- Added whitelist enabled property to Query
|
||||
|
||||
# 1.3.4
|
||||
**This is a compatibility update for Minecraft: Pocket Edition v0.7.3 alpha.**
|
||||
|
||||
Double chests do not work yet, we will fix more bugs and add them when MCPE 0.7.4 is released. There were too many bugs in 0.7.3 to test double chests properly.
|
||||
|
||||
#### Including in this release:
|
||||
- Fixed armor crash
|
||||
- Fixed ghost armor
|
||||
- Fixed packets being received after player disconnection
|
||||
- Fixed player count bug
|
||||
- Added compatibility with encrypted login
|
||||
- Fixed flying check on fences
|
||||
- Fixed players connecting with empty usernames
|
||||
- Fixed several crashes related to Items
|
||||
- Added temporal water flowing. Really buggy
|
||||
- Automatic recovery of index-corrupted maps
|
||||
- Fixed hotbar reset when changing armor
|
||||
- Fixed some hotbar reset bugs on block placement
|
||||
- Added basic tool durability and breaking
|
||||
- Chests now have opening/closing animation.
|
||||
- Fixed /difficulty
|
||||
- In-game player list is now handled correctly
|
||||
- Player entities are saved in all worlds to remove join/leave spam
|
||||
- Quartz slabs
|
||||
|
||||
# 1.3.5
|
||||
#### Including in this release:
|
||||
- Fixed block durability (blocks being replaced)
|
||||
- Added armor replacing (changing the armor while you have other)
|
||||
- Added proper Player object cleanups as a fix to a memory leak
|
||||
|
||||
# 1.3.7
|
||||
**This update is compatible with Minecraft: Pocket Edition v0.7.4 alpha.** Older versions won't work.
|
||||
|
||||
In Minecraft: PE 0.7.4 you can add External servers directly. [How to add servers](https://github.com/PocketMine/PocketMine-MP/wiki/How-to-add-servers)
|
||||
|
||||

|
||||
|
||||
### Changelog
|
||||
- **Updated for 0.7.4 alpha**
|
||||
- **New API version 10**
|
||||
- Adds Tile methods
|
||||
- Changes message events to use new Minecraft protocol
|
||||
- Added Level::getSafeSpawn()
|
||||
- Linux now uses PHP 5.5.3
|
||||
- Removed water updating
|
||||
- Fixes for Player teleporting
|
||||
- Removed invalid Cookie and fish items
|
||||
- Fixed Stone brick and quartz slab recipes
|
||||
- Shears now are used to drop leaves
|
||||
- Fixed a crash on Windows XP
|
||||
- Cake is removed when the bottom block is broken
|
||||
- Added new NBT parser/writer
|
||||
- Fixed chests and furnaces drops when broken.
|
||||
- Fixed signs not spawning on world load
|
||||
- Fixed actions not being deleted (memory leak)
|
||||
- Chests now are spawned correctly
|
||||
- Double chests
|
||||
- Added random x,z offset to item drops
|
||||
|
||||
# 1.3.8
|
||||
This release consists of a few bugfixes and several features added. It is compatible with MCPE 0.7.4 and 0.7.5
|
||||
|
||||
**Changelog:**
|
||||
- No API changes
|
||||
- Fixed x,y,z indexes when opening a Furnace
|
||||
- Fixed invalid fix for CPU usage limiter on idle
|
||||
- Fixed cross-compiling
|
||||
- Fixed some Stonecutter recipes
|
||||
- Fixed a few items stack sizes
|
||||
- Fixed TimeAPI bugs
|
||||
- Forces position on teleport, blocks fast teleport mods
|
||||
- Fixed some blocks havin a send lag on place/break
|
||||
- Fixed Sign Posts not deleting the Tile data when broken by update
|
||||
- Fixed Ice converting to Water on creative mode
|
||||
- Added beds
|
||||
- Added scheduled teleport on spawn to fix spawning underground
|
||||
- Added date to console logs
|
||||
|
||||
# 1.3.9
|
||||
This release is compatible with MCPE 0.7.4 and 0.7.5.
|
||||
|
||||
**Changelog:**
|
||||
- Fixed server crash related to beds
|
||||
- Player movement is less laggy
|
||||
- Added new text formatting system for future updates
|
||||
- New Terminal Emulator for Windows
|
||||
- More colors! Less warnings!
|
||||
|
||||
# 1.3.10
|
||||
**Changelog:**
|
||||
- Added door sounds
|
||||
- Fixed bed sleeping position offset
|
||||
- Added explosions
|
||||
- Flint & Steel on Creative Mode (replaces Eggs)
|
||||
- Changed the Sword and Hoe to the diamond tier on the Creative inventory
|
||||
- Fixed colors on MacOS
|
||||
- Water flow
|
||||
- Fixed Windows console input not being accepted when using special keys
|
||||
- Added a way to disable console colors
|
||||
- Updated PHP to 5.5.6, pthreads to 0.0.55, and cURL
|
||||
- Armor drops
|
||||
- Fixed plugin issues
|
||||
- Fixed some block drops
|
||||
- Fixed a crash when @all is used in console, and only usable for OPs
|
||||
- Fixed some issues regarding teleporting
|
||||
- deop no longer op the player again
|
||||
|
||||
# 1.3.11
|
||||
And here it comes the stable release for **MCPE v0.8.1 alpha**. We decided to remove the improved networking that was delaying this release, but you should see it in the next one. Minecarts couldn't be added for the same reason as mobs, but we will try to implement "fake" minecarts that behave correctly inside rails, but not outside of them.
|
||||
|
||||
Starting with this release, all PocketMine-MP versions will be given a codename. This one received the codename 「甘いビートルート」_(Amai Beetroot)_.
|
||||
|
||||
**Changelog:**
|
||||
- Fixed existing Packets of Death
|
||||
- Fixed lots of bugs related to crafting
|
||||
- Fixed block placement bugs
|
||||
- Redstone ore drops redstone dust
|
||||
- Sideway logs
|
||||
- Sponges
|
||||
- Added new wooden planks & stairs
|
||||
- Added iron bars, cobblestone walls and pumpkins
|
||||
- Added carpets, hay bales and coal blocks
|
||||
- Added potatoes, carrots and beetroots
|
||||
- Additional tall grass drops
|
||||
- Achievements
|
||||
- Added multiple orders for _/gamemode_ command
|
||||
- Chat plugins can work with each other #975
|
||||
- Fixed internal world chunks bug
|
||||
- Private messages are now hidden on console except when the console is the target/origin
|
||||
- PHP plugins are now loaded with include()
|
||||
- Fixed plugin paths
|
||||
- Added source SHA1 sum to crash reports
|
||||
- Added Level::startTime() and Level::stopTime()
|
||||
- Fixed server not being able to start on several OS when offline
|
||||
- More small fixes and small additions
|
||||
|
||||
For more information, check the [complete changelog](https://github.com/PocketMine/PocketMine-MP/compare/Alpha_1.3.10...Alpha_1.3.11).
|
||||
|
||||
# 1.3.12
|
||||
Before starting to rewrite even more parts of the code, we are releasing the last version of the Alpha_1.3.x Amai Beetroot「甘いビートルート」. Next one will be Alpha_1.4 with more rewrite!
|
||||
We have included the new Event API that will be used on the next release, but now it is only used to hook on packets.
|
||||
|
||||
**API Changelog:**
|
||||
- **Full network rewrite.** Plugins can work with packets easily now.
|
||||
- **New Event API,** only implemented for packets right now.
|
||||
- Added player.block.place.bypass and player.block.break.bypass
|
||||
- Level included in data for event item.drop
|
||||
- Added Utils::getUniqueID()
|
||||
- **Added default support in PHP binaries for MySQLi**
|
||||
- Removed Spyc
|
||||
- Call Plugin::__destruct() on PluginAPI::__destruct()
|
||||
- Added more OS detection on Utils::getOS()
|
||||
|
||||
**Changelog:**
|
||||
- New set-up wizard in multiple languages. Help translate it to more languages on http://translate.pocketmine.net/
|
||||
- Updated pthreads and PHP binaries
|
||||
- New font for MinTTY console on Windows
|
||||
- Send partial hotbar history
|
||||
- Fixed Tile saving indexes
|
||||
- Fixed a few teleport bugs
|
||||
- Improved crash dumps
|
||||
- Increased apple health restore
|
||||
- Fixed players being invincible after death
|
||||
- Fixed Level::unloadChunk() not using saveEnabled
|
||||
- Show player name on bad username kick
|
||||
- Fixed item duplication on void #1100
|
||||
- OPs can bypass the player limit
|
||||
- Fixed item replacing on furnace #1114
|
||||
- Fixed multiple small bugs #1058 #1032 #854 #823 #1135 #1150 #1172 #1173 #486 #466 #483
|
||||
- Fixed PHP compilation on 64-bit linux #519 #861 #940 #505 #590 #761 #129
|
||||
- Included OPCache to optimize opcodes
|
||||
|
||||
If you are on Linux, you can use `wget -q -O - http://cdn.pocketmine.net/installer.sh | bash -s - -v Alpha_1.3.12` to update. If you are on a MacOS, use `curl -sL http://cdn.pocketmine.net/installer.sh | bash -s - -v Alpha_1.3.12`
|
1278
changelogs/1.4.md
Normal file
1278
changelogs/1.4.md
Normal file
File diff suppressed because it is too large
Load Diff
72
changelogs/1.6.md
Normal file
72
changelogs/1.6.md
Normal file
@ -0,0 +1,72 @@
|
||||
# 1.6.1dev-87
|
||||
**For Minecraft PE 0.16.0.5 alpha**
|
||||
|
||||
**THIS IS A PRE RELEASE. Do not use it in production unless you are sure you know what you are doing.**
|
||||
|
||||
Only changes since the 1.6dev tag will be documented here. Changes between 1.4.1 and 1.6dev are far too extensive to document effectively.
|
||||
|
||||
## Core
|
||||
- New RNG, based on XorShift128 from the php-random library. This fixes issue with repeating terrain on 32-bit systems. _Note however that new generation into existing worlds will not be seamless._
|
||||
- Block and Item IDs have been moved to interfaces for better consistency
|
||||
- Better method for synchronisation of client/server time (less packet spam)
|
||||
- Utils::getRandomBytes() has been deprecated in favour of php7's random_bytes() function.
|
||||
- `<player>.dat` saving/reading can now be disabled in `pocketmine.yml` (set `player.save-player-data` to `false`)
|
||||
|
||||
## Gameplay/game features
|
||||
- Added Flower Pots
|
||||
- Containers can now be opened in creative
|
||||
- Trapdoors can now be placed without a supporting block
|
||||
|
||||
## API
|
||||
|
||||
This release has API changes, bumping the version to 2.1.0.
|
||||
|
||||
### Entity metadata (0.16)
|
||||
|
||||
Many changes have been made to entity metadata. Many true/false data properties are now entity status flags, such as NoAI, NametagVisible and various others. Entity status flags can be set using:
|
||||
`$entity->setDataFlag(Entity::DATA_FLAGS, Entity::INSERT_DATA_FLAG_NAME, true/false);`
|
||||
|
||||
**Breaking** changes are detailed here. Additions are not documented. https://gist.github.com/dktapps/76b291b7a861762b54f7a8b834389883
|
||||
|
||||
**NOTE: It's strongly recommended to use provided API methods where possible instead of tampering with metadata directly.**
|
||||
|
||||
### AsyncTask API additions
|
||||
- Main thread local storage: Developers can pass any data including objects to the constructor of AsyncTask such that the data can be retrieved after the AsyncTask completes using the new `AsyncTask::fetchLocal()` method, or use the `AsyncTask::peekLocal()` method to get the data without removing it.
|
||||
- Progress updates: Developers can use the new `AsyncTask::publishProgress() method and override`AsyncTask::onProgressUpdated()` to handle AsyncTask progress information in the main thread.
|
||||
|
||||
Refer to #1 and #100 for details.
|
||||
|
||||
### WeakPosition
|
||||
|
||||
WeakPosition was added in 1.6.1 to fix bugs with unloading levels which have player spawn points set in them. This type of position holds a level ID instead of a direct reference. Use this when your position may outlive the level it is in.
|
||||
|
||||
### Removal of Item/NBT circular dependency
|
||||
|
||||
Refer to #121 for details.
|
||||
|
||||
### Other
|
||||
- Added Player->sendWhisper() (#73).
|
||||
- Removed LargeExplodeParticle due to incorrect name - use HugeExplodeParticle. Added HugeExplodeSeedParticle and BlockForceFieldParticle (7314aaf7f7bdae582f674c085c7ae879985bf847)
|
||||
|
||||
## Fixes
|
||||
- Fixed the infamous hotbar spaz bug
|
||||
- Creative/spectator inventory now sends correctly
|
||||
- Fixed spectator flight controls
|
||||
- Fixed issues with items going past the end of the regular inventory
|
||||
- Fixed furnace client crashes
|
||||
- Fixed inventory windows for anvils and enchanting tables
|
||||
- Fixed kicked for walking on lily pads (#blameshoghicp)
|
||||
- Fixed a nasty entity-related memory leak on chunk unload
|
||||
- Fixed sleeping players floating above beds and teleportation of sleeping players.
|
||||
- Fixed a bug in Level::updateAround() where only one block would update
|
||||
- Fixed some slab placement issues (#31)
|
||||
- Fixed crash loading 1.11 worlds (#32)
|
||||
- Fixed broken `--disable-readline` command-line option (#34)
|
||||
- Fixed world unload crash when players have spawnpoints set in that world (#24)
|
||||
- Fixed start.sh detection of system PHP binaries (#66)
|
||||
- Fixed anvil rotation when placed and variant drops (d696049a0ad5e3b878a8f902e4ef75f19ec8cecc)
|
||||
- /timings command is now more verbose about paste errors (#95)
|
||||
- Fixed server crash at shutdown when RCON is enabled (#101)
|
||||
- Fixed server name is always "Minecraft: PE Server" when running setup wizard (92bd1a755d4b171b687538db83893b9bd9c70420)
|
||||
- Fixed CraftItemEvent->getInput() does not return used items (7eb9530346e953d1555623ff871086f85447b6c6)
|
||||
- Fixed useless ServerKiller (#122)
|
1155
changelogs/3.0-alpha.md
Normal file
1155
changelogs/3.0-alpha.md
Normal file
File diff suppressed because it is too large
Load Diff
264
changelogs/3.0.md
Normal file
264
changelogs/3.0.md
Normal file
@ -0,0 +1,264 @@
|
||||
**For Minecraft: Bedrock Edition 1.4.0**
|
||||
|
||||
Plugin scheduler rewrite, RCON rewrite, performance improvements, improved idle memory usage
|
||||
|
||||
**While this release is nominally not an alpha, it is still not feature complete and does not include all gameplay features. Please do not create issues for missing gameplay features.**
|
||||
|
||||
This build has breaking API changes.
|
||||
This release is the first to use the new merged versioning system. The PocketMine-MP version and the API version are now one and the same.
|
||||
|
||||
Please use our issue tracker to report bugs.
|
||||
|
||||
# 3.0.0
|
||||
## Core
|
||||
### General
|
||||
- This release introduces a new dependency library called `Snooze`, which PocketMine-MP utilizes for managing notifications between threads. This library is currently utilized by command reading, RCON and RakLib, allowing faster response times to commands, reduced network latency, and better performance due to lack of need for polling.
|
||||
- Fixed race condition causing `ServerKiller` to sometimes kill the server for no reason on shutdown.
|
||||
|
||||
### Dependency libraries
|
||||
Requires the following libraries:
|
||||
- [`pocketmine/raklib` `^0.12.0`](https://github.com/pmmp/RakLib/releases/0.12.0)
|
||||
- [`pocketmine/spl` `^0.3.0`](https://github.com/pmmp/SPL/releases/0.3.0)
|
||||
- [`pocketmine/binaryutils` `^0.1.0`](https://github.com/pmmp/BinaryUtils/releases/0.1.0)
|
||||
- [`pocketmine/nbt` `^0.2.0`](https://github.com/pmmp/NBT/releases/0.2.0)
|
||||
- [`pocketmine/math` `^0.2.0`](https://github.com/pmmp/Math/releases/0.2.0)
|
||||
- [`pocketmine/snooze` `^0.1.0`](https://github.com/pmmp/Snooze/releases/0.1.0)
|
||||
|
||||
These libraries may individually have changes which are not recorded here. See their independent repository releases for their changelogs.
|
||||
|
||||
### Async pooling
|
||||
- Async workers are now started dynamically when they are needed only, instead of being started immediately on startup. This allows reducing idle memory usage.
|
||||
- AsyncPool now appropriately shuts down the workers when instructed to, instead of leaving it up to the ThreadManager to clean it up. This eliminates debug messages of shutting down async workers on server shutdown.
|
||||
- Default maximum async worker memory limit has been lowered from 1024MB to 256MB.
|
||||
- Async workers are now started using the options `PTHREADS_INHERIT_CONSTANTS | PTHREADS_INHERIT_INI`, which reduces idle memory wastage and works around some bugs in pthreads.
|
||||
|
||||
### Entities
|
||||
- Fixed entities not being despawned when flagged, if they weren't scheduled for an update.
|
||||
|
||||
### Levels
|
||||
- Seed handling is now always consistent between `pocketmine.yml` and `server.properties`.
|
||||
- Fixed generation bugs in imported LevelDB worlds where the classpath was saved into level.dat.
|
||||
- Generators for levels are no longer created on the main thread, reducing memory usage.
|
||||
|
||||
### Plugins
|
||||
- Plugin data is now stored under `<data dir>/plugin_data` by default on new installations, instead of in `<plugins dir>`. This behaviour does not affect existing installations by default - if you want to enable it, set `plugins.legacy-data-dir` to `false` in `pocketmine.yml`.
|
||||
|
||||
### RCON
|
||||
RCON has been almost completely rewritten in this release.
|
||||
- Now event-driven (using Snooze) instead of poll-based, improving performance.
|
||||
- Fixed segmentation fault when stopping the server with RCON enabled.
|
||||
|
||||
## API
|
||||
**WARNING: Dependency library API changes are not listed here. See their individual release notes for changes (linked above in the Core section).**
|
||||
|
||||
### API versioning changes for plugins
|
||||
The way that the API versioning is done has changed. Now the API version is synonymous with the PocketMine-MP version.
|
||||
Plugin compatibility is determined by the following:
|
||||
- Take the base version, and strip any metadata (everything after the `+` sign, for example `3.0.0+dev.1191` becomes `3.0.0`).
|
||||
- Assert that:
|
||||
- The major versions is the same
|
||||
- The server's minor version is greater than or equal to the plugin's
|
||||
- The server's patch version is greater than or equal to the plugin's
|
||||
|
||||
Currently there is no support for locking version by metadata, although this could be implemented if it is a wanted feature.
|
||||
|
||||
### General
|
||||
- `Server->getCodename()` and `\pocketmine\CODENAME` have been removed.
|
||||
- Added API method `Server->getTickSleeper()`, which returns a `\pocketmine\snooze\SleeperHandler` instance.
|
||||
- `Server->getIp()` now returns `0.0.0.0` if not set.
|
||||
|
||||
### Block
|
||||
- Added `Block->getXpDropForTool()`.
|
||||
|
||||
### Entity
|
||||
- Calling `scheduleUpdate()` on an `Entity` after it has been `close()`d will now cause an exception to be thrown.
|
||||
- `Entity->motionX`, `Entity->motionY` `Entity->motionZ` have been removed in favour of an `Entity->motion` `Vector3` field. This also applies for the `lastMotion` fields.
|
||||
- `Entity->isInsideOfWater()` has been renamed to `isUnderwater()`.
|
||||
|
||||
### Events
|
||||
- Added support for `@softDepend` annotation on event handlers, which allows the event handler to not be registered if the dependency plugin is not loaded.
|
||||
- Added support for `@notHandler` annotation for `Listener` methods to indicate that such methods are not event handlers.
|
||||
- Typehints have been applied to the events API to PHP 7.2 standards.
|
||||
- Fixed preventing effect expiry using `EntityEffectRemoveEvent` not being reflected on the client.
|
||||
- `EntityDamageEvent` API has significant changes. The general purpose of this is to split up base damage from modifiers.
|
||||
- Added methods `getBaseDamage()`, `setBaseDamage()`, `getOriginalBaseDamage()`, `getModifiers()`, `getOriginalModifiers()`
|
||||
- `setDamage()` renamed to `setModifier()`, and type parameter is now mandatory
|
||||
- `getDamage()` renamed to `getModifier()`, and type parameter is now mandatory
|
||||
- `getOriginalDamage()` renamed to `getOriginalModifier()`, and type parameter is now mandatory
|
||||
- Removed `MODIFIER_BASE` constant
|
||||
- Constructors now accept: `float baseDamage`, `float[] modifiers` instead of just `float[] modifiers`
|
||||
- Added `BlockBreakEvent->getXpDropAmount()` and `BlockBreakEvent->setXpDropAmount()`.
|
||||
|
||||
### Inventory
|
||||
- `InventoryTransaction->getCreationTime()` has been removed.
|
||||
- `EntityInventoryChangeEvent` and `EntityArmorChangeEvent` are no longer fired during entity inventory intialization.
|
||||
|
||||
### Item
|
||||
- Methods `isPickaxe()`, `isAxe()`, `isSword()`, `isShovel()`, `isHoe()`, `isShears()` have been removed. These should be replaced with `instanceof` checks for the relevant classes.
|
||||
- Removed `Item->useOn()`. This has been superseded by new methods used for handling durability changes.
|
||||
- Added hooks `Item->onDestroyBlock()` and `Item->onAttackEntity()`. These are called when a player uses the item to destroy a block or attack an entity respectively. This is used in the core code for updating durability.
|
||||
- `Item->pop()` now accepts an optional count parameter.
|
||||
- `Enchantment` now has separated primary items (which can be enchanted directly) and secondary items (which can be enchanted on an anvil). The constructor of `Enchantment` has been updated to reflect this.
|
||||
- Removed `Enchantment->getSlot()` and `Enchantment->hasSlot()`.
|
||||
- Added `Enchantment->getPrimaryItemFlags()`, `Enchantment->hasPrimaryItemFlag()`, `Enchantment->getSecondaryItemFlags()` and `Enchantment->hasSecondaryItemFlag()`
|
||||
|
||||
### Level
|
||||
- `Biome` classes have been moved to `pocketmine\level\biome` namespace. This is in preparation for future work on Levels which requires biome information (such as weather conditions).
|
||||
- `WeakPosition` has been removed.
|
||||
- Added `Level->getBiome()`.
|
||||
- `Level->getSafeSpawn()` now always returns a `Position` instance.
|
||||
- `Level->getBlockExtraData()` and `Level->setBlockExtraData()` have been removed (as well as their associated `Chunk` methods).
|
||||
- `ChunkManager->isInWorld()` now accepts integers instead of floats.
|
||||
- Added `SubChunkIteratorManager->invalidate()`.
|
||||
|
||||
#### Generator
|
||||
- `BiomeSelector` has been refactored to make it simpler and more robust.
|
||||
- Generator-management methods `registerDefaultGenerators()`, `addGenerator()`, `getGeneratorList()`, `getGenerator()`, and `getGeneratorName()` have been moved from `Generator` to a new `GeneratorManager` class.
|
||||
- Static noise functions in the `Generator` base class have been moved to `Noise` instance methods.
|
||||
- Added static method `Generator::convertSeed()`, which converts an int or string into a numeric seed for generation.
|
||||
|
||||
### Network
|
||||
- `SourceInterface->process()` no longer returns a value.
|
||||
|
||||
### Plugin
|
||||
- `PluginBase->getResources()` now returns an associative array where the index is the path to the resource relative to the plugin's `resources` directory.
|
||||
- `PluginLoader`s have been almost completely rewritten to make them simpler and more robust.
|
||||
- `PluginManager->registerInterface()` does not return anything, and now accepts a `PluginLoader` instance instead of a `string`.
|
||||
- `PluginLoader`:
|
||||
- `getPluginFilters()`, `enablePlugin()` and `disablePlugin()` are removed.
|
||||
- `loadPlugin()` responsibilities are now solely confined to doing whatever is necessary to make the plugin's classes visible by the server, and does not emit log messages or check for data directories.
|
||||
- Added method `getAccessProtocol()` which determines what prefix to apply to the plugin path to access the files inside it (for example `phar://`).
|
||||
- `PluginBase->init()` and `PluginBase->isInitialized()` have been removed.
|
||||
- `Plugin` interface now declares a signature for the constructor which implementations must comply with.
|
||||
- `Plugin` interface now declares `setEnabled()`.
|
||||
- It is now possible to create a custom `Plugin` implementation without requiring a custom `PluginLoader`.
|
||||
|
||||
### Scheduler
|
||||
This release features major changes to how plugin task scheduling works.
|
||||
- Removed `Server->getScheduler()`. All plugins now have their own scheduler which is accessible using `Plugin->getScheduler()`. Aside from being syntactically more concise and pleasant, this also allows much more effective management of tasks when plugins are disabled.
|
||||
- Removed `PluginTask` class, because it's now unnecessary. Previously it was required to allow the server to delete tasks associated with a plugin when the plugin was disabled. With plugin-owned schedulers, this is no longer a requirement. Plugins may now utilize the `Task` class as a base if they like.
|
||||
- Added `Server->getAsyncPool()`. Since the global scheduler does not exist any more, it does not manage the server's `AsyncPool` any more. Additionally, `ServerScheduler` was previously bloated by a lot of `AsyncTask` related methods, which are now not necessary because direct access to `AsyncPool` is granted instead.
|
||||
- `ServerScheduler`:
|
||||
- `ServerScheduler` has been renamed to `TaskScheduler` since it is now a general-purpose task scheduler which is non-dependent on the user. This allows much greater flexibility and also makes it possible to unit-test.
|
||||
- All `AsyncTask`/`AsyncPool` related methods have been removed - the task scheduler does not manage the async pool anymore.
|
||||
- Calls to `Server->getScheduler()->scheduleAsyncTask()` should be replaced with `Server->getAsyncPool()->submitTask()`.
|
||||
- Calls to `Server->getScheduler()->scheduleAsyncTaskToWorker()` should be replaced with and `Server->getAsyncPool()->submitTaskToWorker()`.
|
||||
|
||||
### Tile
|
||||
- Calling `scheduleUpdate()` on a `Tile` after it has been `close()`d will now cause an exception to be thrown.
|
||||
- Tile NBT is now ephemeral and is not retained after creating the tile.
|
||||
- `Tile->namedtag` has been removed.
|
||||
- `Tile->saveNBT()` now returns a new `CompoundTag` containing saved data.
|
||||
- Added new protected methods `Tile->readSaveData()` and `Tile->writeSaveData()`. These should be overridden to add or read tile-specific data, instead of overriding `saveNBT()` and `__construct()`.
|
||||
|
||||
### Utils
|
||||
- Added `MainLogger->getFormat()` and `MainLogger->setFormat()` to allow manipulating console output format.
|
||||
|
||||
## Gameplay
|
||||
### General
|
||||
- Fixed a range of block collision issues stemming from off-by-one errors when fetching areas.
|
||||
|
||||
### Blocks
|
||||
- Fixed a crash which occurred when leaving a bed which was broken and replaced during sleep.
|
||||
- Fixed dark oak and acacia saplings growing into oak trees - now they will not grow at all (they need to be implemented).
|
||||
- Saplings now take light level into account when trying to grow.
|
||||
- Ores and other blocks now drop experience when broken with an appropriate tool.
|
||||
|
||||
### Entities
|
||||
- Fixed dropped items not being correctly destroyed by fire, cacti and other damage sources.
|
||||
|
||||
### Generation
|
||||
- Grass no longer generates as the top layer of ground cover in river biomes.
|
||||
- Ocean biomes now use gravel instead of grass+dirt for ground cover.
|
||||
- Reduced maximum elevation of plains biomes to make them less bumpy.
|
||||
- Snow layers and other can-be-flowed-into blocks no longer generate underwater.
|
||||
|
||||
### Items
|
||||
- Buckets are no longer able to delete any block by replacing it with water.
|
||||
- Dried Kelp, Bleach, Nautilus Shell and Heart of the Sea items are registered (although crafting recipes for these are not yet available).
|
||||
- Implemented `Vanishing` enchantment.
|
||||
- Implemented Totems.
|
||||
|
||||
### World
|
||||
- Fixed explosions sometimes leaving behind air blocks with non-zero damage values.
|
||||
|
||||
# 3.0.1
|
||||
- Fixed error when players move things around in the crafting grid after plugins cancel `PlayerInteractEvent` on crafting tables.
|
||||
|
||||
# 3.0.2
|
||||
- Fixed memory dumps not showing private properties of parent classes.
|
||||
- Fixed a memory leak when cancelling all tasks in the `TaskScheduler`.
|
||||
- Fixed scheduled task timings showing `Unknown` as the plugin name.
|
||||
|
||||
# 3.0.3
|
||||
- Fixed possible crash in Sign when placed by a plugin.
|
||||
- Fixed slightly-damaged and very-damaged anvils dropping incorrect items.
|
||||
- `Living->applyPostDamageEffects()` is no longer called if the mob died from an attack.
|
||||
- Cooldown for mob attack is now reset prior to applying post-damage effects.
|
||||
- Added constant `ItemIds::MUTTON` to resolve crashes using PC worlds.
|
||||
- Fixed emerald ore not dropping XP when broken with a valid tool.
|
||||
- Fixed mobs getting crazy vertical knockback if attacked while airborne.
|
||||
- Fixed XP orbs continuing to follow dead players.
|
||||
|
||||
# 3.0.4
|
||||
- Fixed RCON spamming the console when a client does not disconnect correctly.
|
||||
- Fixed dropping chunk cache unnecessarily when no blocks need to be updated on a chunk.
|
||||
- Fixed outdated block updates getting sent on chunks replaced using `setBlock()`.
|
||||
|
||||
# 3.0.5
|
||||
- Fixed not being able to place blocks where a player died and has not yet respawned (#2265).
|
||||
- Fixed mob death animation not being played when `Entity->kill()` is called directly or `/kill` is used.
|
||||
- Fixed viewers of different halves of double chests not seeing changes made by viewers who opened the other half (#2261).
|
||||
- Fixed bugs setting items into wrong indexes when double chest halves have differently sized inventories.
|
||||
- Fixed `getConfig()` crashing when called when the plugin's data directory doesn't exist.
|
||||
- Fixed a possible exploit with keychain signing for XBL login.
|
||||
|
||||
# 3.0.6
|
||||
- Fixed invalid keys in `.properties` config files being considered as invalid strings.
|
||||
- Fixed whitespace between key and value `key = value` being invalid in `.properties` config files.
|
||||
- Fixed a bug in exception message when an invalid permission type is written for a command in plugin.yml.
|
||||
- Properly fixed newline issues when parsing event handler annotations - `@notHandler` will now work as expected when CRLF line endings are used.
|
||||
- Fixed `PluginManager->registerEvents()` registering functions as event handlers declared by parent classes which are not `Listener` instances (#2293).
|
||||
|
||||
# 3.0.7
|
||||
- Fixed setting spawn points in un-generated chunks causing the player to fall out of the world.
|
||||
- Fixed spawn protection deactivating when there are no ops set (this was an unwanted/unexpected feature, so it's considered a bug).
|
||||
- Fixed cursor items not getting dropped when closing the inventory or dying.
|
||||
- Fixed more issues with blocks with invalid metadata appearing as update! blocks.
|
||||
- `Entity->setNameTagAlwaysVisible()` now works (although nametags will still not be shown if the entity is invisible, due to a behavioural change in Minecraft PE).
|
||||
- Fixed errors passing zero motions to projectiles in some cases.
|
||||
|
||||
# 3.0.8
|
||||
- Fixed player on-ground state not updating when moving horizontally. This allowed fly hacks with the built in anti-cheat, and also affected some third party anti-cheat plugins due to the effect on `inAirTicks`.
|
||||
- Fixed knockback. PC 1.9-style knockback was mistakenly introduced in 3.0.3. This has now been reverted back to the old 1.8-style behaviour.
|
||||
|
||||
# 3.0.9
|
||||
- Cleaned up odd behaviour of `/kill` due to old broken code.
|
||||
- Fixed patch level check for plugin APIs not allowing lesser patch versions on greater minor versions.
|
||||
- Fixed `/timings paste`. This now reports directly to the timings host instead of using Ubuntu Pastebin.
|
||||
- Minor code cleanups in various places.
|
||||
- Zip resource packs will now give slightly less useless errors - errors for broken manifest have been separated from those with fields missing, and now reports why decoding failed if it failed.
|
||||
|
||||
# 3.0.10
|
||||
- Syntax error crashdumps will no longer be reported to the crash archive.
|
||||
- Chunk sending is now fault-tolerant. Before this release, any error on a worker during async chunk sending (such as memory errors caused by pthreads) would cause that chunk to never get sent, resulting in invisible and missing chunks. Levels will now attempt to retry chunk prepare when a task crashes, which should fix most invisible chunk bugs.
|
||||
- `MainLogger` now logs exception stack traces in a synchronized block to ensure that they are coherent when log messages are emitted from multiple threads at once.
|
||||
- `AsyncTask->isCrashed()` now returns `true` if a fatal error occurred during the task execution.
|
||||
|
||||
# 3.0.11
|
||||
- `DropItemAction` will now consider itself invalid if attempting to drop a null item.
|
||||
- Fixed leaking globally broadcasted Level packets when no players are on the server.
|
||||
- Fixed title bar not being cleared on server stop on some terminals.
|
||||
- Fixed `FallingBlock` saving corrupted data.
|
||||
- Fixed the structure of `GuiDataPickItemPacket`.
|
||||
- Cleaned up some code in `OfflinePlayer`.
|
||||
- Splash potions no longer apply effects to dead (but not yet respawned) players.
|
||||
- Coal ore no longer drops XP when mined with a silk touch tool.
|
||||
- Item entities now cannot be picked up when a negative pickup delay is used.
|
||||
|
||||
# 3.0.12
|
||||
- `Config` keys which are considered bools by YAML 1.1 will no longer be transformed into 1 or 0.
|
||||
- Fixed painting motives not getting saved.
|
||||
- Fixed cacti spewing items when placed in some invalid locations.
|
||||
- Fixed entity fire damage not applying in the void.
|
||||
- Fixed entities not getting updated appropriately in some conditions.
|
68
changelogs/3.1.md
Normal file
68
changelogs/3.1.md
Normal file
@ -0,0 +1,68 @@
|
||||
**For Minecraft: Bedrock Edition 1.5.0**
|
||||
|
||||
### Note
|
||||
Plugins compatible with any previous 3.x.y version will also run on this build 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.
|
||||
|
||||
**This build contains changes to the **protocol** which are not covered by the API version. To lock your plugin to a specific protocol version, declare the `mcpe-protocol` attribute in your `plugin.yml`.
|
||||
|
||||
# 3.1.0
|
||||
- Support for Minecraft: Bedrock Edition version 1.5.0
|
||||
|
||||
# 3.1.1
|
||||
- Fixed player on-ground state not updating when moving horizontally. This allowed fly hacks with the built in anti-cheat, and also affected some third party anti-cheat plugins due to the effect on `inAirTicks`.
|
||||
- Fixed knockback. PC 1.9-style knockback was mistakenly introduced in 3.0.3. This has now been reverted back to the old 1.8-style behaviour.
|
||||
|
||||
# 3.1.2
|
||||
- Cleaned up odd behaviour of `/kill` due to old broken code.
|
||||
- Fixed patch level check for plugin APIs not allowing lesser patch versions on greater minor versions.
|
||||
- Fixed `/timings paste`. This now reports directly to the timings host instead of using Ubuntu Pastebin.
|
||||
- Minor code cleanups in various places.
|
||||
- Zip resource packs will now give slightly less useless errors - errors for broken manifest have been separated from those with fields missing, and now reports why decoding failed if it failed.
|
||||
- Added constant `Entity::DATA_FLAG_SHOW_TRIDENT_ROPE`.
|
||||
|
||||
# 3.1.3
|
||||
- Syntax error crashdumps will no longer be reported to the crash archive.
|
||||
- Chunk sending is now fault-tolerant. Before this release, any error on a worker during async chunk sending (such as memory errors caused by pthreads) would cause that chunk to never get sent, resulting in invisible and missing chunks. Levels will now attempt to retry chunk prepare when a task crashes, which should fix most invisible chunk bugs.
|
||||
- `MainLogger` now logs exception stack traces in a synchronized block to ensure that they are coherent when log messages are emitted from multiple threads at once.
|
||||
- `AsyncTask->isCrashed()` now returns `true` if a fatal error occurred during the task execution.
|
||||
|
||||
# 3.1.4
|
||||
- `DropItemAction` will now consider itself invalid if attempting to drop a null item.
|
||||
- Fixed leaking globally broadcasted Level packets when no players are on the server.
|
||||
- Fixed title bar not being cleared on server stop on some terminals.
|
||||
- Fixed `FallingBlock` saving corrupted data.
|
||||
- Fixed the structure of `GuiDataPickItemPacket`.
|
||||
- Cleaned up some code in `OfflinePlayer`.
|
||||
- Splash potions no longer apply effects to dead (but not yet respawned) players.
|
||||
- Coal ore no longer drops XP when mined with a silk touch tool.
|
||||
- Item entities now cannot be picked up when a negative pickup delay is used.
|
||||
- Fixed extra byte at the end of `PlayerSkinPacket` not being read (1.5 protocol change that somehow got lost).
|
||||
|
||||
# 3.1.5
|
||||
- `Config` keys which are considered bools by YAML 1.1 will no longer be transformed into 1 or 0.
|
||||
- Fixed painting motives not getting saved.
|
||||
- Fixed cacti spewing items when placed in some invalid locations.
|
||||
- Fixed entity fire damage not applying in the void.
|
||||
- Fixed entities not getting updated appropriately in some conditions.
|
||||
|
||||
# 3.1.6
|
||||
- Fixed players disconnected during login verification getting leaked and not destroyed correctly.
|
||||
- Updated NBT dependency to 0.2.1 to receive bug fixes (see https://github.com/pmmp/NBT/releases/tag/0.2.1).
|
||||
|
||||
# 3.1.7
|
||||
- Errors thrown during level tick will now crash the server instead of spamming the console.
|
||||
- Fixed arrows despawning too soon after hitting the ground.
|
||||
- Fixed projectiles despawning before colliding if they were airborne for > 60 seconds.
|
||||
|
||||
# 3.1.8
|
||||
- Fixed levels unloaded during an earlier level's tick on the same tick causing a crash.
|
||||
- PermissibleBase->clearPermissions() now properly unsubscribes from all permissions.
|
||||
- Fixed incorrect break check for standing torch.
|
||||
- Fixed drops for brewing stand.
|
||||
- Fixed block picking brewing stand, bed, double slab, cake, farmland, and mob heads giving the wrong items.
|
||||
- Fixed blocks not placing correctly when clicking on redstone ore.
|
||||
- Fixed unknown PC items in tile inventories crashing the server - now they'll be quietly removed instead.
|
||||
- Fixed server freezing when eating chorus fruit from high altitude.
|
||||
- `readline` is now disabled by default on Windows and must be explicitly enabled with `--enable-readline` due to thread-safety issues.
|
||||
- Fixed server crash when trying to use non-implemented splash potions.
|
||||
- Removed incorrect maximum region file size cap which may have caused some worlds to be incorrectly detected as corrupted.
|
121
changelogs/3.2.md
Normal file
121
changelogs/3.2.md
Normal file
@ -0,0 +1,121 @@
|
||||
**For Minecraft: Bedrock Edition 1.6.0**
|
||||
|
||||
This is a minor feature release, including support for Minecraft Bedrock 1.6.0, some new minor gameplay features and some API deprecations and additions.
|
||||
|
||||
### Note
|
||||
Plugins compatible with any previous 3.x.y version will also run on this build and do not need API bumps.
|
||||
|
||||
However, some API features have been deprecated in this version. Plugin developers do not need to do anything about these deprecations immediately, however they may raise harmless warnings if used.
|
||||
|
||||
Features marked **`@deprecated`** are **recommended** not to be used, but will continue to work for any future 3.x.y versions. They will be removed in the next major release (4.0).
|
||||
|
||||
# 3.2.0
|
||||
### Core
|
||||
- `Level` generators are now registered only when needed instead of as soon as a worker starts. This drastically reduces memory consumption on servers with lots of workers.
|
||||
- Async workers are now garbage-collected along with everything else on the default schedule. Idle workers with 0 queued tasks will be shutdown and removed from the pool to reduce memory usage.
|
||||
- UPnP error messages are now more informative of troubleshooting steps.
|
||||
- Errors are no longer caught in cases where they are unrecoverable.
|
||||
|
||||
### API
|
||||
#### Entity
|
||||
- Arrow pickup mode can now be controlled via `Arrow->setPickupMode()`. This accepts one of three `Arrow` constants: `PICKUP_NONE`, `PICKUP_ANY`, `PICKUP_CREATIVE`.
|
||||
- Added new API methods `Projectile->getBaseDamage()` and `Projectile->setBaseDamage()`.
|
||||
- Added new API methods `Entity->getScoreTag()` and `Entity->setScoreTag()`.
|
||||
|
||||
#### Events
|
||||
- The `Listener` interface has now received in-depth documentation about its behaviour and uses. See the top of the `Listener` class to read it.
|
||||
- It is now possible to declare `@ignoreCancelled` on an event handler without specifying `true` or `false`. If no value is found, `true` will be assumed.
|
||||
- `ServerCommandEvent` and `RemoteServerCommandEvent` are now **`@deprecated`** and their usage discouraged. A new generic `CommandEvent` has been introduced in its place, which allows capturing commands from any type of command sender. This was done in response to difficulties of code duplication when wanting to intercept commands from both console and players.
|
||||
- `EntityDamageEvent`
|
||||
- Added `MODIFIER_WEAPON_ENCHANTMENTS` constant for attack damage bonuses due to enchantments like Sharpness.
|
||||
- Added new API methods `getAttackCooldown()` and `setAttackCooldown()` to allow controlling Living entities attack cooldown times (default 10 ticks).
|
||||
- `PlayerDeathEvent`: Added new static method `deriveMessage()`.
|
||||
- `PlayerKickEvent`: Added new method `setReason()`.
|
||||
|
||||
#### Forms
|
||||
- Added a new `pocketmine\form\Form` interface. Implementing this interface permits custom form implementations to make use of `Player->sendForm()`, eliminating the need to handle packets directly and also solving the form ID collision problem.
|
||||
|
||||
#### Items
|
||||
- `Item` and `ItemFactory` now support negative item IDs (needed for future extended blocks support).
|
||||
- Updated `ItemIds` interface with new constants.
|
||||
|
||||
#### Permission
|
||||
- Added a new `PermissionManager` class which encapsulates all of the permission-management functionality originally bloating `PluginManager`. The API is identical to that of `PluginManager`'s permission API. All methods moved to `PermissionManager` have **`@deprecated`** redirects remaining behind in `PluginManager`, which will be removed in the next major release (4.0).
|
||||
|
||||
#### Plugin
|
||||
- `PluginBase->getConfig()` will now automatically save the default config if it does not already exist.
|
||||
- Plugin data directories will now be automatically created on plugin load, eliminating the need for boilerplate `@mkdir($this->getDataFolder())` calls at the top of every plugin.
|
||||
|
||||
#### Tile
|
||||
- `Tile::createNBT()` will now throw a `BadMethodCallException` when called directly.
|
||||
|
||||
#### Utils
|
||||
- `Utils::getURL()`, `Utils::postURL()`, `Utils::simpleCurl()` and `Utils::getIP()` have been moved to a new `pocketmine\utils\Internet` class. The original methods are **`@deprecated`** and will be removed for the next major version (4.0).
|
||||
- Removed the ability for `Config` to be asynchronously saved. This was discussed for removal because of various problems that it causes. It was deemed not worth fixing since `Config` saving should not be significant enough to cause problems anyway. See #2298 for details.
|
||||
|
||||
#### Server
|
||||
- Deprecated `level` parameter of `findEntity()`. This parameter was premature optimization. Code using it will continue to work as before.
|
||||
|
||||
### Gameplay
|
||||
#### General
|
||||
- Air bubbles are now regenerated at the same speed as vanilla UpdateAquatic, instead of instantly when leaving water.
|
||||
- Implemented Conduit Power effect.
|
||||
|
||||
#### Enchantments
|
||||
- Implemented the following enchantments: Thorns, Sharpness, Knockback, Fire Aspect, Power, Punch, Flame, Infinity, Mending.
|
||||
|
||||
#### Items
|
||||
- Added the following new items: `Scute`
|
||||
|
||||
# 3.2.1
|
||||
- Fixed `VerifyLoginTask` completion bug when players get disconnected prior to the task completing.
|
||||
- Fixed client crash issue due to outdated runtime ID mappings.
|
||||
|
||||
# 3.2.2
|
||||
- Updated NBT dependency to 0.2.1 to receive bug fixes (see https://github.com/pmmp/NBT/releases/tag/0.2.1).
|
||||
|
||||
# 3.2.3
|
||||
- Errors thrown during level tick will now crash the server instead of spamming the console.
|
||||
- Fixed arrows despawning too soon after hitting the ground.
|
||||
- Fixed projectiles despawning before colliding if they were airborne for > 60 seconds.
|
||||
- Fixed crash related to Flame enchantment when the player shooting the arrow was on fire.
|
||||
|
||||
# 3.2.4
|
||||
- Fixed levels unloaded during an earlier level's tick on the same tick causing a crash.
|
||||
- PermissibleBase->clearPermissions() now properly unsubscribes from all permissions.
|
||||
- Fixed incorrect break check for standing torch.
|
||||
- Fixed drops for brewing stand.
|
||||
- Fixed block picking brewing stand, bed, double slab, cake, farmland, and mob heads giving the wrong items.
|
||||
- Fixed blocks not placing correctly when clicking on redstone ore.
|
||||
- Fixed unknown PC items in tile inventories crashing the server - now they'll be quietly removed instead.
|
||||
- Fixed server freezing when eating chorus fruit from high altitude.
|
||||
- `readline` is now disabled by default on Windows and must be explicitly enabled with `--enable-readline` due to thread-safety issues.
|
||||
- Fixed server crash when trying to use non-implemented splash potions.
|
||||
- Removed incorrect maximum region file size cap which may have caused some worlds to be incorrectly detected as corrupted.
|
||||
|
||||
# 3.2.5
|
||||
- `Player->sendForm()` now throws a proper exception when failing to JSON-encode `Form` objects given to it.
|
||||
- Fixed crash when handling later packets in a batch when an earlier packet triggered termination of the player's connection.
|
||||
- Fixed a race condition causing progress updates in `AsyncTasks` to be lost when published near completion.
|
||||
- Fixed bad decoding for some packets with unsupported structures.
|
||||
- Crash dumps no longer report 20 empty lines when an error occurs in `eval()`'d code.
|
||||
- `pocketmine/nbt` dependency updated to `0.2.2` to fix bugs (see NBT repo for changelog).
|
||||
|
||||
# 3.2.6
|
||||
- Chunk ticking no longer occurs in chunks which have an adjacent unloaded chunks, fixing things like grass ticking triggering unintentional chunk loading.
|
||||
- Fixed some lighting propagation issues where step count is the same but light level is different.
|
||||
- Fixed full-chunk light repopulation producing broken lighting when the generator hasn't been registered on a worker.
|
||||
- Fixed a missing field in `MoveEntityDeltaPacket`.
|
||||
- Added client-sided rate limiting for crashdump reporting to mitigate involuntary DDoS of the crash archive.
|
||||
- Fixed a bug in `start.cmd` where quotes would appear around the "couldn't find installation" message.
|
||||
|
||||
# 3.2.7
|
||||
- Added a network-layer check for item NBT size to avoid unexplained client-sided crashes due to length overflow.
|
||||
- Fixed some desync bugs with double chests when one half of a double chest is unloaded.
|
||||
- Anonymous class timings will now have a cleaned path for the identifier relative to the plugins directory.
|
||||
- Anonymous class timings now render correctly on timings.pmmp.io.
|
||||
- Fixed empty garbage subchunks not getting removed from long-life chunks.
|
||||
- `start.ps1`, `start.sh` and `start.cmd` no longer recognize source-code installations. Since source-code installations should only be used by developers who know what they are doing anyway, this was considered unwise to keep.
|
||||
- Fixed a bug/oversight in network chunk preparation that caused chunk prepare to be 4x slower than necessary.
|
||||
- `Chunk->fastSerialize()` now doesn't serialize useless data (data is omitted based on chunk flags). This significantly reduces the amount of useless data getting copied for generation, population and light calculation.
|
||||
- `TaskHandler->cancel()` was incorrectly marked as `@internal` in 2014. This has been fixed. Plugin developers should in fact prefer `TaskHandler->cancel()` since it does not require a task to have a circular dependency on its own executor.
|
44
changelogs/3.3.md
Normal file
44
changelogs/3.3.md
Normal file
@ -0,0 +1,44 @@
|
||||
**For Minecraft: Bedrock Edition 1.7.0**
|
||||
|
||||
### Note
|
||||
Plugins 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 bug fixes in this build.
|
||||
|
||||
# 3.3.0
|
||||
- Compatibility with Minecraft: Bedrock Edition 1.7.0
|
||||
- Removed compatibility with 1.6.0
|
||||
- `Player->sendForm()` now throws a proper exception when failing to JSON-encode `Form` objects given to it.
|
||||
- Fixed crash when handling later packets in a batch when an earlier packet triggered termination of the player's connection.
|
||||
- Fixed a race condition causing progress updates in `AsyncTasks` to be lost when published near completion.
|
||||
- Fixed bad decoding for some packets with unsupported structures.
|
||||
- Crash dumps no longer report 20 empty lines when an error occurs in `eval()`'d code.
|
||||
- `pocketmine/nbt` dependency updated to `0.2.2` to fix bugs (see NBT repo for changelog).
|
||||
|
||||
# 3.3.1
|
||||
- Chunk ticking no longer occurs in chunks which have an adjacent unloaded chunks, fixing things like grass ticking triggering unintentional chunk loading.
|
||||
- Fixed some lighting propagation issues where step count is the same but light level is different.
|
||||
- Fixed full-chunk light repopulation producing broken lighting when the generator hasn't been registered on a worker.
|
||||
- Fixed a missing field in `MoveEntityDeltaPacket`.
|
||||
- Added client-sided rate limiting for crashdump reporting to mitigate involuntary DDoS of the crash archive.
|
||||
- Fixed a bug in `start.cmd` where quotes would appear around the "couldn't find installation" message.
|
||||
|
||||
# 3.3.2
|
||||
- Added a network-layer check for item NBT size to avoid unexplained client-sided crashes due to length overflow.
|
||||
- Fixed some desync bugs with double chests when one half of a double chest is unloaded.
|
||||
- Anonymous class timings will now have a cleaned path for the identifier relative to the plugins directory.
|
||||
- Anonymous class timings now render correctly on timings.pmmp.io.
|
||||
- Fixed empty garbage subchunks not getting removed from long-life chunks.
|
||||
- `start.ps1`, `start.sh` and `start.cmd` no longer recognize source-code installations. Since source-code installations should only be used by developers who know what they are doing anyway, this was considered unwise to keep.
|
||||
- Fixed a bug/oversight in network chunk preparation that caused chunk prepare to be 4x slower than necessary.
|
||||
- `Chunk->fastSerialize()` now doesn't serialize useless data (data is omitted based on chunk flags). This significantly reduces the amount of useless data getting copied for generation, population and light calculation.
|
||||
- `TaskHandler->cancel()` was incorrectly marked as `@internal` in 2014. This has been fixed. Plugin developers should in fact prefer `TaskHandler->cancel()` since it does not require a task to have a circular dependency on its own executor.
|
||||
|
||||
# 3.3.3
|
||||
- Development build error messages are now more user friendly.
|
||||
- Fixed meta-only changes not getting saved correctly in `SubChunk->setBlock()`.
|
||||
- Server will now sleep for up to 120 seconds on a crash if the uptime was less than 120 seconds. This delay is intended to reduce crash archive spam and can be skipped by the user if attended by pressing CTRL+C.
|
||||
- Fixed preprocessed builds sometimes having `new ` calls treated as function calls.
|
||||
- Fixed a rare corruption case where player data could be written incorrectly due to a race condition.
|
||||
- `DataPacket` will now throw errors when attempting to read/write nonexisting fields to make it easier to debug protocol change errors.
|
||||
|
||||
# 3.3.4
|
||||
- Fixed an undefined `DataPacket` field making the previous release unusable.
|
97
changelogs/3.4.md
Normal file
97
changelogs/3.4.md
Normal file
@ -0,0 +1,97 @@
|
||||
**For Minecraft: Bedrock Edition 1.7.0**
|
||||
|
||||
This is a cumulative minor release featuring performance improvements, memory usage improvements, some new minor gameplay features, some API deprecations and additions, and significant changes to error handling.
|
||||
|
||||
### Note
|
||||
Plugins compatible with any previous 3.x.y version will also run on these releases and do not need API bumps.
|
||||
|
||||
However, some API features have been deprecated in this version. Plugin developers do not need to do anything about these deprecations immediately, however they may raise harmless warnings if used.
|
||||
|
||||
Features marked **`@deprecated`** are **recommended** not to be used, but will continue to work for any future 3.x.y versions. They will be removed in the next major release (4.0).
|
||||
|
||||
# 3.4.0
|
||||
## Core changes
|
||||
### Performance & memory improvements
|
||||
- Entity `EXHAUSTION` attribute is no longer synced to the client, which reduces network traffic for survival players and reduces client-sided lag.
|
||||
- A redundant call was removed from an `Event` call hot path which improves event calling performance by ~15% per event handler executed.
|
||||
- Light updates are now batched together and executed on the end of each tick. The effects of this are noticeable when setting a large number of blocks in a close area - significant performance improvements should be noticeable for world editors (the ones that didn't disable light updates) and liquid flow is now significantly less expensive.
|
||||
- Internal enhancements have been made to subchunk light array interfacing to reduce branching and improve access performance.
|
||||
- Memory usage of most chunks has dropped by ~30-40% due to some improvements to internal storage of unlit subchunks. In real terms this translates to ~30% memory usage reduction for a freshly generated world.
|
||||
|
||||
### Error handling
|
||||
The most notable core change in this release revolves around error handling. Internals have been cleaned up substantially to improve the server behaviour under occurrence of unexpected behaviour. The goal of this is to improve consistency and quality while reducing undefined runtime behaviour.
|
||||
The following changes have been made:
|
||||
- Throwing **unexpected** `Throwable`s in the following cases will now cause a server crash (except on network (this will be changed in the future)):
|
||||
- Event handlers
|
||||
- `Task->onRun()` on a scheduler
|
||||
- `AsyncTask->onCompletion()`
|
||||
- `Command->execute()` and `CommandExecutor->onCommand()`
|
||||
- Unexpected `Throwable`s thrown during packet handling will now cause the target player to be disconnected with an `Internal server error` message.
|
||||
|
||||
### Other changes
|
||||
- Anti-flight has been removed, along with the `allow-flight` directive in `server.properties`.
|
||||
- Server language is now controlled by the `language` directive in `server.properties`.
|
||||
- Added `unban` and `unban-ip` as aliases of `pardon` and `pardon-ip` commands respectively.
|
||||
|
||||
## API changes
|
||||
### Block
|
||||
- `BlockSpreadEvent` is now fired when lava or water tries to flow into a block.
|
||||
- `BlockFormEvent` is now fired when lava and water collide to form cobblestone, obsidian or stone.
|
||||
|
||||
### Event
|
||||
- Added new method `Event->call()`. This should be used instead of `PluginManager->callEvent()` in plugins only supporting 3.4+.
|
||||
- `PluginManager->callEvent()` has been `@deprecated`.
|
||||
|
||||
### Level
|
||||
- Attempting to unload a level during its tick will now throw an `InvalidStateException`.
|
||||
- Added the following new methods:
|
||||
- `Level->broadcastPacketToViewers()`
|
||||
- `Level->getViewersForPosition()`
|
||||
- `Level->broadcastGlobalPacket()`
|
||||
- `Level->getChunkAtPosition()`
|
||||
- `Level->isInLoadedTerrain()`
|
||||
- `Level->addGlobalPacket()` has been `@deprecated`.
|
||||
- `LightUpdate` now allows calling `setAndUpdateLight()` for the same position multiple times (needed for light update batching).
|
||||
|
||||
### Permission
|
||||
- `Permission::getByName()` now throws an exception on invalid values instead of silently returning `DEFAULT_FALSE`. This may cause new errors to appear if your plugins had broken permission defaults in `plugin.yml`.
|
||||
|
||||
### Player
|
||||
- `addWindow()` now has stricter validity checks and will now throw exceptions in the following cases: No window IDs left to use, and when a forced window ID collides with an existing window.
|
||||
- The public `$speed` field has been removed (this was only used by anti-cheat which has now been removed).
|
||||
|
||||
### Scheduler
|
||||
- `AsyncTask->setResult()` has had the `$serialize` parameter removed - now it will automatically serialize (or not) as appropriate.
|
||||
- Added a new `ClosureTask` which allows concisely scheduling closure execution on a `TaskScheduler`.
|
||||
- `TaskScheduler->__construct()` `$logger` parameter has been `@deprecated` and will be removed in a future major version.
|
||||
|
||||
### Server
|
||||
- Added new method `Server->hasOfflinePlayerData(string $name) : bool`.
|
||||
- `Server->getAllowFlight()` has been `@deprecated`.
|
||||
|
||||
### Utils
|
||||
- `Config->save()` will no longer catch unexpected exceptions thrown while encoding data.
|
||||
|
||||
## Gameplay changes
|
||||
### Blocks
|
||||
- Rail connectivity has been implemented for normal, powered, detector and activator rails (but there are currently no minecarts).
|
||||
|
||||
# 3.4.1
|
||||
- Updated crashdump format to be compatible with newest CA. This version or newer is required if you want to be able to submit crashdumps to crash.pmmp.io.
|
||||
|
||||
# 3.4.2
|
||||
- `DataPacket` errors when writing to undefined fields are now more clear.
|
||||
- Fixed trees being able to overwrite the log parts of other trees.
|
||||
- Fixed `Player->sendForm()` not working during `PlayerJoinEvent`.
|
||||
- `Entity->setScale()` now explicitly requires a scale larger than 0.
|
||||
- Adding invisible `FloatingTextParticle` to a level no longer causes an error.
|
||||
|
||||
# 3.4.3
|
||||
- Fixed burning TNT setting hurt entities on fire when exploding.
|
||||
- `~` relative coordinates now work in the `/particle` command.
|
||||
- Various boring fixes to error stack trace reporting.
|
||||
- `Level->setChunk()` no longer deletes tiles and entities when replacing a chunk with itself.
|
||||
- Fixed a generator race condition causing rare appearances of half-trees on the client in freshly generated terrain.
|
||||
- `Attribute->resetToDefault()` now fits the default per the min/max bounds, fixing crashes when the bounds are changed to exclude the default.
|
||||
- Fixed a crash with LevelDB worlds when the `TAG_2D_MAPS` tag is missing.
|
||||
- Fixed `Utils::getCoreCount()` crashing on some Debian variants.
|
149
changelogs/3.5.md
Normal file
149
changelogs/3.5.md
Normal file
@ -0,0 +1,149 @@
|
||||
**For Minecraft: Bedrock Edition 1.8.0**
|
||||
|
||||
### Note
|
||||
Plugins 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.
|
||||
|
||||
# 3.5.0
|
||||
- Compatibility with Minecraft: Bedrock Edition 1.8.0
|
||||
- Removed compatibility with 1.7.0
|
||||
|
||||
# 3.5.1
|
||||
- Fixed internal server errors when attempting to craft.
|
||||
- `DataPacket` errors when writing to undefined fields are now more clear.
|
||||
- Fixed trees being able to overwrite the log parts of other trees.
|
||||
- Fixed `Player->sendForm()` not working during `PlayerJoinEvent`.
|
||||
- `Entity->setScale()` now explicitly requires a scale larger than 0.
|
||||
- Adding invisible `FloatingTextParticle` to a level no longer causes an error.
|
||||
|
||||
# 3.5.2
|
||||
- Updated some misc protocol magic numbers.
|
||||
- Fixed burning TNT setting hurt entities on fire when exploding.
|
||||
- `~` relative coordinates now work in the `/particle` command.
|
||||
- Various boring fixes to error stack trace reporting.
|
||||
- `Level->setChunk()` no longer deletes tiles and entities when replacing a chunk with itself.
|
||||
- Fixed a generator race condition causing rare appearances of half-trees on the client in freshly generated terrain.
|
||||
- `Attribute->resetToDefault()` now fits the default per the min/max bounds, fixing crashes when the bounds are changed to exclude the default.
|
||||
- Fixed a crash with LevelDB worlds when the `TAG_2D_MAPS` tag is missing.
|
||||
- Fixed `Utils::getCoreCount()` crashing on some Debian variants.
|
||||
|
||||
# 3.5.3
|
||||
- Rewritten documentation of `PlayerPreLoginEvent`, `PlayerLoginEvent` and `PlayerJoinEvent`. They are now much more detailed and no longer misleading.
|
||||
- Chest items block-picked from double chests will no longer place chests that crash the server when opened.
|
||||
- Ender chests now make the correct sounds when opening and closing.
|
||||
- Fixed Sign errors when a buggy or malicious client sent broken NBT with the wrong tags or wrong number of lines.
|
||||
- Resource packs with comments in the manifest will now load correctly. (MOJANG!!!)
|
||||
- Placement of unknown blocks is now disallowed. This solves a range of problems with invalid blocks in the world, such as #2260 .
|
||||
- Errors thrown during `PlayerQuitEvent` or other `Player->close()` errors will now crash the server instead of causing cryptic bugs later on.
|
||||
- Fixed large chunks (>= 1044476 bytes) becoming corrupted when saved in Region-based worlds - now an exception is thrown instead.
|
||||
- Reduced the range of exceptions caught during chunk loading. Now, only chunk corruption errors are caught, and anything else will produce a crash.
|
||||
- Removed catch-all block on chunk saving. Unexpected errors thrown during chunk save will now create a crash.
|
||||
- Fixed some asserts in packet decode methods.
|
||||
- `Attribute` now throws exceptions with more informative messages on errors.
|
||||
- Properly handled some remaining `Uninitialized string offset` bugs when decoding packets.
|
||||
- Fixed chunk updates taking several seconds to show up on the client. This bug was most apparent during generation and some world editing tools using asynchronous tasks.
|
||||
- Fixed CPU waste ordering chunks for non-moving players.
|
||||
|
||||
# 3.5.4
|
||||
### Fixes
|
||||
- Fixed server crash when a block update occurs on a torch with corrupted metadata.
|
||||
- Added a hack to mitigate client-side right-click spam bug. This mostly eliminates spam of `PlayerInteractEvent` on right-click.
|
||||
- Players will no longer see commands they don't have permission to use in client-sided hints when typing a `/` in the chat window.
|
||||
- `Event->isCancelled()` and `Event->setCancelled()` now throw more informative errors.
|
||||
- Errors thrown during a network interface processing will now _actually_ crash the server.
|
||||
|
||||
### API changes
|
||||
- Deprecated `NetworkInterfaceCrashEvent`. Nobody should have been using this anyway.
|
||||
- Deprecated `Network->processInterface()`
|
||||
- Deprecated `SourceInterface->emergencyShutdown()`
|
||||
|
||||
# 3.5.5
|
||||
- Mobs no longer spawn with their heads facing a different direction to their bodies.
|
||||
- Added a console message when the crash strangler sleeps to stop crash spam.
|
||||
- Fixed crash in `/title` command `times` subcommand when not enough arguments were passed.
|
||||
- AsyncWorkers will now not be shut down on GC unless they have not been used for the last 5 minutes. This reduces lag spikes on garbage collection.
|
||||
- Fixed some unhandled error cases in `AddEntityPacket` encoding.
|
||||
- Fixed `LogicException` descendents being thrown from some packet decoding methods when encountering bad userdata.
|
||||
- Player network inventory transaction processing now catches more specific errors.
|
||||
- Fixed missing decode for `TakeItemEntityPacket`.
|
||||
- Fixed `/gc` and `/status` truncating memory statistics - now they report to 0.01 precision.
|
||||
- Global functions and constants are now imported to improve performance.
|
||||
- Fixed a typo in `pocketmine.command.op.take` description.
|
||||
- Ice no longer creates water when a creative player breaks it.
|
||||
- `spawn-mobs` and `spawn-animals` no longer appear in generated `server.properties` on a newly-installed server.
|
||||
- Added a hack to disable pre-spawn client-sided movement.
|
||||
- Assertions enabled warning now always shows when `zend.assertions` is not `-1`. The config option to disable this warning has been removed.
|
||||
- `/status`,`/dumpmemory` and `/gc` are now enabled by default. The `debug.commands` config option has been removed.
|
||||
- Crash dumps are now more thorough at catching plugin-related crashes.
|
||||
|
||||
# 3.5.6
|
||||
- Fixed `#`-commenting properties in `.properties` files not working.
|
||||
- `pocketmine.yml` now permits writing `worldname:` with no generation settings in the `worlds` section to force a world to be loaded.
|
||||
- Fixed Bow force being too low - now it's consistent with Minecraft Java (but not with Bedrock due to a vanilla bug).
|
||||
- Fixed `recursion detected` bug when encoding crashdumps in some cases.
|
||||
- Items with too-large NBT tags on network will now have their tags ignored when sending over network, instead of crashing the server. This is a workaround for a protocol bug which will be addressed in a future Minecraft release.
|
||||
- `/enchant` no longer crashes the server when out-of-bounds enchantment levels are used.
|
||||
- Fixed some crashes loading Region-based worlds when encountering unexpected EOF.
|
||||
- `Entity->fireTicks` is now protected (but accessible by magic method for BC purposes) and will now throw an exception when written to if the value is > 32767 or < 0.
|
||||
- Fixed Signs asserting on corrupted world data with more than 4 lines of text per sign.
|
||||
|
||||
# 3.5.7
|
||||
- Fixed several bugs in RCON packet receive that would allow an attacker to block or crash the RCON thread, denying service to other legitimate RCON clients.
|
||||
- Fixed RCON connections not working (timing out with no response) on some platforms.
|
||||
- Logins are now permitted to have up to 60 seconds clock drift on the `nbf` and `exp` timestamps in the login JWT.
|
||||
- Fixed XP orbs following players who switched to a location spatially nearby in a different world.
|
||||
- `Player->removeWindow()` now throws `InvalidArgumentException` instead of `BadMethodCallException` when trying to non-forcefully remove a fixed window ID.
|
||||
|
||||
# 3.5.8
|
||||
- Fixed player XP not dropping if a player was fast enough to respawn.
|
||||
- Player XP drop amount now matches vanilla (7x level points, incurs some loss of points for higher levels)
|
||||
- Fixed Doxygen configuration including test sources.
|
||||
- Improved performance of block-cache accesses.
|
||||
- Improved performance of random block-ticking.
|
||||
- Closure tasks will now show the correctly formatted name on timings.
|
||||
- Fixed a crash when a local update happens next to an `ItemFrame` with invalid metadata.
|
||||
- Fixed player being subscribed to broadcast permissions too early when permissions are modified before spawn.
|
||||
- Block-picking is now disallowed on unknown blocks.
|
||||
- Internal IP detection now works correctly on all platforms.
|
||||
- Fixed UPnP portforwarding not working correctly when multiple network adapters are installed.
|
||||
- Starting or stopping flight now resets fall distance and in-air ticks.
|
||||
- Fixed falling causing starvation.
|
||||
- Fixed crops consuming bone meal when fully grown.
|
||||
- Users are no longer able to avoid agreeing to the license by restarting the server.
|
||||
- Explosions no longer create broken double chests which crash the server. Existing chests affected by this bug will continue to crash. This will be addressed in a future release.
|
||||
- Cactus and sugarcane no longer grow through non-air blocks.
|
||||
- Fixed a memory leak in `setChunk()` when the `unload` parameter is true.
|
||||
- Generator will now crash if preset is invalid, instead of producing unexpected results.
|
||||
|
||||
# 3.5.9
|
||||
- Fixed a `setChunk()` bug introduced by 3.5.8.
|
||||
- Applied a hack to disable client-sided automatic regeneration.
|
||||
- `Level->getChunkPlayers()` is now deprecated.
|
||||
|
||||
# 3.5.10
|
||||
- Some internal `Level` functions are now correctly marked `@internal`.
|
||||
- Fixed splash potion distance being measured from player feet instead of eye height.
|
||||
- Fixed tall grass being unplaceable on dirt.
|
||||
- A debug message is now recorded when a chunk is loaded with no associated loaders.
|
||||
- Composer dependencies have been updated to fix bugs in some dependencies.
|
||||
|
||||
# 3.5.11
|
||||
- Fixed crashing when items with negative IDs are found in the inventory (caused by downgrading from dev builds).
|
||||
- Updated creative inventory and crafting recipes.
|
||||
|
||||
# 3.5.12
|
||||
- Fixed crash when too-large values are given to `/effect` for duration.
|
||||
- `/op` and other commands no longer crash when an invalid player name is given.
|
||||
- Startup time no longer includes the time spent in the setup wizard.
|
||||
- `TextFormat::clean()` is now UTF-8 aware, and will scrub any invalid UTF-8 characters from the given string.
|
||||
- Fixed `TextFormat::clean()` not fully removing ANSI escape codes in some cases.
|
||||
- Fixed Korean command arguments failing to parse.
|
||||
- `Sign->setText()` and `Sign->setLine()` now enforce that the given text must be UTF-8 text, or an exception will be thrown.
|
||||
- Sign text is now processed by `mb_scrub()` immediately after loading to remove invalid UTF-8 characters that could crash the client.
|
||||
- `Human->exhaust()` no longer underflows when the hunger attribute has a fractional value.
|
||||
|
||||
# 3.5.13
|
||||
- Added a hack to disable client sided AI for non-moving entities. This fixes items floating in water despite it not being implemented server-side yet.
|
||||
- Fixed max health not working as expected on respawn if changed by plugins.
|
||||
- Fixed Item Frame hardness (0.25 instead of 0).
|
||||
- Fire Aspect tools will now light TNT when right-clicked with.
|
||||
- Fixed incorrect nullable typehints on `TaskScheduler` return values.
|
65
changelogs/3.6.md
Normal file
65
changelogs/3.6.md
Normal file
@ -0,0 +1,65 @@
|
||||
**For Minecraft: Bedrock Edition 1.9.0**
|
||||
|
||||
### Note
|
||||
Plugins 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.
|
||||
|
||||
This changelog **does not account for protocol changes**. If your plugin uses the protocol, you're not shielded by API change constraints.
|
||||
|
||||
# 3.6.0
|
||||
- Compatibility with Minecraft: Bedrock Edition 1.9.0
|
||||
- Removed compatibility with 1.8.0
|
||||
- `Item->getCompoundTag()` is now `@deprecated`.
|
||||
- `Item->setCompoundTag()` now accepts NULL as a possible value.
|
||||
- `ItemFactory::fromString()` now accepts NULL for the `tags` parameter.
|
||||
|
||||
# 3.6.1
|
||||
- Fixed crashing when items with negative IDs are found in the inventory (caused by downgrading from dev builds).
|
||||
- Updated creative inventory and crafting recipes.
|
||||
- Fixed handling for some new blocks which magically appeared without appropriate implementations (extra meta values).
|
||||
|
||||
# 3.6.2
|
||||
- Fixed client-sided crash when upper-case letters appear in command names.
|
||||
- Fixed crash when too-large values are given to `/effect` for duration.
|
||||
- `/op` and other commands no longer crash when an invalid player name is given.
|
||||
- Startup time no longer includes the time spent in the setup wizard.
|
||||
- `TextFormat::clean()` is now UTF-8 aware, and will scrub any invalid UTF-8 characters from the given string.
|
||||
- Fixed `TextFormat::clean()` not fully removing ANSI escape codes in some cases.
|
||||
- Fixed Korean command arguments failing to parse.
|
||||
- `Sign->setText()` and `Sign->setLine()` now enforce that the given text must be UTF-8 text, or an exception will be thrown.
|
||||
- Sign text is now processed by `mb_scrub()` immediately after loading to remove invalid UTF-8 characters that could crash the client.
|
||||
- `Human->exhaust()` no longer underflows when the hunger attribute has a fractional value.
|
||||
|
||||
# 3.6.3
|
||||
- Added a hack to disable client sided AI for non-moving entities. This fixes items floating in water despite it not being implemented server-side yet.
|
||||
- Fixed max health not working as expected on respawn if changed by plugins.
|
||||
- Fixed Item Frame hardness (0.25 instead of 0).
|
||||
- Fire Aspect tools will now light TNT when right-clicked with.
|
||||
- Fixed incorrect nullable typehints on `TaskScheduler` return values.
|
||||
|
||||
# 3.6.4
|
||||
- `NetworkStackLatencyPacket` unhandled debug has been silenced.
|
||||
- Fixed `Player->removeWindow()` removing GUI or crashing clients when removing a window which was not added.
|
||||
- Fixed packed ice dropping itself when mined without a silk touch pickaxe.
|
||||
- Fixed players not taking fall damage when falling off the side of a ladder when their AABB was intersecting with the ladder's full block area.
|
||||
- Fixed arrows reloaded from disk never despawning.
|
||||
- Fixed player XP not dropping on death.
|
||||
- Fixed player's held slot being out of sync when respawning.
|
||||
- Fixed items with different NBT being considered stackable in some cases by `BaseInventory->canAddItem()`.
|
||||
|
||||
# 3.6.5
|
||||
- Fixed stdout silence on crash if a crash occurs when PHP output buffering is enabled.
|
||||
- Fixed `RegionLoader` considering a range of invalid chunk coordinates as valid.
|
||||
- Fixed `RegionLoader` causing region header corruption when an oversized chunk was discovered. This was causing entire regions to be discarded next time they were freshly loaded.
|
||||
- Fixed performance issue loading old LevelDB worlds (from before MCPE 1.0) due to unmodified chunks being converted every time they were loaded.
|
||||
- Added new debug messages when a world takes too long (longer than 50ms) to complete a tick.
|
||||
- Debug messages are now logged when autosave kicks in (with time measurements), which helps debugging unexplained lag spikes.
|
||||
- Level "auto tick rate" anti-feature and its associated `pocketmine.yml` settings have been removed (see #2665). The settings will persist in old configurations, but will be ignored by this version and future versions.
|
||||
- The `/save-all` command now outputs custom (non-vanilla) messages informing the user how long it took to complete autosaving.
|
||||
- The word `level` has been replaced with `world` (where appropriate) throughout language strings and general user interface messages.
|
||||
|
||||
# 3.6.6
|
||||
- Fixed protocol argument types for commands.
|
||||
- Autosave debug message will now report in milliseconds when the time taken is less than 1 second.
|
||||
- Flatworld presets now allow `*` as a multiplier symbol (fixes PC compatibility).
|
||||
- Network runtimeIDs for blocks are now randomized to prevent things (like plugins) relying on them.
|
||||
- Updated NBT dependency to 0.2.7 for some bug fixes.
|
33
changelogs/3.7.md
Normal file
33
changelogs/3.7.md
Normal file
@ -0,0 +1,33 @@
|
||||
**For Minecraft: Bedrock Edition 1.10.0**
|
||||
|
||||
### Note
|
||||
Plugins 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.
|
||||
|
||||
This changelog **does not account for protocol changes**. If your plugin uses the protocol, you're not shielded by API change constraints.
|
||||
|
||||
# 3.7.0
|
||||
- Compatibility with Minecraft: Bedrock Edition 1.10.0
|
||||
- Removed compatibility with 1.9.0
|
||||
|
||||
# 3.7.1
|
||||
- Fixed protocol argument types for commands.
|
||||
- Autosave debug message will now report in milliseconds when the time taken is less than 1 second.
|
||||
- Flatworld presets now allow `*` as a multiplier symbol (fixes PC compatibility).
|
||||
- Network runtimeIDs for blocks are now randomized to prevent things (like plugins) relying on them.
|
||||
- Updated NBT dependency to 0.2.7 for some bug fixes.
|
||||
|
||||
# 3.7.2
|
||||
- Fixed a memory leak when `PlayerLoginEvent` is cancelled.
|
||||
- Fixed permissions `pocketmine.command.ban.list`, `pocketmine.command.difficulty`, `pocketmine.command.whitelist.enable` and `pocketmine.command.whitelist.disable` always being granted to operators.
|
||||
- Fixed some commands outputting `commands.generic.permission` instead of the proper message when running commands that the sender doesn't have permission to use.
|
||||
- Worlds with unknown generator types will now refuse to load instead of getting incorrect terrain generation ruining them.
|
||||
- `TextFormat::tokenize()` no longer corrupts Unicode sequences.
|
||||
- `TextFormat::clean()` now removes non-printable Unicode code points in the private-use area.
|
||||
- Running two servers in the same data directory is no longer allowed and will gracefully halt instead of corrupting your data.
|
||||
- Sign text length is now soft-capped at 1000 characters.
|
||||
|
||||
# 3.7.3
|
||||
- World save timings now include saves that are triggered by chunk unloading.
|
||||
- Fixed several network denial-of-service bugs.
|
||||
- A warning is now emitted when the `ChunkUtils` extension is not loaded.
|
||||
- Moved version constants to a separate `VersionInfo` file for easier parsing and handling.
|
69
changelogs/3.8.md
Normal file
69
changelogs/3.8.md
Normal file
@ -0,0 +1,69 @@
|
||||
**For Minecraft: Bedrock Edition 1.11.0**
|
||||
|
||||
### Note
|
||||
Plugins 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.
|
||||
|
||||
This changelog **does not account for protocol changes**. If your plugin uses the protocol, you're not shielded by API change constraints.
|
||||
|
||||
# 3.8.0
|
||||
- Compatibility with Minecraft: Bedrock Edition 1.11.0
|
||||
- Removed compatibility with 1.10.0
|
||||
|
||||
# 3.8.1
|
||||
- Fixed furnace smelting recipes not working.
|
||||
- Reduced legacy hacks dealing with `BatchPacket` to fix possible ID collisions.
|
||||
- Reduced release phar size by minifying JSON data blobs.
|
||||
- Moved some MCPE-specific JSON blobs to submodule.
|
||||
|
||||
# 3.8.2
|
||||
- Fixed --enable-ansi and --disable-ansi not being respected on threads.
|
||||
- Fixed a crash that could occur when decoding `AvailableCommandsPacket`.
|
||||
- Fixed a crash when loading worlds with entities with missing `Motion` NBT tag.
|
||||
- Fixed a crash when world time overflows signed int64 max.
|
||||
- Fixed world generators and providers being registered too late (this was causing plugin issues).
|
||||
- Updated RakLib version to get a security fix.
|
||||
- Fixed errors when custom clients fill the wrong information in `ResourcePackClientResponsePacket`.
|
||||
- Fixed `setImmobile()` getting overridden directly after `PlayerJoinEvent`.
|
||||
- Fixed air being breakable by creative players.
|
||||
- Fixed performance loss caused by bugs in the preprocessor.
|
||||
|
||||
# 3.8.3
|
||||
- Fixed infinite recursion when using `Entity->close()` during `EntityDespawnEvent`.
|
||||
- Fixed crash reports caused by folder plugins being reported to the crash archive.
|
||||
- Fixed spawning entities on unloaded chunks during spawn sequence (possible client crash cause).
|
||||
- Fixed `/time query` output message.
|
||||
- Fixed `Server->hasOfflinePlayerData()` being case-sensitive.
|
||||
- Improved error messages for skin validation in some places.
|
||||
- Fixed classic stonecutter hardness.
|
||||
- Fixed iron trapdoors being considered a valid furnace fuel.
|
||||
- Fixed apple dropping from leaves happening less frequently than intended.
|
||||
- Fixed tall plants like sunflower being replaceable by the top half.
|
||||
|
||||
# 3.8.4
|
||||
- Plugin load order is now randomised to remove the ability to implicitly depend on filesystem-specific ordering.
|
||||
- Packet logging in debug messages now uses base64 instead of hex (uses less space).
|
||||
- Array and string size are now shown in error stack trace logs.
|
||||
- Stack traces now render a maximum of 80 characters when making string parameters printable.
|
||||
- Improved documentation for some transaction classes.
|
||||
- Action order in inventory transactions is now randomised to prevent dependencies on any accidental or client-dependent ordering. Since the transaction system is specifically designed to avoid depending on order, this does not affect any core functionality.
|
||||
|
||||
# 3.8.5
|
||||
- Moved preprocessor to build/ directory.
|
||||
- Added documentation for `Server->getPlayer()`, `Server->getPlayerExact()` and `Server->matchPlayer()`.
|
||||
- `server.lock` now contains the PID of the currently-running server.
|
||||
- PID of server is now reported in the error message when attempting to run two servers from the same data directory at once.
|
||||
- Fixed sluggish playercount updating on MOTD.
|
||||
- Added new MultiRecipe UUIDs.
|
||||
- Added an extra field to `StartGamePacket` to resolve minor incompatibility issues on different 1.11.x patch versions.
|
||||
|
||||
# 3.8.6
|
||||
- Fixed `Entity->isNameTagAlwaysVisible()` not working.
|
||||
- Log messages are now cleaned of invalid UTF-8 sequences before emitting them.
|
||||
- Fixed negative integers being considered as strings for world seeds.
|
||||
- Fixed out-of-bounds access on invalid inventory data in player data saves.
|
||||
- Fixed crash when custom liquids have flow decays which aren't factors of 4.
|
||||
- Fixed `Entity->noDamageTicks` not working when the entity had no previous damage cause.
|
||||
|
||||
# 3.8.7
|
||||
- Improved documentation of `Player->getDisplayName()` and `Player::isValidUserName()`.
|
||||
- Fixed a bug in `SetScorePacket` decoding causing the entry list to always be empty.
|
102
changelogs/3.9.md
Normal file
102
changelogs/3.9.md
Normal file
@ -0,0 +1,102 @@
|
||||
**For Minecraft: Bedrock Edition 1.12.0**
|
||||
|
||||
### Note about API versions
|
||||
Plugins which don't touch the protocol and compatible with any previous 3.x.y version will also run on these releases and do not need API bumps.
|
||||
Plugin developers should **only** update their required API to this version if you need the changes in this build.
|
||||
|
||||
**WARNING: If your plugin uses the protocol, you're not shielded by API change constraints.** You should consider using the `mcpe-protocol` directive in `plugin.yml` as a constraint if you do.
|
||||
|
||||
# 3.9.0
|
||||
- Added support for Minecraft: Bedrock Edition 1.12.0
|
||||
- Removed compatibility with 1.11.0
|
||||
|
||||
## Protocol
|
||||
- The following classes in the `\pocketmine\network\mcpe\protocol` namespace have been renamed:
|
||||
- `AddEntityPacket` -> `AddActorPacket`
|
||||
- `AddItemEntityPacket` -> `AddItemActorPacket`
|
||||
- `AvailableEntityIdentifiersPacket` -> `AvailableActorIdentifiersPacket`
|
||||
- `BlockEntityDataPacket` -> `BlockActorDataPacket`
|
||||
- `EntityEventPacket` -> `ActorEventPacket`
|
||||
- `EntityFallPacket` -> `ActorFallPacket`
|
||||
- `EntityPickRequestPacket` -> `ActorPickRequestPacket`
|
||||
- `MoveEntityAbsolutePacket` -> `MoveActorAbsolutePacket`
|
||||
- `MoveEntityDeltaPacket` -> `MoveActorDeltaPacket`
|
||||
- `RemoveEntityPacket` -> `RemoveActorPacket`
|
||||
- `SetEntityDataPacket` -> `SetActorDataPacket`
|
||||
- `SetEntityLinkPacket` -> `SetActorLinkPacket`
|
||||
- `SetEntityMotionPacket` -> `SetActorMotionPacket`
|
||||
- `TakeItemEntityPacket` -> `TakeItemActorPacket`
|
||||
- The following classes in the `\pocketmine\network\mcpe\protocol` namespace have been removed:
|
||||
- `FullChunkDataPacket`
|
||||
- The following classes in the `\pocketmine\network\mcpe\protocol` namespace have been added:
|
||||
- `AddEntityPacket` (not to be confused with the old one)
|
||||
- `ClientCacheBlobStatusPacket`
|
||||
- `ClientCacheMissResponsePacket`
|
||||
- `ClientCacheStatusPacket`
|
||||
- `LevelChunkPacket`
|
||||
- `RemoveEntityPacket` (not to be confused with the old one)
|
||||
- `StructureTemplateDataExportRequestPacket`
|
||||
- `StructureTemplateDataExportResponsePacket`
|
||||
|
||||
# 3.9.1
|
||||
- Fixed resource packs not working on 1.12 clients.
|
||||
- Fixed some particles displaying incorrectly (some still don't render at all).
|
||||
- Fixed `Entity->setFireTicks()` with a value of `0` setting the on-fire flag.
|
||||
- Silenced a debug message which appeared every time a player right-clicked a block.
|
||||
- Updated constants for `LevelSoundEventPacket`.
|
||||
|
||||
# 3.9.2
|
||||
- Logger warnings for illegal player movements have been lowered to debug.
|
||||
- TNT explosions now start from the center instead of the base. This fixes unexpected results when TNT is lit on top of obsidian.
|
||||
- Fixed the `loadbefore` directive in `plugin.yml` sometimes being ignored.
|
||||
- Fixed `Item->setCustomName()` with an empty string leaving behind an empty tag.
|
||||
- Fixed incorrect positioning of bucket empty sound.
|
||||
- Fixed some incorrect tag parsing in `/give` involving quoted numbers.
|
||||
|
||||
# 3.9.3
|
||||
- Fixed a memory leak on async task removal in error conditions.
|
||||
- Fixed scheduled block updates (for example liquid) triggering chunk reloading. This could cause a significant performance issue in some conditions.
|
||||
- Fixed some minor cosmetic issues in documentation.
|
||||
|
||||
# 3.9.4
|
||||
- Fixed a memory leak when scheduled updates were pending on a chunk being unloaded.
|
||||
- Fixed plugin detection in crashdumps. Previously `src/pocketmine` anywhere in the path would cause the error to be considered a core crash, regardless of the preceding path.
|
||||
- Fixed entity metadata types for 1.12. The SLOT type was removed and a COMPOUND_TAG type added. This change involves changes to internal API which may break plugins. **See the warning at the top of this changelog about API versioning.**
|
||||
- Fixed random and base populator amounts of trees and tallgrass never being initialized. This bug had no obvious effect, but may have become a problem in future PHP versions.
|
||||
- The following internal methods have been marked as `@deprecated` and documentation warnings added:
|
||||
- `Entity->getBlocksAround()`
|
||||
- `Entity->despawnFrom()`
|
||||
- `Entity->despawnFromAll()`
|
||||
- Fixed plugin `softdepend` not influencing load order when a soft-depended plugin had an unresolved soft dependency of its own.
|
||||
- Fixed endless falling of sand on top of fences.
|
||||
|
||||
# 3.9.5
|
||||
- Fixed some issues with multiple consecutive commas inside quotes in form responses.
|
||||
- Fixed server crash when the manifest json does not contain a json object in a resource pack.
|
||||
- Ender pearls no longer collide with blocks that do not have any collision boxes.
|
||||
|
||||
# 3.9.6
|
||||
- Updated Composer dependencies to their latest versions.
|
||||
- Prevent clients repeating the resource pack sequence. This fixes error spam with bugged 1.12 clients.
|
||||
- `Internet::simpleCurl()` now includes the PocketMine-MP version in the user-agent string.
|
||||
- Spawn protection is now disabled by default in the setup wizard.
|
||||
- Default difficulty is now NORMAL(2) instead of EASY(1).
|
||||
- Fixed crashing on corrupted world manifest and unsupported world formats.
|
||||
- Fixed `/transferserver` being usable without appropriate permissions.
|
||||
- `RegionLoader->removeChunk()` now writes the region header as appropriate.
|
||||
- Fixed performance issue when loading large regions (bug in header validation).
|
||||
- Fixed skin geometry being removed when the JSON contained comments.
|
||||
- Added new constants to `EventPacket`.
|
||||
- Added encode/decode for `StructureTemplateDataExportRequestPacket` and `StructureTemplateDataExportResponsePacket`.
|
||||
- Fixed broken type asserts in `LevelChunkPacket::withCache()` and `ClientCacheMissResponsePacket::create()`.
|
||||
- `types\CommandParameter` field `byte1` has been renamed to `flags`.
|
||||
- Cleaned up public interface of `AvailableCommandsPacket`, removing fields which exposed details of the encoding scheme.
|
||||
- Improved documentation for the following API methods:
|
||||
- `pocketmine\item\Item`:
|
||||
- `addCreativeItem()`
|
||||
- `removeCreativeItem()`
|
||||
- `clearCreativeItems()`
|
||||
- `pocketmine\level\Explosion`:
|
||||
- `explodeA()`
|
||||
- `explodeB()`
|
||||
- Fixed various cosmetic documentation inconsistencies in the core and dependencies.
|
@ -17,17 +17,17 @@
|
||||
"ext-openssl": "*",
|
||||
"ext-pcre": "*",
|
||||
"ext-phar": "*",
|
||||
"ext-pthreads": ">=3.1.7dev",
|
||||
"ext-pthreads": "~3.2.0",
|
||||
"ext-reflection": "*",
|
||||
"ext-sockets": "*",
|
||||
"ext-spl": "*",
|
||||
"ext-yaml": ">=2.0.0",
|
||||
"ext-zip": "*",
|
||||
"ext-zlib": ">=1.2.11",
|
||||
"pocketmine/raklib": "^0.12.0",
|
||||
"pocketmine/raklib": "^0.12.5",
|
||||
"pocketmine/spl": "^0.3.0",
|
||||
"pocketmine/binaryutils": "^0.1.0",
|
||||
"pocketmine/nbt": "^0.2.6",
|
||||
"pocketmine/binaryutils": "^0.1.9",
|
||||
"pocketmine/nbt": "^0.2.10",
|
||||
"pocketmine/math": "^0.2.0",
|
||||
"pocketmine/snooze": "^0.1.0",
|
||||
"daverandom/callback-validator": "dev-master",
|
||||
|
61
composer.lock
generated
61
composer.lock
generated
@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "2f5313e4ebd7b62c785cf683b27464b4",
|
||||
"content-hash": "377d9e0ab5f1a9a4ef9b664706d26f5b",
|
||||
"packages": [
|
||||
{
|
||||
"name": "adhocore/json-comment",
|
||||
@ -92,16 +92,16 @@
|
||||
},
|
||||
{
|
||||
"name": "pocketmine/binaryutils",
|
||||
"version": "0.1.8",
|
||||
"version": "0.1.10",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/pmmp/BinaryUtils.git",
|
||||
"reference": "33f511715d22418c03368b49b45a6c25d6b33806"
|
||||
"reference": "435f2ee265bce75ef1aa9563f9b60ff36d705e80"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/pmmp/BinaryUtils/zipball/33f511715d22418c03368b49b45a6c25d6b33806",
|
||||
"reference": "33f511715d22418c03368b49b45a6c25d6b33806",
|
||||
"url": "https://api.github.com/repos/pmmp/BinaryUtils/zipball/435f2ee265bce75ef1aa9563f9b60ff36d705e80",
|
||||
"reference": "435f2ee265bce75ef1aa9563f9b60ff36d705e80",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -119,23 +119,23 @@
|
||||
],
|
||||
"description": "Classes and methods for conveniently handling binary data",
|
||||
"support": {
|
||||
"source": "https://github.com/pmmp/BinaryUtils/tree/0.1.8",
|
||||
"source": "https://github.com/pmmp/BinaryUtils/tree/0.1.10",
|
||||
"issues": "https://github.com/pmmp/BinaryUtils/issues"
|
||||
},
|
||||
"time": "2019-01-16T17:31:44+00:00"
|
||||
"time": "2019-10-21T14:40:32+00:00"
|
||||
},
|
||||
{
|
||||
"name": "pocketmine/math",
|
||||
"version": "0.2.2",
|
||||
"version": "0.2.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/pmmp/Math.git",
|
||||
"reference": "b755d3fb7025c4ddb7d9d6df0ba7e0b65125e51c"
|
||||
"reference": "68be8a79fd0169043ef514797c304517cb8a6071"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/pmmp/Math/zipball/b755d3fb7025c4ddb7d9d6df0ba7e0b65125e51c",
|
||||
"reference": "b755d3fb7025c4ddb7d9d6df0ba7e0b65125e51c",
|
||||
"url": "https://api.github.com/repos/pmmp/Math/zipball/68be8a79fd0169043ef514797c304517cb8a6071",
|
||||
"reference": "68be8a79fd0169043ef514797c304517cb8a6071",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -153,30 +153,30 @@
|
||||
],
|
||||
"description": "PHP library containing math related code used in PocketMine-MP",
|
||||
"support": {
|
||||
"source": "https://github.com/pmmp/Math/tree/0.2.2",
|
||||
"source": "https://github.com/pmmp/Math/tree/0.2.3",
|
||||
"issues": "https://github.com/pmmp/Math/issues"
|
||||
},
|
||||
"time": "2019-01-04T15:42:36+00:00"
|
||||
"time": "2019-10-21T14:35:10+00:00"
|
||||
},
|
||||
{
|
||||
"name": "pocketmine/nbt",
|
||||
"version": "0.2.7",
|
||||
"version": "0.2.11",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/pmmp/NBT.git",
|
||||
"reference": "2f176c9f2fd9b31db8bc2ada2f38990157ec8f1a"
|
||||
"reference": "78784b93632c51f0fad0719b2d6ffe072529db6d"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/pmmp/NBT/zipball/2f176c9f2fd9b31db8bc2ada2f38990157ec8f1a",
|
||||
"reference": "2f176c9f2fd9b31db8bc2ada2f38990157ec8f1a",
|
||||
"url": "https://api.github.com/repos/pmmp/NBT/zipball/78784b93632c51f0fad0719b2d6ffe072529db6d",
|
||||
"reference": "78784b93632c51f0fad0719b2d6ffe072529db6d",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-zlib": "*",
|
||||
"php": ">=7.2.0",
|
||||
"php-64bit": "*",
|
||||
"pocketmine/binaryutils": "^0.1.0"
|
||||
"pocketmine/binaryutils": "^0.1.9"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
@ -194,33 +194,33 @@
|
||||
],
|
||||
"description": "PHP library for working with Named Binary Tags",
|
||||
"support": {
|
||||
"source": "https://github.com/pmmp/NBT/tree/0.2.7",
|
||||
"source": "https://github.com/pmmp/NBT/tree/0.2.11",
|
||||
"issues": "https://github.com/pmmp/NBT/issues"
|
||||
},
|
||||
"time": "2019-03-29T19:39:42+00:00"
|
||||
"time": "2019-10-21T14:50:43+00:00"
|
||||
},
|
||||
{
|
||||
"name": "pocketmine/raklib",
|
||||
"version": "0.12.4",
|
||||
"version": "0.12.5",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/pmmp/RakLib.git",
|
||||
"reference": "fc1ccc8e61b9033e5372436b2e28a7a95388373f"
|
||||
"reference": "874db2d3c24117db2221c1e4550380478aeea852"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/pmmp/RakLib/zipball/fc1ccc8e61b9033e5372436b2e28a7a95388373f",
|
||||
"reference": "fc1ccc8e61b9033e5372436b2e28a7a95388373f",
|
||||
"url": "https://api.github.com/repos/pmmp/RakLib/zipball/874db2d3c24117db2221c1e4550380478aeea852",
|
||||
"reference": "874db2d3c24117db2221c1e4550380478aeea852",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-bcmath": "*",
|
||||
"ext-pthreads": ">=3.1.7dev",
|
||||
"ext-pthreads": "~3.2.0",
|
||||
"ext-sockets": "*",
|
||||
"php": ">=7.2.0",
|
||||
"php-64bit": "*",
|
||||
"php-ipv6": "*",
|
||||
"pocketmine/binaryutils": "^0.1.0",
|
||||
"pocketmine/binaryutils": "^0.1.9",
|
||||
"pocketmine/snooze": "^0.1.0",
|
||||
"pocketmine/spl": "^0.3.0"
|
||||
},
|
||||
@ -235,10 +235,10 @@
|
||||
],
|
||||
"description": "A RakNet server implementation written in PHP",
|
||||
"support": {
|
||||
"source": "https://github.com/pmmp/RakLib/tree/0.12.4",
|
||||
"source": "https://github.com/pmmp/RakLib/tree/0.12",
|
||||
"issues": "https://github.com/pmmp/RakLib/issues"
|
||||
},
|
||||
"time": "2019-05-02T14:53:51+00:00"
|
||||
"time": "2019-07-22T14:38:20+00:00"
|
||||
},
|
||||
{
|
||||
"name": "pocketmine/snooze",
|
||||
@ -302,7 +302,7 @@
|
||||
],
|
||||
"description": "Standard library files required by PocketMine-MP and related projects",
|
||||
"support": {
|
||||
"source": "https://github.com/pmmp/SPL/tree/0.3.2"
|
||||
"source": "https://github.com/pmmp/SPL/tree/master"
|
||||
},
|
||||
"time": "2018-08-12T15:17:39+00:00"
|
||||
}
|
||||
@ -311,7 +311,6 @@
|
||||
"aliases": [],
|
||||
"minimum-stability": "stable",
|
||||
"stability-flags": {
|
||||
"ext-pthreads": 20,
|
||||
"daverandom/callback-validator": 20
|
||||
},
|
||||
"prefer-stable": false,
|
||||
@ -329,7 +328,7 @@
|
||||
"ext-openssl": "*",
|
||||
"ext-pcre": "*",
|
||||
"ext-phar": "*",
|
||||
"ext-pthreads": ">=3.1.7dev",
|
||||
"ext-pthreads": "~3.2.0",
|
||||
"ext-reflection": "*",
|
||||
"ext-sockets": "*",
|
||||
"ext-spl": "*",
|
||||
|
@ -530,7 +530,7 @@ HIDE_FRIEND_COMPOUNDS = NO
|
||||
# blocks will be appended to the function's detailed documentation block.
|
||||
# The default value is: NO.
|
||||
|
||||
HIDE_IN_BODY_DOCS = NO
|
||||
HIDE_IN_BODY_DOCS = YES
|
||||
|
||||
# The INTERNAL_DOCS tag determines if documentation that is typed after a
|
||||
# \internal command is included. If the tag is set to NO then the documentation
|
||||
@ -600,7 +600,7 @@ SORT_MEMBER_DOCS = YES
|
||||
# this will also influence the order of the classes in the class list.
|
||||
# The default value is: NO.
|
||||
|
||||
SORT_BRIEF_DOCS = NO
|
||||
SORT_BRIEF_DOCS = YES
|
||||
|
||||
# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the
|
||||
# (brief and detailed) documentation of class members so that constructors and
|
||||
@ -612,7 +612,7 @@ SORT_BRIEF_DOCS = NO
|
||||
# detailed member documentation.
|
||||
# The default value is: NO.
|
||||
|
||||
SORT_MEMBERS_CTORS_1ST = NO
|
||||
SORT_MEMBERS_CTORS_1ST = YES
|
||||
|
||||
# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy
|
||||
# of group names into alphabetical order. If set to NO the group names will
|
||||
@ -1565,7 +1565,7 @@ MATHJAX_FORMAT = HTML-CSS
|
||||
# The default value is: https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/.
|
||||
# This tag requires that the tag USE_MATHJAX is set to YES.
|
||||
|
||||
MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest
|
||||
MATHJAX_RELPATH = https://cdn.mathjax.org/mathjax/latest
|
||||
|
||||
# The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax
|
||||
# extension names that should be enabled during MathJax rendering. For example
|
||||
|
@ -291,7 +291,7 @@ class CrashDump{
|
||||
|
||||
private function determinePluginFromFile(string $filePath, bool $crashFrame) : bool{
|
||||
$frameCleanPath = Utils::cleanPath($filePath); //this will be empty in phar stub
|
||||
if($frameCleanPath !== "" and strpos($frameCleanPath, "src/pocketmine/") === false and strpos($frameCleanPath, "vendor/pocketmine/") === false and file_exists($filePath)){
|
||||
if(strpos($frameCleanPath, "plugins") === 0 and file_exists($filePath)){
|
||||
$this->addLine();
|
||||
if($crashFrame){
|
||||
$this->addLine("THIS CRASH WAS CAUSED BY A PLUGIN");
|
||||
|
@ -99,20 +99,20 @@ use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\nbt\tag\DoubleTag;
|
||||
use pocketmine\nbt\tag\ListTag;
|
||||
use pocketmine\network\mcpe\PlayerNetworkSessionAdapter;
|
||||
use pocketmine\network\mcpe\protocol\ActorEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\AdventureSettingsPacket;
|
||||
use pocketmine\network\mcpe\protocol\AnimatePacket;
|
||||
use pocketmine\network\mcpe\protocol\AvailableActorIdentifiersPacket;
|
||||
use pocketmine\network\mcpe\protocol\AvailableCommandsPacket;
|
||||
use pocketmine\network\mcpe\protocol\AvailableEntityIdentifiersPacket;
|
||||
use pocketmine\network\mcpe\protocol\BatchPacket;
|
||||
use pocketmine\network\mcpe\protocol\BiomeDefinitionListPacket;
|
||||
use pocketmine\network\mcpe\protocol\BlockEntityDataPacket;
|
||||
use pocketmine\network\mcpe\protocol\BlockActorDataPacket;
|
||||
use pocketmine\network\mcpe\protocol\BlockPickRequestPacket;
|
||||
use pocketmine\network\mcpe\protocol\BookEditPacket;
|
||||
use pocketmine\network\mcpe\protocol\ChunkRadiusUpdatedPacket;
|
||||
use pocketmine\network\mcpe\protocol\ContainerClosePacket;
|
||||
use pocketmine\network\mcpe\protocol\DataPacket;
|
||||
use pocketmine\network\mcpe\protocol\DisconnectPacket;
|
||||
use pocketmine\network\mcpe\protocol\EntityEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\InteractPacket;
|
||||
use pocketmine\network\mcpe\protocol\InventoryTransactionPacket;
|
||||
use pocketmine\network\mcpe\protocol\ItemFrameDropItemPacket;
|
||||
@ -211,7 +211,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
public const VIEW = Player::SPECTATOR;
|
||||
|
||||
/**
|
||||
* Checks a supplied username and checks it is valid.
|
||||
* Validates the given username.
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
@ -261,6 +261,9 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
/** @var bool */
|
||||
public $loggedIn = false;
|
||||
|
||||
/** @var bool */
|
||||
private $resourcePacksDone = false;
|
||||
|
||||
/** @var bool */
|
||||
public $spawned = false;
|
||||
|
||||
@ -800,7 +803,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the "friendly" name to display of this player to use in the chat.
|
||||
* Returns the "friendly" display name of this player to use in the chat.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@ -1596,7 +1599,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
* If you must tamper with this code, be aware that this can cause very nasty results. Do not waste our time
|
||||
* asking for help if you suffer the consequences of messing with this.
|
||||
*/
|
||||
$this->server->getLogger()->warning($this->getName() . " moved too fast, reverting movement");
|
||||
$this->server->getLogger()->debug($this->getName() . " moved too fast, reverting movement");
|
||||
$this->server->getLogger()->debug("Old position: " . $this->asVector3() . ", new position: " . $this->newPosition);
|
||||
$revert = true;
|
||||
}elseif(!$this->level->isInLoadedTerrain($newPos) or !$this->level->isChunkGenerated($newPos->getFloorX() >> 4, $newPos->getFloorZ() >> 4)){
|
||||
@ -1621,7 +1624,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
|
||||
if(!$ev->isCancelled()){
|
||||
$revert = true;
|
||||
$this->server->getLogger()->warning($this->getServer()->getLanguage()->translateString("pocketmine.player.invalidMove", [$this->getName()]));
|
||||
$this->server->getLogger()->debug($this->getServer()->getLanguage()->translateString("pocketmine.player.invalidMove", [$this->getName()]));
|
||||
$this->server->getLogger()->debug("Old position: " . $this->asVector3() . ", new position: " . $this->newPosition);
|
||||
}
|
||||
}
|
||||
@ -2056,6 +2059,9 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
}
|
||||
|
||||
public function handleResourcePackClientResponse(ResourcePackClientResponsePacket $packet) : bool{
|
||||
if($this->resourcePacksDone){
|
||||
return false;
|
||||
}
|
||||
switch($packet->status){
|
||||
case ResourcePackClientResponsePacket::STATUS_REFUSED:
|
||||
//TODO: add lang strings for this
|
||||
@ -2097,6 +2103,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
$this->dataPacket($pk);
|
||||
break;
|
||||
case ResourcePackClientResponsePacket::STATUS_COMPLETED:
|
||||
$this->resourcePacksDone = true;
|
||||
$this->completeLoginSequence();
|
||||
break;
|
||||
default:
|
||||
@ -2157,7 +2164,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
$pk->worldName = $this->server->getMotd();
|
||||
$this->dataPacket($pk);
|
||||
|
||||
$this->sendDataPacket(new AvailableEntityIdentifiersPacket());
|
||||
$this->sendDataPacket(new AvailableActorIdentifiersPacket());
|
||||
$this->sendDataPacket(new BiomeDefinitionListPacket());
|
||||
|
||||
$this->level->sendTime($this);
|
||||
@ -2279,14 +2286,14 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function handleEntityEvent(EntityEventPacket $packet) : bool{
|
||||
public function handleEntityEvent(ActorEventPacket $packet) : bool{
|
||||
if(!$this->spawned or !$this->isAlive()){
|
||||
return true;
|
||||
}
|
||||
$this->doCloseInventory();
|
||||
|
||||
switch($packet->event){
|
||||
case EntityEventPacket::EATING_ITEM:
|
||||
case ActorEventPacket::EATING_ITEM:
|
||||
if($packet->data === 0){
|
||||
return false;
|
||||
}
|
||||
@ -2855,6 +2862,8 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
case PlayerActionPacket::ACTION_STOP_SWIMMING:
|
||||
//TODO: handle this when it doesn't spam every damn tick (yet another spam bug!!)
|
||||
break;
|
||||
case PlayerActionPacket::ACTION_INTERACT_BLOCK: //ignored (for now)
|
||||
break;
|
||||
default:
|
||||
$this->server->getLogger()->debug("Unhandled/unknown player action type " . $packet->action . " from " . $this->getName());
|
||||
return false;
|
||||
@ -2981,7 +2990,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
return $handled;
|
||||
}
|
||||
|
||||
public function handleBlockEntityData(BlockEntityDataPacket $packet) : bool{
|
||||
public function handleBlockEntityData(BlockActorDataPacket $packet) : bool{
|
||||
if(!$this->spawned or !$this->isAlive()){
|
||||
return true;
|
||||
}
|
||||
@ -3047,6 +3056,9 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
}
|
||||
|
||||
public function handleResourcePackChunkRequest(ResourcePackChunkRequestPacket $packet) : bool{
|
||||
if($this->resourcePacksDone){
|
||||
return false;
|
||||
}
|
||||
$manager = $this->server->getResourcePackManager();
|
||||
$pack = $manager->getPackById($packet->packId);
|
||||
if(!($pack instanceof ResourcePack)){
|
||||
@ -3382,7 +3394,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
$pk->needsTranslation = true;
|
||||
$pk->message = $this->server->getLanguage()->translateString($message, $parameters, "pocketmine.");
|
||||
foreach($parameters as $i => $p){
|
||||
$parameters[$i] = $this->server->getLanguage()->translateString($p, $parameters, "pocketmine.");
|
||||
$parameters[$i] = $this->server->getLanguage()->translateString($p, [], "pocketmine.");
|
||||
}
|
||||
$pk->parameters = $parameters;
|
||||
}else{
|
||||
|
@ -102,8 +102,8 @@ namespace pocketmine {
|
||||
if(substr_count($pthreads_version, ".") < 2){
|
||||
$pthreads_version = "0.$pthreads_version";
|
||||
}
|
||||
if(version_compare($pthreads_version, "3.1.7dev") < 0){
|
||||
$messages[] = "pthreads >= 3.1.7dev is required, while you have $pthreads_version.";
|
||||
if(version_compare($pthreads_version, "3.2.0") < 0){
|
||||
$messages[] = "pthreads >= 3.2.0 is required, while you have $pthreads_version.";
|
||||
}
|
||||
}
|
||||
|
||||
@ -121,168 +121,180 @@ namespace pocketmine {
|
||||
return $messages;
|
||||
}
|
||||
|
||||
if(!empty($messages = check_platform_dependencies())){
|
||||
echo PHP_EOL;
|
||||
$binary = version_compare(PHP_VERSION, "5.4") >= 0 ? PHP_BINARY : "unknown";
|
||||
critical_error("Selected PHP binary ($binary) does not satisfy some requirements.");
|
||||
foreach($messages as $m){
|
||||
echo " - $m" . PHP_EOL;
|
||||
}
|
||||
critical_error("Please recompile PHP with the needed configuration, or refer to the installation instructions at http://pmmp.rtfd.io/en/rtfd/installation.html.");
|
||||
echo PHP_EOL;
|
||||
exit(1);
|
||||
}
|
||||
unset($messages);
|
||||
|
||||
error_reporting(-1);
|
||||
|
||||
if(\Phar::running(true) !== ""){
|
||||
define('pocketmine\PATH', \Phar::running(true) . "/");
|
||||
}else{
|
||||
define('pocketmine\PATH', dirname(__FILE__, 3) . DIRECTORY_SEPARATOR);
|
||||
}
|
||||
|
||||
$opts = getopt("", ["bootstrap:"]);
|
||||
if(isset($opts["bootstrap"])){
|
||||
$bootstrap = realpath($opts["bootstrap"]) ?: $opts["bootstrap"];
|
||||
}else{
|
||||
$bootstrap = \pocketmine\PATH . 'vendor/autoload.php';
|
||||
}
|
||||
define('pocketmine\COMPOSER_AUTOLOADER_PATH', $bootstrap);
|
||||
|
||||
if(\pocketmine\COMPOSER_AUTOLOADER_PATH !== false and is_file(\pocketmine\COMPOSER_AUTOLOADER_PATH)){
|
||||
require_once(\pocketmine\COMPOSER_AUTOLOADER_PATH);
|
||||
}else{
|
||||
critical_error("Composer autoloader not found at " . $bootstrap);
|
||||
critical_error("Please install/update Composer dependencies or use provided builds.");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
set_error_handler([Utils::class, 'errorExceptionHandler']);
|
||||
|
||||
/*
|
||||
* We now use the Composer autoloader, but this autoloader is still for loading plugins.
|
||||
*/
|
||||
$autoloader = new \BaseClassLoader();
|
||||
$autoloader->register(false);
|
||||
|
||||
set_time_limit(0); //Who set it to 30 seconds?!?!
|
||||
|
||||
ini_set("allow_url_fopen", '1');
|
||||
ini_set("display_errors", '1');
|
||||
ini_set("display_startup_errors", '1');
|
||||
ini_set("default_charset", "utf-8");
|
||||
|
||||
ini_set("memory_limit", '-1');
|
||||
|
||||
define('pocketmine\RESOURCE_PATH', \pocketmine\PATH . 'src' . DIRECTORY_SEPARATOR . 'pocketmine' . DIRECTORY_SEPARATOR . 'resources' . DIRECTORY_SEPARATOR);
|
||||
|
||||
$opts = getopt("", ["data:", "plugins:", "no-wizard", "enable-ansi", "disable-ansi"]);
|
||||
|
||||
define('pocketmine\DATA', isset($opts["data"]) ? $opts["data"] . DIRECTORY_SEPARATOR : realpath(getcwd()) . DIRECTORY_SEPARATOR);
|
||||
define('pocketmine\PLUGIN_PATH', isset($opts["plugins"]) ? $opts["plugins"] . DIRECTORY_SEPARATOR : realpath(getcwd()) . DIRECTORY_SEPARATOR . "plugins" . DIRECTORY_SEPARATOR);
|
||||
|
||||
if(!file_exists(\pocketmine\DATA)){
|
||||
mkdir(\pocketmine\DATA, 0777, true);
|
||||
}
|
||||
|
||||
define('pocketmine\LOCK_FILE_PATH', \pocketmine\DATA . 'server.lock');
|
||||
define('pocketmine\LOCK_FILE', fopen(\pocketmine\LOCK_FILE_PATH, "cb"));
|
||||
if(!flock(\pocketmine\LOCK_FILE, LOCK_EX | LOCK_NB)){
|
||||
critical_error("Another " . \pocketmine\NAME . " instance is already using this folder (" . realpath(\pocketmine\DATA) . ").");
|
||||
critical_error("Please stop the other server first before running a new one.");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
//Logger has a dependency on timezone
|
||||
$tzError = Timezone::init();
|
||||
|
||||
if(isset($opts["enable-ansi"])){
|
||||
Terminal::init(true);
|
||||
}elseif(isset($opts["disable-ansi"])){
|
||||
Terminal::init(false);
|
||||
}else{
|
||||
Terminal::init();
|
||||
}
|
||||
|
||||
$logger = new MainLogger(\pocketmine\DATA . "server.log");
|
||||
$logger->registerStatic();
|
||||
|
||||
foreach($tzError as $e){
|
||||
$logger->warning($e);
|
||||
}
|
||||
unset($tzError);
|
||||
|
||||
if(extension_loaded("xdebug")){
|
||||
$logger->warning(PHP_EOL . PHP_EOL . PHP_EOL . "\tYou are running " . \pocketmine\NAME . " with xdebug enabled. This has a major impact on performance." . PHP_EOL . PHP_EOL);
|
||||
}
|
||||
if(!extension_loaded("pocketmine_chunkutils")){
|
||||
$logger->warning("ChunkUtils extension is missing. Anvil-format worlds will experience degraded performance.");
|
||||
}
|
||||
|
||||
if(\Phar::running(true) === ""){
|
||||
$logger->warning("Non-packaged " . \pocketmine\NAME . " installation detected. Consider using a phar in production for better performance.");
|
||||
}
|
||||
|
||||
$version = new VersionString(\pocketmine\BASE_VERSION, \pocketmine\IS_DEVELOPMENT_BUILD, \pocketmine\BUILD_NUMBER);
|
||||
define('pocketmine\VERSION', $version->getFullVersion(true));
|
||||
|
||||
$gitHash = str_repeat("00", 20);
|
||||
|
||||
if(\Phar::running(true) === ""){
|
||||
if(Utils::execute("git rev-parse HEAD", $out) === 0 and $out !== false and strlen($out = trim($out)) === 40){
|
||||
$gitHash = trim($out);
|
||||
if(Utils::execute("git diff --quiet") === 1 or Utils::execute("git diff --cached --quiet") === 1){ //Locally-modified
|
||||
$gitHash .= "-dirty";
|
||||
function server(){
|
||||
if(!empty($messages = check_platform_dependencies())){
|
||||
echo PHP_EOL;
|
||||
$binary = version_compare(PHP_VERSION, "5.4") >= 0 ? PHP_BINARY : "unknown";
|
||||
critical_error("Selected PHP binary ($binary) does not satisfy some requirements.");
|
||||
foreach($messages as $m){
|
||||
echo " - $m" . PHP_EOL;
|
||||
}
|
||||
critical_error("Please recompile PHP with the needed configuration, or refer to the installation instructions at http://pmmp.rtfd.io/en/rtfd/installation.html.");
|
||||
echo PHP_EOL;
|
||||
exit(1);
|
||||
}
|
||||
}else{
|
||||
$phar = new \Phar(\Phar::running(false));
|
||||
$meta = $phar->getMetadata();
|
||||
if(isset($meta["git"])){
|
||||
$gitHash = $meta["git"];
|
||||
unset($messages);
|
||||
|
||||
error_reporting(-1);
|
||||
|
||||
if(\Phar::running(true) !== ""){
|
||||
define('pocketmine\PATH', \Phar::running(true) . "/");
|
||||
}else{
|
||||
define('pocketmine\PATH', dirname(__FILE__, 3) . DIRECTORY_SEPARATOR);
|
||||
}
|
||||
}
|
||||
|
||||
define('pocketmine\GIT_COMMIT', $gitHash);
|
||||
$opts = getopt("", ["bootstrap:"]);
|
||||
if(isset($opts["bootstrap"])){
|
||||
$bootstrap = realpath($opts["bootstrap"]) ?: $opts["bootstrap"];
|
||||
}else{
|
||||
$bootstrap = \pocketmine\PATH . 'vendor/autoload.php';
|
||||
}
|
||||
define('pocketmine\COMPOSER_AUTOLOADER_PATH', $bootstrap);
|
||||
|
||||
if(\pocketmine\COMPOSER_AUTOLOADER_PATH !== false and is_file(\pocketmine\COMPOSER_AUTOLOADER_PATH)){
|
||||
require_once(\pocketmine\COMPOSER_AUTOLOADER_PATH);
|
||||
}else{
|
||||
critical_error("Composer autoloader not found at " . $bootstrap);
|
||||
critical_error("Please install/update Composer dependencies or use provided builds.");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@define("INT32_MASK", is_int(0xffffffff) ? 0xffffffff : -1);
|
||||
@ini_set("opcache.mmap_base", bin2hex(random_bytes(8))); //Fix OPCache address errors
|
||||
set_error_handler([Utils::class, 'errorExceptionHandler']);
|
||||
|
||||
$exitCode = 0;
|
||||
do{
|
||||
if(!file_exists(\pocketmine\DATA . "server.properties") and !isset($opts["no-wizard"])){
|
||||
$installer = new SetupWizard();
|
||||
if(!$installer->run()){
|
||||
$exitCode = -1;
|
||||
break;
|
||||
/*
|
||||
* We now use the Composer autoloader, but this autoloader is still for loading plugins.
|
||||
*/
|
||||
$autoloader = new \BaseClassLoader();
|
||||
$autoloader->register(false);
|
||||
|
||||
set_time_limit(0); //Who set it to 30 seconds?!?!
|
||||
|
||||
ini_set("allow_url_fopen", '1');
|
||||
ini_set("display_errors", '1');
|
||||
ini_set("display_startup_errors", '1');
|
||||
ini_set("default_charset", "utf-8");
|
||||
|
||||
ini_set("memory_limit", '-1');
|
||||
|
||||
define('pocketmine\RESOURCE_PATH', \pocketmine\PATH . 'src' . DIRECTORY_SEPARATOR . 'pocketmine' . DIRECTORY_SEPARATOR . 'resources' . DIRECTORY_SEPARATOR);
|
||||
|
||||
$opts = getopt("", ["data:", "plugins:", "no-wizard", "enable-ansi", "disable-ansi"]);
|
||||
|
||||
define('pocketmine\DATA', isset($opts["data"]) ? $opts["data"] . DIRECTORY_SEPARATOR : realpath(getcwd()) . DIRECTORY_SEPARATOR);
|
||||
define('pocketmine\PLUGIN_PATH', isset($opts["plugins"]) ? $opts["plugins"] . DIRECTORY_SEPARATOR : realpath(getcwd()) . DIRECTORY_SEPARATOR . "plugins" . DIRECTORY_SEPARATOR);
|
||||
|
||||
if(!file_exists(\pocketmine\DATA)){
|
||||
mkdir(\pocketmine\DATA, 0777, true);
|
||||
}
|
||||
|
||||
define('pocketmine\LOCK_FILE_PATH', \pocketmine\DATA . 'server.lock');
|
||||
define('pocketmine\LOCK_FILE', fopen(\pocketmine\LOCK_FILE_PATH, "a+b"));
|
||||
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
|
||||
flock(\pocketmine\LOCK_FILE, LOCK_SH);
|
||||
$pid = stream_get_contents(\pocketmine\LOCK_FILE);
|
||||
critical_error("Another " . \pocketmine\NAME . " instance (PID $pid) is already using this folder (" . realpath(\pocketmine\DATA) . ").");
|
||||
critical_error("Please stop the other server first before running a new one.");
|
||||
exit(1);
|
||||
}
|
||||
ftruncate(\pocketmine\LOCK_FILE, 0);
|
||||
fwrite(\pocketmine\LOCK_FILE, (string) getmypid());
|
||||
fflush(\pocketmine\LOCK_FILE);
|
||||
flock(\pocketmine\LOCK_FILE, LOCK_SH); //prevent acquiring an exclusive lock from another process, but allow reading
|
||||
|
||||
//Logger has a dependency on timezone
|
||||
$tzError = Timezone::init();
|
||||
|
||||
if(isset($opts["enable-ansi"])){
|
||||
Terminal::init(true);
|
||||
}elseif(isset($opts["disable-ansi"])){
|
||||
Terminal::init(false);
|
||||
}else{
|
||||
Terminal::init();
|
||||
}
|
||||
|
||||
$logger = new MainLogger(\pocketmine\DATA . "server.log");
|
||||
$logger->registerStatic();
|
||||
|
||||
foreach($tzError as $e){
|
||||
$logger->warning($e);
|
||||
}
|
||||
unset($tzError);
|
||||
|
||||
if(extension_loaded("xdebug")){
|
||||
$logger->warning(PHP_EOL . PHP_EOL . PHP_EOL . "\tYou are running " . \pocketmine\NAME . " with xdebug enabled. This has a major impact on performance." . PHP_EOL . PHP_EOL);
|
||||
}
|
||||
if(!extension_loaded("pocketmine_chunkutils")){
|
||||
$logger->warning("ChunkUtils extension is missing. Anvil-format worlds will experience degraded performance.");
|
||||
}
|
||||
|
||||
if(\Phar::running(true) === ""){
|
||||
$logger->warning("Non-packaged " . \pocketmine\NAME . " installation detected. Consider using a phar in production for better performance.");
|
||||
}
|
||||
|
||||
$version = new VersionString(\pocketmine\BASE_VERSION, \pocketmine\IS_DEVELOPMENT_BUILD, \pocketmine\BUILD_NUMBER);
|
||||
define('pocketmine\VERSION', $version->getFullVersion(true));
|
||||
|
||||
$gitHash = str_repeat("00", 20);
|
||||
|
||||
if(\Phar::running(true) === ""){
|
||||
if(Utils::execute("git rev-parse HEAD", $out) === 0 and $out !== false and strlen($out = trim($out)) === 40){
|
||||
$gitHash = trim($out);
|
||||
if(Utils::execute("git diff --quiet") === 1 or Utils::execute("git diff --cached --quiet") === 1){ //Locally-modified
|
||||
$gitHash .= "-dirty";
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$phar = new \Phar(\Phar::running(false));
|
||||
$meta = $phar->getMetadata();
|
||||
if(isset($meta["git"])){
|
||||
$gitHash = $meta["git"];
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: move this to a Server field
|
||||
define('pocketmine\START_TIME', microtime(true));
|
||||
ThreadManager::init();
|
||||
new Server($autoloader, $logger, \pocketmine\DATA, \pocketmine\PLUGIN_PATH);
|
||||
define('pocketmine\GIT_COMMIT', $gitHash);
|
||||
|
||||
$logger->info("Stopping other threads");
|
||||
|
||||
$killer = new ServerKiller(8);
|
||||
$killer->start(PTHREADS_INHERIT_NONE);
|
||||
usleep(10000); //Fixes ServerKiller not being able to start on single-core machines
|
||||
@define("INT32_MASK", is_int(0xffffffff) ? 0xffffffff : -1);
|
||||
@ini_set("opcache.mmap_base", bin2hex(random_bytes(8))); //Fix OPCache address errors
|
||||
|
||||
if(ThreadManager::getInstance()->stopAll() > 0){
|
||||
if(\pocketmine\DEBUG > 1){
|
||||
echo "Some threads could not be stopped, performing a force-kill" . PHP_EOL . PHP_EOL;
|
||||
$exitCode = 0;
|
||||
do{
|
||||
if(!file_exists(\pocketmine\DATA . "server.properties") and !isset($opts["no-wizard"])){
|
||||
$installer = new SetupWizard();
|
||||
if(!$installer->run()){
|
||||
$exitCode = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
Utils::kill(getmypid());
|
||||
}
|
||||
}while(false);
|
||||
|
||||
$logger->shutdown();
|
||||
$logger->join();
|
||||
//TODO: move this to a Server field
|
||||
define('pocketmine\START_TIME', microtime(true));
|
||||
ThreadManager::init();
|
||||
new Server($autoloader, $logger, \pocketmine\DATA, \pocketmine\PLUGIN_PATH);
|
||||
|
||||
echo Terminal::$FORMAT_RESET . PHP_EOL;
|
||||
$logger->info("Stopping other threads");
|
||||
|
||||
exit($exitCode);
|
||||
$killer = new ServerKiller(8);
|
||||
$killer->start(PTHREADS_INHERIT_NONE);
|
||||
usleep(10000); //Fixes ServerKiller not being able to start on single-core machines
|
||||
|
||||
if(ThreadManager::getInstance()->stopAll() > 0){
|
||||
if(\pocketmine\DEBUG > 1){
|
||||
echo "Some threads could not be stopped, performing a force-kill" . PHP_EOL . PHP_EOL;
|
||||
}
|
||||
Utils::kill(getmypid());
|
||||
}
|
||||
}while(false);
|
||||
|
||||
$logger->shutdown();
|
||||
$logger->join();
|
||||
|
||||
echo Terminal::$FORMAT_RESET . PHP_EOL;
|
||||
|
||||
exit($exitCode);
|
||||
}
|
||||
|
||||
\pocketmine\server();
|
||||
}
|
||||
|
@ -112,7 +112,6 @@ use function array_sum;
|
||||
use function asort;
|
||||
use function assert;
|
||||
use function base64_encode;
|
||||
use function bin2hex;
|
||||
use function class_exists;
|
||||
use function count;
|
||||
use function define;
|
||||
@ -594,7 +593,7 @@ class Server{
|
||||
* @return int
|
||||
*/
|
||||
public function getDifficulty() : int{
|
||||
return $this->getConfigInt("difficulty", 1);
|
||||
return $this->getConfigInt("difficulty", Level::DIFFICULTY_NORMAL);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -893,6 +892,11 @@ class Server{
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an online player whose name begins with or equals the given string (case insensitive).
|
||||
* The closest match will be returned, or null if there are no online matches.
|
||||
*
|
||||
* @see Server::getPlayerExact()
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return Player|null
|
||||
@ -918,6 +922,8 @@ class Server{
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an online player with the given name (case insensitive), or null if not found.
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return Player|null
|
||||
@ -934,6 +940,9 @@ class Server{
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of online players whose names contain with the given string (case insensitive).
|
||||
* If an exact match is found, only that match is returned.
|
||||
*
|
||||
* @param string $partialName
|
||||
*
|
||||
* @return Player[]
|
||||
@ -1092,11 +1101,17 @@ class Server{
|
||||
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* @var LevelProvider $provider
|
||||
* @see LevelProvider::__construct()
|
||||
*/
|
||||
$provider = new $providerClass($path);
|
||||
|
||||
try{
|
||||
/**
|
||||
* @var LevelProvider $provider
|
||||
* @see LevelProvider::__construct()
|
||||
*/
|
||||
$provider = new $providerClass($path);
|
||||
}catch(LevelException $e){
|
||||
$this->logger->error($this->getLanguage()->translateString("pocketmine.level.loadError", [$name, $e->getMessage()]));
|
||||
return false;
|
||||
}
|
||||
try{
|
||||
GeneratorManager::getGenerator($provider->getGenerator(), true);
|
||||
}catch(\InvalidArgumentException $e){
|
||||
@ -1520,7 +1535,7 @@ class Server{
|
||||
"force-gamemode" => false,
|
||||
"hardcore" => false,
|
||||
"pvp" => true,
|
||||
"difficulty" => 1,
|
||||
"difficulty" => Level::DIFFICULTY_NORMAL,
|
||||
"generator-settings" => "",
|
||||
"level-name" => "world",
|
||||
"level-seed" => "",
|
||||
@ -1710,7 +1725,7 @@ class Server{
|
||||
|
||||
register_shutdown_function([$this, "crashDump"]);
|
||||
|
||||
$this->queryRegenerateTask = new QueryRegenerateEvent($this, 5);
|
||||
$this->queryRegenerateTask = new QueryRegenerateEvent($this);
|
||||
|
||||
$this->pluginManager->loadPlugins($this->pluginPath);
|
||||
|
||||
@ -2191,6 +2206,7 @@ class Server{
|
||||
|
||||
$this->logger->info($this->getLanguage()->translateString("pocketmine.server.defaultGameMode", [self::getGamemodeString($this->getGamemode())]));
|
||||
|
||||
$this->logger->info($this->getLanguage()->translateString("pocketmine.server.donate", [TextFormat::AQUA . "https://patreon.com/pocketminemp" . TextFormat::RESET]));
|
||||
$this->logger->info($this->getLanguage()->translateString("pocketmine.server.startFinished", [round(microtime(true) - \pocketmine\START_TIME, 3)]));
|
||||
|
||||
$this->tickProcessor();
|
||||
@ -2528,7 +2544,7 @@ class Server{
|
||||
if(strlen($payload) > 2 and substr($payload, 0, 2) === "\xfe\xfd" and $this->queryHandler instanceof QueryHandler){
|
||||
$this->queryHandler->handle($interface, $address, $port, $payload);
|
||||
}else{
|
||||
$this->logger->debug("Unhandled raw packet from $address $port: " . bin2hex($payload));
|
||||
$this->logger->debug("Unhandled raw packet from $address $port: " . base64_encode($payload));
|
||||
}
|
||||
}catch(\Throwable $e){
|
||||
$this->logger->logException($e);
|
||||
@ -2577,17 +2593,12 @@ class Server{
|
||||
$this->currentTPS = 20;
|
||||
$this->currentUse = 0;
|
||||
|
||||
($this->queryRegenerateTask = new QueryRegenerateEvent($this))->call();
|
||||
|
||||
$this->network->updateName();
|
||||
$this->network->resetStatistics();
|
||||
}
|
||||
|
||||
if(($this->tickCounter & 0b111111111) === 0){
|
||||
($this->queryRegenerateTask = new QueryRegenerateEvent($this, 5))->call();
|
||||
if($this->queryHandler !== null){
|
||||
$this->queryHandler->regenerateInfo();
|
||||
}
|
||||
}
|
||||
|
||||
if($this->autoSave and ++$this->autoSaveTicker >= $this->autoSaveTicks){
|
||||
$this->autoSaveTicker = 0;
|
||||
$this->getLogger()->debug("[Auto Save] Saving worlds...");
|
||||
|
@ -22,6 +22,6 @@
|
||||
namespace pocketmine;
|
||||
|
||||
const NAME = "PocketMine-MP";
|
||||
const BASE_VERSION = "3.8.3";
|
||||
const BASE_VERSION = "3.9.6";
|
||||
const IS_DEVELOPMENT_BUILD = false;
|
||||
const BUILD_NUMBER = 0;
|
||||
|
@ -69,7 +69,7 @@ class Block extends Position implements BlockIds, Metadatable{
|
||||
/** @var int|null */
|
||||
protected $itemId;
|
||||
|
||||
/** @var AxisAlignedBB */
|
||||
/** @var AxisAlignedBB|null */
|
||||
protected $boundingBox = null;
|
||||
|
||||
|
||||
|
@ -32,6 +32,7 @@ use pocketmine\level\sound\FizzSound;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Vector3;
|
||||
use function array_fill;
|
||||
use function intdiv;
|
||||
use function lcg_value;
|
||||
use function min;
|
||||
|
||||
@ -372,7 +373,7 @@ abstract class Liquid extends Transparent{
|
||||
*/
|
||||
private function getOptimalFlowDirections() : array{
|
||||
$flowCost = array_fill(0, 4, 1000);
|
||||
$maxCost = 4 / $this->getFlowDecayPerBlock();
|
||||
$maxCost = intdiv(4, $this->getFlowDecayPerBlock());
|
||||
for($j = 0; $j < 4; ++$j){
|
||||
$x = $this->x;
|
||||
$y = $this->y;
|
||||
|
@ -74,14 +74,14 @@ class FormattedCommandAlias extends Command{
|
||||
$index = strpos($formatString, '$');
|
||||
while($index !== false){
|
||||
$start = $index;
|
||||
if($index > 0 and $formatString{$start - 1} === "\\"){
|
||||
if($index > 0 and $formatString[$start - 1] === "\\"){
|
||||
$formatString = substr($formatString, 0, $start - 1) . substr($formatString, $start);
|
||||
$index = strpos($formatString, '$', $index);
|
||||
continue;
|
||||
}
|
||||
|
||||
$required = false;
|
||||
if($formatString{$index + 1} == '$'){
|
||||
if($formatString[$index + 1] == '$'){
|
||||
$required = true;
|
||||
|
||||
++$index;
|
||||
@ -91,7 +91,7 @@ class FormattedCommandAlias extends Command{
|
||||
|
||||
$argStart = $index;
|
||||
|
||||
while($index < strlen($formatString) and self::inRange(ord($formatString{$index}) - 48, 0, 9)){
|
||||
while($index < strlen($formatString) and self::inRange(ord($formatString[$index]) - 48, 0, 9)){
|
||||
++$index;
|
||||
}
|
||||
|
||||
@ -109,7 +109,7 @@ class FormattedCommandAlias extends Command{
|
||||
|
||||
$rest = false;
|
||||
|
||||
if($index < strlen($formatString) and $formatString{$index} === "-"){
|
||||
if($index < strlen($formatString) and $formatString[$index] === "-"){
|
||||
$rest = true;
|
||||
++$index;
|
||||
}
|
||||
|
@ -42,6 +42,10 @@ class TransferServerCommand extends VanillaCommand{
|
||||
}
|
||||
|
||||
public function execute(CommandSender $sender, string $commandLabel, array $args){
|
||||
if(!$this->testPermission($sender)){
|
||||
return true;
|
||||
}
|
||||
|
||||
if(count($args) < 1){
|
||||
throw new InvalidCommandSyntaxException();
|
||||
}elseif(!($sender instanceof Player)){
|
||||
|
@ -65,7 +65,7 @@ abstract class VanillaCommand extends Command{
|
||||
* @return float
|
||||
*/
|
||||
protected function getRelativeDouble(float $original, CommandSender $sender, string $input, float $min = self::MIN_COORD, float $max = self::MAX_COORD) : float{
|
||||
if($input{0} === "~"){
|
||||
if($input[0] === "~"){
|
||||
$value = $this->getDouble($sender, substr($input, 1));
|
||||
|
||||
return $original + $value;
|
||||
|
@ -40,6 +40,11 @@ class Attribute{
|
||||
public const ATTACK_DAMAGE = 8;
|
||||
public const EXPERIENCE_LEVEL = 9;
|
||||
public const EXPERIENCE = 10;
|
||||
public const UNDERWATER_MOVEMENT = 11;
|
||||
public const LUCK = 12;
|
||||
public const FALL_DAMAGE = 13;
|
||||
public const HORSE_JUMP_STRENGTH = 14;
|
||||
public const ZOMBIE_SPAWN_REINFORCEMENTS = 15;
|
||||
|
||||
private $id;
|
||||
protected $minValue;
|
||||
@ -66,8 +71,11 @@ class Attribute{
|
||||
self::addAttribute(self::ATTACK_DAMAGE, "minecraft:attack_damage", 0.00, 340282346638528859811704183484516925440.00, 1.00, false);
|
||||
self::addAttribute(self::EXPERIENCE_LEVEL, "minecraft:player.level", 0.00, 24791.00, 0.00);
|
||||
self::addAttribute(self::EXPERIENCE, "minecraft:player.experience", 0.00, 1.00, 0.00);
|
||||
//TODO: minecraft:luck (for fishing?)
|
||||
//TODO: minecraft:fall_damage
|
||||
self::addAttribute(self::UNDERWATER_MOVEMENT, "minecraft:underwater_movement", 0.0, 340282346638528859811704183484516925440.0, 0.02);
|
||||
self::addAttribute(self::LUCK, "minecraft:luck", -1024.0, 1024.0, 0.0);
|
||||
self::addAttribute(self::FALL_DAMAGE, "minecraft:fall_damage", 0.0, 340282346638528859811704183484516925440.0, 1.0);
|
||||
self::addAttribute(self::HORSE_JUMP_STRENGTH, "minecraft:horse.jump_strength", 0.0, 2.0, 0.7);
|
||||
self::addAttribute(self::ZOMBIE_SPAWN_REINFORCEMENTS, "minecraft:zombie.spawn_reinforcements", 0.0, 1.0, 0.0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -23,8 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\entity;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use function assert;
|
||||
use function is_float;
|
||||
use function is_int;
|
||||
@ -140,25 +140,14 @@ class DataPropertyManager{
|
||||
$this->setPropertyValue($key, Entity::DATA_TYPE_STRING, $value, $force);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $key
|
||||
*
|
||||
* @return null|Item
|
||||
*/
|
||||
public function getItem(int $key) : ?Item{
|
||||
$value = $this->getPropertyValue($key, Entity::DATA_TYPE_SLOT);
|
||||
assert($value instanceof Item or $value === null);
|
||||
|
||||
public function getCompoundTag(int $key) : ?CompoundTag{
|
||||
$value = $this->getPropertyValue($key, Entity::DATA_TYPE_COMPOUND_TAG);
|
||||
assert($value instanceof CompoundTag or $value === null);
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $key
|
||||
* @param Item $value
|
||||
* @param bool $force
|
||||
*/
|
||||
public function setItem(int $key, Item $value, bool $force = false) : void{
|
||||
$this->setPropertyValue($key, Entity::DATA_TYPE_SLOT, $value, $force);
|
||||
public function setCompoundTag(int $key, CompoundTag $value, bool $force = false) : void{
|
||||
$this->setPropertyValue($key, Entity::DATA_TYPE_COMPOUND_TAG, $value, $force);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -62,12 +62,12 @@ use pocketmine\nbt\tag\DoubleTag;
|
||||
use pocketmine\nbt\tag\FloatTag;
|
||||
use pocketmine\nbt\tag\ListTag;
|
||||
use pocketmine\nbt\tag\StringTag;
|
||||
use pocketmine\network\mcpe\protocol\AddEntityPacket;
|
||||
use pocketmine\network\mcpe\protocol\EntityEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\MoveEntityAbsolutePacket;
|
||||
use pocketmine\network\mcpe\protocol\RemoveEntityPacket;
|
||||
use pocketmine\network\mcpe\protocol\SetEntityDataPacket;
|
||||
use pocketmine\network\mcpe\protocol\SetEntityMotionPacket;
|
||||
use pocketmine\network\mcpe\protocol\ActorEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\AddActorPacket;
|
||||
use pocketmine\network\mcpe\protocol\MoveActorAbsolutePacket;
|
||||
use pocketmine\network\mcpe\protocol\RemoveActorPacket;
|
||||
use pocketmine\network\mcpe\protocol\SetActorDataPacket;
|
||||
use pocketmine\network\mcpe\protocol\SetActorMotionPacket;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\plugin\Plugin;
|
||||
use pocketmine\Server;
|
||||
@ -102,7 +102,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
|
||||
public const DATA_TYPE_INT = 2;
|
||||
public const DATA_TYPE_FLOAT = 3;
|
||||
public const DATA_TYPE_STRING = 4;
|
||||
public const DATA_TYPE_SLOT = 5;
|
||||
public const DATA_TYPE_COMPOUND_TAG = 5;
|
||||
public const DATA_TYPE_POS = 6;
|
||||
public const DATA_TYPE_LONG = 7;
|
||||
public const DATA_TYPE_VECTOR3F = 8;
|
||||
@ -154,70 +154,76 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
|
||||
public const DATA_LEAD_HOLDER_EID = 37; //long
|
||||
public const DATA_SCALE = 38; //float
|
||||
public const DATA_HAS_NPC_COMPONENT = 39; //byte (???)
|
||||
public const DATA_SKIN_ID = 40; //string
|
||||
public const DATA_NPC_SKIN_ID = 41; //string
|
||||
public const DATA_URL_TAG = 42; //string
|
||||
public const DATA_MAX_AIR = 43; //short
|
||||
public const DATA_MARK_VARIANT = 44; //int
|
||||
public const DATA_CONTAINER_TYPE = 45; //byte (ContainerComponent)
|
||||
public const DATA_CONTAINER_BASE_SIZE = 46; //int (ContainerComponent)
|
||||
public const DATA_CONTAINER_EXTRA_SLOTS_PER_STRENGTH = 47; //int (used for llamas, inventory size is baseSize + thisProp * strength)
|
||||
public const DATA_BLOCK_TARGET = 48; //block coords (ender crystal)
|
||||
public const DATA_WITHER_INVULNERABLE_TICKS = 49; //int
|
||||
public const DATA_WITHER_TARGET_1 = 50; //long
|
||||
public const DATA_WITHER_TARGET_2 = 51; //long
|
||||
public const DATA_WITHER_TARGET_3 = 52; //long
|
||||
/* 53 (short) */
|
||||
public const DATA_BOUNDING_BOX_WIDTH = 54; //float
|
||||
public const DATA_BOUNDING_BOX_HEIGHT = 55; //float
|
||||
public const DATA_FUSE_LENGTH = 56; //int
|
||||
public const DATA_RIDER_SEAT_POSITION = 57; //vector3f
|
||||
public const DATA_RIDER_ROTATION_LOCKED = 58; //byte
|
||||
public const DATA_RIDER_MAX_ROTATION = 59; //float
|
||||
public const DATA_RIDER_MIN_ROTATION = 60; //float
|
||||
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
|
||||
public const DATA_NPC_SKIN_INDEX = 40; //string
|
||||
public const DATA_NPC_ACTIONS = 41; //string (maybe JSON blob?)
|
||||
public const DATA_MAX_AIR = 42; //short
|
||||
public const DATA_MARK_VARIANT = 43; //int
|
||||
public const DATA_CONTAINER_TYPE = 44; //byte (ContainerComponent)
|
||||
public const DATA_CONTAINER_BASE_SIZE = 45; //int (ContainerComponent)
|
||||
public const DATA_CONTAINER_EXTRA_SLOTS_PER_STRENGTH = 46; //int (used for llamas, inventory size is baseSize + thisProp * strength)
|
||||
public const DATA_BLOCK_TARGET = 47; //block coords (ender crystal)
|
||||
public const DATA_WITHER_INVULNERABLE_TICKS = 48; //int
|
||||
public const DATA_WITHER_TARGET_1 = 49; //long
|
||||
public const DATA_WITHER_TARGET_2 = 50; //long
|
||||
public const DATA_WITHER_TARGET_3 = 51; //long
|
||||
/* 52 (short) */
|
||||
public const DATA_BOUNDING_BOX_WIDTH = 53; //float
|
||||
public const DATA_BOUNDING_BOX_HEIGHT = 54; //float
|
||||
public const DATA_FUSE_LENGTH = 55; //int
|
||||
public const DATA_RIDER_SEAT_POSITION = 56; //vector3f
|
||||
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
|
||||
|
||||
/* 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
|
||||
/* 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
|
||||
|
||||
public const DATA_FLAG_ONFIRE = 0;
|
||||
public const DATA_FLAG_SNEAKING = 1;
|
||||
@ -662,7 +668,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
|
||||
* @return bool
|
||||
*/
|
||||
public function isNameTagAlwaysVisible() : bool{
|
||||
return $this->getGenericFlag(self::DATA_FLAG_ALWAYS_SHOW_NAMETAG);
|
||||
return $this->propertyManager->getByte(self::DATA_ALWAYS_SHOW_NAMETAG) === 1;
|
||||
}
|
||||
|
||||
|
||||
@ -1137,7 +1143,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
|
||||
$this->setFireTicks($ticks);
|
||||
}
|
||||
|
||||
$this->setGenericFlag(self::DATA_FLAG_ONFIRE, true);
|
||||
$this->setGenericFlag(self::DATA_FLAG_ONFIRE, $this->isOnFire());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1235,7 +1241,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
|
||||
}
|
||||
|
||||
protected function broadcastMovement(bool $teleport = false) : void{
|
||||
$pk = new MoveEntityAbsolutePacket();
|
||||
$pk = new MoveActorAbsolutePacket();
|
||||
$pk->entityRuntimeId = $this->id;
|
||||
$pk->position = $this->getOffsetPosition($this);
|
||||
|
||||
@ -1247,14 +1253,14 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
|
||||
$pk->zRot = $this->yaw;
|
||||
|
||||
if($teleport){
|
||||
$pk->flags |= MoveEntityAbsolutePacket::FLAG_TELEPORT;
|
||||
$pk->flags |= MoveActorAbsolutePacket::FLAG_TELEPORT;
|
||||
}
|
||||
|
||||
$this->level->broadcastPacketToViewers($this, $pk);
|
||||
}
|
||||
|
||||
protected function broadcastMotion() : void{
|
||||
$pk = new SetEntityMotionPacket();
|
||||
$pk = new SetActorMotionPacket();
|
||||
$pk->entityRuntimeId = $this->id;
|
||||
$pk->motion = $this->getMotion();
|
||||
|
||||
@ -1776,6 +1782,9 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated WARNING: Despite what its name implies, this function DOES NOT return all the blocks around the entity.
|
||||
* Instead, it returns blocks which have reactions for an entity intersecting with them.
|
||||
*
|
||||
* @return Block[]
|
||||
*/
|
||||
public function getBlocksAround() : array{
|
||||
@ -2021,7 +2030,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
|
||||
* @param Player $player
|
||||
*/
|
||||
protected function sendSpawnPacket(Player $player) : void{
|
||||
$pk = new AddEntityPacket();
|
||||
$pk = new AddActorPacket();
|
||||
$pk->entityRuntimeId = $this->getId();
|
||||
$pk->type = static::NETWORK_ID;
|
||||
$pk->position = $this->asVector3();
|
||||
@ -2065,13 +2074,16 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated WARNING: This function DOES NOT permanently hide the entity from the player. As soon as the entity or
|
||||
* player moves, the player will once again be able to see the entity.
|
||||
*
|
||||
* @param Player $player
|
||||
* @param bool $send
|
||||
*/
|
||||
public function despawnFrom(Player $player, bool $send = true) : void{
|
||||
if(isset($this->hasSpawned[$player->getLoaderId()])){
|
||||
if($send){
|
||||
$pk = new RemoveEntityPacket();
|
||||
$pk = new RemoveActorPacket();
|
||||
$pk->entityUniqueId = $this->id;
|
||||
$player->dataPacket($pk);
|
||||
}
|
||||
@ -2079,6 +2091,10 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated WARNING: This function DOES NOT permanently hide the entity from viewers. As soon as the entity or
|
||||
* player moves, viewers will once again be able to see the entity.
|
||||
*/
|
||||
public function despawnFromAll() : void{
|
||||
foreach($this->hasSpawned as $player){
|
||||
$this->despawnFrom($player);
|
||||
@ -2193,7 +2209,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
|
||||
$player = [$player];
|
||||
}
|
||||
|
||||
$pk = new SetEntityDataPacket();
|
||||
$pk = new SetActorDataPacket();
|
||||
$pk->entityRuntimeId = $this->getId();
|
||||
$pk->metadata = $data ?? $this->propertyManager->getAll();
|
||||
|
||||
@ -2210,7 +2226,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
|
||||
}
|
||||
|
||||
public function broadcastEntityEvent(int $eventId, ?int $eventData = null, ?array $players = null) : void{
|
||||
$pk = new EntityEventPacket();
|
||||
$pk = new ActorEventPacket();
|
||||
$pk->entityRuntimeId = $this->id;
|
||||
$pk->event = $eventId;
|
||||
$pk->data = $eventData ?? 0;
|
||||
|
@ -46,8 +46,8 @@ use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\nbt\tag\IntTag;
|
||||
use pocketmine\nbt\tag\ListTag;
|
||||
use pocketmine\nbt\tag\StringTag;
|
||||
use pocketmine\network\mcpe\protocol\ActorEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\AddPlayerPacket;
|
||||
use pocketmine\network\mcpe\protocol\EntityEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\LevelEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\PlayerListPacket;
|
||||
@ -587,6 +587,9 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
|
||||
return (int) min(100, 7 * $this->getXpLevel());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PlayerInventory
|
||||
*/
|
||||
public function getInventory(){
|
||||
return $this->inventory;
|
||||
}
|
||||
@ -628,7 +631,7 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
|
||||
//Old hotbar saving stuff, ignore it
|
||||
}elseif($slot >= 100 and $slot < 104){ //Armor
|
||||
$this->armorInventory->setItem($slot - 100, Item::nbtDeserialize($item));
|
||||
}else{
|
||||
}elseif($slot >= 9 and $slot < $this->inventory->getSize() + 9){
|
||||
$this->inventory->setItem($slot - 9, Item::nbtDeserialize($item));
|
||||
}
|
||||
}
|
||||
@ -754,7 +757,7 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
|
||||
$this->addEffect(new EffectInstance(Effect::getEffect(Effect::FIRE_RESISTANCE), 40 * 20, 1));
|
||||
$this->addEffect(new EffectInstance(Effect::getEffect(Effect::ABSORPTION), 5 * 20, 1));
|
||||
|
||||
$this->broadcastEntityEvent(EntityEventPacket::CONSUME_TOTEM);
|
||||
$this->broadcastEntityEvent(ActorEventPacket::CONSUME_TOTEM);
|
||||
$this->level->broadcastLevelEvent($this->add(0, $this->eyeHeight, 0), LevelEventPacket::EVENT_SOUND_TOTEM);
|
||||
|
||||
$hand = $this->inventory->getItemInHand();
|
||||
|
@ -44,7 +44,7 @@ use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\nbt\tag\FloatTag;
|
||||
use pocketmine\nbt\tag\IntTag;
|
||||
use pocketmine\nbt\tag\ListTag;
|
||||
use pocketmine\network\mcpe\protocol\EntityEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\ActorEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\MobEffectPacket;
|
||||
use pocketmine\Player;
|
||||
@ -143,7 +143,7 @@ abstract class Living extends Entity implements Damageable{
|
||||
parent::setHealth($amount);
|
||||
$this->attributeMap->getAttribute(Attribute::HEALTH)->setValue(ceil($this->getHealth()), true);
|
||||
if($this->isAlive() and !$wasAlive){
|
||||
$this->broadcastEntityEvent(EntityEventPacket::RESPAWN);
|
||||
$this->broadcastEntityEvent(ActorEventPacket::RESPAWN);
|
||||
}
|
||||
}
|
||||
|
||||
@ -541,7 +541,9 @@ abstract class Living extends Entity implements Damageable{
|
||||
}
|
||||
|
||||
public function attack(EntityDamageEvent $source) : void{
|
||||
if($this->attackTime > 0 or $this->noDamageTicks > 0){
|
||||
if($this->noDamageTicks > 0){
|
||||
$source->setCancelled();
|
||||
}elseif($this->attackTime > 0){
|
||||
$lastCause = $this->getLastDamageCause();
|
||||
if($lastCause !== null and $lastCause->getBaseDamage() >= $source->getBaseDamage()){
|
||||
$source->setCancelled();
|
||||
@ -604,7 +606,7 @@ abstract class Living extends Entity implements Damageable{
|
||||
}
|
||||
|
||||
protected function doHitAnimation() : void{
|
||||
$this->broadcastEntityEvent(EntityEventPacket::HURT_ANIMATION);
|
||||
$this->broadcastEntityEvent(ActorEventPacket::HURT_ANIMATION);
|
||||
}
|
||||
|
||||
public function knockBack(Entity $attacker, float $damage, float $x, float $z, float $base = 0.4) : void{
|
||||
@ -662,7 +664,7 @@ abstract class Living extends Entity implements Damageable{
|
||||
}
|
||||
|
||||
protected function startDeathAnimation() : void{
|
||||
$this->broadcastEntityEvent(EntityEventPacket::DEATH_ANIMATION);
|
||||
$this->broadcastEntityEvent(ActorEventPacket::DEATH_ANIMATION);
|
||||
}
|
||||
|
||||
protected function endDeathAnimation() : void{
|
||||
|
@ -23,9 +23,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\entity;
|
||||
|
||||
use Ahc\Json\Comment as CommentedJsonDecoder;
|
||||
use function implode;
|
||||
use function in_array;
|
||||
use function json_decode;
|
||||
use function json_encode;
|
||||
use function strlen;
|
||||
|
||||
@ -129,7 +129,7 @@ class Skin{
|
||||
*/
|
||||
public function debloatGeometryData() : void{
|
||||
if($this->geometryData !== ""){
|
||||
$this->geometryData = (string) json_encode(json_decode($this->geometryData));
|
||||
$this->geometryData = (string) json_encode((new CommentedJsonDecoder())->decode($this->geometryData));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ use pocketmine\event\entity\EntityDamageEvent;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\ItemFactory;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\network\mcpe\protocol\EntityEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\ActorEventPacket;
|
||||
use function atan2;
|
||||
use function mt_rand;
|
||||
use function sqrt;
|
||||
@ -68,7 +68,7 @@ class Squid extends WaterAnimal{
|
||||
$this->swimDirection = (new Vector3($this->x - $e->x, $this->y - $e->y, $this->z - $e->z))->normalize();
|
||||
}
|
||||
|
||||
$this->broadcastEntityEvent(EntityEventPacket::SQUID_INK_CLOUD);
|
||||
$this->broadcastEntityEvent(ActorEventPacket::SQUID_INK_CLOUD);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,6 +33,8 @@ use pocketmine\item\ItemFactory;
|
||||
use pocketmine\level\Position;
|
||||
use pocketmine\nbt\tag\ByteTag;
|
||||
use pocketmine\nbt\tag\IntTag;
|
||||
use function abs;
|
||||
use function floor;
|
||||
use function get_class;
|
||||
|
||||
class FallingBlock extends Entity{
|
||||
@ -110,7 +112,7 @@ class FallingBlock extends Entity{
|
||||
$this->flagForDespawn();
|
||||
|
||||
$block = $this->level->getBlock($pos);
|
||||
if($block->getId() > 0 and $block->isTransparent() and !$block->canBeReplaced()){
|
||||
if(($block->isTransparent() and !$block->canBeReplaced()) or ($this->onGround and abs($this->y - $this->getFloorY()) > 0.001)){
|
||||
//FIXME: anvils are supposed to destroy torches
|
||||
$this->getLevel()->dropItem($this, ItemFactory::get($this->getBlock(), $this->getDamage()));
|
||||
}else{
|
||||
|
@ -28,8 +28,8 @@ use pocketmine\event\entity\ItemDespawnEvent;
|
||||
use pocketmine\event\entity\ItemSpawnEvent;
|
||||
use pocketmine\event\inventory\InventoryPickupItemEvent;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\network\mcpe\protocol\AddItemEntityPacket;
|
||||
use pocketmine\network\mcpe\protocol\TakeItemEntityPacket;
|
||||
use pocketmine\network\mcpe\protocol\AddItemActorPacket;
|
||||
use pocketmine\network\mcpe\protocol\TakeItemActorPacket;
|
||||
use pocketmine\Player;
|
||||
use function get_class;
|
||||
|
||||
@ -192,7 +192,7 @@ class ItemEntity extends Entity{
|
||||
}
|
||||
|
||||
protected function sendSpawnPacket(Player $player) : void{
|
||||
$pk = new AddItemEntityPacket();
|
||||
$pk = new AddItemActorPacket();
|
||||
$pk->entityRuntimeId = $this->getId();
|
||||
$pk->position = $this->asVector3();
|
||||
$pk->motion = $this->getMotion();
|
||||
@ -229,7 +229,7 @@ class ItemEntity extends Entity{
|
||||
break;
|
||||
}
|
||||
|
||||
$pk = new TakeItemEntityPacket();
|
||||
$pk = new TakeItemActorPacket();
|
||||
$pk->eid = $player->getId();
|
||||
$pk->target = $this->getId();
|
||||
$this->server->broadcastPacket($this->getViewers(), $pk);
|
||||
|
@ -152,9 +152,11 @@ class Painting extends Entity{
|
||||
protected function sendSpawnPacket(Player $player) : void{
|
||||
$pk = new AddPaintingPacket();
|
||||
$pk->entityRuntimeId = $this->getId();
|
||||
$pk->x = $this->blockIn->x;
|
||||
$pk->y = $this->blockIn->y;
|
||||
$pk->z = $this->blockIn->z;
|
||||
$pk->position = new Vector3(
|
||||
($this->boundingBox->minX + $this->boundingBox->maxX) / 2,
|
||||
($this->boundingBox->minY + $this->boundingBox->maxY) / 2,
|
||||
($this->boundingBox->minZ + $this->boundingBox->maxZ) / 2
|
||||
);
|
||||
$pk->direction = $this->direction;
|
||||
$pk->title = $this->motive;
|
||||
|
||||
|
@ -28,6 +28,7 @@ use pocketmine\entity\Explosive;
|
||||
use pocketmine\event\entity\EntityDamageEvent;
|
||||
use pocketmine\event\entity\ExplosionPrimeEvent;
|
||||
use pocketmine\level\Explosion;
|
||||
use pocketmine\level\Position;
|
||||
use pocketmine\nbt\tag\ShortTag;
|
||||
use pocketmine\network\mcpe\protocol\LevelEventPacket;
|
||||
|
||||
@ -105,7 +106,7 @@ class PrimedTNT extends Entity implements Explosive{
|
||||
$ev = new ExplosionPrimeEvent($this, 4);
|
||||
$ev->call();
|
||||
if(!$ev->isCancelled()){
|
||||
$explosion = new Explosion($this, $ev->getForce(), $this);
|
||||
$explosion = new Explosion(Position::fromObject($this->add(0, $this->height / 2, 0), $this->level), $ev->getForce(), $this);
|
||||
if($ev->isBlockBreaking()){
|
||||
$explosion->explodeA();
|
||||
}
|
||||
|
@ -32,9 +32,9 @@ use pocketmine\item\ItemFactory;
|
||||
use pocketmine\level\Level;
|
||||
use pocketmine\math\RayTraceResult;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\network\mcpe\protocol\EntityEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\ActorEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\TakeItemEntityPacket;
|
||||
use pocketmine\network\mcpe\protocol\TakeItemActorPacket;
|
||||
use pocketmine\Player;
|
||||
use function mt_rand;
|
||||
use function sqrt;
|
||||
@ -143,7 +143,7 @@ class Arrow extends Projectile{
|
||||
|
||||
protected function onHitBlock(Block $blockHit, RayTraceResult $hitResult) : void{
|
||||
parent::onHitBlock($blockHit, $hitResult);
|
||||
$this->broadcastEntityEvent(EntityEventPacket::ARROW_SHAKE, 7); //7 ticks
|
||||
$this->broadcastEntityEvent(ActorEventPacket::ARROW_SHAKE, 7); //7 ticks
|
||||
}
|
||||
|
||||
protected function onHitEntity(Entity $entityHit, RayTraceResult $hitResult) : void{
|
||||
@ -193,7 +193,7 @@ class Arrow extends Projectile{
|
||||
return;
|
||||
}
|
||||
|
||||
$pk = new TakeItemEntityPacket();
|
||||
$pk = new TakeItemActorPacket();
|
||||
$pk->eid = $player->getId();
|
||||
$pk->target = $this->getId();
|
||||
$this->server->broadcastPacket($this->getViewers(), $pk);
|
||||
|
@ -23,36 +23,14 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\entity\projectile;
|
||||
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\event\entity\EntityDamageEvent;
|
||||
use pocketmine\event\entity\ProjectileHitEvent;
|
||||
use pocketmine\level\sound\EndermanTeleportSound;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\RayTraceResult;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\network\mcpe\protocol\LevelEventPacket;
|
||||
|
||||
class EnderPearl extends Throwable{
|
||||
public const NETWORK_ID = self::ENDER_PEARL;
|
||||
|
||||
protected function calculateInterceptWithBlock(Block $block, Vector3 $start, Vector3 $end) : ?RayTraceResult{
|
||||
if($block->getId() !== Block::AIR and empty($block->getCollisionBoxes())){
|
||||
//TODO: remove this once block collision boxes are fixed properly
|
||||
$bb = new AxisAlignedBB(
|
||||
$block->x,
|
||||
$block->y,
|
||||
$block->z,
|
||||
$block->x + 1,
|
||||
$block->y + 1,
|
||||
$block->z + 1
|
||||
);
|
||||
|
||||
return $bb->calculateIntercept($start, $end);
|
||||
}
|
||||
|
||||
return parent::calculateInterceptWithBlock($block, $start, $end);
|
||||
}
|
||||
|
||||
protected function onHit(ProjectileHitEvent $event) : void{
|
||||
$owner = $this->getOwningEntity();
|
||||
if($owner !== null){
|
||||
|
@ -78,8 +78,6 @@ abstract class Event{
|
||||
* Calls event handlers registered for this event.
|
||||
*
|
||||
* @throws \RuntimeException if event call recursion reaches the max depth limit
|
||||
*
|
||||
* @throws \ReflectionException
|
||||
*/
|
||||
public function call() : void{
|
||||
if(self::$eventCallDepth >= self::MAX_EVENT_CALL_DEPTH){
|
||||
|
@ -35,8 +35,6 @@ use function substr;
|
||||
class QueryRegenerateEvent extends ServerEvent{
|
||||
public const GAME_ID = "MINECRAFTPE";
|
||||
|
||||
/** @var int */
|
||||
private $timeout;
|
||||
/** @var string */
|
||||
private $serverName;
|
||||
/** @var bool */
|
||||
@ -68,13 +66,16 @@ class QueryRegenerateEvent extends ServerEvent{
|
||||
/** @var array */
|
||||
private $extraData = [];
|
||||
|
||||
/** @var string|null */
|
||||
private $longQueryCache = null;
|
||||
/** @var string|null */
|
||||
private $shortQueryCache = null;
|
||||
|
||||
|
||||
/**
|
||||
* @param Server $server
|
||||
* @param int $timeout
|
||||
*/
|
||||
public function __construct(Server $server, int $timeout = 5){
|
||||
$this->timeout = $timeout;
|
||||
public function __construct(Server $server){
|
||||
$this->serverName = $server->getMotd();
|
||||
$this->listPlugins = $server->getProperty("settings.query-plugins", true);
|
||||
$this->plugins = $server->getPluginManager()->getPlugins();
|
||||
@ -98,19 +99,25 @@ class QueryRegenerateEvent extends ServerEvent{
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the min. timeout for Query Regeneration
|
||||
* @deprecated
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getTimeout() : int{
|
||||
return $this->timeout;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @param int $timeout
|
||||
*/
|
||||
public function setTimeout(int $timeout) : void{
|
||||
$this->timeout = $timeout;
|
||||
|
||||
}
|
||||
|
||||
private function destroyCache() : void{
|
||||
$this->longQueryCache = null;
|
||||
$this->shortQueryCache = null;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -125,6 +132,7 @@ class QueryRegenerateEvent extends ServerEvent{
|
||||
*/
|
||||
public function setServerName(string $serverName) : void{
|
||||
$this->serverName = $serverName;
|
||||
$this->destroyCache();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -139,6 +147,7 @@ class QueryRegenerateEvent extends ServerEvent{
|
||||
*/
|
||||
public function setListPlugins(bool $value) : void{
|
||||
$this->listPlugins = $value;
|
||||
$this->destroyCache();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -153,6 +162,7 @@ class QueryRegenerateEvent extends ServerEvent{
|
||||
*/
|
||||
public function setPlugins(array $plugins) : void{
|
||||
$this->plugins = $plugins;
|
||||
$this->destroyCache();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -167,6 +177,7 @@ class QueryRegenerateEvent extends ServerEvent{
|
||||
*/
|
||||
public function setPlayerList(array $players) : void{
|
||||
$this->players = $players;
|
||||
$this->destroyCache();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -181,6 +192,7 @@ class QueryRegenerateEvent extends ServerEvent{
|
||||
*/
|
||||
public function setPlayerCount(int $count) : void{
|
||||
$this->numPlayers = $count;
|
||||
$this->destroyCache();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -195,6 +207,7 @@ class QueryRegenerateEvent extends ServerEvent{
|
||||
*/
|
||||
public function setMaxPlayerCount(int $count) : void{
|
||||
$this->maxPlayers = $count;
|
||||
$this->destroyCache();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -209,6 +222,7 @@ class QueryRegenerateEvent extends ServerEvent{
|
||||
*/
|
||||
public function setWorld(string $world) : void{
|
||||
$this->map = $world;
|
||||
$this->destroyCache();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -225,12 +239,16 @@ class QueryRegenerateEvent extends ServerEvent{
|
||||
*/
|
||||
public function setExtraData(array $extraData) : void{
|
||||
$this->extraData = $extraData;
|
||||
$this->destroyCache();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getLongQuery() : string{
|
||||
if($this->longQueryCache !== null){
|
||||
return $this->longQueryCache;
|
||||
}
|
||||
$query = "";
|
||||
|
||||
$plist = $this->server_engine;
|
||||
@ -273,13 +291,13 @@ class QueryRegenerateEvent extends ServerEvent{
|
||||
}
|
||||
$query .= "\x00";
|
||||
|
||||
return $query;
|
||||
return $this->longQueryCache = $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getShortQuery() : string{
|
||||
return $this->serverName . "\x00" . $this->gametype . "\x00" . $this->map . "\x00" . $this->numPlayers . "\x00" . $this->maxPlayers . "\x00" . Binary::writeLShort($this->port) . $this->ip . "\x00";
|
||||
return $this->shortQueryCache ?? ($this->shortQueryCache = $this->serverName . "\x00" . $this->gametype . "\x00" . $this->map . "\x00" . $this->numPlayers . "\x00" . $this->maxPlayers . "\x00" . Binary::writeLShort($this->port) . $this->ip . "\x00");
|
||||
}
|
||||
}
|
||||
|
@ -94,11 +94,12 @@ class ArmorInventory extends BaseInventory{
|
||||
$target = [$target];
|
||||
}
|
||||
|
||||
$armor = $this->getContents(true);
|
||||
|
||||
$pk = new MobArmorEquipmentPacket();
|
||||
$pk->entityRuntimeId = $this->getHolder()->getId();
|
||||
$pk->slots = $armor;
|
||||
$pk->head = $this->getHelmet();
|
||||
$pk->chest = $this->getChestplate();
|
||||
$pk->legs = $this->getLeggings();
|
||||
$pk->feet = $this->getBoots();
|
||||
$pk->encode();
|
||||
|
||||
foreach($target as $player){
|
||||
@ -121,18 +122,19 @@ class ArmorInventory extends BaseInventory{
|
||||
$target = [$target];
|
||||
}
|
||||
|
||||
$armor = $this->getContents(true);
|
||||
|
||||
$pk = new MobArmorEquipmentPacket();
|
||||
$pk->entityRuntimeId = $this->getHolder()->getId();
|
||||
$pk->slots = $armor;
|
||||
$pk->head = $this->getHelmet();
|
||||
$pk->chest = $this->getChestplate();
|
||||
$pk->legs = $this->getLeggings();
|
||||
$pk->feet = $this->getBoots();
|
||||
$pk->encode();
|
||||
|
||||
foreach($target as $player){
|
||||
if($player === $this->getHolder()){
|
||||
$pk2 = new InventoryContentPacket();
|
||||
$pk2->windowId = $player->getWindowId($this);
|
||||
$pk2->items = $armor;
|
||||
$pk2->items = $this->getContents(true);
|
||||
$player->dataPacket($pk2);
|
||||
}else{
|
||||
$player->dataPacket($pk);
|
||||
|
@ -53,6 +53,7 @@ class CraftingManager{
|
||||
public function init() : void{
|
||||
$recipes = json_decode(file_get_contents(\pocketmine\RESOURCE_PATH . "vanilla" . DIRECTORY_SEPARATOR . "recipes.json"), true);
|
||||
|
||||
$itemDeserializerFunc = \Closure::fromCallable([Item::class, 'jsonDeserialize']);
|
||||
foreach($recipes as $recipe){
|
||||
switch($recipe["type"]){
|
||||
case "shapeless":
|
||||
@ -60,8 +61,8 @@ class CraftingManager{
|
||||
break;
|
||||
}
|
||||
$this->registerRecipe(new ShapelessRecipe(
|
||||
array_map(function(array $data) : Item{ return Item::jsonDeserialize($data); }, $recipe["input"]),
|
||||
array_map(function(array $data) : Item{ return Item::jsonDeserialize($data); }, $recipe["output"])
|
||||
array_map($itemDeserializerFunc, $recipe["input"]),
|
||||
array_map($itemDeserializerFunc, $recipe["output"])
|
||||
));
|
||||
break;
|
||||
case "shaped":
|
||||
@ -70,8 +71,8 @@ class CraftingManager{
|
||||
}
|
||||
$this->registerRecipe(new ShapedRecipe(
|
||||
$recipe["shape"],
|
||||
array_map(function(array $data) : Item{ return Item::jsonDeserialize($data); }, $recipe["input"]),
|
||||
array_map(function(array $data) : Item{ return Item::jsonDeserialize($data); }, $recipe["output"])
|
||||
array_map($itemDeserializerFunc, $recipe["input"]),
|
||||
array_map($itemDeserializerFunc, $recipe["output"])
|
||||
));
|
||||
break;
|
||||
case "smelting":
|
||||
|
@ -28,12 +28,16 @@ use pocketmine\utils\UUID;
|
||||
class MultiRecipe{
|
||||
public const TYPE_REPAIR_ITEM = "00000000-0000-0000-0000-000000000001";
|
||||
public const TYPE_MAP_EXTENDING = "D392B075-4BA1-40AE-8789-AF868D56F6CE";
|
||||
public const TYPE_MAP_EXTENDING_CARTOGRAPHY = "8B36268C-1829-483C-A0F1-993B7156A8F2";
|
||||
public const TYPE_MAP_CLONING = "85939755-BA10-4D9D-A4CC-EFB7A8E943C4";
|
||||
public const TYPE_MAP_CLONING_CARTOGRAPHY = "442D85ED-8272-4543-A6F1-418F90DED05D";
|
||||
public const TYPE_MAP_UPGRADING = "AECD2294-4B94-434B-8667-4499BB2C9327";
|
||||
public const TYPE_MAP_UPGRADING_CARTOGRAPHY = "98C84B38-1085-46BD-B1CE-DD38C159E6CC";
|
||||
public const TYPE_BOOK_CLONING = "D1CA6B84-338E-4F2F-9C6B-76CC8B4BD98D";
|
||||
public const TYPE_BANNER_DUPLICATE = "B5C5D105-75A2-4076-AF2B-923EA2BF4BF0";
|
||||
public const TYPE_BANNER_ADD_PATTERN = "D81AAEAF-E172-4440-9225-868DF030D27B";
|
||||
public const TYPE_FIREWORKS = "00000000-0000-0000-0000-000000000002";
|
||||
public const TYPE_MAP_LOCKING_CARTOGRAPHY = "602234E4-CAC1-4353-8BB7-B1EBFF70024B";
|
||||
|
||||
private $uuid;
|
||||
|
||||
|
@ -79,8 +79,8 @@ class ShapedRecipe implements CraftingRecipe{
|
||||
}
|
||||
|
||||
for($x = 0; $x < $this->width; ++$x){
|
||||
if($row{$x} !== ' ' and !isset($ingredients[$row{$x}])){
|
||||
throw new \InvalidArgumentException("No item specified for symbol '" . $row{$x} . "'");
|
||||
if($row[$x] !== ' ' and !isset($ingredients[$row[$x]])){
|
||||
throw new \InvalidArgumentException("No item specified for symbol '" . $row[$x] . "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,21 @@ use function array_pop;
|
||||
use function count;
|
||||
use function intdiv;
|
||||
|
||||
/**
|
||||
* This transaction type is specialized for crafting validation. It shares most of the same semantics of the base
|
||||
* inventory transaction type, but the requirement for validity is slightly different.
|
||||
*
|
||||
* It is expected that the actions in this transaction type will produce an **unbalanced result**, i.e. some inputs won't
|
||||
* have corresponding outputs, and vice versa. The reason why is because the unmatched inputs are recipe inputs, and
|
||||
* the unmatched outputs are recipe results.
|
||||
*
|
||||
* Therefore, the validity requirement is that the imbalance of the transaction should match the expected inputs and
|
||||
* outputs of a registered crafting recipe.
|
||||
*
|
||||
* This transaction allows multiple repetitions of the same recipe to be crafted in a single batch. In the case of batch
|
||||
* crafting, the number of unmatched inputs and outputs must be exactly divisible by the expected recipe ingredients and
|
||||
* results, with no remainder. Any leftovers are expected to be emitted back to the crafting grid.
|
||||
*/
|
||||
class CraftingTransaction extends InventoryTransaction{
|
||||
/** @var CraftingRecipe|null */
|
||||
protected $recipe;
|
||||
@ -50,6 +65,7 @@ class CraftingTransaction extends InventoryTransaction{
|
||||
* @param int $iterations
|
||||
*
|
||||
* @return int
|
||||
* @throws TransactionValidationException
|
||||
*/
|
||||
protected function matchRecipeItems(array $txItems, array $recipeItems, bool $wildcards, int $iterations = 0) : int{
|
||||
if(empty($recipeItems)){
|
||||
|
@ -29,14 +29,28 @@ use pocketmine\inventory\transaction\action\InventoryAction;
|
||||
use pocketmine\inventory\transaction\action\SlotChangeAction;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\Player;
|
||||
use function array_keys;
|
||||
use function assert;
|
||||
use function count;
|
||||
use function get_class;
|
||||
use function min;
|
||||
use function shuffle;
|
||||
use function spl_object_hash;
|
||||
|
||||
/**
|
||||
* This InventoryTransaction only allows doing Transaction between one / two inventories
|
||||
* This is the basic type for an inventory transaction. This is used for moving items between inventories, dropping
|
||||
* items and more. It allows transactions with multiple inputs and outputs.
|
||||
*
|
||||
* Validation **does not** depend on ordering. This means that the actions can appear in any order and still be valid.
|
||||
* The only validity requirement for this transaction type is that the balance of items must add up to zero. This means:
|
||||
* - No new outputs without matching input amounts
|
||||
* - No inputs without matching output amounts
|
||||
* - No userdata changes (item state, NBT, etc)
|
||||
*
|
||||
* A transaction is composed of "actions", which are pairs of inputs and outputs which target a specific itemstack in
|
||||
* a specific location. There are multiple types of inventory actions which might be involved in a transaction.
|
||||
*
|
||||
* @see InventoryAction
|
||||
*/
|
||||
class InventoryTransaction{
|
||||
protected $hasExecuted = false;
|
||||
@ -75,6 +89,11 @@ class InventoryTransaction{
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an **unordered** set of actions involved in this transaction.
|
||||
*
|
||||
* WARNING: This system is **explicitly designed NOT to care about ordering**. Any order seen in this set has NO
|
||||
* significance and should not be relied on.
|
||||
*
|
||||
* @return InventoryAction[]
|
||||
*/
|
||||
public function getActions() : array{
|
||||
@ -93,6 +112,19 @@ class InventoryTransaction{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Shuffles actions in the transaction to prevent external things relying on any implicit ordering.
|
||||
*/
|
||||
private function shuffleActions() : void{
|
||||
$keys = array_keys($this->actions);
|
||||
shuffle($keys);
|
||||
$actions = [];
|
||||
foreach($keys as $key){
|
||||
$actions[$key] = $this->actions[$key];
|
||||
}
|
||||
$this->actions = $actions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal This method should not be used by plugins, it's used to add tracked inventories for InventoryActions
|
||||
* involving inventories.
|
||||
@ -271,6 +303,8 @@ class InventoryTransaction{
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->shuffleActions();
|
||||
|
||||
$this->validate();
|
||||
|
||||
if(!$this->callExecuteEvent()){
|
||||
|
@ -85,7 +85,7 @@ class Bucket extends Item implements Consumable{
|
||||
$ev->call();
|
||||
if(!$ev->isCancelled()){
|
||||
$player->getLevel()->setBlock($blockReplace, $resultBlock->getFlowingForm(), true, true);
|
||||
$player->getLevel()->broadcastLevelSoundEvent($blockClicked->add(0.5, 0.5, 0.5), $resultBlock->getBucketEmptySound());
|
||||
$player->getLevel()->broadcastLevelSoundEvent($blockReplace->add(0.5, 0.5, 0.5), $resultBlock->getBucketEmptySound());
|
||||
|
||||
if($player->isSurvival()){
|
||||
$player->getInventory()->setItemInHand($ev->getItem());
|
||||
|
@ -46,7 +46,6 @@ use pocketmine\utils\Binary;
|
||||
use function array_map;
|
||||
use function base64_decode;
|
||||
use function base64_encode;
|
||||
use function bin2hex;
|
||||
use function file_get_contents;
|
||||
use function get_class;
|
||||
use function hex2bin;
|
||||
@ -138,6 +137,10 @@ class Item implements ItemIds, \JsonSerializable{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all previously added items from the creative menu.
|
||||
* Note: Players who are already online when this is called will not see this change.
|
||||
*/
|
||||
public static function clearCreativeItems(){
|
||||
Item::$creative = [];
|
||||
}
|
||||
@ -146,10 +149,22 @@ class Item implements ItemIds, \JsonSerializable{
|
||||
return Item::$creative;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an item to the creative menu.
|
||||
* Note: Players who are already online when this is called will not see this change.
|
||||
*
|
||||
* @param Item $item
|
||||
*/
|
||||
public static function addCreativeItem(Item $item){
|
||||
Item::$creative[] = clone $item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes an item from the creative menu.
|
||||
* Note: Players who are already online when this is called will not see this change.
|
||||
*
|
||||
* @param Item $item
|
||||
*/
|
||||
public static function removeCreativeItem(Item $item){
|
||||
$index = self::getCreativeItemIndex($item);
|
||||
if($index !== -1){
|
||||
@ -468,7 +483,7 @@ class Item implements ItemIds, \JsonSerializable{
|
||||
*/
|
||||
public function setCustomName(string $name) : Item{
|
||||
if($name === ""){
|
||||
$this->clearCustomName();
|
||||
return $this->clearCustomName();
|
||||
}
|
||||
|
||||
/** @var CompoundTag $display */
|
||||
@ -874,7 +889,7 @@ class Item implements ItemIds, \JsonSerializable{
|
||||
* @return string
|
||||
*/
|
||||
final public function __toString() : string{
|
||||
return "Item " . $this->name . " (" . $this->id . ":" . ($this->hasAnyDamageValue() ? "?" : $this->meta) . ")x" . $this->count . ($this->hasCompoundTag() ? " tags:0x" . bin2hex($this->getCompoundTag()) : "");
|
||||
return "Item " . $this->name . " (" . $this->id . ":" . ($this->hasAnyDamageValue() ? "?" : $this->meta) . ")x" . $this->count . ($this->hasCompoundTag() ? " tags:" . base64_encode($this->getCompoundTag()) : "");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -48,7 +48,7 @@ class Shears extends Tool{
|
||||
}
|
||||
|
||||
public function onDestroyBlock(Block $block) : bool{
|
||||
if($block->getHardness() === 0 or $block->isCompatibleWithTool($this)){
|
||||
if($block->getHardness() === 0.0 or $block->isCompatibleWithTool($this)){
|
||||
return $this->applyDamage(1);
|
||||
}
|
||||
return false;
|
||||
|
@ -190,7 +190,7 @@ class BaseLang{
|
||||
|
||||
$len = strlen($text);
|
||||
for($i = 0; $i < $len; ++$i){
|
||||
$c = $text{$i};
|
||||
$c = $text[$i];
|
||||
if($replaceString !== null){
|
||||
$ord = ord($c);
|
||||
if(
|
||||
|
Submodule src/pocketmine/lang/locale updated: 73ed1ab3e1...85343cfb7f
@ -89,6 +89,9 @@ class Explosion{
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates which blocks will be destroyed by this explosion. If explodeB() is called without calling this, no blocks
|
||||
* will be destroyed.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function explodeA() : bool{
|
||||
@ -148,6 +151,12 @@ class Explosion{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the explosion's effects on the world. This includes destroying blocks (if any), harming and knocking back entities,
|
||||
* and creating sounds and particles.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function explodeB() : bool{
|
||||
$send = [];
|
||||
$updateBlocks = [];
|
||||
|
@ -72,7 +72,7 @@ use pocketmine\metadata\Metadatable;
|
||||
use pocketmine\metadata\MetadataValue;
|
||||
use pocketmine\nbt\tag\ListTag;
|
||||
use pocketmine\nbt\tag\StringTag;
|
||||
use pocketmine\network\mcpe\protocol\AddEntityPacket;
|
||||
use pocketmine\network\mcpe\protocol\AddActorPacket;
|
||||
use pocketmine\network\mcpe\protocol\BatchPacket;
|
||||
use pocketmine\network\mcpe\protocol\DataPacket;
|
||||
use pocketmine\network\mcpe\protocol\LevelEventPacket;
|
||||
@ -564,7 +564,7 @@ class Level implements ChunkManager, Metadatable{
|
||||
$pk = new LevelSoundEventPacket();
|
||||
$pk->sound = $soundId;
|
||||
$pk->extraData = $extraData;
|
||||
$pk->entityType = AddEntityPacket::LEGACY_ID_MAP_BC[$entityTypeId] ?? ":";
|
||||
$pk->entityType = AddActorPacket::LEGACY_ID_MAP_BC[$entityTypeId] ?? ":";
|
||||
$pk->isBabyMob = $isBabyMob;
|
||||
$pk->disableRelativeVolume = $disableRelativeVolume;
|
||||
$pk->position = $pos->asVector3();
|
||||
@ -820,8 +820,13 @@ class Level implements ChunkManager, Metadatable{
|
||||
|
||||
//Delayed updates
|
||||
while($this->scheduledBlockUpdateQueue->count() > 0 and $this->scheduledBlockUpdateQueue->current()["priority"] <= $currentTick){
|
||||
$block = $this->getBlock($this->scheduledBlockUpdateQueue->extract()["data"]);
|
||||
unset($this->scheduledBlockUpdateQueueIndex[Level::blockHash($block->x, $block->y, $block->z)]);
|
||||
/** @var Vector3 $vec */
|
||||
$vec = $this->scheduledBlockUpdateQueue->extract()["data"];
|
||||
unset($this->scheduledBlockUpdateQueueIndex[Level::blockHash($vec->x, $vec->y, $vec->z)]);
|
||||
if(!$this->isInLoadedTerrain($vec)){
|
||||
continue;
|
||||
}
|
||||
$block = $this->getBlock($vec);
|
||||
$block->onScheduledUpdate();
|
||||
}
|
||||
|
||||
|
@ -460,7 +460,7 @@ class Chunk{
|
||||
* @return int 0-255
|
||||
*/
|
||||
public function getBiomeId(int $x, int $z) : int{
|
||||
return ord($this->biomeIds{($z << 4) | $x});
|
||||
return ord($this->biomeIds[($z << 4) | $x]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -472,7 +472,7 @@ class Chunk{
|
||||
*/
|
||||
public function setBiomeId(int $x, int $z, int $biomeId){
|
||||
$this->hasChanged = true;
|
||||
$this->biomeIds{($z << 4) | $x} = chr($biomeId & 0xff);
|
||||
$this->biomeIds[($z << 4) | $x] = chr($biomeId & 0xff);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -869,13 +869,10 @@ class Chunk{
|
||||
public function networkSerialize() : string{
|
||||
$result = "";
|
||||
$subChunkCount = $this->getSubChunkSendCount();
|
||||
$result .= chr($subChunkCount);
|
||||
for($y = 0; $y < $subChunkCount; ++$y){
|
||||
$result .= $this->subChunks[$y]->networkSerialize();
|
||||
}
|
||||
$result .= pack("v*", ...$this->heightMap)
|
||||
. $this->biomeIds
|
||||
. chr(0); //border block array count
|
||||
$result .= $this->biomeIds . chr(0); //border block array count
|
||||
//Border block entry format: 1 byte (4 bits X, 4 bits Z). These are however useless since they crash the regular client.
|
||||
|
||||
foreach($this->tiles as $tile){
|
||||
|
@ -71,31 +71,31 @@ class SubChunk implements SubChunkInterface{
|
||||
}
|
||||
|
||||
public function getBlockId(int $x, int $y, int $z) : int{
|
||||
return ord($this->ids{($x << 8) | ($z << 4) | $y});
|
||||
return ord($this->ids[($x << 8) | ($z << 4) | $y]);
|
||||
}
|
||||
|
||||
public function setBlockId(int $x, int $y, int $z, int $id) : bool{
|
||||
$this->ids{($x << 8) | ($z << 4) | $y} = chr($id);
|
||||
$this->ids[($x << 8) | ($z << 4) | $y] = chr($id);
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getBlockData(int $x, int $y, int $z) : int{
|
||||
return (ord($this->data{($x << 7) | ($z << 3) | ($y >> 1)}) >> (($y & 1) << 2)) & 0xf;
|
||||
return (ord($this->data[($x << 7) | ($z << 3) | ($y >> 1)]) >> (($y & 1) << 2)) & 0xf;
|
||||
}
|
||||
|
||||
public function setBlockData(int $x, int $y, int $z, int $data) : bool{
|
||||
$i = ($x << 7) | ($z << 3) | ($y >> 1);
|
||||
|
||||
$shift = ($y & 1) << 2;
|
||||
$byte = ord($this->data{$i});
|
||||
$this->data{$i} = chr(($byte & ~(0xf << $shift)) | (($data & 0xf) << $shift));
|
||||
$byte = ord($this->data[$i]);
|
||||
$this->data[$i] = chr(($byte & ~(0xf << $shift)) | (($data & 0xf) << $shift));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getFullBlock(int $x, int $y, int $z) : int{
|
||||
$i = ($x << 8) | ($z << 4) | $y;
|
||||
return (ord($this->ids{$i}) << 4) | ((ord($this->data{$i >> 1}) >> (($y & 1) << 2)) & 0xf);
|
||||
return (ord($this->ids[$i]) << 4) | ((ord($this->data[$i >> 1]) >> (($y & 1) << 2)) & 0xf);
|
||||
}
|
||||
|
||||
public function setBlock(int $x, int $y, int $z, ?int $id = null, ?int $data = null) : bool{
|
||||
@ -103,8 +103,8 @@ class SubChunk implements SubChunkInterface{
|
||||
$changed = false;
|
||||
if($id !== null){
|
||||
$block = chr($id);
|
||||
if($this->ids{$i} !== $block){
|
||||
$this->ids{$i} = $block;
|
||||
if($this->ids[$i] !== $block){
|
||||
$this->ids[$i] = $block;
|
||||
$changed = true;
|
||||
}
|
||||
}
|
||||
@ -113,10 +113,10 @@ class SubChunk implements SubChunkInterface{
|
||||
$i >>= 1;
|
||||
|
||||
$shift = ($y & 1) << 2;
|
||||
$oldPair = ord($this->data{$i});
|
||||
$oldPair = ord($this->data[$i]);
|
||||
$newPair = ($oldPair & ~(0xf << $shift)) | (($data & 0xf) << $shift);
|
||||
if($newPair !== $oldPair){
|
||||
$this->data{$i} = chr($newPair);
|
||||
$this->data[$i] = chr($newPair);
|
||||
$changed = true;
|
||||
}
|
||||
}
|
||||
@ -125,29 +125,29 @@ class SubChunk implements SubChunkInterface{
|
||||
}
|
||||
|
||||
public function getBlockLight(int $x, int $y, int $z) : int{
|
||||
return (ord($this->blockLight{($x << 7) | ($z << 3) | ($y >> 1)}) >> (($y & 1) << 2)) & 0xf;
|
||||
return (ord($this->blockLight[($x << 7) | ($z << 3) | ($y >> 1)]) >> (($y & 1) << 2)) & 0xf;
|
||||
}
|
||||
|
||||
public function setBlockLight(int $x, int $y, int $z, int $level) : bool{
|
||||
$i = ($x << 7) | ($z << 3) | ($y >> 1);
|
||||
|
||||
$shift = ($y & 1) << 2;
|
||||
$byte = ord($this->blockLight{$i});
|
||||
$this->blockLight{$i} = chr(($byte & ~(0xf << $shift)) | (($level & 0xf) << $shift));
|
||||
$byte = ord($this->blockLight[$i]);
|
||||
$this->blockLight[$i] = chr(($byte & ~(0xf << $shift)) | (($level & 0xf) << $shift));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getBlockSkyLight(int $x, int $y, int $z) : int{
|
||||
return (ord($this->skyLight{($x << 7) | ($z << 3) | ($y >> 1)}) >> (($y & 1) << 2)) & 0xf;
|
||||
return (ord($this->skyLight[($x << 7) | ($z << 3) | ($y >> 1)]) >> (($y & 1) << 2)) & 0xf;
|
||||
}
|
||||
|
||||
public function setBlockSkyLight(int $x, int $y, int $z, int $level) : bool{
|
||||
$i = ($x << 7) | ($z << 3) | ($y >> 1);
|
||||
|
||||
$shift = ($y & 1) << 2;
|
||||
$byte = ord($this->skyLight{$i});
|
||||
$this->skyLight{$i} = chr(($byte & ~(0xf << $shift)) | (($level & 0xf) << $shift));
|
||||
$byte = ord($this->skyLight[$i]);
|
||||
$this->skyLight[$i] = chr(($byte & ~(0xf << $shift)) | (($level & 0xf) << $shift));
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -156,7 +156,7 @@ class SubChunk implements SubChunkInterface{
|
||||
$low = ($x << 8) | ($z << 4);
|
||||
$i = $low | 0x0f;
|
||||
for(; $i >= $low; --$i){
|
||||
if($this->ids{$i} !== "\x00"){
|
||||
if($this->ids[$i] !== "\x00"){
|
||||
return $i & 0x0f;
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ namespace pocketmine\level\format\io;
|
||||
use pocketmine\level\format\Chunk;
|
||||
use pocketmine\level\Level;
|
||||
use pocketmine\network\mcpe\protocol\BatchPacket;
|
||||
use pocketmine\network\mcpe\protocol\FullChunkDataPacket;
|
||||
use pocketmine\network\mcpe\protocol\LevelChunkPacket;
|
||||
use pocketmine\scheduler\AsyncTask;
|
||||
use pocketmine\Server;
|
||||
use function assert;
|
||||
@ -42,6 +42,9 @@ class ChunkRequestTask extends AsyncTask{
|
||||
|
||||
protected $compressionLevel;
|
||||
|
||||
/** @var int */
|
||||
private $subChunkCount;
|
||||
|
||||
public function __construct(Level $level, int $chunkX, int $chunkZ, Chunk $chunk){
|
||||
$this->levelId = $level->getId();
|
||||
$this->compressionLevel = $level->getServer()->networkCompressionLevel;
|
||||
@ -49,13 +52,11 @@ class ChunkRequestTask extends AsyncTask{
|
||||
$this->chunk = $chunk->networkSerialize();
|
||||
$this->chunkX = $chunkX;
|
||||
$this->chunkZ = $chunkZ;
|
||||
$this->subChunkCount = $chunk->getSubChunkSendCount();
|
||||
}
|
||||
|
||||
public function onRun(){
|
||||
$pk = new FullChunkDataPacket();
|
||||
$pk->chunkX = $this->chunkX;
|
||||
$pk->chunkZ = $this->chunkZ;
|
||||
$pk->data = $this->chunk;
|
||||
$pk = LevelChunkPacket::withoutCache($this->chunkX, $this->chunkZ, $this->subChunkCount, $this->chunk);
|
||||
|
||||
$batch = new BatchPacket();
|
||||
$batch->addPacket($pk);
|
||||
|
@ -47,7 +47,7 @@ if(!extension_loaded('pocketmine_chunkutils')){
|
||||
for($z = $x; $z < $zM; $z += 16){
|
||||
$yM = $z + 4096;
|
||||
for($y = $z; $y < $yM; $y += 256){
|
||||
$result{$i} = $array{$y};
|
||||
$result[$i] = $array[$y];
|
||||
++$i;
|
||||
}
|
||||
}
|
||||
@ -76,13 +76,13 @@ if(!extension_loaded('pocketmine_chunkutils')){
|
||||
for($y = 0; $y < 8; ++$y){
|
||||
$j = (($y << 8) | $zx);
|
||||
$j80 = ($j | 0x80);
|
||||
if($array{$j} === $commonValue and $array{$j80} === $commonValue){
|
||||
if($array[$j] === $commonValue and $array[$j80] === $commonValue){
|
||||
//values are already filled
|
||||
}else{
|
||||
$i1 = ord($array{$j});
|
||||
$i2 = ord($array{$j80});
|
||||
$result{$i} = chr(($i2 << 4) | ($i1 & 0x0f));
|
||||
$result{$i | 0x80} = chr(($i1 >> 4) | ($i2 & 0xf0));
|
||||
$i1 = ord($array[$j]);
|
||||
$i2 = ord($array[$j80]);
|
||||
$result[$i] = chr(($i2 << 4) | ($i1 & 0x0f));
|
||||
$result[$i | 0x80] = chr(($i1 >> 4) | ($i2 & 0xf0));
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
@ -104,7 +104,7 @@ if(!extension_loaded('pocketmine_chunkutils')){
|
||||
public static function convertBiomeColors(array $array) : string{
|
||||
$result = str_repeat("\x00", 256);
|
||||
foreach($array as $i => $color){
|
||||
$result{$i} = chr(($color >> 24) & 0xff);
|
||||
$result[$i] = chr(($color >> 24) & 0xff);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ class LevelDB extends BaseLevelProvider{
|
||||
|
||||
$version = $this->levelData->getInt("StorageVersion", INT32_MAX, true);
|
||||
if($version > self::CURRENT_STORAGE_VERSION){
|
||||
throw new LevelException("Specified LevelDB world format version ($version) is not supported by " . \pocketmine\NAME);
|
||||
throw new LevelException("Specified LevelDB world format version ($version) is not supported");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,11 +27,10 @@ use pocketmine\level\format\ChunkException;
|
||||
use pocketmine\level\format\io\exception\CorruptedChunkException;
|
||||
use pocketmine\utils\Binary;
|
||||
use pocketmine\utils\MainLogger;
|
||||
use function array_fill;
|
||||
use function ceil;
|
||||
use function chr;
|
||||
use function fclose;
|
||||
use function fgetc;
|
||||
use function feof;
|
||||
use function file_exists;
|
||||
use function filesize;
|
||||
use function fopen;
|
||||
@ -40,6 +39,7 @@ use function fseek;
|
||||
use function ftruncate;
|
||||
use function fwrite;
|
||||
use function is_resource;
|
||||
use function max;
|
||||
use function ord;
|
||||
use function pack;
|
||||
use function str_pad;
|
||||
@ -60,6 +60,8 @@ class RegionLoader{
|
||||
public const MAX_SECTOR_LENGTH = 255 << 12; //255 sectors (~0.996 MiB)
|
||||
public const REGION_HEADER_LENGTH = 8192; //4096 location table + 4096 timestamps
|
||||
|
||||
private const FIRST_SECTOR = 2; //location table occupies 0 and 1
|
||||
|
||||
public static $COMPRESSION_LEVEL = 7;
|
||||
|
||||
/** @var int */
|
||||
@ -71,8 +73,8 @@ class RegionLoader{
|
||||
/** @var resource */
|
||||
protected $filePointer;
|
||||
/** @var int */
|
||||
protected $lastSector;
|
||||
/** @var int[][] [offset in sectors, chunk size in sectors, timestamp] */
|
||||
protected $nextSector = self::FIRST_SECTOR;
|
||||
/** @var RegionLocationTableEntry[] */
|
||||
protected $locationTable = [];
|
||||
/** @var int */
|
||||
public $lastUsed = 0;
|
||||
@ -83,6 +85,9 @@ class RegionLoader{
|
||||
$this->filePath = $filePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws CorruptedRegionException
|
||||
*/
|
||||
public function open(){
|
||||
$exists = file_exists($this->filePath);
|
||||
if(!$exists){
|
||||
@ -111,7 +116,7 @@ class RegionLoader{
|
||||
}
|
||||
|
||||
protected function isChunkGenerated(int $index) : bool{
|
||||
return !($this->locationTable[$index][0] === 0 or $this->locationTable[$index][1] === 0);
|
||||
return !$this->locationTable[$index]->isNull();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -131,23 +136,25 @@ class RegionLoader{
|
||||
return null;
|
||||
}
|
||||
|
||||
fseek($this->filePointer, $this->locationTable[$index][0] << 12);
|
||||
fseek($this->filePointer, $this->locationTable[$index]->getFirstSector() << 12);
|
||||
|
||||
$prefix = fread($this->filePointer, 4);
|
||||
if($prefix === false or strlen($prefix) !== 4){
|
||||
throw new CorruptedChunkException("Corrupted chunk header detected (unexpected end of file reading length prefix)");
|
||||
}
|
||||
$length = Binary::readInt($prefix);
|
||||
|
||||
if($length <= 0 or $length > self::MAX_SECTOR_LENGTH){ //Not yet generated / corrupted
|
||||
if($length >= self::MAX_SECTOR_LENGTH){
|
||||
throw new CorruptedChunkException("Corrupted chunk header detected (sector count $length larger than max " . self::MAX_SECTOR_LENGTH . ")");
|
||||
}
|
||||
if($length <= 0){ //TODO: if we reached here, the locationTable probably needs updating
|
||||
return null;
|
||||
}
|
||||
if($length > self::MAX_SECTOR_LENGTH){ //corrupted
|
||||
throw new CorruptedChunkException("Length for chunk x=$x,z=$z ($length) is larger than maximum " . self::MAX_SECTOR_LENGTH);
|
||||
}
|
||||
|
||||
if($length > ($this->locationTable[$index][1] << 12)){ //Invalid chunk, bigger than defined number of sectors
|
||||
MainLogger::getLogger()->error("Chunk x=$x,z=$z length mismatch (expected " . ($this->locationTable[$index][1] << 12) . " sectors, got $length sectors)");
|
||||
$this->locationTable[$index][1] = $length >> 12;
|
||||
if($length > ($this->locationTable[$index]->getSectorCount() << 12)){ //Invalid chunk, bigger than defined number of sectors
|
||||
MainLogger::getLogger()->error("Chunk x=$x,z=$z length mismatch (expected " . ($this->locationTable[$index]->getSectorCount() << 12) . " sectors, got $length sectors)");
|
||||
$old = $this->locationTable[$index];
|
||||
$this->locationTable[$index] = new RegionLocationTableEntry($old->getFirstSector(), $length >> 12, time());
|
||||
$this->writeLocationIndex($index);
|
||||
}
|
||||
|
||||
@ -190,26 +197,22 @@ class RegionLoader{
|
||||
if($length + 4 > self::MAX_SECTOR_LENGTH){
|
||||
throw new ChunkException("Chunk is too big! " . ($length + 4) . " > " . self::MAX_SECTOR_LENGTH);
|
||||
}
|
||||
$sectors = (int) ceil(($length + 4) / 4096);
|
||||
|
||||
$newSize = (int) ceil(($length + 4) / 4096);
|
||||
$index = self::getChunkOffset($x, $z);
|
||||
$indexChanged = false;
|
||||
if($this->locationTable[$index][1] < $sectors){
|
||||
$this->locationTable[$index][0] = $this->lastSector + 1;
|
||||
$this->lastSector += $sectors; //The GC will clean this shift "later"
|
||||
$indexChanged = true;
|
||||
}elseif($this->locationTable[$index][1] != $sectors){
|
||||
$indexChanged = true;
|
||||
$offset = $this->locationTable[$index]->getFirstSector();
|
||||
|
||||
if($this->locationTable[$index]->getSectorCount() < $newSize){
|
||||
$offset = $this->nextSector;
|
||||
}
|
||||
|
||||
$this->locationTable[$index][1] = $sectors;
|
||||
$this->locationTable[$index][2] = time();
|
||||
$this->locationTable[$index] = new RegionLocationTableEntry($offset, $newSize, time());
|
||||
$this->bumpNextFreeSector($this->locationTable[$index]);
|
||||
|
||||
fseek($this->filePointer, $this->locationTable[$index][0] << 12);
|
||||
fwrite($this->filePointer, str_pad(Binary::writeInt($length) . chr(self::COMPRESSION_ZLIB) . $chunkData, $sectors << 12, "\x00", STR_PAD_RIGHT));
|
||||
fseek($this->filePointer, $offset << 12);
|
||||
fwrite($this->filePointer, str_pad(Binary::writeInt($length) . chr(self::COMPRESSION_ZLIB) . $chunkData, $newSize << 12, "\x00", STR_PAD_RIGHT));
|
||||
|
||||
if($indexChanged){
|
||||
$this->writeLocationIndex($index);
|
||||
}
|
||||
$this->writeLocationIndex($index);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -220,8 +223,8 @@ class RegionLoader{
|
||||
*/
|
||||
public function removeChunk(int $x, int $z){
|
||||
$index = self::getChunkOffset($x, $z);
|
||||
$this->locationTable[$index][0] = 0;
|
||||
$this->locationTable[$index][1] = 0;
|
||||
$this->locationTable[$index] = new RegionLocationTableEntry(0, 0, 0);
|
||||
$this->writeLocationIndex($index);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -263,9 +266,11 @@ class RegionLoader{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws CorruptedRegionException
|
||||
*/
|
||||
protected function loadLocationTable(){
|
||||
fseek($this->filePointer, 0);
|
||||
$this->lastSector = 1;
|
||||
|
||||
$headerRaw = fread($this->filePointer, self::REGION_HEADER_LENGTH);
|
||||
if(($len = strlen($headerRaw)) !== self::REGION_HEADER_LENGTH){
|
||||
@ -273,43 +278,64 @@ class RegionLoader{
|
||||
}
|
||||
|
||||
$data = unpack("N*", $headerRaw);
|
||||
/** @var int[] $usedOffsets */
|
||||
$usedOffsets = [];
|
||||
|
||||
for($i = 0; $i < 1024; ++$i){
|
||||
$index = $data[$i + 1];
|
||||
$offset = $index >> 8;
|
||||
if($offset !== 0){
|
||||
self::getChunkCoords($i, $x, $z);
|
||||
$fileOffset = $offset << 12;
|
||||
$timestamp = $data[$i + 1025];
|
||||
|
||||
fseek($this->filePointer, $fileOffset);
|
||||
if(fgetc($this->filePointer) === false){ //Try and read from the location
|
||||
throw new CorruptedRegionException("Region file location offset x=$x,z=$z points to invalid file location $fileOffset");
|
||||
}elseif(isset($usedOffsets[$offset])){
|
||||
self::getChunkCoords($usedOffsets[$offset], $existingX, $existingZ);
|
||||
throw new CorruptedRegionException("Found two chunk offsets (chunk1: x=$existingX,z=$existingZ, chunk2: x=$x,z=$z) pointing to the file location $fileOffset");
|
||||
}else{
|
||||
$usedOffsets[$offset] = $i;
|
||||
}
|
||||
}
|
||||
|
||||
$this->locationTable[$i] = [$index >> 8, $index & 0xff, $data[1024 + $i + 1]];
|
||||
if(($this->locationTable[$i][0] + $this->locationTable[$i][1] - 1) > $this->lastSector){
|
||||
$this->lastSector = $this->locationTable[$i][0] + $this->locationTable[$i][1] - 1;
|
||||
if($offset === 0){
|
||||
$this->locationTable[$i] = new RegionLocationTableEntry(0, 0, 0);
|
||||
}else{
|
||||
$this->locationTable[$i] = new RegionLocationTableEntry($offset, $index & 0xff, $timestamp);
|
||||
$this->bumpNextFreeSector($this->locationTable[$i]);
|
||||
}
|
||||
}
|
||||
|
||||
$this->checkLocationTableValidity();
|
||||
|
||||
fseek($this->filePointer, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws CorruptedRegionException
|
||||
*/
|
||||
private function checkLocationTableValidity() : void{
|
||||
/** @var int[] $usedOffsets */
|
||||
$usedOffsets = [];
|
||||
|
||||
for($i = 0; $i < 1024; ++$i){
|
||||
$entry = $this->locationTable[$i];
|
||||
if($entry->isNull()){
|
||||
continue;
|
||||
}
|
||||
|
||||
self::getChunkCoords($i, $x, $z);
|
||||
$offset = $entry->getFirstSector();
|
||||
$fileOffset = $offset << 12;
|
||||
|
||||
//TODO: more validity checks
|
||||
|
||||
fseek($this->filePointer, $fileOffset);
|
||||
if(feof($this->filePointer)){
|
||||
throw new CorruptedRegionException("Region file location offset x=$x,z=$z points to invalid file location $fileOffset");
|
||||
}
|
||||
if(isset($usedOffsets[$offset])){
|
||||
self::getChunkCoords($usedOffsets[$offset], $existingX, $existingZ);
|
||||
throw new CorruptedRegionException("Found two chunk offsets (chunk1: x=$existingX,z=$existingZ, chunk2: x=$x,z=$z) pointing to the file location $fileOffset");
|
||||
}
|
||||
$usedOffsets[$offset] = $i;
|
||||
}
|
||||
}
|
||||
|
||||
private function writeLocationTable(){
|
||||
$write = [];
|
||||
|
||||
for($i = 0; $i < 1024; ++$i){
|
||||
$write[] = (($this->locationTable[$i][0] << 8) | $this->locationTable[$i][1]);
|
||||
$write[] = (($this->locationTable[$i]->getFirstSector() << 8) | $this->locationTable[$i]->getSectorCount());
|
||||
}
|
||||
for($i = 0; $i < 1024; ++$i){
|
||||
$write[] = $this->locationTable[$i][2];
|
||||
$write[] = $this->locationTable[$i]->getTimestamp();
|
||||
}
|
||||
fseek($this->filePointer, 0);
|
||||
fwrite($this->filePointer, pack("N*", ...$write), 4096 * 2);
|
||||
@ -317,16 +343,21 @@ class RegionLoader{
|
||||
|
||||
protected function writeLocationIndex($index){
|
||||
fseek($this->filePointer, $index << 2);
|
||||
fwrite($this->filePointer, Binary::writeInt(($this->locationTable[$index][0] << 8) | $this->locationTable[$index][1]), 4);
|
||||
fwrite($this->filePointer, Binary::writeInt(($this->locationTable[$index]->getFirstSector() << 8) | $this->locationTable[$index]->getSectorCount()), 4);
|
||||
fseek($this->filePointer, 4096 + ($index << 2));
|
||||
fwrite($this->filePointer, Binary::writeInt($this->locationTable[$index][2]), 4);
|
||||
fwrite($this->filePointer, Binary::writeInt($this->locationTable[$index]->getTimestamp()), 4);
|
||||
}
|
||||
|
||||
protected function createBlank(){
|
||||
fseek($this->filePointer, 0);
|
||||
ftruncate($this->filePointer, 8192); // this fills the file with the null byte
|
||||
$this->lastSector = 1;
|
||||
$this->locationTable = array_fill(0, 1024, [0, 0, 0]);
|
||||
for($i = 0; $i < 1024; ++$i){
|
||||
$this->locationTable[$i] = new RegionLocationTableEntry(0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
private function bumpNextFreeSector(RegionLocationTableEntry $entry) : void{
|
||||
$this->nextSector = max($this->nextSector, $entry->getLastSector()) + 1;
|
||||
}
|
||||
|
||||
public function getX() : int{
|
||||
|
@ -0,0 +1,98 @@
|
||||
<?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\level\format\io\region;
|
||||
|
||||
use function range;
|
||||
|
||||
class RegionLocationTableEntry{
|
||||
|
||||
/** @var int */
|
||||
private $firstSector;
|
||||
/** @var int */
|
||||
private $sectorCount;
|
||||
/** @var int */
|
||||
private $timestamp;
|
||||
|
||||
/**
|
||||
* @param int $firstSector
|
||||
* @param int $sectorCount
|
||||
* @param int $timestamp
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function __construct(int $firstSector, int $sectorCount, int $timestamp){
|
||||
if($firstSector < 0){
|
||||
throw new \InvalidArgumentException("Start sector must be positive, got $firstSector");
|
||||
}
|
||||
$this->firstSector = $firstSector;
|
||||
if($sectorCount < 0 or $sectorCount > 255){
|
||||
throw new \InvalidArgumentException("Sector count must be in range 0...255, got $sectorCount");
|
||||
}
|
||||
$this->sectorCount = $sectorCount;
|
||||
$this->timestamp = $timestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getFirstSector() : int{
|
||||
return $this->firstSector;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getLastSector() : int{
|
||||
return $this->firstSector + $this->sectorCount - 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of sector offsets reserved by this chunk.
|
||||
* @return int[]
|
||||
*/
|
||||
public function getUsedSectors() : array{
|
||||
return range($this->getFirstSector(), $this->getLastSector());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getSectorCount() : int{
|
||||
return $this->sectorCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getTimestamp() : int{
|
||||
return $this->timestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isNull() : bool{
|
||||
return $this->firstSector === 0 or $this->sectorCount === 0;
|
||||
}
|
||||
}
|
@ -30,7 +30,7 @@ use pocketmine\level\ChunkManager;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\utils\Random;
|
||||
use pocketmine\utils\Utils;
|
||||
use function ctype_digit;
|
||||
use function preg_match;
|
||||
|
||||
abstract class Generator{
|
||||
|
||||
@ -44,7 +44,7 @@ abstract class Generator{
|
||||
public static function convertSeed(string $seed) : ?int{
|
||||
if($seed === ""){ //empty seed should cause a random seed to be selected - can't use 0 here because 0 is a valid seed
|
||||
$convertedSeed = null;
|
||||
}elseif(ctype_digit($seed)){ //this avoids treating seeds like "404.4" as integer seeds
|
||||
}elseif(preg_match('/^-?\d+$/', $seed) === 1){ //this avoids treating seeds like "404.4" as integer seeds
|
||||
$convertedSeed = (int) $seed;
|
||||
}else{
|
||||
$convertedSeed = Utils::javaStringHash($seed);
|
||||
|
@ -48,7 +48,7 @@ class GroundCover extends Populator{
|
||||
|
||||
$column = $chunk->getBlockIdColumn($x, $z);
|
||||
for($y = 127; $y > 0; --$y){
|
||||
if($column{$y} !== "\x00" and !BlockFactory::get(ord($column{$y}))->isTransparent()){
|
||||
if($column[$y] !== "\x00" and !BlockFactory::get(ord($column[$y]))->isTransparent()){
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -56,10 +56,10 @@ class GroundCover extends Populator{
|
||||
$endY = $startY - count($cover);
|
||||
for($y = $startY; $y > $endY and $y >= 0; --$y){
|
||||
$b = $cover[$startY - $y];
|
||||
if($column{$y} === "\x00" and $b->isSolid()){
|
||||
if($column[$y] === "\x00" and $b->isSolid()){
|
||||
break;
|
||||
}
|
||||
if($b->canBeFlowedInto() and BlockFactory::get(ord($column{$y})) instanceof Liquid){
|
||||
if($b->canBeFlowedInto() and BlockFactory::get(ord($column[$y])) instanceof Liquid){
|
||||
continue;
|
||||
}
|
||||
if($b->getDamage() === 0){
|
||||
|
@ -30,8 +30,8 @@ use pocketmine\utils\Random;
|
||||
class TallGrass extends Populator{
|
||||
/** @var ChunkManager */
|
||||
private $level;
|
||||
private $randomAmount;
|
||||
private $baseAmount;
|
||||
private $randomAmount = 1;
|
||||
private $baseAmount = 0;
|
||||
|
||||
public function setRandomAmount($amount){
|
||||
$this->randomAmount = $amount;
|
||||
@ -43,7 +43,7 @@ class TallGrass extends Populator{
|
||||
|
||||
public function populate(ChunkManager $level, int $chunkX, int $chunkZ, Random $random){
|
||||
$this->level = $level;
|
||||
$amount = $random->nextRange(0, $this->randomAmount + 1) + $this->baseAmount;
|
||||
$amount = $random->nextRange(0, $this->randomAmount) + $this->baseAmount;
|
||||
for($i = 0; $i < $amount; ++$i){
|
||||
$x = $random->nextRange($chunkX * 16, $chunkX * 16 + 15);
|
||||
$z = $random->nextRange($chunkZ * 16, $chunkZ * 16 + 15);
|
||||
|
@ -32,8 +32,8 @@ use pocketmine\utils\Random;
|
||||
class Tree extends Populator{
|
||||
/** @var ChunkManager */
|
||||
private $level;
|
||||
private $randomAmount;
|
||||
private $baseAmount;
|
||||
private $randomAmount = 1;
|
||||
private $baseAmount = 0;
|
||||
|
||||
private $type;
|
||||
|
||||
@ -51,7 +51,7 @@ class Tree extends Populator{
|
||||
|
||||
public function populate(ChunkManager $level, int $chunkX, int $chunkZ, Random $random){
|
||||
$this->level = $level;
|
||||
$amount = $random->nextRange(0, $this->randomAmount + 1) + $this->baseAmount;
|
||||
$amount = $random->nextRange(0, $this->randomAmount) + $this->baseAmount;
|
||||
for($i = 0; $i < $amount; ++$i){
|
||||
$x = $random->nextRange($chunkX << 4, ($chunkX << 4) + 15);
|
||||
$z = $random->nextRange($chunkZ << 4, ($chunkZ << 4) + 15);
|
||||
|
@ -34,7 +34,7 @@ abstract class LightUpdate{
|
||||
/** @var ChunkManager */
|
||||
protected $level;
|
||||
|
||||
/** @var int[] blockhash => new light level */
|
||||
/** @var int[][] blockhash => [x, y, z, new light level] */
|
||||
protected $updateNodes = [];
|
||||
|
||||
/** @var \SplQueue */
|
||||
|
@ -30,7 +30,7 @@ use pocketmine\item\ItemFactory;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\network\mcpe\protocol\AddPlayerPacket;
|
||||
use pocketmine\network\mcpe\protocol\PlayerListPacket;
|
||||
use pocketmine\network\mcpe\protocol\RemoveEntityPacket;
|
||||
use pocketmine\network\mcpe\protocol\RemoveActorPacket;
|
||||
use pocketmine\network\mcpe\protocol\types\PlayerListEntry;
|
||||
use pocketmine\utils\UUID;
|
||||
use function str_repeat;
|
||||
@ -84,7 +84,7 @@ class FloatingTextParticle extends Particle{
|
||||
if($this->entityId === null){
|
||||
$this->entityId = Entity::$entityCount++;
|
||||
}else{
|
||||
$pk0 = new RemoveEntityPacket();
|
||||
$pk0 = new RemoveActorPacket();
|
||||
$pk0->entityUniqueId = $this->entityId;
|
||||
|
||||
$p[] = $pk0;
|
||||
|
@ -29,59 +29,67 @@ use pocketmine\network\mcpe\protocol\DataPacket;
|
||||
abstract class Particle extends Vector3{
|
||||
|
||||
public const TYPE_BUBBLE = 1;
|
||||
public const TYPE_CRITICAL = 2;
|
||||
public const TYPE_BLOCK_FORCE_FIELD = 3;
|
||||
public const TYPE_SMOKE = 4;
|
||||
public const TYPE_EXPLODE = 5;
|
||||
public const TYPE_EVAPORATION = 6;
|
||||
public const TYPE_FLAME = 7;
|
||||
public const TYPE_LAVA = 8;
|
||||
public const TYPE_LARGE_SMOKE = 9;
|
||||
public const TYPE_REDSTONE = 10;
|
||||
public const TYPE_RISING_RED_DUST = 11;
|
||||
public const TYPE_ITEM_BREAK = 12;
|
||||
public const TYPE_SNOWBALL_POOF = 13;
|
||||
public const TYPE_HUGE_EXPLODE = 14;
|
||||
public const TYPE_HUGE_EXPLODE_SEED = 15;
|
||||
public const TYPE_MOB_FLAME = 16;
|
||||
public const TYPE_HEART = 17;
|
||||
public const TYPE_TERRAIN = 18;
|
||||
public const TYPE_SUSPENDED_TOWN = 19, TYPE_TOWN_AURA = 19;
|
||||
public const TYPE_PORTAL = 20;
|
||||
public const TYPE_SPLASH = 21, TYPE_WATER_SPLASH = 21;
|
||||
public const TYPE_WATER_WAKE = 22;
|
||||
public const TYPE_DRIP_WATER = 23;
|
||||
public const TYPE_DRIP_LAVA = 24;
|
||||
public const TYPE_FALLING_DUST = 25, TYPE_DUST = 25;
|
||||
public const TYPE_MOB_SPELL = 26;
|
||||
public const TYPE_MOB_SPELL_AMBIENT = 27;
|
||||
public const TYPE_MOB_SPELL_INSTANTANEOUS = 28;
|
||||
public const TYPE_INK = 29;
|
||||
public const TYPE_SLIME = 30;
|
||||
public const TYPE_RAIN_SPLASH = 31;
|
||||
public const TYPE_VILLAGER_ANGRY = 32;
|
||||
public const TYPE_VILLAGER_HAPPY = 33;
|
||||
public const TYPE_ENCHANTMENT_TABLE = 34;
|
||||
public const TYPE_TRACKING_EMITTER = 35;
|
||||
public const TYPE_NOTE = 36;
|
||||
public const TYPE_WITCH_SPELL = 37;
|
||||
public const TYPE_CARROT = 38;
|
||||
//39 unknown
|
||||
public const TYPE_END_ROD = 40;
|
||||
public const TYPE_DRAGONS_BREATH = 41;
|
||||
public const TYPE_SPIT = 42;
|
||||
public const TYPE_TOTEM = 43;
|
||||
public const TYPE_FOOD = 44;
|
||||
public const TYPE_FIREWORKS_STARTER = 45;
|
||||
public const TYPE_FIREWORKS_SPARK = 46;
|
||||
public const TYPE_FIREWORKS_OVERLAY = 47;
|
||||
public const TYPE_BALLOON_GAS = 48;
|
||||
public const TYPE_COLORED_FLAME = 49;
|
||||
public const TYPE_SPARKLER = 50;
|
||||
public const TYPE_CONDUIT = 51;
|
||||
public const TYPE_BUBBLE_COLUMN_UP = 52;
|
||||
public const TYPE_BUBBLE_COLUMN_DOWN = 53;
|
||||
public const TYPE_SNEEZE = 54;
|
||||
//2 same as 1
|
||||
public const TYPE_CRITICAL = 3;
|
||||
public const TYPE_BLOCK_FORCE_FIELD = 4;
|
||||
public const TYPE_SMOKE = 5;
|
||||
public const TYPE_EXPLODE = 6;
|
||||
public const TYPE_EVAPORATION = 7;
|
||||
public const TYPE_FLAME = 8;
|
||||
public const TYPE_LAVA = 9;
|
||||
public const TYPE_LARGE_SMOKE = 10;
|
||||
public const TYPE_REDSTONE = 11;
|
||||
public const TYPE_RISING_RED_DUST = 12;
|
||||
//62 same as 12
|
||||
public const TYPE_ITEM_BREAK = 13;
|
||||
public const TYPE_SNOWBALL_POOF = 14;
|
||||
public const TYPE_HUGE_EXPLODE = 15;
|
||||
//60 same as 15
|
||||
public const TYPE_HUGE_EXPLODE_SEED = 16;
|
||||
public const TYPE_MOB_FLAME = 17;
|
||||
public const TYPE_HEART = 18;
|
||||
public const TYPE_TERRAIN = 19;
|
||||
public const TYPE_SUSPENDED_TOWN = 20, TYPE_TOWN_AURA = 20;
|
||||
//61 same as 20
|
||||
public const TYPE_PORTAL = 21;
|
||||
//22 same as 21
|
||||
public const TYPE_SPLASH = 23, TYPE_WATER_SPLASH = 23;
|
||||
//24 same as 23
|
||||
public const TYPE_WATER_WAKE = 25;
|
||||
public const TYPE_DRIP_WATER = 26;
|
||||
public const TYPE_DRIP_LAVA = 27;
|
||||
public const TYPE_FALLING_DUST = 28, TYPE_DUST = 28;
|
||||
public const TYPE_MOB_SPELL = 29;
|
||||
public const TYPE_MOB_SPELL_AMBIENT = 30;
|
||||
public const TYPE_MOB_SPELL_INSTANTANEOUS = 31;
|
||||
public const TYPE_INK = 32;
|
||||
public const TYPE_SLIME = 33;
|
||||
public const TYPE_RAIN_SPLASH = 34;
|
||||
public const TYPE_VILLAGER_ANGRY = 35;
|
||||
//59 same as 35
|
||||
public const TYPE_VILLAGER_HAPPY = 36;
|
||||
public const TYPE_ENCHANTMENT_TABLE = 37;
|
||||
public const TYPE_TRACKING_EMITTER = 38;
|
||||
public const TYPE_NOTE = 39;
|
||||
public const TYPE_WITCH_SPELL = 40;
|
||||
public const TYPE_CARROT = 41;
|
||||
//42 unknown
|
||||
public const TYPE_END_ROD = 43;
|
||||
//58 same as 43
|
||||
public const TYPE_DRAGONS_BREATH = 44;
|
||||
public const TYPE_SPIT = 45;
|
||||
public const TYPE_TOTEM = 46;
|
||||
public const TYPE_FOOD = 47;
|
||||
public const TYPE_FIREWORKS_STARTER = 48;
|
||||
public const TYPE_FIREWORKS_SPARK = 49;
|
||||
public const TYPE_FIREWORKS_OVERLAY = 50;
|
||||
public const TYPE_BALLOON_GAS = 51;
|
||||
public const TYPE_COLORED_FLAME = 52;
|
||||
public const TYPE_SPARKLER = 53;
|
||||
public const TYPE_CONDUIT = 54;
|
||||
public const TYPE_BUBBLE_COLUMN_UP = 55;
|
||||
public const TYPE_BUBBLE_COLUMN_DOWN = 56;
|
||||
public const TYPE_SNEEZE = 57;
|
||||
|
||||
/**
|
||||
* @return DataPacket|DataPacket[]
|
||||
|
@ -27,14 +27,17 @@ namespace pocketmine\network\mcpe;
|
||||
|
||||
use pocketmine\entity\Attribute;
|
||||
use pocketmine\entity\Entity;
|
||||
use pocketmine\item\Durable;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\item\ItemFactory;
|
||||
use pocketmine\item\ItemIds;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\nbt\NetworkLittleEndianNBTStream;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\nbt\tag\IntTag;
|
||||
use pocketmine\network\mcpe\protocol\types\CommandOriginData;
|
||||
use pocketmine\network\mcpe\protocol\types\EntityLink;
|
||||
use pocketmine\network\mcpe\protocol\types\StructureSettings;
|
||||
use pocketmine\utils\BinaryStream;
|
||||
use pocketmine\utils\UUID;
|
||||
use function count;
|
||||
@ -42,6 +45,9 @@ use function strlen;
|
||||
|
||||
class NetworkBinaryStream extends BinaryStream{
|
||||
|
||||
private const DAMAGE_TAG = "Damage"; //TAG_Int
|
||||
private const DAMAGE_TAG_CONFLICT_RESOLUTION = "___Damage_ProtocolCollisionResolution___";
|
||||
|
||||
public function getString() : string{
|
||||
return $this->get($this->getUnsignedVarInt());
|
||||
}
|
||||
@ -76,15 +82,12 @@ class NetworkBinaryStream extends BinaryStream{
|
||||
|
||||
$auxValue = $this->getVarInt();
|
||||
$data = $auxValue >> 8;
|
||||
if($data === 0x7fff){
|
||||
$data = -1;
|
||||
}
|
||||
$cnt = $auxValue & 0xff;
|
||||
|
||||
$nbtLen = $this->getLShort();
|
||||
|
||||
/** @var CompoundTag|string $nbt */
|
||||
$nbt = "";
|
||||
/** @var CompoundTag|null $nbt */
|
||||
$nbt = null;
|
||||
if($nbtLen === 0xffff){
|
||||
$c = $this->getByte();
|
||||
if($c !== 1){
|
||||
@ -108,7 +111,22 @@ class NetworkBinaryStream extends BinaryStream{
|
||||
if($id === ItemIds::SHIELD){
|
||||
$this->getVarLong(); //"blocking tick" (ffs mojang)
|
||||
}
|
||||
|
||||
if($nbt !== null){
|
||||
if($nbt->hasTag(self::DAMAGE_TAG, IntTag::class)){
|
||||
$data = $nbt->getInt(self::DAMAGE_TAG);
|
||||
$nbt->removeTag(self::DAMAGE_TAG);
|
||||
if($nbt->count() === 0){
|
||||
$nbt = null;
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
end:
|
||||
return ItemFactory::get($id, $data, $cnt, $nbt);
|
||||
}
|
||||
|
||||
@ -124,10 +142,27 @@ class NetworkBinaryStream extends BinaryStream{
|
||||
$auxValue = (($item->getDamage() & 0x7fff) << 8) | $item->getCount();
|
||||
$this->putVarInt($auxValue);
|
||||
|
||||
$nbt = null;
|
||||
if($item->hasCompoundTag()){
|
||||
$nbt = clone $item->getNamedTag();
|
||||
}
|
||||
if($item instanceof Durable and $item->getDamage() > 0){
|
||||
if($nbt !== null){
|
||||
if(($existing = $nbt->getTag(self::DAMAGE_TAG)) !== null){
|
||||
$nbt->removeTag(self::DAMAGE_TAG);
|
||||
$existing->setName(self::DAMAGE_TAG_CONFLICT_RESOLUTION);
|
||||
$nbt->setTag($existing);
|
||||
}
|
||||
}else{
|
||||
$nbt = new CompoundTag();
|
||||
}
|
||||
$nbt->setInt(self::DAMAGE_TAG, $item->getDamage());
|
||||
}
|
||||
|
||||
if($nbt !== null){
|
||||
$this->putLShort(0xffff);
|
||||
$this->putByte(1); //TODO: some kind of count field? always 1 as of 1.9.0
|
||||
$this->put((new NetworkLittleEndianNBTStream())->write($item->getNamedTag()));
|
||||
$this->put((new NetworkLittleEndianNBTStream())->write($nbt));
|
||||
}else{
|
||||
$this->putLShort(0);
|
||||
}
|
||||
@ -140,6 +175,29 @@ class NetworkBinaryStream extends BinaryStream{
|
||||
}
|
||||
}
|
||||
|
||||
public function getRecipeIngredient() : Item{
|
||||
$id = $this->getVarInt();
|
||||
if($id === 0){
|
||||
return ItemFactory::get(ItemIds::AIR, 0, 0);
|
||||
}
|
||||
$meta = $this->getVarInt();
|
||||
if($meta === 0x7fff){
|
||||
$meta = -1;
|
||||
}
|
||||
$count = $this->getVarInt();
|
||||
return ItemFactory::get($id, $meta, $count);
|
||||
}
|
||||
|
||||
public function putRecipeIngredient(Item $item) : void{
|
||||
if($item->isNull()){
|
||||
$this->putVarInt(0);
|
||||
}else{
|
||||
$this->putVarInt($item->getId());
|
||||
$this->putVarInt($item->getDamage() & 0x7fff);
|
||||
$this->putVarInt($item->getCount());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Decodes entity metadata from the stream.
|
||||
*
|
||||
@ -170,8 +228,8 @@ class NetworkBinaryStream extends BinaryStream{
|
||||
case Entity::DATA_TYPE_STRING:
|
||||
$value = $this->getString();
|
||||
break;
|
||||
case Entity::DATA_TYPE_SLOT:
|
||||
$value = $this->getSlot();
|
||||
case Entity::DATA_TYPE_COMPOUND_TAG:
|
||||
$value = (new NetworkLittleEndianNBTStream())->read($this->buffer, false, $this->offset, 512);
|
||||
break;
|
||||
case Entity::DATA_TYPE_POS:
|
||||
$value = new Vector3();
|
||||
@ -222,8 +280,8 @@ class NetworkBinaryStream extends BinaryStream{
|
||||
case Entity::DATA_TYPE_STRING:
|
||||
$this->putString($d[1]);
|
||||
break;
|
||||
case Entity::DATA_TYPE_SLOT:
|
||||
$this->putSlot($d[1]);
|
||||
case Entity::DATA_TYPE_COMPOUND_TAG:
|
||||
$this->put((new NetworkLittleEndianNBTStream())->write($d[1]));
|
||||
break;
|
||||
case Entity::DATA_TYPE_POS:
|
||||
$v = $d[1];
|
||||
@ -535,4 +593,40 @@ class NetworkBinaryStream extends BinaryStream{
|
||||
$this->putVarLong($data->varlong1);
|
||||
}
|
||||
}
|
||||
|
||||
protected function getStructureSettings() : StructureSettings{
|
||||
$result = new StructureSettings();
|
||||
|
||||
$result->paletteName = $this->getString();
|
||||
|
||||
$result->ignoreEntities = $this->getBool();
|
||||
$result->ignoreBlocks = $this->getBool();
|
||||
|
||||
$this->getBlockPosition($result->structureSizeX, $result->structureSizeY, $result->structureSizeZ);
|
||||
$this->getBlockPosition($result->structureOffsetX, $result->structureOffsetY, $result->structureOffsetZ);
|
||||
|
||||
$result->lastTouchedByPlayerID = $this->getEntityUniqueId();
|
||||
$result->rotation = $this->getByte();
|
||||
$result->mirror = $this->getByte();
|
||||
$result->integrityValue = $this->getFloat();
|
||||
$result->integritySeed = $this->getInt();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function putStructureSettings(StructureSettings $structureSettings) : void{
|
||||
$this->putString($structureSettings->paletteName);
|
||||
|
||||
$this->putBool($structureSettings->ignoreEntities);
|
||||
$this->putBool($structureSettings->ignoreBlocks);
|
||||
|
||||
$this->putBlockPosition($structureSettings->structureSizeX, $structureSettings->structureSizeY, $structureSettings->structureSizeZ);
|
||||
$this->putBlockPosition($structureSettings->structureOffsetX, $structureSettings->structureOffsetY, $structureSettings->structureOffsetZ);
|
||||
|
||||
$this->putEntityUniqueId($structureSettings->lastTouchedByPlayerID);
|
||||
$this->putByte($structureSettings->rotation);
|
||||
$this->putByte($structureSettings->mirror);
|
||||
$this->putFloat($structureSettings->integrityValue);
|
||||
$this->putInt($structureSettings->integritySeed);
|
||||
}
|
||||
}
|
||||
|
@ -23,18 +23,22 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\network\mcpe;
|
||||
|
||||
use pocketmine\network\mcpe\protocol\ActorEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\ActorFallPacket;
|
||||
use pocketmine\network\mcpe\protocol\ActorPickRequestPacket;
|
||||
use pocketmine\network\mcpe\protocol\AddActorPacket;
|
||||
use pocketmine\network\mcpe\protocol\AddBehaviorTreePacket;
|
||||
use pocketmine\network\mcpe\protocol\AddEntityPacket;
|
||||
use pocketmine\network\mcpe\protocol\AddItemEntityPacket;
|
||||
use pocketmine\network\mcpe\protocol\AddItemActorPacket;
|
||||
use pocketmine\network\mcpe\protocol\AddPaintingPacket;
|
||||
use pocketmine\network\mcpe\protocol\AddPlayerPacket;
|
||||
use pocketmine\network\mcpe\protocol\AdventureSettingsPacket;
|
||||
use pocketmine\network\mcpe\protocol\AnimatePacket;
|
||||
use pocketmine\network\mcpe\protocol\AutomationClientConnectPacket;
|
||||
use pocketmine\network\mcpe\protocol\AvailableActorIdentifiersPacket;
|
||||
use pocketmine\network\mcpe\protocol\AvailableCommandsPacket;
|
||||
use pocketmine\network\mcpe\protocol\AvailableEntityIdentifiersPacket;
|
||||
use pocketmine\network\mcpe\protocol\BiomeDefinitionListPacket;
|
||||
use pocketmine\network\mcpe\protocol\BlockEntityDataPacket;
|
||||
use pocketmine\network\mcpe\protocol\BlockActorDataPacket;
|
||||
use pocketmine\network\mcpe\protocol\BlockEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\BlockPickRequestPacket;
|
||||
use pocketmine\network\mcpe\protocol\BookEditPacket;
|
||||
@ -43,6 +47,9 @@ use pocketmine\network\mcpe\protocol\CameraPacket;
|
||||
use pocketmine\network\mcpe\protocol\ChangeDimensionPacket;
|
||||
use pocketmine\network\mcpe\protocol\ChunkRadiusUpdatedPacket;
|
||||
use pocketmine\network\mcpe\protocol\ClientboundMapItemDataPacket;
|
||||
use pocketmine\network\mcpe\protocol\ClientCacheBlobStatusPacket;
|
||||
use pocketmine\network\mcpe\protocol\ClientCacheMissResponsePacket;
|
||||
use pocketmine\network\mcpe\protocol\ClientCacheStatusPacket;
|
||||
use pocketmine\network\mcpe\protocol\ClientToServerHandshakePacket;
|
||||
use pocketmine\network\mcpe\protocol\CommandBlockUpdatePacket;
|
||||
use pocketmine\network\mcpe\protocol\CommandOutputPacket;
|
||||
@ -54,12 +61,8 @@ use pocketmine\network\mcpe\protocol\CraftingDataPacket;
|
||||
use pocketmine\network\mcpe\protocol\CraftingEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\DataPacket;
|
||||
use pocketmine\network\mcpe\protocol\DisconnectPacket;
|
||||
use pocketmine\network\mcpe\protocol\EntityEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\EntityFallPacket;
|
||||
use pocketmine\network\mcpe\protocol\EntityPickRequestPacket;
|
||||
use pocketmine\network\mcpe\protocol\EventPacket;
|
||||
use pocketmine\network\mcpe\protocol\ExplodePacket;
|
||||
use pocketmine\network\mcpe\protocol\FullChunkDataPacket;
|
||||
use pocketmine\network\mcpe\protocol\GameRulesChangedPacket;
|
||||
use pocketmine\network\mcpe\protocol\GuiDataPickItemPacket;
|
||||
use pocketmine\network\mcpe\protocol\HurtArmorPacket;
|
||||
@ -70,6 +73,8 @@ use pocketmine\network\mcpe\protocol\InventoryTransactionPacket;
|
||||
use pocketmine\network\mcpe\protocol\ItemFrameDropItemPacket;
|
||||
use pocketmine\network\mcpe\protocol\LabTablePacket;
|
||||
use pocketmine\network\mcpe\protocol\LecternUpdatePacket;
|
||||
use pocketmine\network\mcpe\protocol\LevelChunkPacket;
|
||||
use pocketmine\network\mcpe\protocol\LevelEventGenericPacket;
|
||||
use pocketmine\network\mcpe\protocol\LevelEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\LevelSoundEventPacketV1;
|
||||
@ -82,8 +87,8 @@ use pocketmine\network\mcpe\protocol\MobEffectPacket;
|
||||
use pocketmine\network\mcpe\protocol\MobEquipmentPacket;
|
||||
use pocketmine\network\mcpe\protocol\ModalFormRequestPacket;
|
||||
use pocketmine\network\mcpe\protocol\ModalFormResponsePacket;
|
||||
use pocketmine\network\mcpe\protocol\MoveEntityAbsolutePacket;
|
||||
use pocketmine\network\mcpe\protocol\MoveEntityDeltaPacket;
|
||||
use pocketmine\network\mcpe\protocol\MoveActorAbsolutePacket;
|
||||
use pocketmine\network\mcpe\protocol\MoveActorDeltaPacket;
|
||||
use pocketmine\network\mcpe\protocol\MovePlayerPacket;
|
||||
use pocketmine\network\mcpe\protocol\NetworkChunkPublisherUpdatePacket;
|
||||
use pocketmine\network\mcpe\protocol\NetworkStackLatencyPacket;
|
||||
@ -98,6 +103,7 @@ use pocketmine\network\mcpe\protocol\PlayerSkinPacket;
|
||||
use pocketmine\network\mcpe\protocol\PlaySoundPacket;
|
||||
use pocketmine\network\mcpe\protocol\PlayStatusPacket;
|
||||
use pocketmine\network\mcpe\protocol\PurchaseReceiptPacket;
|
||||
use pocketmine\network\mcpe\protocol\RemoveActorPacket;
|
||||
use pocketmine\network\mcpe\protocol\RemoveEntityPacket;
|
||||
use pocketmine\network\mcpe\protocol\RemoveObjectivePacket;
|
||||
use pocketmine\network\mcpe\protocol\RequestChunkRadiusPacket;
|
||||
@ -113,13 +119,13 @@ use pocketmine\network\mcpe\protocol\ScriptCustomEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\ServerSettingsRequestPacket;
|
||||
use pocketmine\network\mcpe\protocol\ServerSettingsResponsePacket;
|
||||
use pocketmine\network\mcpe\protocol\ServerToClientHandshakePacket;
|
||||
use pocketmine\network\mcpe\protocol\SetActorDataPacket;
|
||||
use pocketmine\network\mcpe\protocol\SetActorLinkPacket;
|
||||
use pocketmine\network\mcpe\protocol\SetActorMotionPacket;
|
||||
use pocketmine\network\mcpe\protocol\SetCommandsEnabledPacket;
|
||||
use pocketmine\network\mcpe\protocol\SetDefaultGameTypePacket;
|
||||
use pocketmine\network\mcpe\protocol\SetDifficultyPacket;
|
||||
use pocketmine\network\mcpe\protocol\SetDisplayObjectivePacket;
|
||||
use pocketmine\network\mcpe\protocol\SetEntityDataPacket;
|
||||
use pocketmine\network\mcpe\protocol\SetEntityLinkPacket;
|
||||
use pocketmine\network\mcpe\protocol\SetEntityMotionPacket;
|
||||
use pocketmine\network\mcpe\protocol\SetHealthPacket;
|
||||
use pocketmine\network\mcpe\protocol\SetLastHurtByPacket;
|
||||
use pocketmine\network\mcpe\protocol\SetLocalPlayerAsInitializedPacket;
|
||||
@ -138,12 +144,15 @@ use pocketmine\network\mcpe\protocol\SpawnParticleEffectPacket;
|
||||
use pocketmine\network\mcpe\protocol\StartGamePacket;
|
||||
use pocketmine\network\mcpe\protocol\StopSoundPacket;
|
||||
use pocketmine\network\mcpe\protocol\StructureBlockUpdatePacket;
|
||||
use pocketmine\network\mcpe\protocol\StructureTemplateDataExportRequestPacket;
|
||||
use pocketmine\network\mcpe\protocol\StructureTemplateDataExportResponsePacket;
|
||||
use pocketmine\network\mcpe\protocol\SubClientLoginPacket;
|
||||
use pocketmine\network\mcpe\protocol\TakeItemEntityPacket;
|
||||
use pocketmine\network\mcpe\protocol\TakeItemActorPacket;
|
||||
use pocketmine\network\mcpe\protocol\TextPacket;
|
||||
use pocketmine\network\mcpe\protocol\TransferPacket;
|
||||
use pocketmine\network\mcpe\protocol\UpdateAttributesPacket;
|
||||
use pocketmine\network\mcpe\protocol\UpdateBlockPacket;
|
||||
use pocketmine\network\mcpe\protocol\UpdateBlockPropertiesPacket;
|
||||
use pocketmine\network\mcpe\protocol\UpdateBlockSyncedPacket;
|
||||
use pocketmine\network\mcpe\protocol\UpdateEquipPacket;
|
||||
use pocketmine\network\mcpe\protocol\UpdateSoftEnumPacket;
|
||||
@ -202,23 +211,23 @@ abstract class NetworkSession{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleAddEntity(AddEntityPacket $packet) : bool{
|
||||
public function handleAddActor(AddActorPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleRemoveEntity(RemoveEntityPacket $packet) : bool{
|
||||
public function handleRemoveActor(RemoveActorPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleAddItemEntity(AddItemEntityPacket $packet) : bool{
|
||||
public function handleAddItemActor(AddItemActorPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleTakeItemEntity(TakeItemEntityPacket $packet) : bool{
|
||||
public function handleTakeItemActor(TakeItemActorPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleMoveEntityAbsolute(MoveEntityAbsolutePacket $packet) : bool{
|
||||
public function handleMoveActorAbsolute(MoveActorAbsolutePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -254,7 +263,7 @@ abstract class NetworkSession{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleEntityEvent(EntityEventPacket $packet) : bool{
|
||||
public function handleActorEvent(ActorEventPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -286,7 +295,7 @@ abstract class NetworkSession{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleEntityPickRequest(EntityPickRequestPacket $packet) : bool{
|
||||
public function handleActorPickRequest(ActorPickRequestPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -294,7 +303,7 @@ abstract class NetworkSession{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleEntityFall(EntityFallPacket $packet) : bool{
|
||||
public function handleActorFall(ActorFallPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -302,15 +311,15 @@ abstract class NetworkSession{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSetEntityData(SetEntityDataPacket $packet) : bool{
|
||||
public function handleSetActorData(SetActorDataPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSetEntityMotion(SetEntityMotionPacket $packet) : bool{
|
||||
public function handleSetActorMotion(SetActorMotionPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSetEntityLink(SetEntityLinkPacket $packet) : bool{
|
||||
public function handleSetActorLink(SetActorLinkPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -370,7 +379,7 @@ abstract class NetworkSession{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleBlockEntityData(BlockEntityDataPacket $packet) : bool{
|
||||
public function handleBlockActorData(BlockActorDataPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -378,7 +387,7 @@ abstract class NetworkSession{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleFullChunkData(FullChunkDataPacket $packet) : bool{
|
||||
public function handleLevelChunk(LevelChunkPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -590,7 +599,7 @@ abstract class NetworkSession{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleMoveEntityDelta(MoveEntityDeltaPacket $packet) : bool{
|
||||
public function handleMoveActorDelta(MoveActorDeltaPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -618,7 +627,7 @@ abstract class NetworkSession{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleAvailableEntityIdentifiers(AvailableEntityIdentifiersPacket $packet) : bool{
|
||||
public function handleAvailableActorIdentifiers(AvailableActorIdentifiersPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -638,6 +647,10 @@ abstract class NetworkSession{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleLevelEventGeneric(LevelEventGenericPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleLecternUpdate(LecternUpdatePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
@ -646,11 +659,43 @@ abstract class NetworkSession{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleMapCreateLockedCopy(MapCreateLockedCopyPacket $packet) : bool{
|
||||
public function handleAddEntity(AddEntityPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleRemoveEntity(RemoveEntityPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleClientCacheStatus(ClientCacheStatusPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleOnScreenTextureAnimation(OnScreenTextureAnimationPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleMapCreateLockedCopy(MapCreateLockedCopyPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleStructureTemplateDataExportRequest(StructureTemplateDataExportRequestPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleStructureTemplateDataExportResponse(StructureTemplateDataExportResponsePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleUpdateBlockProperties(UpdateBlockPropertiesPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleClientCacheBlobStatus(ClientCacheBlobStatusPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleClientCacheMissResponse(ClientCacheMissResponsePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -25,9 +25,12 @@ namespace pocketmine\network\mcpe;
|
||||
|
||||
|
||||
use pocketmine\event\server\DataPacketReceiveEvent;
|
||||
use pocketmine\network\mcpe\protocol\ActorEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\ActorFallPacket;
|
||||
use pocketmine\network\mcpe\protocol\ActorPickRequestPacket;
|
||||
use pocketmine\network\mcpe\protocol\AdventureSettingsPacket;
|
||||
use pocketmine\network\mcpe\protocol\AnimatePacket;
|
||||
use pocketmine\network\mcpe\protocol\BlockEntityDataPacket;
|
||||
use pocketmine\network\mcpe\protocol\BlockActorDataPacket;
|
||||
use pocketmine\network\mcpe\protocol\BlockPickRequestPacket;
|
||||
use pocketmine\network\mcpe\protocol\BookEditPacket;
|
||||
use pocketmine\network\mcpe\protocol\BossEventPacket;
|
||||
@ -37,9 +40,6 @@ use pocketmine\network\mcpe\protocol\CommandRequestPacket;
|
||||
use pocketmine\network\mcpe\protocol\ContainerClosePacket;
|
||||
use pocketmine\network\mcpe\protocol\CraftingEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\DataPacket;
|
||||
use pocketmine\network\mcpe\protocol\EntityEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\EntityFallPacket;
|
||||
use pocketmine\network\mcpe\protocol\EntityPickRequestPacket;
|
||||
use pocketmine\network\mcpe\protocol\InteractPacket;
|
||||
use pocketmine\network\mcpe\protocol\InventoryTransactionPacket;
|
||||
use pocketmine\network\mcpe\protocol\ItemFrameDropItemPacket;
|
||||
@ -68,12 +68,12 @@ use pocketmine\network\mcpe\protocol\TextPacket;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\Server;
|
||||
use pocketmine\timings\Timings;
|
||||
use function base64_encode;
|
||||
use function bin2hex;
|
||||
use function implode;
|
||||
use function json_decode;
|
||||
use function json_last_error_msg;
|
||||
use function preg_match;
|
||||
use function preg_split;
|
||||
use function strlen;
|
||||
use function substr;
|
||||
use function trim;
|
||||
@ -107,7 +107,7 @@ class PlayerNetworkSessionAdapter extends NetworkSession{
|
||||
$ev = new DataPacketReceiveEvent($this->player, $packet);
|
||||
$ev->call();
|
||||
if(!$ev->isCancelled() and !$packet->handle($this)){
|
||||
$this->server->getLogger()->debug("Unhandled " . $packet->getName() . " received from " . $this->player->getName() . ": 0x" . bin2hex($packet->buffer));
|
||||
$this->server->getLogger()->debug("Unhandled " . $packet->getName() . " received from " . $this->player->getName() . ": " . base64_encode($packet->buffer));
|
||||
}
|
||||
|
||||
$timings->stopTiming();
|
||||
@ -141,7 +141,7 @@ class PlayerNetworkSessionAdapter extends NetworkSession{
|
||||
return true; //useless leftover from 1.8
|
||||
}
|
||||
|
||||
public function handleEntityEvent(EntityEventPacket $packet) : bool{
|
||||
public function handleActorEvent(ActorEventPacket $packet) : bool{
|
||||
return $this->player->handleEntityEvent($packet);
|
||||
}
|
||||
|
||||
@ -165,7 +165,7 @@ class PlayerNetworkSessionAdapter extends NetworkSession{
|
||||
return $this->player->handleBlockPickRequest($packet);
|
||||
}
|
||||
|
||||
public function handleEntityPickRequest(EntityPickRequestPacket $packet) : bool{
|
||||
public function handleActorPickRequest(ActorPickRequestPacket $packet) : bool{
|
||||
return false; //TODO
|
||||
}
|
||||
|
||||
@ -173,7 +173,7 @@ class PlayerNetworkSessionAdapter extends NetworkSession{
|
||||
return $this->player->handlePlayerAction($packet);
|
||||
}
|
||||
|
||||
public function handleEntityFall(EntityFallPacket $packet) : bool{
|
||||
public function handleActorFall(ActorFallPacket $packet) : bool{
|
||||
return true; //Not used
|
||||
}
|
||||
|
||||
@ -197,7 +197,7 @@ class PlayerNetworkSessionAdapter extends NetworkSession{
|
||||
return $this->player->handleAdventureSettings($packet);
|
||||
}
|
||||
|
||||
public function handleBlockEntityData(BlockEntityDataPacket $packet) : bool{
|
||||
public function handleBlockActorData(BlockActorDataPacket $packet) : bool{
|
||||
return $this->player->handleBlockEntityData($packet);
|
||||
}
|
||||
|
||||
@ -269,16 +269,31 @@ class PlayerNetworkSessionAdapter extends NetworkSession{
|
||||
*/
|
||||
private static function stupid_json_decode(string $json, bool $assoc = false){
|
||||
if(preg_match('/^\[(.+)\]$/s', $json, $matches) > 0){
|
||||
$parts = preg_split('/(?:"(?:\\"|[^"])*"|)\K(,)/', $matches[1]); //Splits on commas not inside quotes, ignoring escaped quotes
|
||||
foreach($parts as $k => $part){
|
||||
$part = trim($part);
|
||||
if($part === ""){
|
||||
$part = "\"\"";
|
||||
$raw = $matches[1];
|
||||
$lastComma = -1;
|
||||
$newParts = [];
|
||||
$quoteType = null;
|
||||
for($i = 0, $len = strlen($raw); $i <= $len; ++$i){
|
||||
if($i === $len or ($raw[$i] === "," and $quoteType === null)){
|
||||
$part = substr($raw, $lastComma + 1, $i - ($lastComma + 1));
|
||||
if(trim($part) === ""){ //regular parts will have quotes or something else that makes them non-empty
|
||||
$part = '""';
|
||||
}
|
||||
$newParts[] = $part;
|
||||
$lastComma = $i;
|
||||
}elseif($raw[$i] === '"'){
|
||||
if($quoteType === null){
|
||||
$quoteType = $raw[$i];
|
||||
}elseif($raw[$i] === $quoteType){
|
||||
for($backslashes = 0; $backslashes < $i && $raw[$i - $backslashes - 1] === "\\"; ++$backslashes){}
|
||||
if(($backslashes % 2) === 0){ //unescaped quote
|
||||
$quoteType = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
$parts[$k] = $part;
|
||||
}
|
||||
|
||||
$fixed = "[" . implode(",", $parts) . "]";
|
||||
$fixed = "[" . implode(",", $newParts) . "]";
|
||||
if(($ret = json_decode($fixed, $assoc)) === null){
|
||||
throw new \InvalidArgumentException("Failed to fix JSON: " . json_last_error_msg() . "(original: $json, modified: $fixed)");
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ use raklib\server\ServerHandler;
|
||||
use raklib\server\ServerInstance;
|
||||
use raklib\utils\InternetAddress;
|
||||
use function addcslashes;
|
||||
use function bin2hex;
|
||||
use function base64_encode;
|
||||
use function get_class;
|
||||
use function implode;
|
||||
use function rtrim;
|
||||
@ -170,7 +170,7 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{
|
||||
}
|
||||
}catch(\Throwable $e){
|
||||
$logger = $this->server->getLogger();
|
||||
$logger->debug("Packet " . (isset($pk) ? get_class($pk) : "unknown") . " 0x" . bin2hex($packet->buffer));
|
||||
$logger->debug("Packet " . (isset($pk) ? get_class($pk) : "unknown") . ": " . base64_encode($packet->buffer));
|
||||
$logger->logException($e);
|
||||
|
||||
$player->close($player->getLeaveMessage(), "Internal server error");
|
||||
|
@ -120,12 +120,12 @@ class VerifyLoginTask extends AsyncTask{
|
||||
[$rString, $sString] = str_split($plainSignature, 48);
|
||||
|
||||
$rString = ltrim($rString, "\x00");
|
||||
if(ord($rString{0}) >= 128){ //Would be considered signed, pad it with an extra zero
|
||||
if(ord($rString[0]) >= 128){ //Would be considered signed, pad it with an extra zero
|
||||
$rString = "\x00" . $rString;
|
||||
}
|
||||
|
||||
$sString = ltrim($sString, "\x00");
|
||||
if(ord($sString{0}) >= 128){ //Would be considered signed, pad it with an extra zero
|
||||
if(ord($sString[0]) >= 128){ //Would be considered signed, pad it with an extra zero
|
||||
$sString = "\x00" . $sString;
|
||||
}
|
||||
|
||||
|
@ -28,8 +28,8 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class EntityEventPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::ENTITY_EVENT_PACKET;
|
||||
class ActorEventPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::ACTOR_EVENT_PACKET;
|
||||
|
||||
public const HURT_ANIMATION = 2;
|
||||
public const DEATH_ANIMATION = 3;
|
||||
@ -103,6 +103,6 @@ class EntityEventPacket extends DataPacket{
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleEntityEvent($this);
|
||||
return $session->handleActorEvent($this);
|
||||
}
|
||||
}
|
@ -28,8 +28,8 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class EntityFallPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::ENTITY_FALL_PACKET;
|
||||
class ActorFallPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::ACTOR_FALL_PACKET;
|
||||
|
||||
/** @var int */
|
||||
public $entityRuntimeId;
|
||||
@ -51,6 +51,6 @@ class EntityFallPacket extends DataPacket{
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleEntityFall($this);
|
||||
return $session->handleActorFall($this);
|
||||
}
|
||||
}
|
@ -27,8 +27,8 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class EntityPickRequestPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::ENTITY_PICK_REQUEST_PACKET;
|
||||
class ActorPickRequestPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::ACTOR_PICK_REQUEST_PACKET;
|
||||
|
||||
/** @var int */
|
||||
public $entityUniqueId;
|
||||
@ -46,6 +46,6 @@ class EntityPickRequestPacket extends DataPacket{
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleEntityPickRequest($this);
|
||||
return $session->handleActorPickRequest($this);
|
||||
}
|
||||
}
|
240
src/pocketmine/network/mcpe/protocol/AddActorPacket.php
Normal file
240
src/pocketmine/network/mcpe/protocol/AddActorPacket.php
Normal file
@ -0,0 +1,240 @@
|
||||
<?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\entity\Attribute;
|
||||
use pocketmine\entity\EntityIds;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\protocol\types\EntityLink;
|
||||
use function array_search;
|
||||
use function count;
|
||||
|
||||
class AddActorPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::ADD_ACTOR_PACKET;
|
||||
|
||||
/*
|
||||
* Really really really really really nasty hack, to preserve backwards compatibility.
|
||||
* We can't transition to string IDs within 3.x because the network IDs (the integer ones) are exposed
|
||||
* to the API in some places (for god's sake shoghi).
|
||||
*
|
||||
* TODO: remove this on 4.0
|
||||
*/
|
||||
public const LEGACY_ID_MAP_BC = [
|
||||
EntityIds::NPC => "minecraft:npc",
|
||||
EntityIds::PLAYER => "minecraft:player",
|
||||
EntityIds::WITHER_SKELETON => "minecraft:wither_skeleton",
|
||||
EntityIds::HUSK => "minecraft:husk",
|
||||
EntityIds::STRAY => "minecraft:stray",
|
||||
EntityIds::WITCH => "minecraft:witch",
|
||||
EntityIds::ZOMBIE_VILLAGER => "minecraft:zombie_villager",
|
||||
EntityIds::BLAZE => "minecraft:blaze",
|
||||
EntityIds::MAGMA_CUBE => "minecraft:magma_cube",
|
||||
EntityIds::GHAST => "minecraft:ghast",
|
||||
EntityIds::CAVE_SPIDER => "minecraft:cave_spider",
|
||||
EntityIds::SILVERFISH => "minecraft:silverfish",
|
||||
EntityIds::ENDERMAN => "minecraft:enderman",
|
||||
EntityIds::SLIME => "minecraft:slime",
|
||||
EntityIds::ZOMBIE_PIGMAN => "minecraft:zombie_pigman",
|
||||
EntityIds::SPIDER => "minecraft:spider",
|
||||
EntityIds::SKELETON => "minecraft:skeleton",
|
||||
EntityIds::CREEPER => "minecraft:creeper",
|
||||
EntityIds::ZOMBIE => "minecraft:zombie",
|
||||
EntityIds::SKELETON_HORSE => "minecraft:skeleton_horse",
|
||||
EntityIds::MULE => "minecraft:mule",
|
||||
EntityIds::DONKEY => "minecraft:donkey",
|
||||
EntityIds::DOLPHIN => "minecraft:dolphin",
|
||||
EntityIds::TROPICALFISH => "minecraft:tropicalfish",
|
||||
EntityIds::WOLF => "minecraft:wolf",
|
||||
EntityIds::SQUID => "minecraft:squid",
|
||||
EntityIds::DROWNED => "minecraft:drowned",
|
||||
EntityIds::SHEEP => "minecraft:sheep",
|
||||
EntityIds::MOOSHROOM => "minecraft:mooshroom",
|
||||
EntityIds::PANDA => "minecraft:panda",
|
||||
EntityIds::SALMON => "minecraft:salmon",
|
||||
EntityIds::PIG => "minecraft:pig",
|
||||
EntityIds::VILLAGER => "minecraft:villager",
|
||||
EntityIds::COD => "minecraft:cod",
|
||||
EntityIds::PUFFERFISH => "minecraft:pufferfish",
|
||||
EntityIds::COW => "minecraft:cow",
|
||||
EntityIds::CHICKEN => "minecraft:chicken",
|
||||
EntityIds::BALLOON => "minecraft:balloon",
|
||||
EntityIds::LLAMA => "minecraft:llama",
|
||||
EntityIds::IRON_GOLEM => "minecraft:iron_golem",
|
||||
EntityIds::RABBIT => "minecraft:rabbit",
|
||||
EntityIds::SNOW_GOLEM => "minecraft:snow_golem",
|
||||
EntityIds::BAT => "minecraft:bat",
|
||||
EntityIds::OCELOT => "minecraft:ocelot",
|
||||
EntityIds::HORSE => "minecraft:horse",
|
||||
EntityIds::CAT => "minecraft:cat",
|
||||
EntityIds::POLAR_BEAR => "minecraft:polar_bear",
|
||||
EntityIds::ZOMBIE_HORSE => "minecraft:zombie_horse",
|
||||
EntityIds::TURTLE => "minecraft:turtle",
|
||||
EntityIds::PARROT => "minecraft:parrot",
|
||||
EntityIds::GUARDIAN => "minecraft:guardian",
|
||||
EntityIds::ELDER_GUARDIAN => "minecraft:elder_guardian",
|
||||
EntityIds::VINDICATOR => "minecraft:vindicator",
|
||||
EntityIds::WITHER => "minecraft:wither",
|
||||
EntityIds::ENDER_DRAGON => "minecraft:ender_dragon",
|
||||
EntityIds::SHULKER => "minecraft:shulker",
|
||||
EntityIds::ENDERMITE => "minecraft:endermite",
|
||||
EntityIds::MINECART => "minecraft:minecart",
|
||||
EntityIds::HOPPER_MINECART => "minecraft:hopper_minecart",
|
||||
EntityIds::TNT_MINECART => "minecraft:tnt_minecart",
|
||||
EntityIds::CHEST_MINECART => "minecraft:chest_minecart",
|
||||
EntityIds::COMMAND_BLOCK_MINECART => "minecraft:command_block_minecart",
|
||||
EntityIds::ARMOR_STAND => "minecraft:armor_stand",
|
||||
EntityIds::ITEM => "minecraft:item",
|
||||
EntityIds::TNT => "minecraft:tnt",
|
||||
EntityIds::FALLING_BLOCK => "minecraft:falling_block",
|
||||
EntityIds::XP_BOTTLE => "minecraft:xp_bottle",
|
||||
EntityIds::XP_ORB => "minecraft:xp_orb",
|
||||
EntityIds::EYE_OF_ENDER_SIGNAL => "minecraft:eye_of_ender_signal",
|
||||
EntityIds::ENDER_CRYSTAL => "minecraft:ender_crystal",
|
||||
EntityIds::SHULKER_BULLET => "minecraft:shulker_bullet",
|
||||
EntityIds::FISHING_HOOK => "minecraft:fishing_hook",
|
||||
EntityIds::DRAGON_FIREBALL => "minecraft:dragon_fireball",
|
||||
EntityIds::ARROW => "minecraft:arrow",
|
||||
EntityIds::SNOWBALL => "minecraft:snowball",
|
||||
EntityIds::EGG => "minecraft:egg",
|
||||
EntityIds::PAINTING => "minecraft:painting",
|
||||
EntityIds::THROWN_TRIDENT => "minecraft:thrown_trident",
|
||||
EntityIds::FIREBALL => "minecraft:fireball",
|
||||
EntityIds::SPLASH_POTION => "minecraft:splash_potion",
|
||||
EntityIds::ENDER_PEARL => "minecraft:ender_pearl",
|
||||
EntityIds::LEASH_KNOT => "minecraft:leash_knot",
|
||||
EntityIds::WITHER_SKULL => "minecraft:wither_skull",
|
||||
EntityIds::WITHER_SKULL_DANGEROUS => "minecraft:wither_skull_dangerous",
|
||||
EntityIds::BOAT => "minecraft:boat",
|
||||
EntityIds::LIGHTNING_BOLT => "minecraft:lightning_bolt",
|
||||
EntityIds::SMALL_FIREBALL => "minecraft:small_fireball",
|
||||
EntityIds::LLAMA_SPIT => "minecraft:llama_spit",
|
||||
EntityIds::AREA_EFFECT_CLOUD => "minecraft:area_effect_cloud",
|
||||
EntityIds::LINGERING_POTION => "minecraft:lingering_potion",
|
||||
EntityIds::FIREWORKS_ROCKET => "minecraft:fireworks_rocket",
|
||||
EntityIds::EVOCATION_FANG => "minecraft:evocation_fang",
|
||||
EntityIds::EVOCATION_ILLAGER => "minecraft:evocation_illager",
|
||||
EntityIds::VEX => "minecraft:vex",
|
||||
EntityIds::AGENT => "minecraft:agent",
|
||||
EntityIds::ICE_BOMB => "minecraft:ice_bomb",
|
||||
EntityIds::PHANTOM => "minecraft:phantom",
|
||||
EntityIds::TRIPOD_CAMERA => "minecraft:tripod_camera"
|
||||
];
|
||||
|
||||
/** @var int|null */
|
||||
public $entityUniqueId = null; //TODO
|
||||
/** @var int */
|
||||
public $entityRuntimeId;
|
||||
/** @var int */
|
||||
public $type;
|
||||
/** @var Vector3 */
|
||||
public $position;
|
||||
/** @var Vector3|null */
|
||||
public $motion;
|
||||
/** @var float */
|
||||
public $pitch = 0.0;
|
||||
/** @var float */
|
||||
public $yaw = 0.0;
|
||||
/** @var float */
|
||||
public $headYaw = 0.0;
|
||||
|
||||
/** @var Attribute[] */
|
||||
public $attributes = [];
|
||||
/** @var array */
|
||||
public $metadata = [];
|
||||
/** @var EntityLink[] */
|
||||
public $links = [];
|
||||
|
||||
protected function decodePayload(){
|
||||
$this->entityUniqueId = $this->getEntityUniqueId();
|
||||
$this->entityRuntimeId = $this->getEntityRuntimeId();
|
||||
$this->type = array_search($t = $this->getString(), self::LEGACY_ID_MAP_BC, true);
|
||||
if($this->type === false){
|
||||
throw new \UnexpectedValueException("Can't map ID $t to legacy ID");
|
||||
}
|
||||
$this->position = $this->getVector3();
|
||||
$this->motion = $this->getVector3();
|
||||
$this->pitch = $this->getLFloat();
|
||||
$this->yaw = $this->getLFloat();
|
||||
$this->headYaw = $this->getLFloat();
|
||||
|
||||
$attrCount = $this->getUnsignedVarInt();
|
||||
for($i = 0; $i < $attrCount; ++$i){
|
||||
$name = $this->getString();
|
||||
$min = $this->getLFloat();
|
||||
$current = $this->getLFloat();
|
||||
$max = $this->getLFloat();
|
||||
$attr = Attribute::getAttributeByName($name);
|
||||
|
||||
if($attr !== null){
|
||||
$attr->setMinValue($min);
|
||||
$attr->setMaxValue($max);
|
||||
$attr->setValue($current);
|
||||
$this->attributes[] = $attr;
|
||||
}else{
|
||||
throw new \UnexpectedValueException("Unknown attribute type \"$name\"");
|
||||
}
|
||||
}
|
||||
|
||||
$this->metadata = $this->getEntityMetadata();
|
||||
$linkCount = $this->getUnsignedVarInt();
|
||||
for($i = 0; $i < $linkCount; ++$i){
|
||||
$this->links[] = $this->getEntityLink();
|
||||
}
|
||||
}
|
||||
|
||||
protected function encodePayload(){
|
||||
$this->putEntityUniqueId($this->entityUniqueId ?? $this->entityRuntimeId);
|
||||
$this->putEntityRuntimeId($this->entityRuntimeId);
|
||||
if(!isset(self::LEGACY_ID_MAP_BC[$this->type])){
|
||||
throw new \InvalidArgumentException("Unknown entity numeric ID $this->type");
|
||||
}
|
||||
$this->putString(self::LEGACY_ID_MAP_BC[$this->type]);
|
||||
$this->putVector3($this->position);
|
||||
$this->putVector3Nullable($this->motion);
|
||||
$this->putLFloat($this->pitch);
|
||||
$this->putLFloat($this->yaw);
|
||||
$this->putLFloat($this->headYaw);
|
||||
|
||||
$this->putUnsignedVarInt(count($this->attributes));
|
||||
foreach($this->attributes as $attribute){
|
||||
$this->putString($attribute->getName());
|
||||
$this->putLFloat($attribute->getMinValue());
|
||||
$this->putLFloat($attribute->getValue());
|
||||
$this->putLFloat($attribute->getMaxValue());
|
||||
}
|
||||
|
||||
$this->putEntityMetadata($this->metadata);
|
||||
$this->putUnsignedVarInt(count($this->links));
|
||||
foreach($this->links as $link){
|
||||
$this->putEntityLink($link);
|
||||
}
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleAddActor($this);
|
||||
}
|
||||
}
|
@ -25,216 +25,36 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\entity\Attribute;
|
||||
use pocketmine\entity\EntityIds;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\protocol\types\EntityLink;
|
||||
use function array_search;
|
||||
use function count;
|
||||
|
||||
class AddEntityPacket extends DataPacket{
|
||||
class AddEntityPacket extends DataPacket/* implements ClientboundPacket*/{
|
||||
public const NETWORK_ID = ProtocolInfo::ADD_ENTITY_PACKET;
|
||||
|
||||
/*
|
||||
* Really really really really really nasty hack, to preserve backwards compatibility.
|
||||
* We can't transition to string IDs within 3.x because the network IDs (the integer ones) are exposed
|
||||
* to the API in some places (for god's sake shoghi).
|
||||
*
|
||||
* TODO: remove this on 4.0
|
||||
/** @var int */
|
||||
private $uvarint1;
|
||||
|
||||
public static function create(int $uvarint1) : self{
|
||||
$result = new self;
|
||||
$result->uvarint1 = $uvarint1;
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public const LEGACY_ID_MAP_BC = [
|
||||
EntityIds::NPC => "minecraft:npc",
|
||||
EntityIds::PLAYER => "minecraft:player",
|
||||
EntityIds::WITHER_SKELETON => "minecraft:wither_skeleton",
|
||||
EntityIds::HUSK => "minecraft:husk",
|
||||
EntityIds::STRAY => "minecraft:stray",
|
||||
EntityIds::WITCH => "minecraft:witch",
|
||||
EntityIds::ZOMBIE_VILLAGER => "minecraft:zombie_villager",
|
||||
EntityIds::BLAZE => "minecraft:blaze",
|
||||
EntityIds::MAGMA_CUBE => "minecraft:magma_cube",
|
||||
EntityIds::GHAST => "minecraft:ghast",
|
||||
EntityIds::CAVE_SPIDER => "minecraft:cave_spider",
|
||||
EntityIds::SILVERFISH => "minecraft:silverfish",
|
||||
EntityIds::ENDERMAN => "minecraft:enderman",
|
||||
EntityIds::SLIME => "minecraft:slime",
|
||||
EntityIds::ZOMBIE_PIGMAN => "minecraft:zombie_pigman",
|
||||
EntityIds::SPIDER => "minecraft:spider",
|
||||
EntityIds::SKELETON => "minecraft:skeleton",
|
||||
EntityIds::CREEPER => "minecraft:creeper",
|
||||
EntityIds::ZOMBIE => "minecraft:zombie",
|
||||
EntityIds::SKELETON_HORSE => "minecraft:skeleton_horse",
|
||||
EntityIds::MULE => "minecraft:mule",
|
||||
EntityIds::DONKEY => "minecraft:donkey",
|
||||
EntityIds::DOLPHIN => "minecraft:dolphin",
|
||||
EntityIds::TROPICALFISH => "minecraft:tropicalfish",
|
||||
EntityIds::WOLF => "minecraft:wolf",
|
||||
EntityIds::SQUID => "minecraft:squid",
|
||||
EntityIds::DROWNED => "minecraft:drowned",
|
||||
EntityIds::SHEEP => "minecraft:sheep",
|
||||
EntityIds::MOOSHROOM => "minecraft:mooshroom",
|
||||
EntityIds::PANDA => "minecraft:panda",
|
||||
EntityIds::SALMON => "minecraft:salmon",
|
||||
EntityIds::PIG => "minecraft:pig",
|
||||
EntityIds::VILLAGER => "minecraft:villager",
|
||||
EntityIds::COD => "minecraft:cod",
|
||||
EntityIds::PUFFERFISH => "minecraft:pufferfish",
|
||||
EntityIds::COW => "minecraft:cow",
|
||||
EntityIds::CHICKEN => "minecraft:chicken",
|
||||
EntityIds::BALLOON => "minecraft:balloon",
|
||||
EntityIds::LLAMA => "minecraft:llama",
|
||||
EntityIds::IRON_GOLEM => "minecraft:iron_golem",
|
||||
EntityIds::RABBIT => "minecraft:rabbit",
|
||||
EntityIds::SNOW_GOLEM => "minecraft:snow_golem",
|
||||
EntityIds::BAT => "minecraft:bat",
|
||||
EntityIds::OCELOT => "minecraft:ocelot",
|
||||
EntityIds::HORSE => "minecraft:horse",
|
||||
EntityIds::CAT => "minecraft:cat",
|
||||
EntityIds::POLAR_BEAR => "minecraft:polar_bear",
|
||||
EntityIds::ZOMBIE_HORSE => "minecraft:zombie_horse",
|
||||
EntityIds::TURTLE => "minecraft:turtle",
|
||||
EntityIds::PARROT => "minecraft:parrot",
|
||||
EntityIds::GUARDIAN => "minecraft:guardian",
|
||||
EntityIds::ELDER_GUARDIAN => "minecraft:elder_guardian",
|
||||
EntityIds::VINDICATOR => "minecraft:vindicator",
|
||||
EntityIds::WITHER => "minecraft:wither",
|
||||
EntityIds::ENDER_DRAGON => "minecraft:ender_dragon",
|
||||
EntityIds::SHULKER => "minecraft:shulker",
|
||||
EntityIds::ENDERMITE => "minecraft:endermite",
|
||||
EntityIds::MINECART => "minecraft:minecart",
|
||||
EntityIds::HOPPER_MINECART => "minecraft:hopper_minecart",
|
||||
EntityIds::TNT_MINECART => "minecraft:tnt_minecart",
|
||||
EntityIds::CHEST_MINECART => "minecraft:chest_minecart",
|
||||
EntityIds::COMMAND_BLOCK_MINECART => "minecraft:command_block_minecart",
|
||||
EntityIds::ARMOR_STAND => "minecraft:armor_stand",
|
||||
EntityIds::ITEM => "minecraft:item",
|
||||
EntityIds::TNT => "minecraft:tnt",
|
||||
EntityIds::FALLING_BLOCK => "minecraft:falling_block",
|
||||
EntityIds::XP_BOTTLE => "minecraft:xp_bottle",
|
||||
EntityIds::XP_ORB => "minecraft:xp_orb",
|
||||
EntityIds::EYE_OF_ENDER_SIGNAL => "minecraft:eye_of_ender_signal",
|
||||
EntityIds::ENDER_CRYSTAL => "minecraft:ender_crystal",
|
||||
EntityIds::SHULKER_BULLET => "minecraft:shulker_bullet",
|
||||
EntityIds::FISHING_HOOK => "minecraft:fishing_hook",
|
||||
EntityIds::DRAGON_FIREBALL => "minecraft:dragon_fireball",
|
||||
EntityIds::ARROW => "minecraft:arrow",
|
||||
EntityIds::SNOWBALL => "minecraft:snowball",
|
||||
EntityIds::EGG => "minecraft:egg",
|
||||
EntityIds::PAINTING => "minecraft:painting",
|
||||
EntityIds::THROWN_TRIDENT => "minecraft:thrown_trident",
|
||||
EntityIds::FIREBALL => "minecraft:fireball",
|
||||
EntityIds::SPLASH_POTION => "minecraft:splash_potion",
|
||||
EntityIds::ENDER_PEARL => "minecraft:ender_pearl",
|
||||
EntityIds::LEASH_KNOT => "minecraft:leash_knot",
|
||||
EntityIds::WITHER_SKULL => "minecraft:wither_skull",
|
||||
EntityIds::WITHER_SKULL_DANGEROUS => "minecraft:wither_skull_dangerous",
|
||||
EntityIds::BOAT => "minecraft:boat",
|
||||
EntityIds::LIGHTNING_BOLT => "minecraft:lightning_bolt",
|
||||
EntityIds::SMALL_FIREBALL => "minecraft:small_fireball",
|
||||
EntityIds::LLAMA_SPIT => "minecraft:llama_spit",
|
||||
EntityIds::AREA_EFFECT_CLOUD => "minecraft:area_effect_cloud",
|
||||
EntityIds::LINGERING_POTION => "minecraft:lingering_potion",
|
||||
EntityIds::FIREWORKS_ROCKET => "minecraft:fireworks_rocket",
|
||||
EntityIds::EVOCATION_FANG => "minecraft:evocation_fang",
|
||||
EntityIds::EVOCATION_ILLAGER => "minecraft:evocation_illager",
|
||||
EntityIds::VEX => "minecraft:vex",
|
||||
EntityIds::AGENT => "minecraft:agent",
|
||||
EntityIds::ICE_BOMB => "minecraft:ice_bomb",
|
||||
EntityIds::PHANTOM => "minecraft:phantom",
|
||||
EntityIds::TRIPOD_CAMERA => "minecraft:tripod_camera"
|
||||
];
|
||||
|
||||
/** @var int|null */
|
||||
public $entityUniqueId = null; //TODO
|
||||
/** @var int */
|
||||
public $entityRuntimeId;
|
||||
/** @var int */
|
||||
public $type;
|
||||
/** @var Vector3 */
|
||||
public $position;
|
||||
/** @var Vector3|null */
|
||||
public $motion;
|
||||
/** @var float */
|
||||
public $pitch = 0.0;
|
||||
/** @var float */
|
||||
public $yaw = 0.0;
|
||||
/** @var float */
|
||||
public $headYaw = 0.0;
|
||||
|
||||
/** @var Attribute[] */
|
||||
public $attributes = [];
|
||||
/** @var array */
|
||||
public $metadata = [];
|
||||
/** @var EntityLink[] */
|
||||
public $links = [];
|
||||
|
||||
protected function decodePayload(){
|
||||
$this->entityUniqueId = $this->getEntityUniqueId();
|
||||
$this->entityRuntimeId = $this->getEntityRuntimeId();
|
||||
$this->type = array_search($t = $this->getString(), self::LEGACY_ID_MAP_BC, true);
|
||||
if($this->type === false){
|
||||
throw new \UnexpectedValueException("Can't map ID $t to legacy ID");
|
||||
}
|
||||
$this->position = $this->getVector3();
|
||||
$this->motion = $this->getVector3();
|
||||
$this->pitch = $this->getLFloat();
|
||||
$this->yaw = $this->getLFloat();
|
||||
$this->headYaw = $this->getLFloat();
|
||||
|
||||
$attrCount = $this->getUnsignedVarInt();
|
||||
for($i = 0; $i < $attrCount; ++$i){
|
||||
$name = $this->getString();
|
||||
$min = $this->getLFloat();
|
||||
$current = $this->getLFloat();
|
||||
$max = $this->getLFloat();
|
||||
$attr = Attribute::getAttributeByName($name);
|
||||
|
||||
if($attr !== null){
|
||||
$attr->setMinValue($min);
|
||||
$attr->setMaxValue($max);
|
||||
$attr->setValue($current);
|
||||
$this->attributes[] = $attr;
|
||||
}else{
|
||||
throw new \UnexpectedValueException("Unknown attribute type \"$name\"");
|
||||
}
|
||||
}
|
||||
|
||||
$this->metadata = $this->getEntityMetadata();
|
||||
$linkCount = $this->getUnsignedVarInt();
|
||||
for($i = 0; $i < $linkCount; ++$i){
|
||||
$this->links[] = $this->getEntityLink();
|
||||
}
|
||||
public function getUvarint1() : int{
|
||||
return $this->uvarint1;
|
||||
}
|
||||
|
||||
protected function encodePayload(){
|
||||
$this->putEntityUniqueId($this->entityUniqueId ?? $this->entityRuntimeId);
|
||||
$this->putEntityRuntimeId($this->entityRuntimeId);
|
||||
if(!isset(self::LEGACY_ID_MAP_BC[$this->type])){
|
||||
throw new \InvalidArgumentException("Unknown entity numeric ID $this->type");
|
||||
}
|
||||
$this->putString(self::LEGACY_ID_MAP_BC[$this->type]);
|
||||
$this->putVector3($this->position);
|
||||
$this->putVector3Nullable($this->motion);
|
||||
$this->putLFloat($this->pitch);
|
||||
$this->putLFloat($this->yaw);
|
||||
$this->putLFloat($this->headYaw);
|
||||
|
||||
$this->putUnsignedVarInt(count($this->attributes));
|
||||
foreach($this->attributes as $attribute){
|
||||
$this->putString($attribute->getName());
|
||||
$this->putLFloat($attribute->getMinValue());
|
||||
$this->putLFloat($attribute->getValue());
|
||||
$this->putLFloat($attribute->getMaxValue());
|
||||
}
|
||||
|
||||
$this->putEntityMetadata($this->metadata);
|
||||
$this->putUnsignedVarInt(count($this->links));
|
||||
foreach($this->links as $link){
|
||||
$this->putEntityLink($link);
|
||||
}
|
||||
protected function decodePayload() : void{
|
||||
$this->uvarint1 = $this->getUnsignedVarInt();
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleAddEntity($this);
|
||||
protected function encodePayload() : void{
|
||||
$this->putUnsignedVarInt($this->uvarint1);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $handler) : bool{
|
||||
return $handler->handleAddEntity($this);
|
||||
}
|
||||
}
|
||||
|
@ -29,8 +29,8 @@ use pocketmine\item\Item;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class AddItemEntityPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::ADD_ITEM_ENTITY_PACKET;
|
||||
class AddItemActorPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::ADD_ITEM_ACTOR_PACKET;
|
||||
|
||||
/** @var int|null */
|
||||
public $entityUniqueId = null; //TODO
|
||||
@ -68,6 +68,6 @@ class AddItemEntityPacket extends DataPacket{
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleAddItemEntity($this);
|
||||
return $session->handleAddItemActor($this);
|
||||
}
|
||||
}
|
@ -26,30 +26,27 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class AddPaintingPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::ADD_PAINTING_PACKET;
|
||||
|
||||
/** @var string */
|
||||
public $title;
|
||||
/** @var int */
|
||||
public $entityRuntimeId;
|
||||
/** @var int */
|
||||
public $x;
|
||||
/** @var int|null */
|
||||
public $entityUniqueId = null;
|
||||
/** @var int */
|
||||
public $y;
|
||||
/** @var int */
|
||||
public $z;
|
||||
public $entityRuntimeId;
|
||||
/** @var Vector3 */
|
||||
public $position;
|
||||
/** @var int */
|
||||
public $direction;
|
||||
/** @var string */
|
||||
public $title;
|
||||
|
||||
protected function decodePayload(){
|
||||
$this->entityUniqueId = $this->getEntityUniqueId();
|
||||
$this->entityRuntimeId = $this->getEntityRuntimeId();
|
||||
$this->getBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->position = $this->getVector3();
|
||||
$this->direction = $this->getVarInt();
|
||||
$this->title = $this->getString();
|
||||
}
|
||||
@ -57,7 +54,7 @@ class AddPaintingPacket extends DataPacket{
|
||||
protected function encodePayload(){
|
||||
$this->putEntityUniqueId($this->entityUniqueId ?? $this->entityRuntimeId);
|
||||
$this->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->putBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->putVector3($this->position);
|
||||
$this->putVarInt($this->direction);
|
||||
$this->putString($this->title);
|
||||
}
|
||||
|
@ -35,6 +35,8 @@ class AnimatePacket extends DataPacket{
|
||||
|
||||
public const ACTION_STOP_SLEEP = 3;
|
||||
public const ACTION_CRITICAL_HIT = 4;
|
||||
public const ACTION_ROW_RIGHT = 128;
|
||||
public const ACTION_ROW_LEFT = 129;
|
||||
|
||||
/** @var int */
|
||||
public $action;
|
||||
|
File diff suppressed because one or more lines are too long
@ -29,11 +29,6 @@ use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\protocol\types\CommandData;
|
||||
use pocketmine\network\mcpe\protocol\types\CommandEnum;
|
||||
use pocketmine\network\mcpe\protocol\types\CommandParameter;
|
||||
use function array_flip;
|
||||
use function array_keys;
|
||||
use function array_map;
|
||||
use function array_search;
|
||||
use function array_values;
|
||||
use function count;
|
||||
use function dechex;
|
||||
|
||||
@ -83,30 +78,6 @@ class AvailableCommandsPacket extends DataPacket{
|
||||
*/
|
||||
public const ARG_FLAG_POSTFIX = 0x1000000;
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
* A list of every single enum value for every single command in the packet, including alias names.
|
||||
*/
|
||||
public $enumValues = [];
|
||||
/** @var int */
|
||||
private $enumValuesCount = 0;
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
* A list of argument postfixes. Used for the /xp command's <int>L.
|
||||
*/
|
||||
public $postfixes = [];
|
||||
|
||||
/**
|
||||
* @var CommandEnum[]
|
||||
* List of command enums, from command aliases to argument enums.
|
||||
*/
|
||||
public $enums = [];
|
||||
/**
|
||||
* @var int[] string => int map of enum name to index
|
||||
*/
|
||||
private $enumMap = [];
|
||||
|
||||
/**
|
||||
* @var CommandData[]
|
||||
* List of command data, including name, description, alias indexes and parameters.
|
||||
@ -121,20 +92,26 @@ class AvailableCommandsPacket extends DataPacket{
|
||||
public $softEnums = [];
|
||||
|
||||
protected function decodePayload(){
|
||||
for($i = 0, $this->enumValuesCount = $this->getUnsignedVarInt(); $i < $this->enumValuesCount; ++$i){
|
||||
$this->enumValues[] = $this->getString();
|
||||
/** @var string[] $enumValues */
|
||||
$enumValues = [];
|
||||
for($i = 0, $enumValuesCount = $this->getUnsignedVarInt(); $i < $enumValuesCount; ++$i){
|
||||
$enumValues[] = $this->getString();
|
||||
}
|
||||
|
||||
/** @var string[] $postfixes */
|
||||
$postfixes = [];
|
||||
for($i = 0, $count = $this->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
$postfixes[] = $this->getString();
|
||||
}
|
||||
|
||||
/** @var CommandEnum[] $enums */
|
||||
$enums = [];
|
||||
for($i = 0, $count = $this->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
$enums[] = $this->getEnum($enumValues);
|
||||
}
|
||||
|
||||
for($i = 0, $count = $this->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
$this->postfixes[] = $this->getString();
|
||||
}
|
||||
|
||||
for($i = 0, $count = $this->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
$this->enums[] = $this->getEnum();
|
||||
}
|
||||
|
||||
for($i = 0, $count = $this->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
$this->commandData[] = $this->getCommandData();
|
||||
$this->commandData[] = $this->getCommandData($enums, $postfixes);
|
||||
}
|
||||
|
||||
for($i = 0, $count = $this->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
@ -142,17 +119,26 @@ class AvailableCommandsPacket extends DataPacket{
|
||||
}
|
||||
}
|
||||
|
||||
protected function getEnum() : CommandEnum{
|
||||
/**
|
||||
* @param string[] $enumValueList
|
||||
*
|
||||
* @return CommandEnum
|
||||
* @throws \UnexpectedValueException
|
||||
* @throws BinaryDataException
|
||||
*/
|
||||
protected function getEnum(array $enumValueList) : CommandEnum{
|
||||
$retval = new CommandEnum();
|
||||
$retval->enumName = $this->getString();
|
||||
|
||||
$listSize = count($enumValueList);
|
||||
|
||||
for($i = 0, $count = $this->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
$index = $this->getEnumValueIndex();
|
||||
if(!isset($this->enumValues[$index])){
|
||||
$index = $this->getEnumValueIndex($listSize);
|
||||
if(!isset($enumValueList[$index])){
|
||||
throw new \UnexpectedValueException("Invalid enum value index $index");
|
||||
}
|
||||
//Get the enum value from the initial pile of mess
|
||||
$retval->enumValues[] = $this->enumValues[$index];
|
||||
$retval->enumValues[] = $enumValueList[$index];
|
||||
}
|
||||
|
||||
return $retval;
|
||||
@ -170,17 +156,21 @@ class AvailableCommandsPacket extends DataPacket{
|
||||
return $retval;
|
||||
}
|
||||
|
||||
protected function putEnum(CommandEnum $enum){
|
||||
/**
|
||||
* @param CommandEnum $enum
|
||||
* @param int[] $enumValueMap string enum name -> int index
|
||||
*/
|
||||
protected function putEnum(CommandEnum $enum, array $enumValueMap) : void{
|
||||
$this->putString($enum->enumName);
|
||||
|
||||
$this->putUnsignedVarInt(count($enum->enumValues));
|
||||
$listSize = count($enumValueMap);
|
||||
foreach($enum->enumValues as $value){
|
||||
//Dumb bruteforce search. I hate this packet.
|
||||
$index = array_search($value, $this->enumValues, true);
|
||||
if($index === false){
|
||||
$index = $enumValueMap[$value] ?? -1;
|
||||
if($index === -1){
|
||||
throw new \InvalidStateException("Enum value '$value' not found");
|
||||
}
|
||||
$this->putEnumValueIndex($index);
|
||||
$this->putEnumValueIndex($index, $listSize);
|
||||
}
|
||||
}
|
||||
|
||||
@ -193,33 +183,47 @@ class AvailableCommandsPacket extends DataPacket{
|
||||
}
|
||||
}
|
||||
|
||||
protected function getEnumValueIndex() : int{
|
||||
if($this->enumValuesCount < 256){
|
||||
/**
|
||||
* @param int $valueCount
|
||||
*
|
||||
* @return int
|
||||
* @throws BinaryDataException
|
||||
*/
|
||||
protected function getEnumValueIndex(int $valueCount) : int{
|
||||
if($valueCount < 256){
|
||||
return $this->getByte();
|
||||
}elseif($this->enumValuesCount < 65536){
|
||||
}elseif($valueCount < 65536){
|
||||
return $this->getLShort();
|
||||
}else{
|
||||
return $this->getLInt();
|
||||
}
|
||||
}
|
||||
|
||||
protected function putEnumValueIndex(int $index){
|
||||
if($this->enumValuesCount < 256){
|
||||
protected function putEnumValueIndex(int $index, int $valueCount) : void{
|
||||
if($valueCount < 256){
|
||||
$this->putByte($index);
|
||||
}elseif($this->enumValuesCount < 65536){
|
||||
}elseif($valueCount < 65536){
|
||||
$this->putLShort($index);
|
||||
}else{
|
||||
$this->putLInt($index);
|
||||
}
|
||||
}
|
||||
|
||||
protected function getCommandData() : CommandData{
|
||||
/**
|
||||
* @param CommandEnum[] $enums
|
||||
* @param string[] $postfixes
|
||||
*
|
||||
* @return CommandData
|
||||
* @throws \UnexpectedValueException
|
||||
* @throws BinaryDataException
|
||||
*/
|
||||
protected function getCommandData(array $enums, array $postfixes) : CommandData{
|
||||
$retval = new CommandData();
|
||||
$retval->commandName = $this->getString();
|
||||
$retval->commandDescription = $this->getString();
|
||||
$retval->flags = $this->getByte();
|
||||
$retval->permission = $this->getByte();
|
||||
$retval->aliases = $this->enums[$this->getLInt()] ?? null;
|
||||
$retval->aliases = $enums[$this->getLInt()] ?? null;
|
||||
|
||||
for($overloadIndex = 0, $overloadCount = $this->getUnsignedVarInt(); $overloadIndex < $overloadCount; ++$overloadIndex){
|
||||
for($paramIndex = 0, $paramCount = $this->getUnsignedVarInt(); $paramIndex < $paramCount; ++$paramIndex){
|
||||
@ -227,17 +231,17 @@ class AvailableCommandsPacket extends DataPacket{
|
||||
$parameter->paramName = $this->getString();
|
||||
$parameter->paramType = $this->getLInt();
|
||||
$parameter->isOptional = $this->getBool();
|
||||
$parameter->byte1 = $this->getByte();
|
||||
$parameter->flags = $this->getByte();
|
||||
|
||||
if($parameter->paramType & self::ARG_FLAG_ENUM){
|
||||
$index = ($parameter->paramType & 0xffff);
|
||||
$parameter->enum = $this->enums[$index] ?? null;
|
||||
$parameter->enum = $enums[$index] ?? null;
|
||||
if($parameter->enum === null){
|
||||
throw new \UnexpectedValueException("deserializing $retval->commandName parameter $parameter->paramName: expected enum at $index, but got none");
|
||||
}
|
||||
}elseif($parameter->paramType & self::ARG_FLAG_POSTFIX){
|
||||
$index = ($parameter->paramType & 0xffff);
|
||||
$parameter->postfix = $this->postfixes[$index] ?? null;
|
||||
$parameter->postfix = $postfixes[$index] ?? null;
|
||||
if($parameter->postfix === null){
|
||||
throw new \UnexpectedValueException("deserializing $retval->commandName parameter $parameter->paramName: expected postfix at $index, but got none");
|
||||
}
|
||||
@ -252,14 +256,19 @@ class AvailableCommandsPacket extends DataPacket{
|
||||
return $retval;
|
||||
}
|
||||
|
||||
protected function putCommandData(CommandData $data){
|
||||
/**
|
||||
* @param CommandData $data
|
||||
* @param int[] $enumIndexes string enum name -> int index
|
||||
* @param int[] $postfixIndexes
|
||||
*/
|
||||
protected function putCommandData(CommandData $data, array $enumIndexes, array $postfixIndexes) : void{
|
||||
$this->putString($data->commandName);
|
||||
$this->putString($data->commandDescription);
|
||||
$this->putByte($data->flags);
|
||||
$this->putByte($data->permission);
|
||||
|
||||
if($data->aliases !== null){
|
||||
$this->putLInt($this->enumMap[$data->aliases->enumName] ?? -1);
|
||||
$this->putLInt($enumIndexes[$data->aliases->enumName] ?? -1);
|
||||
}else{
|
||||
$this->putLInt(-1);
|
||||
}
|
||||
@ -272,10 +281,10 @@ class AvailableCommandsPacket extends DataPacket{
|
||||
$this->putString($parameter->paramName);
|
||||
|
||||
if($parameter->enum !== null){
|
||||
$type = self::ARG_FLAG_ENUM | self::ARG_FLAG_VALID | ($this->enumMap[$parameter->enum->enumName] ?? -1);
|
||||
$type = self::ARG_FLAG_ENUM | self::ARG_FLAG_VALID | ($enumIndexes[$parameter->enum->enumName] ?? -1);
|
||||
}elseif($parameter->postfix !== null){
|
||||
$key = array_search($parameter->postfix, $this->postfixes, true);
|
||||
if($key === false){
|
||||
$key = $postfixIndexes[$parameter->postfix] ?? -1;
|
||||
if($key === -1){
|
||||
throw new \InvalidStateException("Postfix '$parameter->postfix' not in postfixes array");
|
||||
}
|
||||
$type = self::ARG_FLAG_POSTFIX | $key;
|
||||
@ -285,12 +294,12 @@ class AvailableCommandsPacket extends DataPacket{
|
||||
|
||||
$this->putLInt($type);
|
||||
$this->putBool($parameter->isOptional);
|
||||
$this->putByte($parameter->byte1);
|
||||
$this->putByte($parameter->flags);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function argTypeToString(int $argtype) : string{
|
||||
private function argTypeToString(int $argtype, array $postfixes) : string{
|
||||
if($argtype & self::ARG_FLAG_VALID){
|
||||
if($argtype & self::ARG_FLAG_ENUM){
|
||||
return "stringenum (" . ($argtype & 0xffff) . ")";
|
||||
@ -319,7 +328,7 @@ class AvailableCommandsPacket extends DataPacket{
|
||||
return "command";
|
||||
}
|
||||
}elseif($argtype & self::ARG_FLAG_POSTFIX){
|
||||
$postfix = $this->postfixes[$argtype & 0xffff];
|
||||
$postfix = $postfixes[$argtype & 0xffff];
|
||||
|
||||
return "int (postfix $postfix)";
|
||||
}else{
|
||||
@ -330,15 +339,22 @@ class AvailableCommandsPacket extends DataPacket{
|
||||
}
|
||||
|
||||
protected function encodePayload(){
|
||||
$enumValuesMap = [];
|
||||
$postfixesMap = [];
|
||||
$enumMap = [];
|
||||
/** @var int[] $enumValueIndexes */
|
||||
$enumValueIndexes = [];
|
||||
/** @var int[] $postfixIndexes */
|
||||
$postfixIndexes = [];
|
||||
/** @var int[] $enumIndexes */
|
||||
$enumIndexes = [];
|
||||
/** @var CommandEnum[] $enums */
|
||||
$enums = [];
|
||||
foreach($this->commandData as $commandData){
|
||||
if($commandData->aliases !== null){
|
||||
$enumMap[$commandData->aliases->enumName] = $commandData->aliases;
|
||||
if(!isset($enumIndexes[$commandData->aliases->enumName])){
|
||||
$enums[$enumIndexes[$commandData->aliases->enumName] = count($enumIndexes)] = $commandData->aliases;
|
||||
}
|
||||
|
||||
foreach($commandData->aliases->enumValues as $str){
|
||||
$enumValuesMap[$str] = true;
|
||||
$enumValueIndexes[$str] = $enumValueIndexes[$str] ?? count($enumValueIndexes); //latest index
|
||||
}
|
||||
}
|
||||
|
||||
@ -349,41 +365,39 @@ class AvailableCommandsPacket extends DataPacket{
|
||||
*/
|
||||
foreach($overload as $parameter){
|
||||
if($parameter->enum !== null){
|
||||
$enumMap[$parameter->enum->enumName] = $parameter->enum;
|
||||
if(!isset($enumIndexes[$parameter->enum->enumName])){
|
||||
$enums[$enumIndexes[$parameter->enum->enumName] = count($enumIndexes)] = $parameter->enum;
|
||||
}
|
||||
foreach($parameter->enum->enumValues as $str){
|
||||
$enumValuesMap[$str] = true;
|
||||
$enumValueIndexes[$str] = $enumValueIndexes[$str] ?? count($enumValueIndexes);
|
||||
}
|
||||
}
|
||||
|
||||
if($parameter->postfix !== null){
|
||||
$postfixesMap[$parameter->postfix] = true;
|
||||
$postfixIndexes[$parameter->postfix] = $postfixIndexes[$parameter->postfix] ?? count($postfixIndexes);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->enumValues = array_map('\strval', array_keys($enumValuesMap)); //stupid PHP key casting D:
|
||||
$this->putUnsignedVarInt($this->enumValuesCount = count($this->enumValues));
|
||||
foreach($this->enumValues as $enumValue){
|
||||
$this->putString($enumValue);
|
||||
$this->putUnsignedVarInt(count($enumValueIndexes));
|
||||
foreach($enumValueIndexes as $enumValue => $index){
|
||||
$this->putString((string) $enumValue); //stupid PHP key casting D:
|
||||
}
|
||||
|
||||
$this->postfixes = array_map('\strval', array_keys($postfixesMap));
|
||||
$this->putUnsignedVarInt(count($this->postfixes));
|
||||
foreach($this->postfixes as $postfix){
|
||||
$this->putString($postfix);
|
||||
$this->putUnsignedVarInt(count($postfixIndexes));
|
||||
foreach($postfixIndexes as $postfix => $index){
|
||||
$this->putString((string) $postfix); //stupid PHP key casting D:
|
||||
}
|
||||
|
||||
$this->enums = array_values($enumMap);
|
||||
$this->enumMap = array_flip(array_keys($enumMap));
|
||||
$this->putUnsignedVarInt(count($this->enums));
|
||||
foreach($this->enums as $enum){
|
||||
$this->putEnum($enum);
|
||||
$this->putUnsignedVarInt(count($enums));
|
||||
foreach($enums as $enum){
|
||||
$this->putEnum($enum, $enumValueIndexes);
|
||||
}
|
||||
|
||||
$this->putUnsignedVarInt(count($this->commandData));
|
||||
foreach($this->commandData as $data){
|
||||
$this->putCommandData($data);
|
||||
$this->putCommandData($data, $enumIndexes, $postfixIndexes);
|
||||
}
|
||||
|
||||
$this->putUnsignedVarInt(count($this->softEnums));
|
||||
|
File diff suppressed because one or more lines are too long
@ -28,8 +28,8 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class BlockEntityDataPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::BLOCK_ENTITY_DATA_PACKET;
|
||||
class BlockActorDataPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::BLOCK_ACTOR_DATA_PACKET;
|
||||
|
||||
/** @var int */
|
||||
public $x;
|
||||
@ -51,6 +51,6 @@ class BlockEntityDataPacket extends DataPacket{
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleBlockEntityData($this);
|
||||
return $session->handleBlockActorData($this);
|
||||
}
|
||||
}
|
@ -39,9 +39,9 @@ class BossEventPacket extends DataPacket{
|
||||
public const TYPE_HIDE = 2;
|
||||
/* C2S: Unregisters a player from a boss fight. */
|
||||
public const TYPE_UNREGISTER_PLAYER = 3;
|
||||
/* S2C: Appears not to be implemented. Currently bar percentage only appears to change in response to the target entity's health. */
|
||||
/* S2C: Sets the bar percentage. */
|
||||
public const TYPE_HEALTH_PERCENT = 4;
|
||||
/* S2C: Also appears to not be implemented. Title client-side sticks as the target entity's nametag, or their entity type name if not set. */
|
||||
/* S2C: Sets title of the bar. */
|
||||
public const TYPE_TITLE = 5;
|
||||
/* S2C: Not sure on this. Includes color and overlay fields, plus an unknown short. TODO: check this */
|
||||
public const TYPE_UNKNOWN_6 = 6;
|
||||
|
@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use function count;
|
||||
|
||||
class ClientCacheBlobStatusPacket extends DataPacket/* implements ServerboundPacket*/{
|
||||
public const NETWORK_ID = ProtocolInfo::CLIENT_CACHE_BLOB_STATUS_PACKET;
|
||||
|
||||
/** @var int[] xxHash64 subchunk data hashes */
|
||||
private $hitHashes = [];
|
||||
/** @var int[] xxHash64 subchunk data hashes */
|
||||
private $missHashes = [];
|
||||
|
||||
/**
|
||||
* @param int[] $hitHashes
|
||||
* @param int[] $missHashes
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public static function create(array $hitHashes, array $missHashes) : self{
|
||||
//type checks
|
||||
(static function(int ...$hashes){})(...$hitHashes);
|
||||
(static function(int ...$hashes){})(...$missHashes);
|
||||
|
||||
$result = new self;
|
||||
$result->hitHashes = $hitHashes;
|
||||
$result->missHashes = $missHashes;
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int[]
|
||||
*/
|
||||
public function getHitHashes() : array{
|
||||
return $this->hitHashes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int[]
|
||||
*/
|
||||
public function getMissHashes() : array{
|
||||
return $this->missHashes;
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$hitCount = $this->getUnsignedVarInt();
|
||||
$missCount = $this->getUnsignedVarInt();
|
||||
for($i = 0; $i < $hitCount; ++$i){
|
||||
$this->hitHashes[] = $this->getLLong();
|
||||
}
|
||||
for($i = 0; $i < $missCount; ++$i){
|
||||
$this->missHashes[] = $this->getLLong();
|
||||
}
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putUnsignedVarInt(count($this->hitHashes));
|
||||
$this->putUnsignedVarInt(count($this->missHashes));
|
||||
foreach($this->hitHashes as $hash){
|
||||
$this->putLLong($hash);
|
||||
}
|
||||
foreach($this->missHashes as $hash){
|
||||
$this->putLLong($hash);
|
||||
}
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $handler) : bool{
|
||||
return $handler->handleClientCacheBlobStatus($this);
|
||||
}
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\protocol\types\ChunkCacheBlob;
|
||||
use function count;
|
||||
|
||||
class ClientCacheMissResponsePacket extends DataPacket/* implements ClientboundPacket*/{
|
||||
public const NETWORK_ID = ProtocolInfo::CLIENT_CACHE_MISS_RESPONSE_PACKET;
|
||||
|
||||
/** @var ChunkCacheBlob[] */
|
||||
private $blobs = [];
|
||||
|
||||
/**
|
||||
* @param ChunkCacheBlob[] $blobs
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public static function create(array $blobs) : self{
|
||||
//type check
|
||||
(static function(ChunkCacheBlob ...$blobs){})(...$blobs);
|
||||
|
||||
$result = new self;
|
||||
$result->blobs = $blobs;
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ChunkCacheBlob[]
|
||||
*/
|
||||
public function getBlobs() : array{
|
||||
return $this->blobs;
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
for($i = 0, $count = $this->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
$hash = $this->getLLong();
|
||||
$payload = $this->getString();
|
||||
$this->blobs[] = new ChunkCacheBlob($hash, $payload);
|
||||
}
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putUnsignedVarInt(count($this->blobs));
|
||||
foreach($this->blobs as $blob){
|
||||
$this->putLLong($blob->getHash());
|
||||
$this->putString($blob->getPayload());
|
||||
}
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $handler) : bool{
|
||||
return $handler->handleClientCacheMissResponse($this);
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class ClientCacheStatusPacket extends DataPacket/* implements ServerboundPacket*/{
|
||||
public const NETWORK_ID = ProtocolInfo::CLIENT_CACHE_STATUS_PACKET;
|
||||
|
||||
/** @var bool */
|
||||
private $enabled;
|
||||
|
||||
public static function create(bool $enabled) : self{
|
||||
$result = new self;
|
||||
$result->enabled = $enabled;
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isEnabled() : bool{
|
||||
return $this->enabled;
|
||||
}
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->enabled = $this->getBool();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putBool($this->enabled);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $handler) : bool{
|
||||
return $handler->handleClientCacheStatus($this);
|
||||
}
|
||||
}
|
@ -59,6 +59,10 @@ class CommandBlockUpdatePacket extends DataPacket{
|
||||
public $name;
|
||||
/** @var bool */
|
||||
public $shouldTrackOutput;
|
||||
/** @var int */
|
||||
public $tickDelay;
|
||||
/** @var bool */
|
||||
public $executeOnFirstTick;
|
||||
|
||||
protected function decodePayload(){
|
||||
$this->isBlock = $this->getBool();
|
||||
@ -78,6 +82,8 @@ class CommandBlockUpdatePacket extends DataPacket{
|
||||
$this->name = $this->getString();
|
||||
|
||||
$this->shouldTrackOutput = $this->getBool();
|
||||
$this->tickDelay = $this->getLInt();
|
||||
$this->executeOnFirstTick = $this->getBool();
|
||||
}
|
||||
|
||||
protected function encodePayload(){
|
||||
@ -97,6 +103,8 @@ class CommandBlockUpdatePacket extends DataPacket{
|
||||
$this->putString($this->name);
|
||||
|
||||
$this->putBool($this->shouldTrackOutput);
|
||||
$this->putLInt($this->tickDelay);
|
||||
$this->putBool($this->executeOnFirstTick);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
|
@ -34,7 +34,7 @@ class ContainerSetDataPacket extends DataPacket{
|
||||
public const PROPERTY_FURNACE_TICK_COUNT = 0;
|
||||
public const PROPERTY_FURNACE_LIT_TIME = 1;
|
||||
public const PROPERTY_FURNACE_LIT_DURATION = 2;
|
||||
//TODO: check property 3
|
||||
public const PROPERTY_FURNACE_STORED_XP = 3;
|
||||
public const PROPERTY_FURNACE_FUEL_AUX = 4;
|
||||
|
||||
public const PROPERTY_BREWING_STAND_BREW_TIME = 0;
|
||||
|
@ -33,6 +33,9 @@ use pocketmine\item\Item;
|
||||
use pocketmine\item\ItemFactory;
|
||||
use pocketmine\network\mcpe\NetworkBinaryStream;
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
#ifndef COMPILE
|
||||
use pocketmine\utils\Binary;
|
||||
#endif
|
||||
use function count;
|
||||
use function str_repeat;
|
||||
|
||||
@ -72,11 +75,13 @@ class CraftingDataPacket extends DataPacket{
|
||||
case self::ENTRY_SHAPELESS:
|
||||
case self::ENTRY_SHULKER_BOX:
|
||||
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"][] = $this->getSlot();
|
||||
$entry["input"][] = $in = $this->getRecipeIngredient();
|
||||
$in->setCount(1); //TODO HACK: they send a useless count field which breaks the PM crafting system because it isn't always 1
|
||||
}
|
||||
$resultCount = $this->getUnsignedVarInt();
|
||||
$entry["output"] = [];
|
||||
@ -85,16 +90,19 @@ class CraftingDataPacket extends DataPacket{
|
||||
}
|
||||
$entry["uuid"] = $this->getUUID()->toString();
|
||||
$entry["block"] = $this->getString();
|
||||
$entry["priority"] = $this->getVarInt();
|
||||
|
||||
break;
|
||||
case self::ENTRY_SHAPED:
|
||||
case self::ENTRY_SHAPED_CHEMISTRY:
|
||||
$entry["recipe_id"] = $this->getString();
|
||||
$entry["width"] = $this->getVarInt();
|
||||
$entry["height"] = $this->getVarInt();
|
||||
$count = $entry["width"] * $entry["height"];
|
||||
$entry["input"] = [];
|
||||
for($j = 0; $j < $count; ++$j){
|
||||
$entry["input"][] = $this->getSlot();
|
||||
$entry["input"][] = $in = $this->getRecipeIngredient();
|
||||
$in->setCount(1); //TODO HACK: they send a useless count field which breaks the PM crafting system
|
||||
}
|
||||
$resultCount = $this->getUnsignedVarInt();
|
||||
$entry["output"] = [];
|
||||
@ -103,6 +111,7 @@ class CraftingDataPacket extends DataPacket{
|
||||
}
|
||||
$entry["uuid"] = $this->getUUID()->toString();
|
||||
$entry["block"] = $this->getString();
|
||||
$entry["priority"] = $this->getVarInt();
|
||||
|
||||
break;
|
||||
case self::ENTRY_FURNACE:
|
||||
@ -116,7 +125,10 @@ class CraftingDataPacket extends DataPacket{
|
||||
}
|
||||
}
|
||||
$entry["input"] = ItemFactory::get($inputId, $inputData);
|
||||
$entry["output"] = $this->getSlot();
|
||||
$entry["output"] = $out = $this->getSlot();
|
||||
if($out->getDamage() === 0x7fff){
|
||||
$out->setDamage(0); //TODO HACK: some 1.12 furnace recipe outputs have wildcard damage values
|
||||
}
|
||||
$entry["block"] = $this->getString();
|
||||
|
||||
break;
|
||||
@ -131,11 +143,11 @@ class CraftingDataPacket extends DataPacket{
|
||||
$this->getBool(); //cleanRecipes
|
||||
}
|
||||
|
||||
private static function writeEntry($entry, NetworkBinaryStream $stream){
|
||||
private static function writeEntry($entry, NetworkBinaryStream $stream, int $pos){
|
||||
if($entry instanceof ShapelessRecipe){
|
||||
return self::writeShapelessRecipe($entry, $stream);
|
||||
return self::writeShapelessRecipe($entry, $stream, $pos);
|
||||
}elseif($entry instanceof ShapedRecipe){
|
||||
return self::writeShapedRecipe($entry, $stream);
|
||||
return self::writeShapedRecipe($entry, $stream, $pos);
|
||||
}elseif($entry instanceof FurnaceRecipe){
|
||||
return self::writeFurnaceRecipe($entry, $stream);
|
||||
}
|
||||
@ -144,10 +156,11 @@ class CraftingDataPacket extends DataPacket{
|
||||
return -1;
|
||||
}
|
||||
|
||||
private static function writeShapelessRecipe(ShapelessRecipe $recipe, NetworkBinaryStream $stream){
|
||||
private static function writeShapelessRecipe(ShapelessRecipe $recipe, NetworkBinaryStream $stream, int $pos){
|
||||
$stream->putString(Binary::writeInt($pos)); //some kind of recipe ID, doesn't matter what it is as long as it's unique
|
||||
$stream->putUnsignedVarInt($recipe->getIngredientCount());
|
||||
foreach($recipe->getIngredientList() as $item){
|
||||
$stream->putSlot($item);
|
||||
$stream->putRecipeIngredient($item);
|
||||
}
|
||||
|
||||
$results = $recipe->getResults();
|
||||
@ -158,17 +171,19 @@ class CraftingDataPacket extends DataPacket{
|
||||
|
||||
$stream->put(str_repeat("\x00", 16)); //Null UUID
|
||||
$stream->putString("crafting_table"); //TODO: blocktype (no prefix) (this might require internal API breaks)
|
||||
$stream->putVarInt(50); //TODO: priority
|
||||
|
||||
return CraftingDataPacket::ENTRY_SHAPELESS;
|
||||
}
|
||||
|
||||
private static function writeShapedRecipe(ShapedRecipe $recipe, NetworkBinaryStream $stream){
|
||||
private static function writeShapedRecipe(ShapedRecipe $recipe, NetworkBinaryStream $stream, int $pos){
|
||||
$stream->putString(Binary::writeInt($pos)); //some kind of recipe ID, doesn't matter what it is as long as it's unique
|
||||
$stream->putVarInt($recipe->getWidth());
|
||||
$stream->putVarInt($recipe->getHeight());
|
||||
|
||||
for($z = 0; $z < $recipe->getHeight(); ++$z){
|
||||
for($x = 0; $x < $recipe->getWidth(); ++$x){
|
||||
$stream->putSlot($recipe->getIngredient($x, $z));
|
||||
$stream->putRecipeIngredient($recipe->getIngredient($x, $z));
|
||||
}
|
||||
}
|
||||
|
||||
@ -180,6 +195,7 @@ class CraftingDataPacket extends DataPacket{
|
||||
|
||||
$stream->put(str_repeat("\x00", 16)); //Null UUID
|
||||
$stream->putString("crafting_table"); //TODO: blocktype (no prefix) (this might require internal API breaks)
|
||||
$stream->putVarInt(50); //TODO: priority
|
||||
|
||||
return CraftingDataPacket::ENTRY_SHAPED;
|
||||
}
|
||||
@ -212,8 +228,9 @@ class CraftingDataPacket extends DataPacket{
|
||||
$this->putUnsignedVarInt(count($this->entries));
|
||||
|
||||
$writer = new NetworkBinaryStream();
|
||||
$counter = 0;
|
||||
foreach($this->entries as $d){
|
||||
$entryType = self::writeEntry($d, $writer);
|
||||
$entryType = self::writeEntry($d, $writer, $counter++);
|
||||
if($entryType >= 0){
|
||||
$this->putVarInt($entryType);
|
||||
$this->put($writer->getBuffer());
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user