Merge branch 'next-major' into modern-world-support

This commit is contained in:
Dylan K. Taylor 2022-04-20 14:29:22 +01:00
commit e383f6d8f8
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
13 changed files with 68 additions and 26 deletions

View File

@ -107,3 +107,15 @@ Released 17th April 2022.
- Fixed a memory leak in RakLib which could result in a server crash when players stay online for a long time. - Fixed a memory leak in RakLib which could result in a server crash when players stay online for a long time.
- Fixed server crash when attempting to load a corrupted empty resource pack. - Fixed server crash when attempting to load a corrupted empty resource pack.
- Fixed users with the same name with differerently cased letters being able to duplicate items (userdata is matched by case-insensitive name). - Fixed users with the same name with differerently cased letters being able to duplicate items (userdata is matched by case-insensitive name).
# 4.2.9
Released 19th April 2022.
## Fixes
- Fixed several potential crashes when deserializing item NBT (due to insufficient validation of input data).
# 4.2.10
Released 20th April 2022.
## Fixes
- Fixed performance issue when chat messages received from the client contain many newlines. This security vulnerability was disclosed publicly necessitating a priority fix.

14
changelogs/4.3.md Normal file
View File

@ -0,0 +1,14 @@
**For Minecraft: Bedrock Edition 1.18.30**
### Note about API versions
Plugins which don't touch the protocol and compatible with any previous 4.x.y version will also run on these releases and do not need API bumps.
Plugin developers should **only** update their required API to this version if you need the changes in this build.
**WARNING: If your plugin uses the protocol, you're not shielded by API change constraints.** You should consider using the `mcpe-protocol` directive in `plugin.yml` as a constraint if you do.
# 4.3.0
Released 20th April 2022.
## General
- Added support for Minecraft: Bedrock Edition 1.18.30.
- Removed support for older versions.

View File

@ -35,8 +35,8 @@
"fgrosse/phpasn1": "^2.3", "fgrosse/phpasn1": "^2.3",
"netresearch/jsonmapper": "^4.0", "netresearch/jsonmapper": "^4.0",
"pocketmine/bedrock-block-upgrade-schema": "dev-master@dev", "pocketmine/bedrock-block-upgrade-schema": "dev-master@dev",
"pocketmine/bedrock-data": "~1.6.0+bedrock-1.18.10", "pocketmine/bedrock-data": "~1.7.0+bedrock-1.18.30",
"pocketmine/bedrock-protocol": "~8.0.2+bedrock-1.18.10", "pocketmine/bedrock-protocol": "~9.0.0+bedrock-1.18.30",
"pocketmine/binaryutils": "^0.2.1", "pocketmine/binaryutils": "^0.2.1",
"pocketmine/callback-validator": "^1.0.2", "pocketmine/callback-validator": "^1.0.2",
"pocketmine/classloader": "^0.2.0", "pocketmine/classloader": "^0.2.0",

