mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-10-19 23:37:45 +00:00
Merge branch 'next-major' into modern-world-support
This commit is contained in:
@@ -31,7 +31,7 @@ use function str_repeat;
|
||||
|
||||
final class VersionInfo{
|
||||
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 BUILD_CHANNEL = "beta";
|
||||
|
||||
|
@@ -44,7 +44,7 @@ trait ContainerTrait{
|
||||
abstract public function getRealInventory();
|
||||
|
||||
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();
|
||||
$listeners = $inventory->getListeners()->toArray();
|
||||
$inventory->getListeners()->remove(...$listeners); //prevent any events being fired by initialization
|
||||
|
@@ -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\EntityMetadataProperties;
|
||||
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\PlayerListEntry;
|
||||
use pocketmine\player\Player;
|
||||
@@ -479,6 +480,7 @@ class Human extends Living implements ProjectileSource, InventoryHolder{
|
||||
$this->location->yaw,
|
||||
$this->location->yaw, //TODO: head yaw
|
||||
ItemStackWrapper::legacy(TypeConverter::getInstance()->coreItemStackToNet($this->getInventory()->getItemInHand())),
|
||||
GameMode::SURVIVAL,
|
||||
$this->getAllNetworkData(),
|
||||
AdventureSettingsPacket::create(0, 0, 0, 0, 0, $this->getId()), //TODO
|
||||
[], //TODO: entity links
|
||||
|
@@ -29,6 +29,7 @@ use pocketmine\block\utils\BannerPatternLayer;
|
||||
use pocketmine\block\utils\DyeColor;
|
||||
use pocketmine\data\bedrock\BannerPatternTypeIdMap;
|
||||
use pocketmine\data\bedrock\DyeColorIdMap;
|
||||
use pocketmine\nbt\NBT;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\nbt\tag\ListTag;
|
||||
use function count;
|
||||
@@ -98,7 +99,7 @@ class Banner extends ItemBlockWallOrFloor{
|
||||
$colorIdMap = DyeColorIdMap::getInstance();
|
||||
$patternIdMap = BannerPatternTypeIdMap::getInstance();
|
||||
$patterns = $tag->getListTag(self::TAG_PATTERNS);
|
||||
if($patterns !== null){
|
||||
if($patterns !== null && $patterns->getTagType() === NBT::TAG_Compound){
|
||||
/** @var CompoundTag $t */
|
||||
foreach($patterns as $t){
|
||||
$patternColor = $colorIdMap->fromInvertedId($t->getInt(self::TAG_PATTERN_COLOR)) ?? DyeColor::BLACK(); //TODO: missing pattern colour should be an error
|
||||
|
@@ -306,7 +306,7 @@ class Item implements \JsonSerializable{
|
||||
|
||||
$this->canPlaceOn = [];
|
||||
$canPlaceOn = $tag->getListTag("CanPlaceOn");
|
||||
if($canPlaceOn !== null){
|
||||
if($canPlaceOn !== null && $canPlaceOn->getTagType() === NBT::TAG_String){
|
||||
/** @var StringTag $entry */
|
||||
foreach($canPlaceOn as $entry){
|
||||
$this->canPlaceOn[$entry->getValue()] = $entry->getValue();
|
||||
@@ -314,7 +314,7 @@ class Item implements \JsonSerializable{
|
||||
}
|
||||
$this->canDestroy = [];
|
||||
$canDestroy = $tag->getListTag("CanDestroy");
|
||||
if($canDestroy !== null){
|
||||
if($canDestroy !== null && $canDestroy->getTagType() === NBT::TAG_String){
|
||||
/** @var StringTag $entry */
|
||||
foreach($canDestroy as $entry){
|
||||
$this->canDestroy[$entry->getValue()] = $entry->getValue();
|
||||
|
@@ -28,6 +28,7 @@ use pocketmine\data\bedrock\blockstate\BlockStateSerializeException;
|
||||
use pocketmine\data\bedrock\blockstate\BlockStateSerializer;
|
||||
use pocketmine\data\bedrock\blockstate\BlockTypeNames;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\network\mcpe\protocol\SimulationTypePacket;
|
||||
use pocketmine\utils\AssumptionFailedError;
|
||||
use pocketmine\utils\SingletonTrait;
|
||||
use pocketmine\utils\Utils;
|
||||
@@ -53,8 +54,12 @@ final class RuntimeBlockMapping{
|
||||
private BlockStateData $fallbackStateData;
|
||||
private int $fallbackStateId;
|
||||
|
||||
private function __construct(){
|
||||
$contents = Utils::assumeNotFalse(file_get_contents(Path::join(\pocketmine\BEDROCK_DATA_PATH, "canonical_block_states.nbt")), "Missing required resource file");
|
||||
private static function make() : self{
|
||||
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->blockStateSerializer = GlobalBlockStateHandlers::getSerializer();
|
||||
|
||||
|
@@ -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
|
||||
$encodedBiomePalette = self::serializeBiomesAsPalette($chunk);
|
||||
$stream->put(str_repeat($encodedBiomePalette, 25));
|
||||
$stream->put(str_repeat($encodedBiomePalette, 24));
|
||||
|
||||
$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.
|
||||
|
@@ -1377,8 +1377,14 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
||||
public function chat(string $message) : bool{
|
||||
$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);
|
||||
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(strpos($messagePart, './') === 0){
|
||||
$messagePart = substr($messagePart, 1);
|
||||
|
@@ -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\FloatMetadataProperty;
|
||||
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\ItemStackWrapper;
|
||||
use pocketmine\network\mcpe\protocol\types\PlayerListEntry;
|
||||
@@ -117,6 +118,7 @@ class FloatingTextParticle implements Particle{
|
||||
0,
|
||||
0,
|
||||
ItemStackWrapper::legacy(ItemStack::null()),
|
||||
GameMode::SURVIVAL,
|
||||
$actorMetadata,
|
||||
AdventureSettingsPacket::create(0, 0, 0, 0, 0, $this->entityId),
|
||||
[],
|
||||
|
Reference in New Issue
Block a user