diff --git a/src/pocketmine/Server.php b/src/pocketmine/Server.php index b86101f13..a5c3a488b 100644 --- a/src/pocketmine/Server.php +++ b/src/pocketmine/Server.php @@ -2309,7 +2309,7 @@ class Server{ $pk = new PlayerListPacket(); $pk->type = PlayerListPacket::TYPE_ADD; - $pk->entries[] = PlayerListEntry::createAdditionEntry($uuid, $entityId, $name, "", 0, $skin, $xboxUserId); + $pk->entries[] = PlayerListEntry::createAdditionEntry($uuid, $entityId, $name, $skin, $xboxUserId); $this->broadcastPacket($players ?? $this->playerList, $pk); } @@ -2332,7 +2332,7 @@ class Server{ $pk = new PlayerListPacket(); $pk->type = PlayerListPacket::TYPE_ADD; foreach($this->playerList as $player){ - $pk->entries[] = PlayerListEntry::createAdditionEntry($player->getUniqueId(), $player->getId(), $player->getDisplayName(), "", 0, $player->getSkin(), $player->getXuid()); + $pk->entries[] = PlayerListEntry::createAdditionEntry($player->getUniqueId(), $player->getId(), $player->getDisplayName(), $player->getSkin(), $player->getXuid()); } $p->dataPacket($pk); diff --git a/src/pocketmine/entity/Entity.php b/src/pocketmine/entity/Entity.php index d363d43ac..8a22fe02f 100644 --- a/src/pocketmine/entity/Entity.php +++ b/src/pocketmine/entity/Entity.php @@ -206,34 +206,38 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ public const DATA_FLAG_INTERESTED = 26; public const DATA_FLAG_CHARGED = 27; public const DATA_FLAG_TAMED = 28; - public const DATA_FLAG_LEASHED = 29; - public const DATA_FLAG_SHEARED = 30; - public const DATA_FLAG_GLIDING = 31; - public const DATA_FLAG_ELDER = 32; - public const DATA_FLAG_MOVING = 33; - public const DATA_FLAG_BREATHING = 34; - public const DATA_FLAG_CHESTED = 35; - public const DATA_FLAG_STACKABLE = 36; - public const DATA_FLAG_SHOWBASE = 37; - public const DATA_FLAG_REARING = 38; - public const DATA_FLAG_VIBRATING = 39; - public const DATA_FLAG_IDLING = 40; - public const DATA_FLAG_EVOKER_SPELL = 41; - public const DATA_FLAG_CHARGE_ATTACK = 42; - public const DATA_FLAG_WASD_CONTROLLED = 43; - public const DATA_FLAG_CAN_POWER_JUMP = 44; - public const DATA_FLAG_LINGER = 45; - public const DATA_FLAG_HAS_COLLISION = 46; - public const DATA_FLAG_AFFECTED_BY_GRAVITY = 47; - public const DATA_FLAG_FIRE_IMMUNE = 48; - public const DATA_FLAG_DANCING = 49; - public const DATA_FLAG_ENCHANTED = 50; - public const DATA_FLAG_SHOW_TRIDENT_ROPE = 51; // tridents show an animated rope when enchanted with loyalty after they are thrown and return to their owner. To be combined with DATA_OWNER_EID - 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 const DATA_FLAG_ORPHANED = 29; + public const DATA_FLAG_LEASHED = 30; + public const DATA_FLAG_SHEARED = 31; + public const DATA_FLAG_GLIDING = 32; + public const DATA_FLAG_ELDER = 33; + public const DATA_FLAG_MOVING = 34; + public const DATA_FLAG_BREATHING = 35; + public const DATA_FLAG_CHESTED = 36; + public const DATA_FLAG_STACKABLE = 37; + public const DATA_FLAG_SHOWBASE = 38; + public const DATA_FLAG_REARING = 39; + public const DATA_FLAG_VIBRATING = 40; + public const DATA_FLAG_IDLING = 41; + public const DATA_FLAG_EVOKER_SPELL = 42; + public const DATA_FLAG_CHARGE_ATTACK = 43; + public const DATA_FLAG_WASD_CONTROLLED = 44; + public const DATA_FLAG_CAN_POWER_JUMP = 45; + public const DATA_FLAG_LINGER = 46; + public const DATA_FLAG_HAS_COLLISION = 47; + public const DATA_FLAG_AFFECTED_BY_GRAVITY = 48; + public const DATA_FLAG_FIRE_IMMUNE = 49; + public const DATA_FLAG_DANCING = 50; + public const DATA_FLAG_ENCHANTED = 51; + public const DATA_FLAG_SHOW_TRIDENT_ROPE = 52; // tridents show an animated rope when enchanted with loyalty after they are thrown and return to their owner. To be combined with DATA_OWNER_EID + public const DATA_FLAG_CONTAINER_PRIVATE = 53; //inventory is private, doesn't drop contents when killed if true + //54 TransformationComponent + public const DATA_FLAG_SPIN_ATTACK = 55; + public const DATA_FLAG_SWIMMING = 56; + public const DATA_FLAG_BRIBED = 57; //dolphins have this set when they go to find treasure for the player + public const DATA_FLAG_PREGNANT = 58; + public const DATA_FLAG_LAYING_EGG = 59; + //60 ?? public static $entityCount = 1; /** @var Entity[] */ diff --git a/src/pocketmine/entity/Human.php b/src/pocketmine/entity/Human.php index da5a7220b..ab93b4459 100644 --- a/src/pocketmine/entity/Human.php +++ b/src/pocketmine/entity/Human.php @@ -841,7 +841,7 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{ /* we don't use Server->updatePlayerListData() because that uses batches, which could cause race conditions in async compression mode */ $pk = new PlayerListPacket(); $pk->type = PlayerListPacket::TYPE_ADD; - $pk->entries = [PlayerListEntry::createAdditionEntry($this->uuid, $this->id, $this->getName(), $this->getName(), 0, $this->skin)]; + $pk->entries = [PlayerListEntry::createAdditionEntry($this->uuid, $this->id, $this->getName(), $this->skin)]; $player->dataPacket($pk); } diff --git a/src/pocketmine/level/particle/FloatingTextParticle.php b/src/pocketmine/level/particle/FloatingTextParticle.php index f393d22eb..cf0badbd9 100644 --- a/src/pocketmine/level/particle/FloatingTextParticle.php +++ b/src/pocketmine/level/particle/FloatingTextParticle.php @@ -95,7 +95,7 @@ class FloatingTextParticle extends Particle{ $add = new PlayerListPacket(); $add->type = PlayerListPacket::TYPE_ADD; - $add->entries = [PlayerListEntry::createAdditionEntry($uuid, $this->entityId, $name, $name, 0, new Skin("Standard_Custom", str_repeat("\x00", 8192)))]; + $add->entries = [PlayerListEntry::createAdditionEntry($uuid, $this->entityId, $name, new Skin("Standard_Custom", str_repeat("\x00", 8192)))]; $p[] = $add; $pk = new AddPlayerPacket(); diff --git a/src/pocketmine/network/mcpe/NetworkSession.php b/src/pocketmine/network/mcpe/NetworkSession.php index 33fa61d90..f24878c40 100644 --- a/src/pocketmine/network/mcpe/NetworkSession.php +++ b/src/pocketmine/network/mcpe/NetworkSession.php @@ -101,6 +101,7 @@ use pocketmine\network\mcpe\protocol\ResourcePackStackPacket; use pocketmine\network\mcpe\protocol\ResourcePacksInfoPacket; use pocketmine\network\mcpe\protocol\RespawnPacket; use pocketmine\network\mcpe\protocol\RiderJumpPacket; +use pocketmine\network\mcpe\protocol\ScriptCustomEventPacket; use pocketmine\network\mcpe\protocol\ServerSettingsRequestPacket; use pocketmine\network\mcpe\protocol\ServerSettingsResponsePacket; use pocketmine\network\mcpe\protocol\ServerToClientHandshakePacket; @@ -603,4 +604,8 @@ abstract class NetworkSession{ public function handleNetworkStackLatency(NetworkStackLatencyPacket $packet) : bool{ return false; } + + public function handleScriptCustomEvent(ScriptCustomEventPacket $packet) : bool{ + return false; + } } diff --git a/src/pocketmine/network/mcpe/protocol/AddPlayerPacket.php b/src/pocketmine/network/mcpe/protocol/AddPlayerPacket.php index 537e1d543..b32dca219 100644 --- a/src/pocketmine/network/mcpe/protocol/AddPlayerPacket.php +++ b/src/pocketmine/network/mcpe/protocol/AddPlayerPacket.php @@ -38,10 +38,6 @@ class AddPlayerPacket extends DataPacket{ public $uuid; /** @var string */ public $username; - /** @var string */ - public $thirdPartyName = ""; - /** @var int */ - public $platform = 0; /** @var int|null */ public $entityUniqueId = null; //TODO /** @var int */ @@ -81,8 +77,6 @@ class AddPlayerPacket extends DataPacket{ protected function decodePayload(){ $this->uuid = $this->getUUID(); $this->username = $this->getString(); - $this->thirdPartyName = $this->getString(); - $this->platform = $this->getVarInt(); $this->entityUniqueId = $this->getEntityUniqueId(); $this->entityRuntimeId = $this->getEntityRuntimeId(); $this->platformChatId = $this->getString(); @@ -113,8 +107,6 @@ class AddPlayerPacket extends DataPacket{ protected function encodePayload(){ $this->putUUID($this->uuid); $this->putString($this->username); - $this->putString($this->thirdPartyName); - $this->putVarInt($this->platform); $this->putEntityUniqueId($this->entityUniqueId ?? $this->entityRuntimeId); $this->putEntityRuntimeId($this->entityRuntimeId); $this->putString($this->platformChatId); diff --git a/src/pocketmine/network/mcpe/protocol/EventPacket.php b/src/pocketmine/network/mcpe/protocol/EventPacket.php index 612f5ded7..307092dcf 100644 --- a/src/pocketmine/network/mcpe/protocol/EventPacket.php +++ b/src/pocketmine/network/mcpe/protocol/EventPacket.php @@ -40,6 +40,9 @@ class EventPacket extends DataPacket{ public const TYPE_BOSS_KILLED = 7; public const TYPE_AGENT_COMMAND = 8; public const TYPE_AGENT_CREATED = 9; + public const TYPE_PATTERN_REMOVED = 10; //??? + public const TYPE_COMMANED_EXECUTED = 11; + public const TYPE_FISH_BUCKETED = 12; /** @var int */ public $playerRuntimeId; diff --git a/src/pocketmine/network/mcpe/protocol/PacketPool.php b/src/pocketmine/network/mcpe/protocol/PacketPool.php index 814d082a6..a156aeb18 100644 --- a/src/pocketmine/network/mcpe/protocol/PacketPool.php +++ b/src/pocketmine/network/mcpe/protocol/PacketPool.php @@ -146,6 +146,7 @@ class PacketPool{ static::registerPacket(new SetLocalPlayerAsInitializedPacket()); static::registerPacket(new UpdateSoftEnumPacket()); static::registerPacket(new NetworkStackLatencyPacket()); + static::registerPacket(new ScriptCustomEventPacket()); static::registerPacket(new BatchPacket()); } diff --git a/src/pocketmine/network/mcpe/protocol/PlayerListPacket.php b/src/pocketmine/network/mcpe/protocol/PlayerListPacket.php index 6e756982d..09e342215 100644 --- a/src/pocketmine/network/mcpe/protocol/PlayerListPacket.php +++ b/src/pocketmine/network/mcpe/protocol/PlayerListPacket.php @@ -56,8 +56,6 @@ class PlayerListPacket extends DataPacket{ $entry->uuid = $this->getUUID(); $entry->entityUniqueId = $this->getEntityUniqueId(); $entry->username = $this->getString(); - $entry->thirdPartyName = $this->getString(); - $entry->platform = $this->getVarInt(); $skinId = $this->getString(); $skinData = $this->getString(); @@ -90,8 +88,6 @@ class PlayerListPacket extends DataPacket{ $this->putUUID($entry->uuid); $this->putEntityUniqueId($entry->entityUniqueId); $this->putString($entry->username); - $this->putString($entry->thirdPartyName); - $this->putVarInt($entry->platform); $this->putString($entry->skin->getSkinId()); $this->putString($entry->skin->getSkinData()); $this->putString($entry->skin->getCapeData()); diff --git a/src/pocketmine/network/mcpe/protocol/ProtocolInfo.php b/src/pocketmine/network/mcpe/protocol/ProtocolInfo.php index 65c98a6f5..d685e565e 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 = 282; + public const CURRENT_PROTOCOL = 291; /** * Current Minecraft PE version reported by the server. This is usually the earliest currently supported version. */ - public const MINECRAFT_VERSION = 'v1.6.0'; + public const MINECRAFT_VERSION = 'v1.7.0.5 beta'; /** * Version number sent to clients in ping responses. */ - public const MINECRAFT_VERSION_NETWORK = '1.6.0'; + public const MINECRAFT_VERSION_NETWORK = '1.7.0.5'; public const LOGIN_PACKET = 0x01; public const PLAY_STATUS_PACKET = 0x02; @@ -164,5 +164,6 @@ interface ProtocolInfo{ public const SET_LOCAL_PLAYER_AS_INITIALIZED_PACKET = 0x71; public const UPDATE_SOFT_ENUM_PACKET = 0x72; public const NETWORK_STACK_LATENCY_PACKET = 0x73; + public const SCRIPT_CUSTOM_EVENT_PACKET = 0x75; } diff --git a/src/pocketmine/network/mcpe/protocol/ScriptCustomEventPacket.php b/src/pocketmine/network/mcpe/protocol/ScriptCustomEventPacket.php new file mode 100644 index 000000000..78e9df905 --- /dev/null +++ b/src/pocketmine/network/mcpe/protocol/ScriptCustomEventPacket.php @@ -0,0 +1,51 @@ + + +use pocketmine\network\mcpe\NetworkSession; + +class ScriptCustomEventPacket extends DataPacket{ + public const NETWORK_ID = ProtocolInfo::SCRIPT_CUSTOM_EVENT_PACKET; + + /** @var string */ + public $eventName; + /** @var string json data */ + public $eventData; + + protected function decodePayload(){ + $this->eventName = $this->getString(); + $this->eventData = $this->getString(); + } + + protected function encodePayload(){ + $this->putString($this->eventName); + $this->putString($this->eventData); + } + + public function handle(NetworkSession $session) : bool{ + return $session->handleScriptCustomEvent($this); + } +} diff --git a/src/pocketmine/network/mcpe/protocol/SetScorePacket.php b/src/pocketmine/network/mcpe/protocol/SetScorePacket.php index f1efb6579..f6fba05b0 100644 --- a/src/pocketmine/network/mcpe/protocol/SetScorePacket.php +++ b/src/pocketmine/network/mcpe/protocol/SetScorePacket.php @@ -31,8 +31,8 @@ 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; + public const TYPE_CHANGE = 0; + public const TYPE_REMOVE = 1; /** @var int */ public $type; @@ -43,9 +43,23 @@ class SetScorePacket extends DataPacket{ $this->type = $this->getByte(); for($i = 0, $i2 = $this->getUnsignedVarInt(); $i < $i2; ++$i){ $entry = new ScorePacketEntry(); - $entry->uuid = $this->getUUID(); + $entry->scoreboardId = $this->getVarLong(); $entry->objectiveName = $this->getString(); $entry->score = $this->getLInt(); + if($this->type !== self::TYPE_REMOVE){ + $entry->type = $this->getByte(); + switch($entry->type){ + case ScorePacketEntry::TYPE_PLAYER: + case ScorePacketEntry::TYPE_ENTITY: + $entry->entityUniqueId = $this->getEntityUniqueId(); + break; + case ScorePacketEntry::TYPE_FAKE_PLAYER: + $entry->customName = $this->getString(); + break; + default: + throw new \UnexpectedValueException("Unknown entry type $entry->type"); + } + } } } @@ -53,9 +67,23 @@ class SetScorePacket extends DataPacket{ $this->putByte($this->type); $this->putUnsignedVarInt(count($this->entries)); foreach($this->entries as $entry){ - $this->putUUID($entry->uuid); + $this->putVarLong($entry->scoreboardId); $this->putString($entry->objectiveName); $this->putLInt($entry->score); + if($this->type !== self::TYPE_REMOVE){ + $this->putByte($entry->type); + switch($entry->type){ + case ScorePacketEntry::TYPE_PLAYER: + case ScorePacketEntry::TYPE_ENTITY: + $this->putEntityUniqueId($entry->entityUniqueId); + break; + case ScorePacketEntry::TYPE_FAKE_PLAYER: + $this->putString($entry->customName); + break; + default: + throw new \UnexpectedValueException("Unknown entry type $entry->type"); + } + } } } diff --git a/src/pocketmine/network/mcpe/protocol/SetScoreboardIdentityPacket.php b/src/pocketmine/network/mcpe/protocol/SetScoreboardIdentityPacket.php index 91cd54612..00c21d47d 100644 --- a/src/pocketmine/network/mcpe/protocol/SetScoreboardIdentityPacket.php +++ b/src/pocketmine/network/mcpe/protocol/SetScoreboardIdentityPacket.php @@ -45,7 +45,7 @@ class SetScoreboardIdentityPacket extends DataPacket{ $entry = new ScoreboardIdentityPacketEntry(); $entry->scoreboardId = $this->getVarLong(); if($this->type === self::TYPE_REGISTER_IDENTITY){ - $entry->uuid = $this->getUUID(); + $entry->entityUniqueId = $this->getEntityUniqueId(); } $this->entries[] = $entry; @@ -58,7 +58,7 @@ class SetScoreboardIdentityPacket extends DataPacket{ foreach($this->entries as $entry){ $this->putVarLong($entry->scoreboardId); if($this->type === self::TYPE_REGISTER_IDENTITY){ - $this->putUUID($entry->uuid); + $this->putEntityUniqueId($entry->entityUniqueId); } } } diff --git a/src/pocketmine/network/mcpe/protocol/StartGamePacket.php b/src/pocketmine/network/mcpe/protocol/StartGamePacket.php index 1c016a2c2..9d5e76f60 100644 --- a/src/pocketmine/network/mcpe/protocol/StartGamePacket.php +++ b/src/pocketmine/network/mcpe/protocol/StartGamePacket.php @@ -116,6 +116,8 @@ class StartGamePacket extends DataPacket{ public $hasLockedResourcePack = false; /** @var bool */ public $isFromLockedWorldTemplate = false; + /** @var bool */ + public $useMsaGamertagsOnly = false; /** @var string */ public $levelId = ""; //base64 string, usually the same as world folder name in vanilla @@ -173,6 +175,7 @@ class StartGamePacket extends DataPacket{ $this->hasLockedBehaviorPack = $this->getBool(); $this->hasLockedResourcePack = $this->getBool(); $this->isFromLockedWorldTemplate = $this->getBool(); + $this->useMsaGamertagsOnly = $this->getBool(); $this->levelId = $this->getString(); $this->worldName = $this->getString(); @@ -232,6 +235,7 @@ class StartGamePacket extends DataPacket{ $this->putBool($this->hasLockedBehaviorPack); $this->putBool($this->hasLockedResourcePack); $this->putBool($this->isFromLockedWorldTemplate); + $this->putBool($this->useMsaGamertagsOnly); $this->putString($this->levelId); $this->putString($this->worldName); diff --git a/src/pocketmine/network/mcpe/protocol/TextPacket.php b/src/pocketmine/network/mcpe/protocol/TextPacket.php index cb6990275..4d00937be 100644 --- a/src/pocketmine/network/mcpe/protocol/TextPacket.php +++ b/src/pocketmine/network/mcpe/protocol/TextPacket.php @@ -48,10 +48,6 @@ class TextPacket extends DataPacket{ /** @var string */ public $sourceName; /** @var string */ - public $sourceThirdPartyName = ""; - /** @var int */ - public $sourcePlatform = 0; - /** @var string */ public $message; /** @var string[] */ public $parameters = []; @@ -69,8 +65,6 @@ class TextPacket extends DataPacket{ /** @noinspection PhpMissingBreakStatementInspection */ case self::TYPE_ANNOUNCEMENT: $this->sourceName = $this->getString(); - $this->sourceThirdPartyName = $this->getString(); - $this->sourcePlatform = $this->getVarInt(); case self::TYPE_RAW: case self::TYPE_TIP: case self::TYPE_SYSTEM: @@ -101,8 +95,6 @@ class TextPacket extends DataPacket{ /** @noinspection PhpMissingBreakStatementInspection */ case self::TYPE_ANNOUNCEMENT: $this->putString($this->sourceName); - $this->putString($this->sourceThirdPartyName); - $this->putVarInt($this->sourcePlatform); case self::TYPE_RAW: case self::TYPE_TIP: case self::TYPE_SYSTEM: diff --git a/src/pocketmine/network/mcpe/protocol/types/PlayerListEntry.php b/src/pocketmine/network/mcpe/protocol/types/PlayerListEntry.php index 1b5a34ddd..81f0a82ee 100644 --- a/src/pocketmine/network/mcpe/protocol/types/PlayerListEntry.php +++ b/src/pocketmine/network/mcpe/protocol/types/PlayerListEntry.php @@ -52,13 +52,11 @@ class PlayerListEntry{ return $entry; } - public static function createAdditionEntry(UUID $uuid, int $entityUniqueId, string $username, string $thirdPartyName, int $platform, Skin $skin, string $xboxUserId = "", string $platformChatId = "") : PlayerListEntry{ + public static function createAdditionEntry(UUID $uuid, int $entityUniqueId, string $username, Skin $skin, string $xboxUserId = "", string $platformChatId = "") : PlayerListEntry{ $entry = new PlayerListEntry(); $entry->uuid = $uuid; $entry->entityUniqueId = $entityUniqueId; $entry->username = $username; - $entry->thirdPartyName = $thirdPartyName; - $entry->platform = $platform; $entry->skin = $skin; $entry->xboxUserId = $xboxUserId; $entry->platformChatId = $platformChatId; diff --git a/src/pocketmine/network/mcpe/protocol/types/ScorePacketEntry.php b/src/pocketmine/network/mcpe/protocol/types/ScorePacketEntry.php index a2c0326d1..ce8c0d07f 100644 --- a/src/pocketmine/network/mcpe/protocol/types/ScorePacketEntry.php +++ b/src/pocketmine/network/mcpe/protocol/types/ScorePacketEntry.php @@ -23,13 +23,23 @@ declare(strict_types=1); namespace pocketmine\network\mcpe\protocol\types; -use pocketmine\utils\UUID; - class ScorePacketEntry{ - /** @var UUID */ - public $uuid; + public const TYPE_PLAYER = 1; + public const TYPE_ENTITY = 2; + public const TYPE_FAKE_PLAYER = 3; + + /** @var int */ + public $scoreboardId; /** @var string */ public $objectiveName; /** @var int */ public $score; + + /** @var int */ + public $type; + + /** @var int|null (if type entity or player) */ + public $entityUniqueId; + /** @var string|null (if type fake player) */ + public $customName; } diff --git a/src/pocketmine/network/mcpe/protocol/types/ScoreboardIdentityPacketEntry.php b/src/pocketmine/network/mcpe/protocol/types/ScoreboardIdentityPacketEntry.php index 416e2434d..4ea15366c 100644 --- a/src/pocketmine/network/mcpe/protocol/types/ScoreboardIdentityPacketEntry.php +++ b/src/pocketmine/network/mcpe/protocol/types/ScoreboardIdentityPacketEntry.php @@ -23,12 +23,10 @@ declare(strict_types=1); namespace pocketmine\network\mcpe\protocol\types; -use pocketmine\utils\UUID; - class ScoreboardIdentityPacketEntry{ /** @var int */ public $scoreboardId; - /** @var UUID|null */ - public $uuid; + /** @var int|null */ + public $entityUniqueId; }