30
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "751c8e23dc6763022e8a780f0083f629", "content-hash": "90fd504df83303dbc46c7834a312f3b0",
"packages": [ "packages": [
{ {
"name": "adhocore/json-comment", "name": "adhocore/json-comment",
@ -276,42 +276,42 @@
}, },
{ {
"name": "pocketmine/bedrock-data", "name": "pocketmine/bedrock-data",
"version": "1.6.0+bedrock-1.18.10", "version": "1.7.0+bedrock-1.18.30",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/pmmp/BedrockData.git", "url": "https://github.com/pmmp/BedrockData.git",
"reference": "e98c511584a7bd58a95986374d2df4b04c6a2ba0" "reference": "c8f323ff0cbdb36a5d95e7e4a23969f562445be0"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/pmmp/BedrockData/zipball/e98c511584a7bd58a95986374d2df4b04c6a2ba0", "url": "https://api.github.com/repos/pmmp/BedrockData/zipball/c8f323ff0cbdb36a5d95e7e4a23969f562445be0",
"reference": "e98c511584a7bd58a95986374d2df4b04c6a2ba0", "reference": "c8f323ff0cbdb36a5d95e7e4a23969f562445be0",
"shasum": "" "shasum": ""
}, },
"type": "library", "type": "library",
"notification-url": "https://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"LGPL-3.0" "CC0-1.0"
], ],
"description": "Blobs of data generated from Minecraft: Bedrock Edition, used by PocketMine-MP", "description": "Blobs of data generated from Minecraft: Bedrock Edition, used by PocketMine-MP",
"support": { "support": {
"issues": "https://github.com/pmmp/BedrockData/issues", "issues": "https://github.com/pmmp/BedrockData/issues",
"source": "https://github.com/pmmp/BedrockData/tree/bedrock-1.18.10" "source": "https://github.com/pmmp/BedrockData/tree/bedrock-1.18.30"
}, },
"time": "2022-02-08T19:13:47+00:00" "time": "2022-04-20T12:40:59+00:00"
}, },
{ {
"name": "pocketmine/bedrock-protocol", "name": "pocketmine/bedrock-protocol",
"version": "8.0.2+bedrock-1.18.10", "version": "9.0.0+bedrock-1.18.30",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/pmmp/BedrockProtocol.git", "url": "https://github.com/pmmp/BedrockProtocol.git",
"reference": "d1f1afdbb4ea61ea52eb511a79ee1ca561da349c" "reference": "76cf00af0070dbb3f63a3e7fe74039d011a5475e"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/pmmp/BedrockProtocol/zipball/d1f1afdbb4ea61ea52eb511a79ee1ca561da349c", "url": "https://api.github.com/repos/pmmp/BedrockProtocol/zipball/76cf00af0070dbb3f63a3e7fe74039d011a5475e",
"reference": "d1f1afdbb4ea61ea52eb511a79ee1ca561da349c", "reference": "76cf00af0070dbb3f63a3e7fe74039d011a5475e",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -325,7 +325,7 @@
"ramsey/uuid": "^4.1" "ramsey/uuid": "^4.1"
}, },
"require-dev": { "require-dev": {
"phpstan/phpstan": "1.5.3", "phpstan/phpstan": "1.5.4",
"phpstan/phpstan-phpunit": "^1.0.0", "phpstan/phpstan-phpunit": "^1.0.0",
"phpstan/phpstan-strict-rules": "^1.0.0", "phpstan/phpstan-strict-rules": "^1.0.0",
"phpunit/phpunit": "^9.5" "phpunit/phpunit": "^9.5"
@ -343,9 +343,9 @@
"description": "An implementation of the Minecraft: Bedrock Edition protocol in PHP", "description": "An implementation of the Minecraft: Bedrock Edition protocol in PHP",
"support": { "support": {
"issues": "https://github.com/pmmp/BedrockProtocol/issues", "issues": "https://github.com/pmmp/BedrockProtocol/issues",
"source": "https://github.com/pmmp/BedrockProtocol/tree/8.0.2+bedrock-1.18.10" "source": "https://github.com/pmmp/BedrockProtocol/tree/9.0.0+bedrock-1.18.30"
}, },
"time": "2022-04-01T21:55:10+00:00" "time": "2022-04-20T12:44:11+00:00"
}, },
{ {
"name": "pocketmine/binaryutils", "name": "pocketmine/binaryutils",

View File

@ -31,7 +31,7 @@ use function str_repeat;
final class VersionInfo{ final class VersionInfo{
public const NAME = "PocketMine-MP"; public const NAME = "PocketMine-MP";
public const BASE_VERSION = "4.3.0"; public const BASE_VERSION = "4.4.0";
public const IS_DEVELOPMENT_BUILD = true; public const IS_DEVELOPMENT_BUILD = true;
public const BUILD_CHANNEL = "beta"; public const BUILD_CHANNEL = "beta";

View File

@ -44,7 +44,7 @@ trait ContainerTrait{
abstract public function getRealInventory(); abstract public function getRealInventory();
protected function loadItems(CompoundTag $tag) : void{ protected function loadItems(CompoundTag $tag) : void{
if(($inventoryTag = $tag->getTag(Container::TAG_ITEMS)) instanceof ListTag){ if(($inventoryTag = $tag->getTag(Container::TAG_ITEMS)) instanceof ListTag && $inventoryTag->getTagType() === NBT::TAG_Compound){
$inventory = $this->getRealInventory(); $inventory = $this->getRealInventory();
$listeners = $inventory->getListeners()->toArray(); $listeners = $inventory->getListeners()->toArray();
$inventory->getListeners()->remove(...$listeners); //prevent any events being fired by initialization $inventory->getListeners()->remove(...$listeners); //prevent any events being fired by initialization

View File

@ -55,6 +55,7 @@ use pocketmine\network\mcpe\protocol\types\DeviceOS;
use pocketmine\network\mcpe\protocol\types\entity\EntityIds; use pocketmine\network\mcpe\protocol\types\entity\EntityIds;
use pocketmine\network\mcpe\protocol\types\entity\EntityMetadataProperties; use pocketmine\network\mcpe\protocol\types\entity\EntityMetadataProperties;
use pocketmine\network\mcpe\protocol\types\entity\StringMetadataProperty; use pocketmine\network\mcpe\protocol\types\entity\StringMetadataProperty;
use pocketmine\network\mcpe\protocol\types\GameMode;
use pocketmine\network\mcpe\protocol\types\inventory\ItemStackWrapper; use pocketmine\network\mcpe\protocol\types\inventory\ItemStackWrapper;
use pocketmine\network\mcpe\protocol\types\PlayerListEntry; use pocketmine\network\mcpe\protocol\types\PlayerListEntry;
use pocketmine\player\Player; use pocketmine\player\Player;
@ -479,6 +480,7 @@ class Human extends Living implements ProjectileSource, InventoryHolder{
$this->location->yaw, $this->location->yaw,
$this->location->yaw, //TODO: head yaw $this->location->yaw, //TODO: head yaw
ItemStackWrapper::legacy(TypeConverter::getInstance()->coreItemStackToNet($this->getInventory()->getItemInHand())), ItemStackWrapper::legacy(TypeConverter::getInstance()->coreItemStackToNet($this->getInventory()->getItemInHand())),
GameMode::SURVIVAL,
$this->getAllNetworkData(), $this->getAllNetworkData(),
AdventureSettingsPacket::create(0, 0, 0, 0, 0, $this->getId()), //TODO AdventureSettingsPacket::create(0, 0, 0, 0, 0, $this->getId()), //TODO
[], //TODO: entity links [], //TODO: entity links

View File

@ -29,6 +29,7 @@ use pocketmine\block\utils\BannerPatternLayer;
use pocketmine\block\utils\DyeColor; use pocketmine\block\utils\DyeColor;
use pocketmine\data\bedrock\BannerPatternTypeIdMap; use pocketmine\data\bedrock\BannerPatternTypeIdMap;
use pocketmine\data\bedrock\DyeColorIdMap; use pocketmine\data\bedrock\DyeColorIdMap;
use pocketmine\nbt\NBT;
use pocketmine\nbt\tag\CompoundTag; use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\ListTag; use pocketmine\nbt\tag\ListTag;
use function count; use function count;
@ -98,7 +99,7 @@ class Banner extends ItemBlockWallOrFloor{
$colorIdMap = DyeColorIdMap::getInstance(); $colorIdMap = DyeColorIdMap::getInstance();
$patternIdMap = BannerPatternTypeIdMap::getInstance(); $patternIdMap = BannerPatternTypeIdMap::getInstance();
$patterns = $tag->getListTag(self::TAG_PATTERNS); $patterns = $tag->getListTag(self::TAG_PATTERNS);
if($patterns !== null){ if($patterns !== null && $patterns->getTagType() === NBT::TAG_Compound){
/** @var CompoundTag $t */ /** @var CompoundTag $t */
foreach($patterns as $t){ foreach($patterns as $t){
$patternColor = $colorIdMap->fromInvertedId($t->getInt(self::TAG_PATTERN_COLOR)) ?? DyeColor::BLACK(); //TODO: missing pattern colour should be an error $patternColor = $colorIdMap->fromInvertedId($t->getInt(self::TAG_PATTERN_COLOR)) ?? DyeColor::BLACK(); //TODO: missing pattern colour should be an error

View File

@ -306,7 +306,7 @@ class Item implements \JsonSerializable{
$this->canPlaceOn = []; $this->canPlaceOn = [];
$canPlaceOn = $tag->getListTag("CanPlaceOn"); $canPlaceOn = $tag->getListTag("CanPlaceOn");
if($canPlaceOn !== null){ if($canPlaceOn !== null && $canPlaceOn->getTagType() === NBT::TAG_String){
/** @var StringTag $entry */ /** @var StringTag $entry */
foreach($canPlaceOn as $entry){ foreach($canPlaceOn as $entry){
$this->canPlaceOn[$entry->getValue()] = $entry->getValue(); $this->canPlaceOn[$entry->getValue()] = $entry->getValue();
@ -314,7 +314,7 @@ class Item implements \JsonSerializable{
} }
$this->canDestroy = []; $this->canDestroy = [];
$canDestroy = $tag->getListTag("CanDestroy"); $canDestroy = $tag->getListTag("CanDestroy");
if($canDestroy !== null){ if($canDestroy !== null && $canDestroy->getTagType() === NBT::TAG_String){
/** @var StringTag $entry */ /** @var StringTag $entry */
foreach($canDestroy as $entry){ foreach($canDestroy as $entry){
$this->canDestroy[$entry->getValue()] = $entry->getValue(); $this->canDestroy[$entry->getValue()] = $entry->getValue();

View File

@ -28,6 +28,7 @@ use pocketmine\data\bedrock\blockstate\BlockStateSerializeException;
use pocketmine\data\bedrock\blockstate\BlockStateSerializer; use pocketmine\data\bedrock\blockstate\BlockStateSerializer;
use pocketmine\data\bedrock\blockstate\BlockTypeNames; use pocketmine\data\bedrock\blockstate\BlockTypeNames;
use pocketmine\nbt\tag\CompoundTag; use pocketmine\nbt\tag\CompoundTag;
use pocketmine\network\mcpe\protocol\SimulationTypePacket;
use pocketmine\utils\AssumptionFailedError; use pocketmine\utils\AssumptionFailedError;
use pocketmine\utils\SingletonTrait; use pocketmine\utils\SingletonTrait;
use pocketmine\utils\Utils; use pocketmine\utils\Utils;
@ -53,8 +54,12 @@ final class RuntimeBlockMapping{
private BlockStateData $fallbackStateData; private BlockStateData $fallbackStateData;
private int $fallbackStateId; private int $fallbackStateId;
private function __construct(){ private static function make() : self{
$contents = Utils::assumeNotFalse(file_get_contents(Path::join(\pocketmine\BEDROCK_DATA_PATH, "canonical_block_states.nbt")), "Missing required resource file"); return new self(Path::join(\pocketmine\BEDROCK_DATA_PATH, "canonical_block_states.nbt"));
}
public function __construct(string $canonicalBlockStatesFile){
$contents = Utils::assumeNotFalse(file_get_contents($canonicalBlockStatesFile), "Missing required resource file");
$this->blockStateDictionary = BlockStateDictionary::loadFromString($contents); $this->blockStateDictionary = BlockStateDictionary::loadFromString($contents);
$this->blockStateSerializer = GlobalBlockStateHandlers::getSerializer(); $this->blockStateSerializer = GlobalBlockStateHandlers::getSerializer();

View File

@ -70,7 +70,7 @@ final class ChunkSerializer{
//TODO: right now we don't support 3D natively, so we just 3Dify our 2D biomes so they fill the column //TODO: right now we don't support 3D natively, so we just 3Dify our 2D biomes so they fill the column
$encodedBiomePalette = self::serializeBiomesAsPalette($chunk); $encodedBiomePalette = self::serializeBiomesAsPalette($chunk);
$stream->put(str_repeat($encodedBiomePalette, 25)); $stream->put(str_repeat($encodedBiomePalette, 24));
$stream->putByte(0); //border block array count $stream->putByte(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. //Border block entry format: 1 byte (4 bits X, 4 bits Z). These are however useless since they crash the regular client.

View File

@ -1377,8 +1377,14 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
public function chat(string $message) : bool{ public function chat(string $message) : bool{
$this->removeCurrentWindow(); $this->removeCurrentWindow();
//Fast length check, to make sure we don't get hung trying to explode MBs of string ...
$maxTotalLength = $this->messageCounter * (self::MAX_CHAT_BYTE_LENGTH + 1);
if(strlen($message) > $maxTotalLength){
return false;
}
$message = TextFormat::clean($message, false); $message = TextFormat::clean($message, false);
foreach(explode("\n", $message) as $messagePart){ foreach(explode("\n", $message, $this->messageCounter + 1) as $messagePart){
if(trim($messagePart) !== "" && strlen($messagePart) <= self::MAX_CHAT_BYTE_LENGTH && mb_strlen($messagePart, 'UTF-8') <= self::MAX_CHAT_CHAR_LENGTH && $this->messageCounter-- > 0){ if(trim($messagePart) !== "" && strlen($messagePart) <= self::MAX_CHAT_BYTE_LENGTH && mb_strlen($messagePart, 'UTF-8') <= self::MAX_CHAT_CHAR_LENGTH && $this->messageCounter-- > 0){
if(strpos($messagePart, './') === 0){ if(strpos($messagePart, './') === 0){
$messagePart = substr($messagePart, 1); $messagePart = substr($messagePart, 1);

View File

@ -36,6 +36,7 @@ use pocketmine\network\mcpe\protocol\types\entity\EntityMetadataFlags;
use pocketmine\network\mcpe\protocol\types\entity\EntityMetadataProperties; use pocketmine\network\mcpe\protocol\types\entity\EntityMetadataProperties;
use pocketmine\network\mcpe\protocol\types\entity\FloatMetadataProperty; use pocketmine\network\mcpe\protocol\types\entity\FloatMetadataProperty;
use pocketmine\network\mcpe\protocol\types\entity\LongMetadataProperty; use pocketmine\network\mcpe\protocol\types\entity\LongMetadataProperty;
use pocketmine\network\mcpe\protocol\types\GameMode;
use pocketmine\network\mcpe\protocol\types\inventory\ItemStack; use pocketmine\network\mcpe\protocol\types\inventory\ItemStack;
use pocketmine\network\mcpe\protocol\types\inventory\ItemStackWrapper; use pocketmine\network\mcpe\protocol\types\inventory\ItemStackWrapper;
use pocketmine\network\mcpe\protocol\types\PlayerListEntry; use pocketmine\network\mcpe\protocol\types\PlayerListEntry;
@ -117,6 +118,7 @@ class FloatingTextParticle implements Particle{
0, 0,
0, 0,
ItemStackWrapper::legacy(ItemStack::null()), ItemStackWrapper::legacy(ItemStack::null()),
GameMode::SURVIVAL,
$actorMetadata, $actorMetadata,
AdventureSettingsPacket::create(0, 0, 0, 0, 0, $this->entityId), AdventureSettingsPacket::create(0, 0, 0, 0, 0, $this->entityId),
[], [],