diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index 88f96fa67..1780f729d 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -2785,6 +2785,11 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ $this->level->broadcastLevelEvent($pos, LevelEventPacket::EVENT_PARTICLE_PUNCH_BLOCK, BlockFactory::toStaticRuntimeId($block->getId(), $block->getDamage()) | ($packet->face << 24)); //TODO: destroy-progress level event break; + case PlayerActionPacket::ACTION_START_SWIMMING: + break; //TODO + case PlayerActionPacket::ACTION_STOP_SWIMMING: + //TODO: handle this when it doesn't spam every damn tick (yet another spam bug!!) + break; default: $this->server->getLogger()->debug("Unhandled/unknown player action type " . $packet->action . " from " . $this->getName()); return false; @@ -3278,6 +3283,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ $pk = new TextPacket(); if(!$this->server->isLanguageForced()){ $pk->type = TextPacket::TYPE_TRANSLATION; + $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."); diff --git a/src/pocketmine/entity/Entity.php b/src/pocketmine/entity/Entity.php index 139c6c098..78f66473b 100644 --- a/src/pocketmine/entity/Entity.php +++ b/src/pocketmine/entity/Entity.php @@ -134,9 +134,9 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ public const DATA_URL_TAG = 41; //string public const DATA_MAX_AIR = 42; //short public const DATA_MARK_VARIANT = 43; //int - /* 44 (byte) container stuff - * 45 (int) container stuff - * 46 (int) container stuff */ + 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 @@ -171,6 +171,11 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ public const DATA_ARMOR_STAND_POSE_INDEX = 78; //int public const DATA_ENDER_CRYSTAL_TIME_OFFSET = 79; //int /* 80 (byte) something to do with nametag visibility? */ + 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_FLAG_ONFIRE = 0; @@ -224,6 +229,12 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ public const DATA_FLAG_FIRE_IMMUNE = 48; public const DATA_FLAG_DANCING = 49; public const DATA_FLAG_ENCHANTED = 50; + //51 is something to do with tridents + public const DATA_FLAG_CONTAINER_PRIVATE = 52; //inventory is private, doesn't drop contents when killed if true + //53 TransformationComponent + public const DATA_FLAG_SPIN_ATTACK = 54; + public const DATA_FLAG_SWIMMING = 55; + public const DATA_FLAG_BRIBED = 56; //dolphins have this set when they go to find treasure for the player public static $entityCount = 1; /** @var Entity[] */ diff --git a/src/pocketmine/level/Level.php b/src/pocketmine/level/Level.php index 7dceba83f..e3f2d68d0 100644 --- a/src/pocketmine/level/Level.php +++ b/src/pocketmine/level/Level.php @@ -846,6 +846,16 @@ class Level implements ChunkManager, Metadatable{ $this->sleepTicks = $ticks; } + /** + * @deprecated + * + * @param int $x + * @param int $y + * @param int $z + * @param int $id + * @param int $data + * @param Player[]|null $targets + */ public function sendBlockExtraData(int $x, int $y, int $z, int $id, int $data, array $targets = null){ $pk = new LevelEventPacket; $pk->evid = LevelEventPacket::EVENT_SET_DATA; @@ -2130,6 +2140,8 @@ class Level implements ChunkManager, Metadatable{ } /** + * @deprecated This functionality no longer produces any effect and will be removed in a future release + * * Gets the raw block extra data * * @param int $x @@ -2143,6 +2155,7 @@ class Level implements ChunkManager, Metadatable{ } /** + * @deprecated This functionality no longer produces any effect and will be removed in a future release * Sets the raw block metadata. * * @param int $x diff --git a/src/pocketmine/level/format/Chunk.php b/src/pocketmine/level/format/Chunk.php index 46717551b..4c20ffbbe 100644 --- a/src/pocketmine/level/format/Chunk.php +++ b/src/pocketmine/level/format/Chunk.php @@ -98,7 +98,7 @@ class Chunk{ * @param CompoundTag[] $tiles * @param string $biomeIds * @param int[] $heightMap - * @param int[] $extraData + * @param int[] $extraData @deprecated */ public function __construct(int $chunkX, int $chunkZ, array $subChunks = [], array $entities = [], array $tiles = [], string $biomeIds = "", array $heightMap = [], array $extraData = []){ $this->x = $chunkX; @@ -255,7 +255,7 @@ class Chunk{ } /** - * Returns the raw block extra data value at the specified chunk block coordinates, or 0 if no data exists + * @deprecated This functionality no longer produces any visible effects and will be removed in a future release * * @param int $x 0-15 * @param int $y @@ -268,7 +268,7 @@ class Chunk{ } /** - * Sets the raw block extra data value at the specified chunk block coordinates + * @deprecated This functionality no longer produces any visible effects and will be removed in a future release * * @param int $x 0-15 * @param int $y @@ -780,6 +780,7 @@ class Chunk{ } /** + * @deprecated * @return int[] */ public function getBlockExtraDataArray() : array{ @@ -906,14 +907,6 @@ class Chunk{ . 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. - $extraData = new BinaryStream(); - $extraData->putVarInt(count($this->extraData)); //WHY, Mojang, WHY - foreach($this->extraData as $key => $value){ - $extraData->putVarInt($key); - $extraData->putLShort($value); - } - $result .= $extraData->getBuffer(); - foreach($this->tiles as $tile){ if($tile instanceof Spawnable){ $result .= $tile->getSerializedSpawnCompound(); @@ -979,6 +972,8 @@ class Chunk{ } /** + * @deprecated This will be removed in a future release + * * Creates a block hash from chunk block coordinates. Used for extra data keys in chunk packets. * @internal * diff --git a/src/pocketmine/network/mcpe/NetworkSession.php b/src/pocketmine/network/mcpe/NetworkSession.php index 8a51e8562..44a17df01 100644 --- a/src/pocketmine/network/mcpe/NetworkSession.php +++ b/src/pocketmine/network/mcpe/NetworkSession.php @@ -66,6 +66,7 @@ use pocketmine\network\mcpe\protocol\InventoryContentPacket; use pocketmine\network\mcpe\protocol\InventorySlotPacket; use pocketmine\network\mcpe\protocol\InventoryTransactionPacket; use pocketmine\network\mcpe\protocol\ItemFrameDropItemPacket; +use pocketmine\network\mcpe\protocol\LabTablePacket; use pocketmine\network\mcpe\protocol\LevelEventPacket; use pocketmine\network\mcpe\protocol\LevelSoundEventPacket; use pocketmine\network\mcpe\protocol\LoginPacket; @@ -88,6 +89,7 @@ use pocketmine\network\mcpe\protocol\PlayerListPacket; use pocketmine\network\mcpe\protocol\PlayerSkinPacket; use pocketmine\network\mcpe\protocol\PurchaseReceiptPacket; use pocketmine\network\mcpe\protocol\RemoveEntityPacket; +use pocketmine\network\mcpe\protocol\RemoveObjectivePacket; use pocketmine\network\mcpe\protocol\RequestChunkRadiusPacket; use pocketmine\network\mcpe\protocol\ResourcePackChunkDataPacket; use pocketmine\network\mcpe\protocol\ResourcePackChunkRequestPacket; @@ -103,12 +105,14 @@ use pocketmine\network\mcpe\protocol\ServerToClientHandshakePacket; 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\SetPlayerGameTypePacket; +use pocketmine\network\mcpe\protocol\SetScorePacket; use pocketmine\network\mcpe\protocol\SetSpawnPositionPacket; use pocketmine\network\mcpe\protocol\SetTimePacket; use pocketmine\network\mcpe\protocol\SetTitlePacket; @@ -126,6 +130,7 @@ 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\UpdateBlockSyncedPacket; use pocketmine\network\mcpe\protocol\UpdateEquipPacket; use pocketmine\network\mcpe\protocol\UpdateTradePacket; use pocketmine\network\mcpe\protocol\WSConnectPacket; @@ -554,4 +559,24 @@ abstract class NetworkSession{ return false; } + public function handleRemoveObjective(RemoveObjectivePacket $packet) : bool{ + return false; + } + + public function handleSetDisplayObjective(SetDisplayObjectivePacket $packet) : bool{ + return false; + } + + public function handleSetScore(SetScorePacket $packet) : bool{ + return false; + } + + public function handleLabTable(LabTablePacket $packet) : bool{ + return false; + } + + public function handleUpdateBlockSynced(UpdateBlockSyncedPacket $packet) : bool{ + return false; + } + } diff --git a/src/pocketmine/network/mcpe/protocol/AvailableCommandsPacket.php b/src/pocketmine/network/mcpe/protocol/AvailableCommandsPacket.php index 6bb6cbb48..3b69e1859 100644 --- a/src/pocketmine/network/mcpe/protocol/AvailableCommandsPacket.php +++ b/src/pocketmine/network/mcpe/protocol/AvailableCommandsPacket.php @@ -35,7 +35,7 @@ class AvailableCommandsPacket extends DataPacket{ /** - * This flag is set on all types EXCEPT the TEMPLATE type. Not completely sure what this is for, but it is required + * This flag is set on all types EXCEPT the POSTFIX type. Not completely sure what this is for, but it is required * for the argtype to work correctly. VALID seems as good a name as any. */ public const ARG_FLAG_VALID = 0x100000; @@ -44,21 +44,23 @@ class AvailableCommandsPacket extends DataPacket{ * Basic parameter types. These must be combined with the ARG_FLAG_VALID constant. * ARG_FLAG_VALID | (type const) */ - public const ARG_TYPE_INT = 0x01; - public const ARG_TYPE_FLOAT = 0x02; - public const ARG_TYPE_VALUE = 0x03; - public const ARG_TYPE_TARGET = 0x04; + public const ARG_TYPE_INT = 0x01; + public const ARG_TYPE_FLOAT = 0x02; + public const ARG_TYPE_VALUE = 0x03; + public const ARG_TYPE_WILDCARD_INT = 0x04; + public const ARG_TYPE_TARGET = 0x05; + public const ARG_TYPE_WILDCARD_TARGET = 0x06; - public const ARG_TYPE_STRING = 0x0d; - public const ARG_TYPE_POSITION = 0x0e; + public const ARG_TYPE_STRING = 0x0f; + public const ARG_TYPE_POSITION = 0x10; - public const ARG_TYPE_RAWTEXT = 0x11; + public const ARG_TYPE_MESSAGE = 0x13; - public const ARG_TYPE_TEXT = 0x13; + public const ARG_TYPE_RAWTEXT = 0x15; - public const ARG_TYPE_JSON = 0x16; + public const ARG_TYPE_JSON = 0x18; - public const ARG_TYPE_COMMAND = 0x1d; + public const ARG_TYPE_COMMAND = 0x1f; /** * Enums are a little different: they are composed as follows: @@ -67,7 +69,7 @@ class AvailableCommandsPacket extends DataPacket{ public const ARG_FLAG_ENUM = 0x200000; /** - * This is used for /xp L. + * This is used for /xp L. It can only be applied to integer parameters. */ public const ARG_FLAG_POSTFIX = 0x1000000; @@ -255,9 +257,9 @@ class AvailableCommandsPacket extends DataPacket{ return "string"; case self::ARG_TYPE_POSITION: return "xyz"; + case self::ARG_TYPE_MESSAGE: + return "message"; case self::ARG_TYPE_RAWTEXT: - return "rawtext"; - case self::ARG_TYPE_TEXT: return "text"; case self::ARG_TYPE_JSON: return "json"; diff --git a/src/pocketmine/network/mcpe/protocol/ClientboundMapItemDataPacket.php b/src/pocketmine/network/mcpe/protocol/ClientboundMapItemDataPacket.php index 80d92e87b..df6b1dcbc 100644 --- a/src/pocketmine/network/mcpe/protocol/ClientboundMapItemDataPacket.php +++ b/src/pocketmine/network/mcpe/protocol/ClientboundMapItemDataPacket.php @@ -87,8 +87,8 @@ class ClientboundMapItemDataPacket extends DataPacket{ } for($i = 0, $count = $this->getUnsignedVarInt(); $i < $count; ++$i){ - $this->decorations[$i]["rot"] = $this->getByte(); $this->decorations[$i]["img"] = $this->getByte(); + $this->decorations[$i]["rot"] = $this->getByte(); $this->decorations[$i]["xOffset"] = $this->getByte(); $this->decorations[$i]["yOffset"] = $this->getByte(); $this->decorations[$i]["label"] = $this->getString(); @@ -150,8 +150,8 @@ class ClientboundMapItemDataPacket extends DataPacket{ $this->putUnsignedVarInt($decorationCount); foreach($this->decorations as $decoration){ - $this->putByte($decoration["rot"]); $this->putByte($decoration["img"]); + $this->putByte($decoration["rot"]); $this->putByte($decoration["xOffset"]); $this->putByte($decoration["yOffset"]); $this->putString($decoration["label"]); diff --git a/src/pocketmine/network/mcpe/protocol/CraftingDataPacket.php b/src/pocketmine/network/mcpe/protocol/CraftingDataPacket.php index eba91dea2..0161c8b00 100644 --- a/src/pocketmine/network/mcpe/protocol/CraftingDataPacket.php +++ b/src/pocketmine/network/mcpe/protocol/CraftingDataPacket.php @@ -42,6 +42,8 @@ class CraftingDataPacket extends DataPacket{ public const ENTRY_FURNACE_DATA = 3; public const ENTRY_MULTI = 4; //TODO public const ENTRY_SHULKER_BOX = 5; //TODO + public const ENTRY_SHAPELESS_CHEMISTRY = 6; //TODO + public const ENTRY_SHAPED_CHEMISTRY = 7; //TODO /** @var object[] */ public $entries = []; @@ -66,6 +68,7 @@ class CraftingDataPacket extends DataPacket{ switch($recipeType){ case self::ENTRY_SHAPELESS: case self::ENTRY_SHULKER_BOX: + case self::ENTRY_SHAPELESS_CHEMISTRY: $ingredientCount = $this->getUnsignedVarInt(); /** @var Item */ $entry["input"] = []; @@ -81,6 +84,7 @@ class CraftingDataPacket extends DataPacket{ break; case self::ENTRY_SHAPED: + case self::ENTRY_SHAPED_CHEMISTRY: $entry["width"] = $this->getVarInt(); $entry["height"] = $this->getVarInt(); $count = $entry["width"] * $entry["height"]; diff --git a/src/pocketmine/network/mcpe/protocol/LabTablePacket.php b/src/pocketmine/network/mcpe/protocol/LabTablePacket.php new file mode 100644 index 000000000..8f45bcc56 --- /dev/null +++ b/src/pocketmine/network/mcpe/protocol/LabTablePacket.php @@ -0,0 +1,61 @@ + + +use pocketmine\network\mcpe\NetworkSession; + +class LabTablePacket extends DataPacket{ + public const NETWORK_ID = ProtocolInfo::LAB_TABLE_PACKET; + + /** @var int */ + public $uselessByte; //0 for client -> server, 1 for server -> client. Seems useless. + + /** @var int */ + public $x; + /** @var int */ + public $y; + /** @var int */ + public $z; + + /** @var int */ + public $reactionType; + + protected function decodePayload(){ + $this->uselessByte = $this->getByte(); + $this->getSignedBlockPosition($this->x, $this->y, $this->z); + $this->reactionType = $this->getByte(); + } + + protected function encodePayload(){ + $this->putByte($this->uselessByte); + $this->putSignedBlockPosition($this->x, $this->y, $this->z); + $this->putByte($this->reactionType); + } + + public function handle(NetworkSession $session) : bool{ + return $session->handleLabTable($this); + } +} diff --git a/src/pocketmine/network/mcpe/protocol/PacketPool.php b/src/pocketmine/network/mcpe/protocol/PacketPool.php index c1f61c488..18df6cd45 100644 --- a/src/pocketmine/network/mcpe/protocol/PacketPool.php +++ b/src/pocketmine/network/mcpe/protocol/PacketPool.php @@ -136,6 +136,11 @@ class PacketPool{ static::registerPacket(new ServerSettingsResponsePacket()); static::registerPacket(new ShowProfilePacket()); static::registerPacket(new SetDefaultGameTypePacket()); + static::registerPacket(new RemoveObjectivePacket()); + static::registerPacket(new SetDisplayObjectivePacket()); + static::registerPacket(new SetScorePacket()); + static::registerPacket(new LabTablePacket()); + static::registerPacket(new UpdateBlockSyncedPacket()); static::registerPacket(new BatchPacket()); } diff --git a/src/pocketmine/network/mcpe/protocol/PlayStatusPacket.php b/src/pocketmine/network/mcpe/protocol/PlayStatusPacket.php index 99e67941b..a4cf2fc5d 100644 --- a/src/pocketmine/network/mcpe/protocol/PlayStatusPacket.php +++ b/src/pocketmine/network/mcpe/protocol/PlayStatusPacket.php @@ -38,6 +38,7 @@ class PlayStatusPacket extends DataPacket{ public const LOGIN_FAILED_INVALID_TENANT = 4; public const LOGIN_FAILED_VANILLA_EDU = 5; public const LOGIN_FAILED_EDU_VANILLA = 6; + public const LOGIN_FAILED_SERVER_FULL = 7; /** @var int */ public $status; diff --git a/src/pocketmine/network/mcpe/protocol/PlayerActionPacket.php b/src/pocketmine/network/mcpe/protocol/PlayerActionPacket.php index 6968c69a3..e6276b707 100644 --- a/src/pocketmine/network/mcpe/protocol/PlayerActionPacket.php +++ b/src/pocketmine/network/mcpe/protocol/PlayerActionPacket.php @@ -52,6 +52,10 @@ class PlayerActionPacket extends DataPacket{ public const ACTION_CONTINUE_BREAK = 18; public const ACTION_SET_ENCHANTMENT_SEED = 20; + public const ACTION_START_SWIMMING = 21; + public const ACTION_STOP_SWIMMING = 22; + public const ACTION_START_SPIN_ATTACK = 23; + public const ACTION_STOP_SPIN_ATTACK = 24; /** @var int */ public $entityRuntimeId; diff --git a/src/pocketmine/network/mcpe/protocol/ProtocolInfo.php b/src/pocketmine/network/mcpe/protocol/ProtocolInfo.php index cc534aba0..275cb1b28 100644 --- a/src/pocketmine/network/mcpe/protocol/ProtocolInfo.php +++ b/src/pocketmine/network/mcpe/protocol/ProtocolInfo.php @@ -39,15 +39,15 @@ interface ProtocolInfo{ /** * Actual Minecraft: PE protocol version */ - public const CURRENT_PROTOCOL = 223; + public const CURRENT_PROTOCOL = 261; /** * Current Minecraft PE version reported by the server. This is usually the earliest currently supported version. */ - public const MINECRAFT_VERSION = 'v1.2.13'; + public const MINECRAFT_VERSION = 'v1.4.0'; /** * Version number sent to clients in ping responses. */ - public const MINECRAFT_VERSION_NETWORK = '1.2.13'; + public const MINECRAFT_VERSION_NETWORK = '1.4.0'; public const LOGIN_PACKET = 0x01; public const PLAY_STATUS_PACKET = 0x02; @@ -154,5 +154,10 @@ interface ProtocolInfo{ public const SERVER_SETTINGS_RESPONSE_PACKET = 0x67; public const SHOW_PROFILE_PACKET = 0x68; public const SET_DEFAULT_GAME_TYPE_PACKET = 0x69; + public const REMOVE_OBJECTIVE_PACKET = 0x6a; + public const SET_DISPLAY_OBJECTIVE_PACKET = 0x6b; + public const SET_SCORE_PACKET = 0x6c; + public const LAB_TABLE_PACKET = 0x6d; + public const UPDATE_BLOCK_SYNCED_PACKET = 0x6e; } diff --git a/src/pocketmine/network/mcpe/protocol/RemoveObjectivePacket.php b/src/pocketmine/network/mcpe/protocol/RemoveObjectivePacket.php new file mode 100644 index 000000000..6216c43ea --- /dev/null +++ b/src/pocketmine/network/mcpe/protocol/RemoveObjectivePacket.php @@ -0,0 +1,47 @@ + + +use pocketmine\network\mcpe\NetworkSession; + +class RemoveObjectivePacket extends DataPacket{ + public const NETWORK_ID = ProtocolInfo::REMOVE_OBJECTIVE_PACKET; + + /** @var string */ + public $objectiveName; + + protected function decodePayload(){ + $this->objectiveName = $this->getString(); + } + + protected function encodePayload(){ + $this->putString($this->objectiveName); + } + + public function handle(NetworkSession $session) : bool{ + return $session->handleRemoveObjective($this); + } +} diff --git a/src/pocketmine/network/mcpe/protocol/SetDisplayObjectivePacket.php b/src/pocketmine/network/mcpe/protocol/SetDisplayObjectivePacket.php new file mode 100644 index 000000000..a4b1aa54a --- /dev/null +++ b/src/pocketmine/network/mcpe/protocol/SetDisplayObjectivePacket.php @@ -0,0 +1,63 @@ + + +use pocketmine\network\mcpe\NetworkSession; + +class SetDisplayObjectivePacket extends DataPacket{ + public const NETWORK_ID = ProtocolInfo::SET_DISPLAY_OBJECTIVE_PACKET; + + /** @var string */ + public $displaySlot; + /** @var string */ + public $objectiveName; + /** @var string */ + public $displayName; + /** @var string */ + public $criteriaName; + /** @var int */ + public $sortOrder; + + protected function decodePayload(){ + $this->displaySlot = $this->getString(); + $this->objectiveName = $this->getString(); + $this->displayName = $this->getString(); + $this->criteriaName = $this->getString(); + $this->sortOrder = $this->getVarInt(); + } + + protected function encodePayload(){ + $this->putString($this->displaySlot); + $this->putString($this->objectiveName); + $this->putString($this->displayName); + $this->putString($this->criteriaName); + $this->putVarInt($this->sortOrder); + } + + public function handle(NetworkSession $session) : bool{ + return $session->handleSetDisplayObjective($this); + } +} diff --git a/src/pocketmine/network/mcpe/protocol/SetScorePacket.php b/src/pocketmine/network/mcpe/protocol/SetScorePacket.php new file mode 100644 index 000000000..f1efb6579 --- /dev/null +++ b/src/pocketmine/network/mcpe/protocol/SetScorePacket.php @@ -0,0 +1,65 @@ + + +use pocketmine\network\mcpe\NetworkSession; +use pocketmine\network\mcpe\protocol\types\ScorePacketEntry; + +class SetScorePacket extends DataPacket{ + public const NETWORK_ID = ProtocolInfo::SET_SCORE_PACKET; + + public const TYPE_MODIFY_SCORE = 0; + public const TYPE_RESET_SCORE = 1; + + /** @var int */ + public $type; + /** @var ScorePacketEntry[] */ + public $entries = []; + + protected function decodePayload(){ + $this->type = $this->getByte(); + for($i = 0, $i2 = $this->getUnsignedVarInt(); $i < $i2; ++$i){ + $entry = new ScorePacketEntry(); + $entry->uuid = $this->getUUID(); + $entry->objectiveName = $this->getString(); + $entry->score = $this->getLInt(); + } + } + + protected function encodePayload(){ + $this->putByte($this->type); + $this->putUnsignedVarInt(count($this->entries)); + foreach($this->entries as $entry){ + $this->putUUID($entry->uuid); + $this->putString($entry->objectiveName); + $this->putLInt($entry->score); + } + } + + public function handle(NetworkSession $session) : bool{ + return $session->handleSetScore($this); + } +} diff --git a/src/pocketmine/network/mcpe/protocol/StartGamePacket.php b/src/pocketmine/network/mcpe/protocol/StartGamePacket.php index 8a29d7b7f..c7df1520d 100644 --- a/src/pocketmine/network/mcpe/protocol/StartGamePacket.php +++ b/src/pocketmine/network/mcpe/protocol/StartGamePacket.php @@ -70,6 +70,8 @@ class StartGamePacket extends DataPacket{ public $time = -1; /** @var bool */ public $eduMode = false; + /** @var bool */ + public $hasEduFeaturesEnabled = false; /** @var float */ public $rainLevel; /** @var float */ @@ -104,6 +106,12 @@ class StartGamePacket extends DataPacket{ public $platformBroadcastMode = 0; /** @var bool */ public $xboxLiveBroadcastIntent = false; + /** @var bool */ + public $hasLockedBehaviorPack = false; + /** @var bool */ + public $hasLockedResourcePack = false; + /** @var bool */ + public $isFromLockedWorldTemplate = false; /** @var string */ public $levelId = ""; //base64 string, usually the same as world folder name in vanilla @@ -138,6 +146,7 @@ class StartGamePacket extends DataPacket{ $this->hasAchievementsDisabled = $this->getBool(); $this->time = $this->getVarInt(); $this->eduMode = $this->getBool(); + $this->hasEduFeaturesEnabled = $this->getBool(); $this->rainLevel = $this->getLFloat(); $this->lightningLevel = $this->getLFloat(); $this->isMultiplayerGame = $this->getBool(); @@ -153,8 +162,11 @@ class StartGamePacket extends DataPacket{ $this->xboxLiveBroadcastMode = $this->getVarInt(); $this->serverChunkTickRadius = $this->getLInt(); $this->hasPlatformBroadcast = $this->getBool(); - $this->platformBroadcastMode = $this->getUnsignedVarInt(); + $this->platformBroadcastMode = $this->getVarInt(); $this->xboxLiveBroadcastIntent = $this->getBool(); + $this->hasLockedBehaviorPack = $this->getBool(); + $this->hasLockedResourcePack = $this->getBool(); + $this->isFromLockedWorldTemplate = $this->getBool(); $this->levelId = $this->getString(); $this->worldName = $this->getString(); @@ -185,6 +197,7 @@ class StartGamePacket extends DataPacket{ $this->putBool($this->hasAchievementsDisabled); $this->putVarInt($this->time); $this->putBool($this->eduMode); + $this->putBool($this->hasEduFeaturesEnabled); $this->putLFloat($this->rainLevel); $this->putLFloat($this->lightningLevel); $this->putBool($this->isMultiplayerGame); @@ -200,8 +213,11 @@ class StartGamePacket extends DataPacket{ $this->putVarInt($this->xboxLiveBroadcastMode); $this->putLInt($this->serverChunkTickRadius); $this->putBool($this->hasPlatformBroadcast); - $this->putUnsignedVarInt($this->platformBroadcastMode); + $this->putVarInt($this->platformBroadcastMode); $this->putBool($this->xboxLiveBroadcastIntent); + $this->putBool($this->hasLockedBehaviorPack); + $this->putBool($this->hasLockedResourcePack); + $this->putBool($this->isFromLockedWorldTemplate); $this->putString($this->levelId); $this->putString($this->worldName); diff --git a/src/pocketmine/network/mcpe/protocol/UpdateBlockPacket.php b/src/pocketmine/network/mcpe/protocol/UpdateBlockPacket.php index 7b4614527..94e2e56a4 100644 --- a/src/pocketmine/network/mcpe/protocol/UpdateBlockPacket.php +++ b/src/pocketmine/network/mcpe/protocol/UpdateBlockPacket.php @@ -40,6 +40,9 @@ class UpdateBlockPacket extends DataPacket{ public const FLAG_ALL = self::FLAG_NEIGHBORS | self::FLAG_NETWORK; public const FLAG_ALL_PRIORITY = self::FLAG_ALL | self::FLAG_PRIORITY; + public const DATA_LAYER_NORMAL = 0; + public const DATA_LAYER_LIQUID = 1; + /** @var int */ public $x; /** @var int */ @@ -50,17 +53,21 @@ class UpdateBlockPacket extends DataPacket{ public $blockRuntimeId; /** @var int */ public $flags; + /** @var int */ + public $dataLayerId = self::DATA_LAYER_NORMAL; protected function decodePayload(){ $this->getBlockPosition($this->x, $this->y, $this->z); $this->blockRuntimeId = $this->getUnsignedVarInt(); $this->flags = $this->getUnsignedVarInt(); + $this->dataLayerId = $this->getUnsignedVarInt(); } protected function encodePayload(){ $this->putBlockPosition($this->x, $this->y, $this->z); $this->putUnsignedVarInt($this->blockRuntimeId); $this->putUnsignedVarInt($this->flags); + $this->putUnsignedVarInt($this->dataLayerId); } public function handle(NetworkSession $session) : bool{ diff --git a/src/pocketmine/network/mcpe/protocol/UpdateBlockSyncedPacket.php b/src/pocketmine/network/mcpe/protocol/UpdateBlockSyncedPacket.php new file mode 100644 index 000000000..42eb0e6ee --- /dev/null +++ b/src/pocketmine/network/mcpe/protocol/UpdateBlockSyncedPacket.php @@ -0,0 +1,53 @@ + + +use pocketmine\network\mcpe\NetworkSession; + +class UpdateBlockSyncedPacket extends UpdateBlockPacket{ + public const NETWORK_ID = ProtocolInfo::UPDATE_BLOCK_SYNCED_PACKET; + + /** @var int */ + protected $uvarint64_1 = 0; + /** @var int */ + protected $uvarint64_2 = 0; + + protected function decodePayload(){ + parent::decodePayload(); + $this->uvarint64_1 = $this->getUnsignedVarLong(); + $this->uvarint64_2 = $this->getUnsignedVarLong(); + } + + protected function encodePayload(){ + parent::encodePayload(); + $this->putUnsignedVarLong($this->uvarint64_1); + $this->putUnsignedVarLong($this->uvarint64_2); + } + + public function handle(NetworkSession $session) : bool{ + return $session->handleUpdateBlockSynced($this); + } +} diff --git a/src/pocketmine/network/mcpe/protocol/types/ScorePacketEntry.php b/src/pocketmine/network/mcpe/protocol/types/ScorePacketEntry.php new file mode 100644 index 000000000..a2c0326d1 --- /dev/null +++ b/src/pocketmine/network/mcpe/protocol/types/ScorePacketEntry.php @@ -0,0 +1,35 @@ +