More broken mess to spawn 1.2

This commit is contained in:
Dylan K. Taylor 2017-08-01 20:06:02 +01:00
parent 10ff2948ac
commit 77cd8e7799
52 changed files with 1558 additions and 506 deletions

View File

@ -115,9 +115,7 @@ use pocketmine\network\mcpe\protocol\BossEventPacket;
use pocketmine\network\mcpe\protocol\ChunkRadiusUpdatedPacket; use pocketmine\network\mcpe\protocol\ChunkRadiusUpdatedPacket;
use pocketmine\network\mcpe\protocol\ClientToServerHandshakePacket; use pocketmine\network\mcpe\protocol\ClientToServerHandshakePacket;
use pocketmine\network\mcpe\protocol\CommandBlockUpdatePacket; use pocketmine\network\mcpe\protocol\CommandBlockUpdatePacket;
use pocketmine\network\mcpe\protocol\CommandStepPacket;
use pocketmine\network\mcpe\protocol\ContainerClosePacket; use pocketmine\network\mcpe\protocol\ContainerClosePacket;
use pocketmine\network\mcpe\protocol\ContainerSetContentPacket;
use pocketmine\network\mcpe\protocol\ContainerSetSlotPacket; use pocketmine\network\mcpe\protocol\ContainerSetSlotPacket;
use pocketmine\network\mcpe\protocol\CraftingEventPacket; use pocketmine\network\mcpe\protocol\CraftingEventPacket;
use pocketmine\network\mcpe\protocol\DataPacket; use pocketmine\network\mcpe\protocol\DataPacket;
@ -156,6 +154,7 @@ use pocketmine\network\mcpe\protocol\TextPacket;
use pocketmine\network\mcpe\protocol\TransferPacket; use pocketmine\network\mcpe\protocol\TransferPacket;
use pocketmine\network\mcpe\protocol\types\ContainerIds; use pocketmine\network\mcpe\protocol\types\ContainerIds;
use pocketmine\network\mcpe\protocol\types\DimensionIds; use pocketmine\network\mcpe\protocol\types\DimensionIds;
use pocketmine\network\mcpe\protocol\types\PlayerPermissions;
use pocketmine\network\mcpe\protocol\UpdateAttributesPacket; use pocketmine\network\mcpe\protocol\UpdateAttributesPacket;
use pocketmine\network\mcpe\protocol\UpdateBlockPacket; use pocketmine\network\mcpe\protocol\UpdateBlockPacket;
use pocketmine\network\mcpe\protocol\UseItemPacket; use pocketmine\network\mcpe\protocol\UseItemPacket;
@ -1321,14 +1320,17 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
*/ */
public function sendSettings(){ public function sendSettings(){
$pk = new AdventureSettingsPacket(); $pk = new AdventureSettingsPacket();
$pk->flags = 0;
$pk->worldImmutable = $this->isSpectator(); $pk->setFlag(AdventureSettingsPacket::WORLD_IMMUTABLE, $this->isSpectator());
$pk->noPvp = $this->isSpectator(); $pk->setFlag(AdventureSettingsPacket::NO_PVP, $this->isSpectator());
$pk->autoJump = $this->autoJump; $pk->setFlag(AdventureSettingsPacket::AUTO_JUMP, $this->autoJump);
$pk->allowFlight = $this->allowFlight; $pk->setFlag(AdventureSettingsPacket::ALLOW_FLIGHT, $this->allowFlight);
$pk->noClip = $this->isSpectator(); $pk->setFlag(AdventureSettingsPacket::NO_CLIP, $this->isSpectator());
$pk->isFlying = $this->flying; $pk->setFlag(AdventureSettingsPacket::FLYING, $this->flying);
$pk->userPermission = ($this->isOp() ? AdventureSettingsPacket::PERMISSION_OPERATOR : AdventureSettingsPacket::PERMISSION_NORMAL);
$pk->commandPermission = ($this->isOp() ? AdventureSettingsPacket::PERMISSION_OPERATOR : AdventureSettingsPacket::PERMISSION_NORMAL);
$pk->playerPermission = ($this->isOp() ? PlayerPermissions::OPERATOR : PlayerPermissions::MEMBER);
$this->dataPacket($pk); $this->dataPacket($pk);
} }
@ -1864,7 +1866,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
$pk->spawnY = $spawnPosition->getFloorY(); $pk->spawnY = $spawnPosition->getFloorY();
$pk->spawnZ = $spawnPosition->getFloorZ(); $pk->spawnZ = $spawnPosition->getFloorZ();
$pk->hasAchievementsDisabled = true; $pk->hasAchievementsDisabled = true;
$pk->dayCycleStopTime = -1; //TODO: implement this properly $pk->time = $this->level->getTime();
$pk->eduMode = false; $pk->eduMode = false;
$pk->rainLevel = 0; //TODO: implement these properly $pk->rainLevel = 0; //TODO: implement these properly
$pk->lightningLevel = 0; $pk->lightningLevel = 0;
@ -2029,40 +2031,40 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
return true; return true;
} }
public function handleText(TextPacket $packet) : bool{ /**
* Sends a chat message as this player. If the message begins with a / (forward-slash) it will be treated
* as a command.
*
* @param string $message
*
* @return bool
*/
public function chat(string $message) : bool{
if($this->spawned === false or !$this->isAlive()){ if($this->spawned === false or !$this->isAlive()){
return true; return false;
} }
$this->craftingType = 0; $this->craftingType = 0;
if($packet->type === TextPacket::TYPE_CHAT){
$packet->message = TextFormat::clean($packet->message, $this->removeFormat);
foreach(explode("\n", $packet->message) as $message){
if(trim($message) != "" and strlen($message) <= 255 and $this->messageCounter-- > 0){
if(substr($message, 0, 2) === "./"){ //Command (./ = fast hack for old plugins post 0.16)
$message = substr($message, 1);
}
$ev = new PlayerCommandPreprocessEvent($this, $message); $message = TextFormat::clean($message, $this->removeFormat);
foreach(explode("\n", $message) as $messagePart){
if(trim($messagePart) !== "" and strlen($messagePart) <= 255 and $this->messageCounter-- > 0){
$ev = new PlayerCommandPreprocessEvent($this, $message);
if(mb_strlen($ev->getMessage(), "UTF-8") > 320){ $this->server->getPluginManager()->callEvent($ev);
$ev->setCancelled();
}
$this->server->getPluginManager()->callEvent($ev);
if($ev->isCancelled()){ if($ev->isCancelled()){
break; break;
} }
if(substr($ev->getMessage(), 0, 1) === "/"){ if(strpos($ev->getMessage(), "/") === 0){
Timings::$playerCommandTimer->startTiming(); Timings::$playerCommandTimer->startTiming();
$this->server->dispatchCommand($ev->getPlayer(), substr($ev->getMessage(), 1)); $this->server->dispatchCommand($ev->getPlayer(), substr($ev->getMessage(), 1));
Timings::$playerCommandTimer->stopTiming(); Timings::$playerCommandTimer->stopTiming();
}else{ }else{
$this->server->getPluginManager()->callEvent($ev = new PlayerChatEvent($this, $ev->getMessage())); $this->server->getPluginManager()->callEvent($ev = new PlayerChatEvent($this, $ev->getMessage()));
if(!$ev->isCancelled()){ if(!$ev->isCancelled()){
$this->server->broadcastMessage($this->getServer()->getLanguage()->translateString($ev->getFormat(), [$ev->getPlayer()->getDisplayName(), $ev->getMessage()]), $ev->getRecipients()); $this->server->broadcastMessage($this->getServer()->getLanguage()->translateString($ev->getFormat(), [$ev->getPlayer()->getDisplayName(), $ev->getMessage()]), $ev->getRecipients());
}
} }
} }
} }
@ -2475,7 +2477,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
} }
public function handlePlayerAction(PlayerActionPacket $packet) : bool{ public function handlePlayerAction(PlayerActionPacket $packet) : bool{
if($this->spawned === false or (!$this->isAlive() and $packet->action !== PlayerActionPacket::ACTION_RESPAWN and $packet->action !== PlayerActionPacket::ACTION_DIMENSION_CHANGE)){ if($this->spawned === false or (!$this->isAlive() and $packet->action !== PlayerActionPacket::ACTION_RESPAWN and $packet->action !== PlayerActionPacket::ACTION_DIMENSION_CHANGE_REQUEST)){
return true; return true;
} }
@ -3033,11 +3035,12 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
} }
public function handleAdventureSettings(AdventureSettingsPacket $packet) : bool{ public function handleAdventureSettings(AdventureSettingsPacket $packet) : bool{
if($packet->isFlying and !$this->allowFlight and !$this->server->getAllowFlight()){ $isFlying = $packet->getFlag(AdventureSettingsPacket::FLYING);
if($isFlying and !$this->allowFlight and !$this->server->getAllowFlight()){
$this->kick($this->server->getLanguage()->translateString("kick.reason.cheat", ["%ability.flight"])); $this->kick($this->server->getLanguage()->translateString("kick.reason.cheat", ["%ability.flight"]));
return true; return true;
}elseif($packet->isFlying !== $this->isFlying()){ }elseif($isFlying !== $this->isFlying()){
$this->server->getPluginManager()->callEvent($ev = new PlayerToggleFlightEvent($this, $packet->isFlying)); $this->server->getPluginManager()->callEvent($ev = new PlayerToggleFlightEvent($this, $isFlying));
if($ev->isCancelled()){ if($ev->isCancelled()){
$this->sendSettings(); $this->sendSettings();
}else{ }else{
@ -3045,7 +3048,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
} }
} }
if($packet->noClip and !$this->allowMovementCheats and !$this->isSpectator()){ if($packet->getFlag(AdventureSettingsPacket::NO_CLIP) and !$this->allowMovementCheats and !$this->isSpectator()){
$this->kick($this->server->getLanguage()->translateString("kick.reason.cheat", ["%ability.noclip"])); $this->kick($this->server->getLanguage()->translateString("kick.reason.cheat", ["%ability.noclip"]));
return true; return true;
} }
@ -3143,29 +3146,6 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
return false; //TODO: handle resume return false; //TODO: handle resume
} }
public function handleCommandStep(CommandStepPacket $packet) : bool{
if($this->spawned === false or !$this->isAlive()){
return true;
}
$this->craftingType = 0;
$commandText = $packet->command;
if($packet->inputJson !== null){
foreach($packet->inputJson as $arg){ //command ordering will be an issue
$commandText .= " " . $arg;
}
}
$this->server->getPluginManager()->callEvent($ev = new PlayerCommandPreprocessEvent($this, "/" . $commandText));
if($ev->isCancelled()){
return true;
}
Timings::$playerCommandTimer->startTiming();
$this->server->dispatchCommand($ev->getPlayer(), substr($ev->getMessage(), 1));
Timings::$playerCommandTimer->stopTiming();
return true;
}
public function handleCommandBlockUpdate(CommandBlockUpdatePacket $packet) : bool{ public function handleCommandBlockUpdate(CommandBlockUpdatePacket $packet) : bool{
return false; //TODO return false; //TODO
} }

View File

@ -200,7 +200,9 @@ abstract class Entity extends Location implements Metadatable{
const DATA_FLAG_EVOKER_SPELL = 40; const DATA_FLAG_EVOKER_SPELL = 40;
const DATA_FLAG_CHARGE_ATTACK = 41; const DATA_FLAG_CHARGE_ATTACK = 41;
const DATA_FLAG_LINGER = 45; const DATA_FLAG_LINGER = 44;
const DATA_FLAG_HAS_COLLISION = 45;
const DATA_FLAG_AFFECTED_BY_GRAVITY = 46;
public static $entityCount = 1; public static $entityCount = 1;
/** @var Entity[] */ /** @var Entity[] */
@ -397,6 +399,9 @@ abstract class Entity extends Location implements Metadatable{
$this->attributeMap = new AttributeMap(); $this->attributeMap = new AttributeMap();
$this->addAttributes(); $this->addAttributes();
$this->setDataFlag(self::DATA_FLAGS, self::DATA_FLAG_AFFECTED_BY_GRAVITY, true);
$this->setDataFlag(self::DATA_FLAGS, self::DATA_FLAG_HAS_COLLISION, true);
$this->chunk->addEntity($this); $this->chunk->addEntity($this);
$this->level->addEntity($this); $this->level->addEntity($this);
$this->initEntity(); $this->initEntity();

View File

@ -27,8 +27,8 @@ use pocketmine\entity\Entity;
use pocketmine\event\entity\EntityInventoryChangeEvent; use pocketmine\event\entity\EntityInventoryChangeEvent;
use pocketmine\event\inventory\InventoryOpenEvent; use pocketmine\event\inventory\InventoryOpenEvent;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\network\mcpe\protocol\ContainerSetContentPacket; use pocketmine\network\mcpe\protocol\InventoryContentPacket;
use pocketmine\network\mcpe\protocol\ContainerSetSlotPacket; use pocketmine\network\mcpe\protocol\InventorySlotPacket;
use pocketmine\Player; use pocketmine\Player;
use pocketmine\Server; use pocketmine\Server;
@ -419,10 +419,9 @@ abstract class BaseInventory implements Inventory{
$target = [$target]; $target = [$target];
} }
$pk = new ContainerSetContentPacket(); $pk = new InventoryContentPacket();
$pk->slots = [];
for($i = 0; $i < $this->getSize(); ++$i){ for($i = 0; $i < $this->getSize(); ++$i){
$pk->slots[$i] = $this->getItem($i); $pk->items[$i] = $this->getItem($i);
} }
foreach($target as $player){ foreach($target as $player){
@ -430,8 +429,7 @@ abstract class BaseInventory implements Inventory{
$this->close($player); $this->close($player);
continue; continue;
} }
$pk->windowid = $id; $pk->windowId = $id;
$pk->targetEid = $player->getId();
$player->dataPacket($pk); $player->dataPacket($pk);
} }
} }
@ -445,8 +443,8 @@ abstract class BaseInventory implements Inventory{
$target = [$target]; $target = [$target];
} }
$pk = new ContainerSetSlotPacket(); $pk = new InventorySlotPacket();
$pk->slot = $index; $pk->slotIndex = $index;
$pk->item = clone $this->getItem($index); $pk->item = clone $this->getItem($index);
foreach($target as $player){ foreach($target as $player){
@ -454,7 +452,7 @@ abstract class BaseInventory implements Inventory{
$this->close($player); $this->close($player);
continue; continue;
} }
$pk->windowid = $id; $pk->windowId = $id;
$player->dataPacket($pk); $player->dataPacket($pk);
} }
} }

View File

@ -28,10 +28,11 @@ use pocketmine\event\entity\EntityArmorChangeEvent;
use pocketmine\event\entity\EntityInventoryChangeEvent; use pocketmine\event\entity\EntityInventoryChangeEvent;
use pocketmine\event\player\PlayerItemHeldEvent; use pocketmine\event\player\PlayerItemHeldEvent;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\network\mcpe\protocol\ContainerSetContentPacket; use pocketmine\network\mcpe\protocol\InventoryContentPacket;
use pocketmine\network\mcpe\protocol\ContainerSetSlotPacket; use pocketmine\network\mcpe\protocol\InventorySlotPacket;
use pocketmine\network\mcpe\protocol\MobArmorEquipmentPacket; use pocketmine\network\mcpe\protocol\MobArmorEquipmentPacket;
use pocketmine\network\mcpe\protocol\MobEquipmentPacket; use pocketmine\network\mcpe\protocol\MobEquipmentPacket;
use pocketmine\network\mcpe\protocol\PlayerHotbarPacket;
use pocketmine\network\mcpe\protocol\types\ContainerIds; use pocketmine\network\mcpe\protocol\types\ContainerIds;
use pocketmine\Player; use pocketmine\Player;
use pocketmine\Server; use pocketmine\Server;
@ -424,10 +425,9 @@ class PlayerInventory extends BaseInventory{
foreach($target as $player){ foreach($target as $player){
if($player === $this->getHolder()){ if($player === $this->getHolder()){
$pk2 = new ContainerSetContentPacket(); $pk2 = new InventoryContentPacket();
$pk2->windowid = ContainerIds::ARMOR; $pk2->windowId = ContainerIds::ARMOR;
$pk2->slots = $armor; $pk2->items = $armor;
$pk2->targetEid = $player->getId();
$player->dataPacket($pk2); $player->dataPacket($pk2);
}else{ }else{
$player->dataPacket($pk); $player->dataPacket($pk);
@ -472,9 +472,10 @@ class PlayerInventory extends BaseInventory{
foreach($target as $player){ foreach($target as $player){
if($player === $this->getHolder()){ if($player === $this->getHolder()){
/** @var Player $player */ /** @var Player $player */
$pk2 = new ContainerSetSlotPacket();
$pk2->windowid = ContainerIds::ARMOR; $pk2 = new InventorySlotPacket();
$pk2->slot = $index - $this->getSize(); $pk2->windowId = ContainerIds::ARMOR;
$pk2->slotIndex = $index - $this->getSize();
$pk2->item = $this->getItem($index); $pk2->item = $this->getItem($index);
$player->dataPacket($pk2); $player->dataPacket($pk2);
}else{ }else{
@ -491,45 +492,39 @@ class PlayerInventory extends BaseInventory{
$target = [$target]; $target = [$target];
} }
$pk = new ContainerSetContentPacket(); $pk = new InventoryContentPacket();
$pk->slots = [];
for($i = 0; $i < $this->getSize(); ++$i){ //Do not send armor by error here for($i = 0; $i < $this->getSize(); ++$i){ //Do not send armor by error here
$pk->slots[$i] = $this->getItem($i); $pk->items[$i] = $this->getItem($i);
}
//Because PE is stupid and shows 9 less slots than you send it, give it 9 dummy slots so it shows all the REAL slots.
for($i = $this->getSize(); $i < $this->getSize() + $this->getHotbarSize(); ++$i){
$pk->slots[$i] = Item::get(Item::AIR, 0, 0);
} }
foreach($target as $player){ foreach($target as $player){
$pk->hotbar = [];
if($player === $this->getHolder()){
for($i = 0; $i < $this->getHotbarSize(); ++$i){
$index = $this->getHotbarSlotIndex($i);
$pk->hotbar[] = $index <= -1 ? -1 : $index + $this->getHotbarSize();
}
}
if(($id = $player->getWindowId($this)) === -1 or $player->spawned !== true){ if(($id = $player->getWindowId($this)) === -1 or $player->spawned !== true){
$this->close($player); $this->close($player);
continue; continue;
} }
$pk->windowid = $id; $pk->windowId = $id;
$pk->targetEid = $player->getId(); //TODO: check if this is correct
$player->dataPacket(clone $pk); $player->dataPacket(clone $pk);
if($player === $this->getHolder()){
$pk = new PlayerHotbarPacket();
$pk->slots = array_map(function(int $i){ return $i + $this->getHotbarSize(); }, $this->hotbar);
$pk->selectedSlot = $this->getHeldItemIndex();
$pk->windowId = ContainerIds::INVENTORY;
$player->dataPacket($pk);
}
} }
} }
public function sendCreativeContents(){ public function sendCreativeContents(){
$pk = new ContainerSetContentPacket(); $pk = new InventoryContentPacket();
$pk->windowid = ContainerIds::CREATIVE; $pk->windowId = ContainerIds::CREATIVE;
if($this->getHolder()->getGamemode() === Player::CREATIVE){ if($this->getHolder()->getGamemode() === Player::CREATIVE){
foreach(Item::getCreativeItems() as $i => $item){ foreach(Item::getCreativeItems() as $i => $item){
$pk->slots[$i] = clone $item; $pk->items[$i] = clone $item;
} }
} }
$pk->targetEid = $this->getHolder()->getId();
$this->getHolder()->dataPacket($pk); $this->getHolder()->dataPacket($pk);
} }
@ -542,21 +537,21 @@ class PlayerInventory extends BaseInventory{
$target = [$target]; $target = [$target];
} }
$pk = new ContainerSetSlotPacket(); $pk = new InventorySlotPacket();
$pk->slot = $index; $pk->slotIndex = $index;
$pk->item = clone $this->getItem($index); $pk->item = clone $this->getItem($index);
foreach($target as $player){ foreach($target as $player){
if($player === $this->getHolder()){ if($player === $this->getHolder()){
/** @var Player $player */ /** @var Player $player */
$pk->windowid = 0; $pk->windowId = ContainerIds::INVENTORY;
$player->dataPacket(clone $pk); $player->dataPacket(clone $pk);
}else{ }else{
if(($id = $player->getWindowId($this)) === -1){ if(($id = $player->getWindowId($this)) === -1){
$this->close($player); $this->close($player);
continue; continue;
} }
$pk->windowid = $id; $pk->windowId = $id;
$player->dataPacket(clone $pk); $player->dataPacket(clone $pk);
} }
} }

View File

@ -114,7 +114,7 @@ class EmptySubChunk implements SubChunkInterface{
} }
public function networkSerialize() : string{ public function networkSerialize() : string{
return "\x00" . str_repeat("\x00", 10240); return "\x00" . str_repeat("\x00", 6144);
} }
public function fastSerialize() : string{ public function fastSerialize() : string{

View File

@ -219,8 +219,7 @@ class SubChunk implements SubChunkInterface{
} }
public function networkSerialize() : string{ public function networkSerialize() : string{
// storage version, ids, data, skylight, blocklight return "\x00" . $this->ids . $this->data;
return "\x00" . $this->ids . $this->data . $this->skyLight . $this->blockLight;
} }
public function fastSerialize() : string{ public function fastSerialize() : string{

View File

@ -27,7 +27,6 @@ use pocketmine\network\mcpe\protocol\AddBehaviorTreePacket;
use pocketmine\network\mcpe\protocol\AddEntityPacket; use pocketmine\network\mcpe\protocol\AddEntityPacket;
use pocketmine\network\mcpe\protocol\AddHangingEntityPacket; use pocketmine\network\mcpe\protocol\AddHangingEntityPacket;
use pocketmine\network\mcpe\protocol\AddItemEntityPacket; use pocketmine\network\mcpe\protocol\AddItemEntityPacket;
use pocketmine\network\mcpe\protocol\AddItemPacket;
use pocketmine\network\mcpe\protocol\AddPaintingPacket; use pocketmine\network\mcpe\protocol\AddPaintingPacket;
use pocketmine\network\mcpe\protocol\AddPlayerPacket; use pocketmine\network\mcpe\protocol\AddPlayerPacket;
use pocketmine\network\mcpe\protocol\AdventureSettingsPacket; use pocketmine\network\mcpe\protocol\AdventureSettingsPacket;
@ -36,6 +35,7 @@ use pocketmine\network\mcpe\protocol\AvailableCommandsPacket;
use pocketmine\network\mcpe\protocol\BlockEntityDataPacket; use pocketmine\network\mcpe\protocol\BlockEntityDataPacket;
use pocketmine\network\mcpe\protocol\BlockEventPacket; use pocketmine\network\mcpe\protocol\BlockEventPacket;
use pocketmine\network\mcpe\protocol\BlockPickRequestPacket; use pocketmine\network\mcpe\protocol\BlockPickRequestPacket;
use pocketmine\network\mcpe\protocol\BookEditPacket;
use pocketmine\network\mcpe\protocol\BossEventPacket; use pocketmine\network\mcpe\protocol\BossEventPacket;
use pocketmine\network\mcpe\protocol\CameraPacket; use pocketmine\network\mcpe\protocol\CameraPacket;
use pocketmine\network\mcpe\protocol\ChangeDimensionPacket; use pocketmine\network\mcpe\protocol\ChangeDimensionPacket;
@ -43,26 +43,28 @@ use pocketmine\network\mcpe\protocol\ChunkRadiusUpdatedPacket;
use pocketmine\network\mcpe\protocol\ClientToServerHandshakePacket; use pocketmine\network\mcpe\protocol\ClientToServerHandshakePacket;
use pocketmine\network\mcpe\protocol\ClientboundMapItemDataPacket; use pocketmine\network\mcpe\protocol\ClientboundMapItemDataPacket;
use pocketmine\network\mcpe\protocol\CommandBlockUpdatePacket; use pocketmine\network\mcpe\protocol\CommandBlockUpdatePacket;
use pocketmine\network\mcpe\protocol\CommandStepPacket; use pocketmine\network\mcpe\protocol\CommandOutputPacket;
use pocketmine\network\mcpe\protocol\CommandRequestPacket;
use pocketmine\network\mcpe\protocol\ContainerClosePacket; use pocketmine\network\mcpe\protocol\ContainerClosePacket;
use pocketmine\network\mcpe\protocol\ContainerOpenPacket; use pocketmine\network\mcpe\protocol\ContainerOpenPacket;
use pocketmine\network\mcpe\protocol\ContainerSetContentPacket;
use pocketmine\network\mcpe\protocol\ContainerSetDataPacket; use pocketmine\network\mcpe\protocol\ContainerSetDataPacket;
use pocketmine\network\mcpe\protocol\ContainerSetSlotPacket;
use pocketmine\network\mcpe\protocol\CraftingDataPacket; use pocketmine\network\mcpe\protocol\CraftingDataPacket;
use pocketmine\network\mcpe\protocol\CraftingEventPacket; use pocketmine\network\mcpe\protocol\CraftingEventPacket;
use pocketmine\network\mcpe\protocol\DataPacket; use pocketmine\network\mcpe\protocol\DataPacket;
use pocketmine\network\mcpe\protocol\DisconnectPacket; use pocketmine\network\mcpe\protocol\DisconnectPacket;
use pocketmine\network\mcpe\protocol\DropItemPacket;
use pocketmine\network\mcpe\protocol\EntityEventPacket; use pocketmine\network\mcpe\protocol\EntityEventPacket;
use pocketmine\network\mcpe\protocol\EntityFallPacket; use pocketmine\network\mcpe\protocol\EntityFallPacket;
use pocketmine\network\mcpe\protocol\EntityPickRequestPacket;
use pocketmine\network\mcpe\protocol\EventPacket; use pocketmine\network\mcpe\protocol\EventPacket;
use pocketmine\network\mcpe\protocol\ExplodePacket; use pocketmine\network\mcpe\protocol\ExplodePacket;
use pocketmine\network\mcpe\protocol\FullChunkDataPacket; use pocketmine\network\mcpe\protocol\FullChunkDataPacket;
use pocketmine\network\mcpe\protocol\GameRulesChangedPacket; use pocketmine\network\mcpe\protocol\GameRulesChangedPacket;
use pocketmine\network\mcpe\protocol\GuiDataPickItemPacket;
use pocketmine\network\mcpe\protocol\HurtArmorPacket; use pocketmine\network\mcpe\protocol\HurtArmorPacket;
use pocketmine\network\mcpe\protocol\InteractPacket; use pocketmine\network\mcpe\protocol\InteractPacket;
use pocketmine\network\mcpe\protocol\InventoryActionPacket; 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\ItemFrameDropItemPacket;
use pocketmine\network\mcpe\protocol\LevelEventPacket; use pocketmine\network\mcpe\protocol\LevelEventPacket;
use pocketmine\network\mcpe\protocol\LevelSoundEventPacket; use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
@ -71,17 +73,21 @@ use pocketmine\network\mcpe\protocol\MapInfoRequestPacket;
use pocketmine\network\mcpe\protocol\MobArmorEquipmentPacket; use pocketmine\network\mcpe\protocol\MobArmorEquipmentPacket;
use pocketmine\network\mcpe\protocol\MobEffectPacket; use pocketmine\network\mcpe\protocol\MobEffectPacket;
use pocketmine\network\mcpe\protocol\MobEquipmentPacket; use pocketmine\network\mcpe\protocol\MobEquipmentPacket;
use pocketmine\network\mcpe\protocol\ModalFormRequestPacket;
use pocketmine\network\mcpe\protocol\ModalFormResponsePacket;
use pocketmine\network\mcpe\protocol\MoveEntityPacket; use pocketmine\network\mcpe\protocol\MoveEntityPacket;
use pocketmine\network\mcpe\protocol\MovePlayerPacket; use pocketmine\network\mcpe\protocol\MovePlayerPacket;
use pocketmine\network\mcpe\protocol\NpcRequestPacket;
use pocketmine\network\mcpe\protocol\PhotoTransferPacket;
use pocketmine\network\mcpe\protocol\PlaySoundPacket; use pocketmine\network\mcpe\protocol\PlaySoundPacket;
use pocketmine\network\mcpe\protocol\PlayStatusPacket; use pocketmine\network\mcpe\protocol\PlayStatusPacket;
use pocketmine\network\mcpe\protocol\PlayerActionPacket; use pocketmine\network\mcpe\protocol\PlayerActionPacket;
use pocketmine\network\mcpe\protocol\PlayerHotbarPacket;
use pocketmine\network\mcpe\protocol\PlayerInputPacket; use pocketmine\network\mcpe\protocol\PlayerInputPacket;
use pocketmine\network\mcpe\protocol\PlayerListPacket; use pocketmine\network\mcpe\protocol\PlayerListPacket;
use pocketmine\network\mcpe\protocol\PlayerSkinPacket;
use pocketmine\network\mcpe\protocol\PurchaseReceiptPacket; use pocketmine\network\mcpe\protocol\PurchaseReceiptPacket;
use pocketmine\network\mcpe\protocol\RemoveBlockPacket;
use pocketmine\network\mcpe\protocol\RemoveEntityPacket; use pocketmine\network\mcpe\protocol\RemoveEntityPacket;
use pocketmine\network\mcpe\protocol\ReplaceItemInSlotPacket;
use pocketmine\network\mcpe\protocol\RequestChunkRadiusPacket; use pocketmine\network\mcpe\protocol\RequestChunkRadiusPacket;
use pocketmine\network\mcpe\protocol\ResourcePackChunkDataPacket; use pocketmine\network\mcpe\protocol\ResourcePackChunkDataPacket;
use pocketmine\network\mcpe\protocol\ResourcePackChunkRequestPacket; use pocketmine\network\mcpe\protocol\ResourcePackChunkRequestPacket;
@ -91,6 +97,8 @@ use pocketmine\network\mcpe\protocol\ResourcePackStackPacket;
use pocketmine\network\mcpe\protocol\ResourcePacksInfoPacket; use pocketmine\network\mcpe\protocol\ResourcePacksInfoPacket;
use pocketmine\network\mcpe\protocol\RespawnPacket; use pocketmine\network\mcpe\protocol\RespawnPacket;
use pocketmine\network\mcpe\protocol\RiderJumpPacket; use pocketmine\network\mcpe\protocol\RiderJumpPacket;
use pocketmine\network\mcpe\protocol\ServerSettingsRequestPacket;
use pocketmine\network\mcpe\protocol\ServerSettingsResponsePacket;
use pocketmine\network\mcpe\protocol\ServerToClientHandshakePacket; use pocketmine\network\mcpe\protocol\ServerToClientHandshakePacket;
use pocketmine\network\mcpe\protocol\SetCommandsEnabledPacket; use pocketmine\network\mcpe\protocol\SetCommandsEnabledPacket;
use pocketmine\network\mcpe\protocol\SetDifficultyPacket; use pocketmine\network\mcpe\protocol\SetDifficultyPacket;
@ -98,6 +106,7 @@ use pocketmine\network\mcpe\protocol\SetEntityDataPacket;
use pocketmine\network\mcpe\protocol\SetEntityLinkPacket; use pocketmine\network\mcpe\protocol\SetEntityLinkPacket;
use pocketmine\network\mcpe\protocol\SetEntityMotionPacket; use pocketmine\network\mcpe\protocol\SetEntityMotionPacket;
use pocketmine\network\mcpe\protocol\SetHealthPacket; use pocketmine\network\mcpe\protocol\SetHealthPacket;
use pocketmine\network\mcpe\protocol\SetLastHurtByPacket;
use pocketmine\network\mcpe\protocol\SetPlayerGameTypePacket; use pocketmine\network\mcpe\protocol\SetPlayerGameTypePacket;
use pocketmine\network\mcpe\protocol\SetSpawnPositionPacket; use pocketmine\network\mcpe\protocol\SetSpawnPositionPacket;
use pocketmine\network\mcpe\protocol\SetTimePacket; use pocketmine\network\mcpe\protocol\SetTimePacket;
@ -109,6 +118,7 @@ use pocketmine\network\mcpe\protocol\SpawnExperienceOrbPacket;
use pocketmine\network\mcpe\protocol\StartGamePacket; use pocketmine\network\mcpe\protocol\StartGamePacket;
use pocketmine\network\mcpe\protocol\StopSoundPacket; use pocketmine\network\mcpe\protocol\StopSoundPacket;
use pocketmine\network\mcpe\protocol\StructureBlockUpdatePacket; use pocketmine\network\mcpe\protocol\StructureBlockUpdatePacket;
use pocketmine\network\mcpe\protocol\SubClientLoginPacket;
use pocketmine\network\mcpe\protocol\TakeItemEntityPacket; use pocketmine\network\mcpe\protocol\TakeItemEntityPacket;
use pocketmine\network\mcpe\protocol\TextPacket; use pocketmine\network\mcpe\protocol\TextPacket;
use pocketmine\network\mcpe\protocol\TransferPacket; use pocketmine\network\mcpe\protocol\TransferPacket;
@ -116,7 +126,7 @@ use pocketmine\network\mcpe\protocol\UpdateAttributesPacket;
use pocketmine\network\mcpe\protocol\UpdateBlockPacket; use pocketmine\network\mcpe\protocol\UpdateBlockPacket;
use pocketmine\network\mcpe\protocol\UpdateEquipPacket; use pocketmine\network\mcpe\protocol\UpdateEquipPacket;
use pocketmine\network\mcpe\protocol\UpdateTradePacket; use pocketmine\network\mcpe\protocol\UpdateTradePacket;
use pocketmine\network\mcpe\protocol\UseItemPacket; use pocketmine\network\mcpe\protocol\WSConnectPacket;
abstract class NetworkSession{ abstract class NetworkSession{
@ -202,10 +212,6 @@ abstract class NetworkSession{
return false; return false;
} }
public function handleRemoveBlock(RemoveBlockPacket $packet) : bool{
return false;
}
public function handleUpdateBlock(UpdateBlockPacket $packet) : bool{ public function handleUpdateBlock(UpdateBlockPacket $packet) : bool{
return false; return false;
} }
@ -242,6 +248,10 @@ abstract class NetworkSession{
return false; return false;
} }
public function handleInventoryTransaction(InventoryTransactionPacket $packet) : bool{
return false;
}
public function handleMobEquipment(MobEquipmentPacket $packet) : bool{ public function handleMobEquipment(MobEquipmentPacket $packet) : bool{
return false; return false;
} }
@ -258,7 +268,7 @@ abstract class NetworkSession{
return false; return false;
} }
public function handleUseItem(UseItemPacket $packet) : bool{ public function handleEntityPickRequest(EntityPickRequestPacket $packet) : bool{
return false; return false;
} }
@ -302,14 +312,6 @@ abstract class NetworkSession{
return false; return false;
} }
public function handleDropItem(DropItemPacket $packet) : bool{
return false;
}
public function handleInventoryAction(InventoryActionPacket $packet) : bool{
return false;
}
public function handleContainerOpen(ContainerOpenPacket $packet) : bool{ public function handleContainerOpen(ContainerOpenPacket $packet) : bool{
return false; return false;
} }
@ -318,7 +320,15 @@ abstract class NetworkSession{
return false; return false;
} }
public function handleContainerSetSlot(ContainerSetSlotPacket $packet) : bool{ public function handlePlayerHotbar(PlayerHotbarPacket $packet) : bool{
return false;
}
public function handleInventoryContent(InventoryContentPacket $packet) : bool{
return false;
}
public function handleInventorySlot(InventorySlotPacket $packet) : bool{
return false; return false;
} }
@ -326,10 +336,6 @@ abstract class NetworkSession{
return false; return false;
} }
public function handleContainerSetContent(ContainerSetContentPacket $packet) : bool{
return false;
}
public function handleCraftingData(CraftingDataPacket $packet) : bool{ public function handleCraftingData(CraftingDataPacket $packet) : bool{
return false; return false;
} }
@ -338,6 +344,10 @@ abstract class NetworkSession{
return false; return false;
} }
public function handleGuiDataPickItem(GuiDataPickItemPacket $packet) : bool{
return false;
}
public function handleAdventureSettings(AdventureSettingsPacket $packet) : bool{ public function handleAdventureSettings(AdventureSettingsPacket $packet) : bool{
return false; return false;
} }
@ -406,10 +416,6 @@ abstract class NetworkSession{
return false; return false;
} }
public function handleReplaceItemInSlot(ReplaceItemInSlotPacket $packet) : bool{
return false;
}
public function handleGameRulesChanged(GameRulesChangedPacket $packet) : bool{ public function handleGameRulesChanged(GameRulesChangedPacket $packet) : bool{
return false; return false;
} }
@ -418,10 +424,6 @@ abstract class NetworkSession{
return false; return false;
} }
public function handleAddItem(AddItemPacket $packet) : bool{
return false;
}
public function handleBossEvent(BossEventPacket $packet) : bool{ public function handleBossEvent(BossEventPacket $packet) : bool{
return false; return false;
} }
@ -434,7 +436,7 @@ abstract class NetworkSession{
return false; return false;
} }
public function handleCommandStep(CommandStepPacket $packet) : bool{ public function handleCommandRequest(CommandRequestPacket $packet) : bool{
return false; return false;
} }
@ -442,6 +444,10 @@ abstract class NetworkSession{
return false; return false;
} }
public function handleCommandOutput(CommandOutputPacket $packet) : bool{
return false;
}
public function handleUpdateTrade(UpdateTradePacket $packet) : bool{ public function handleUpdateTrade(UpdateTradePacket $packet) : bool{
return false; return false;
} }
@ -494,4 +500,48 @@ abstract class NetworkSession{
return false; return false;
} }
public function handlePlayerSkin(PlayerSkinPacket $packet) : bool{
return false;
}
public function handleSubClientLogin(SubClientLoginPacket $packet) : bool{
return false;
}
public function handleWSConnect(WSConnectPacket $packet) : bool{
return false;
}
public function handleSetLastHurtBy(SetLastHurtByPacket $packet) : bool{
return false;
}
public function handleBookEdit(BookEditPacket $packet) : bool{
return false;
}
public function handleNpcRequest(NpcRequestPacket $packet) : bool{
return false;
}
public function handlePhotoTransfer(PhotoTransferPacket $packet) : bool{
return false;
}
public function handleModalFormRequest(ModalFormRequestPacket $packet) : bool{
return false;
}
public function handleModalFormResponse(ModalFormResponsePacket $packet) : bool{
return false;
}
public function handleServerSettingsRequest(ServerSettingsRequestPacket $packet) : bool{
return false;
}
public function handleServerSettingsResponse(ServerSettingsResponsePacket $packet) : bool{
return false;
}
} }

View File

@ -33,7 +33,7 @@ use pocketmine\network\mcpe\protocol\BlockPickRequestPacket;
use pocketmine\network\mcpe\protocol\BossEventPacket; use pocketmine\network\mcpe\protocol\BossEventPacket;
use pocketmine\network\mcpe\protocol\ClientToServerHandshakePacket; use pocketmine\network\mcpe\protocol\ClientToServerHandshakePacket;
use pocketmine\network\mcpe\protocol\CommandBlockUpdatePacket; use pocketmine\network\mcpe\protocol\CommandBlockUpdatePacket;
use pocketmine\network\mcpe\protocol\CommandStepPacket; use pocketmine\network\mcpe\protocol\CommandRequestPacket;
use pocketmine\network\mcpe\protocol\ContainerClosePacket; use pocketmine\network\mcpe\protocol\ContainerClosePacket;
use pocketmine\network\mcpe\protocol\ContainerSetSlotPacket; use pocketmine\network\mcpe\protocol\ContainerSetSlotPacket;
use pocketmine\network\mcpe\protocol\CraftingEventPacket; use pocketmine\network\mcpe\protocol\CraftingEventPacket;
@ -51,6 +51,7 @@ use pocketmine\network\mcpe\protocol\MobEquipmentPacket;
use pocketmine\network\mcpe\protocol\MovePlayerPacket; use pocketmine\network\mcpe\protocol\MovePlayerPacket;
use pocketmine\network\mcpe\protocol\PlayerActionPacket; use pocketmine\network\mcpe\protocol\PlayerActionPacket;
use pocketmine\network\mcpe\protocol\PlayerInputPacket; use pocketmine\network\mcpe\protocol\PlayerInputPacket;
use pocketmine\network\mcpe\protocol\PlayerSkinPacket;
use pocketmine\network\mcpe\protocol\RemoveBlockPacket; use pocketmine\network\mcpe\protocol\RemoveBlockPacket;
use pocketmine\network\mcpe\protocol\RequestChunkRadiusPacket; use pocketmine\network\mcpe\protocol\RequestChunkRadiusPacket;
use pocketmine\network\mcpe\protocol\ResourcePackChunkRequestPacket; use pocketmine\network\mcpe\protocol\ResourcePackChunkRequestPacket;
@ -76,11 +77,6 @@ class PlayerNetworkSessionAdapter extends NetworkSession{
} }
public function handleDataPacket(DataPacket $packet){ public function handleDataPacket(DataPacket $packet){
//TODO: Remove this hack once InteractPacket spam issue is fixed
if($packet->buffer === "\x21\x04\x00"){
return;
}
$timings = Timings::getReceiveDataPacketTimings($packet); $timings = Timings::getReceiveDataPacketTimings($packet);
$timings->startTiming(); $timings->startTiming();
@ -111,13 +107,23 @@ class PlayerNetworkSessionAdapter extends NetworkSession{
} }
public function handleText(TextPacket $packet) : bool{ public function handleText(TextPacket $packet) : bool{
return $this->player->handleText($packet); if($packet->type === TextPacket::TYPE_CHAT){
return $this->player->chat($packet->message);
}
return false;
} }
public function handleMovePlayer(MovePlayerPacket $packet) : bool{ public function handleMovePlayer(MovePlayerPacket $packet) : bool{
return $this->player->handleMovePlayer($packet); return $this->player->handleMovePlayer($packet);
} }
/**
* TODO: REMOVE
* @param RemoveBlockPacket $packet
*
* @return bool
*/
public function handleRemoveBlock(RemoveBlockPacket $packet) : bool{ public function handleRemoveBlock(RemoveBlockPacket $packet) : bool{
return $this->player->handleRemoveBlock($packet); return $this->player->handleRemoveBlock($packet);
} }
@ -146,6 +152,12 @@ class PlayerNetworkSessionAdapter extends NetworkSession{
return $this->player->handleBlockPickRequest($packet); return $this->player->handleBlockPickRequest($packet);
} }
/**
* TODO: REMOVE
* @param UseItemPacket $packet
*
* @return bool
*/
public function handleUseItem(UseItemPacket $packet) : bool{ public function handleUseItem(UseItemPacket $packet) : bool{
return $this->player->handleUseItem($packet); return $this->player->handleUseItem($packet);
} }
@ -162,6 +174,12 @@ class PlayerNetworkSessionAdapter extends NetworkSession{
return $this->player->handleAnimate($packet); return $this->player->handleAnimate($packet);
} }
/**
* TODO: REMOVE
* @param DropItemPacket $packet
*
* @return bool
*/
public function handleDropItem(DropItemPacket $packet) : bool{ public function handleDropItem(DropItemPacket $packet) : bool{
return $this->player->handleDropItem($packet); return $this->player->handleDropItem($packet);
} }
@ -170,6 +188,12 @@ class PlayerNetworkSessionAdapter extends NetworkSession{
return $this->player->handleContainerClose($packet); return $this->player->handleContainerClose($packet);
} }
/**
* TODO: REMOVE
* @param ContainerSetSlotPacket $packet
*
* @return bool
*/
public function handleContainerSetSlot(ContainerSetSlotPacket $packet) : bool{ public function handleContainerSetSlot(ContainerSetSlotPacket $packet) : bool{
return $this->player->handleContainerSetSlot($packet); return $this->player->handleContainerSetSlot($packet);
} }
@ -218,8 +242,8 @@ class PlayerNetworkSessionAdapter extends NetworkSession{
return $this->player->handleShowCredits($packet); return $this->player->handleShowCredits($packet);
} }
public function handleCommandStep(CommandStepPacket $packet) : bool{ public function handleCommandRequest(CommandRequestPacket $packet) : bool{
return $this->player->handleCommandStep($packet); return $this->player->chat($packet->command);
} }
public function handleCommandBlockUpdate(CommandBlockUpdatePacket $packet) : bool{ public function handleCommandBlockUpdate(CommandBlockUpdatePacket $packet) : bool{
@ -229,4 +253,8 @@ class PlayerNetworkSessionAdapter extends NetworkSession{
public function handleResourcePackChunkRequest(ResourcePackChunkRequestPacket $packet) : bool{ public function handleResourcePackChunkRequest(ResourcePackChunkRequestPacket $packet) : bool{
return $this->player->handleResourcePackChunkRequest($packet); return $this->player->handleResourcePackChunkRequest($packet);
} }
public function handlePlayerSkin(PlayerSkinPacket $packet) : bool{
return false; //TODO
}
} }

View File

@ -79,9 +79,7 @@ class AddEntityPacket extends DataPacket{
$this->metadata = $this->getEntityMetadata(); $this->metadata = $this->getEntityMetadata();
$linkCount = $this->getUnsignedVarInt(); $linkCount = $this->getUnsignedVarInt();
for($i = 0; $i < $linkCount; ++$i){ for($i = 0; $i < $linkCount; ++$i){
$this->links[$i][0] = $this->getEntityUniqueId(); $this->links[] = $this->getEntityLink();
$this->links[$i][1] = $this->getEntityUniqueId();
$this->links[$i][2] = $this->getByte();
} }
} }
@ -105,9 +103,7 @@ class AddEntityPacket extends DataPacket{
$this->putEntityMetadata($this->metadata); $this->putEntityMetadata($this->metadata);
$this->putUnsignedVarInt(count($this->links)); $this->putUnsignedVarInt(count($this->links));
foreach($this->links as $link){ foreach($this->links as $link){
$this->putEntityUniqueId($link[0]); $this->putEntityLink($link);
$this->putEntityUniqueId($link[1]);
$this->putByte($link[2]);
} }
} }

View File

@ -53,6 +53,13 @@ class AddPlayerPacket extends DataPacket{
public $item; public $item;
public $metadata = []; public $metadata = [];
//TODO
public $uvarint1 = 0;
public $uvarint2 = 0;
public $uvarint3 = 0;
public $uvarint4 = 0;
public $long1 = 0;
public function decodePayload(){ public function decodePayload(){
$this->uuid = $this->getUUID(); $this->uuid = $this->getUUID();
$this->username = $this->getString(); $this->username = $this->getString();
@ -65,6 +72,12 @@ class AddPlayerPacket extends DataPacket{
$this->yaw = $this->getLFloat(); $this->yaw = $this->getLFloat();
$this->item = $this->getSlot(); $this->item = $this->getSlot();
$this->metadata = $this->getEntityMetadata(); $this->metadata = $this->getEntityMetadata();
$this->uvarint1 = $this->getUnsignedVarInt();
$this->uvarint2 = $this->getUnsignedVarInt();
$this->uvarint3 = $this->getUnsignedVarInt();
$this->uvarint4 = $this->getUnsignedVarInt();
$this->long1 = $this->getLLong();
} }
public function encodePayload(){ public function encodePayload(){
@ -79,6 +92,12 @@ class AddPlayerPacket extends DataPacket{
$this->putLFloat($this->yaw); $this->putLFloat($this->yaw);
$this->putSlot($this->item); $this->putSlot($this->item);
$this->putEntityMetadata($this->metadata); $this->putEntityMetadata($this->metadata);
$this->putUnsignedVarInt($this->uvarint1);
$this->putUnsignedVarInt($this->uvarint2);
$this->putUnsignedVarInt($this->uvarint3);
$this->putUnsignedVarInt($this->uvarint4);
$this->putLLong($this->long1);
} }
public function handle(NetworkSession $session) : bool{ public function handle(NetworkSession $session) : bool{

View File

@ -27,6 +27,7 @@ namespace pocketmine\network\mcpe\protocol;
use pocketmine\network\mcpe\NetworkSession; use pocketmine\network\mcpe\NetworkSession;
use pocketmine\network\mcpe\protocol\types\PlayerPermissions;
class AdventureSettingsPacket extends DataPacket{ class AdventureSettingsPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::ADVENTURE_SETTINGS_PACKET; const NETWORK_ID = ProtocolInfo::ADVENTURE_SETTINGS_PACKET;
@ -37,53 +38,75 @@ class AdventureSettingsPacket extends DataPacket{
const PERMISSION_AUTOMATION = 3; const PERMISSION_AUTOMATION = 3;
const PERMISSION_ADMIN = 4; const PERMISSION_ADMIN = 4;
public $worldImmutable = false; //TODO: check level 3
public $noPvp = false;
public $noPvm = false;
public $noMvp = false;
public $autoJump = true; /**
public $allowFlight = false; * This constant is used to identify flags that should be set on the second field. In a sensible world, these
public $noClip = false; * flags would all be set on the same packet field, but as of MCPE 1.2, the new abilities flags have for some
public $worldBuilder = false; * reason been assigned a separate field.
public $isFlying = false; */
public $muted = false; const BITFLAG_SECOND_SET = 1 << 16;
const WORLD_IMMUTABLE = 0x01;
const NO_PVP = 0x02;
const AUTO_JUMP = 0x20;
const ALLOW_FLIGHT = 0x40;
const NO_CLIP = 0x80;
const WORLD_BUILDER = 0x100;
const FLYING = 0x200;
const MUTED = 0x400;
const BUILD_AND_MINE = 0x01 | self::BITFLAG_SECOND_SET;
const DOORS_AND_SWITCHES = 0x02 | self::BITFLAG_SECOND_SET;
const OPEN_CONTAINERS = 0x04 | self::BITFLAG_SECOND_SET;
const ATTACK_PLAYERS = 0x08 | self::BITFLAG_SECOND_SET;
const ATTACK_MOBS = 0x10 | self::BITFLAG_SECOND_SET;
const OPERATOR = 0x20 | self::BITFLAG_SECOND_SET;
const TELEPORT = 0x80 | self::BITFLAG_SECOND_SET;
public $flags = 0; public $flags = 0;
public $userPermission; public $commandPermission = self::PERMISSION_NORMAL;
public $flags2 = -1;
public $playerPermission = PlayerPermissions::MEMBER;
public $long1 = 0;
public function decodePayload(){ public function decodePayload(){
$this->flags = $this->getUnsignedVarInt(); $this->flags = $this->getUnsignedVarInt();
$this->userPermission = $this->getUnsignedVarInt(); $this->commandPermission = $this->getUnsignedVarInt();
$this->flags2 = $this->getUnsignedVarInt();
$this->worldImmutable = (bool) ($this->flags & 1); $this->playerPermission = $this->getUnsignedVarInt();
$this->noPvp = (bool) ($this->flags & (1 << 1)); $this->long1 = $this->getLLong();
$this->noPvm = (bool) ($this->flags & (1 << 2));
$this->noMvp = (bool) ($this->flags & (1 << 3));
$this->autoJump = (bool) ($this->flags & (1 << 5));
$this->allowFlight = (bool) ($this->flags & (1 << 6));
$this->noClip = (bool) ($this->flags & (1 << 7));
$this->worldBuilder = (bool) ($this->flags & (1 << 8));
$this->isFlying = (bool) ($this->flags & (1 << 9));
$this->muted = (bool) ($this->flags & (1 << 10));
} }
public function encodePayload(){ public function encodePayload(){
$this->flags |= ((int) $this->worldImmutable);
$this->flags |= ((int) $this->noPvp) << 1;
$this->flags |= ((int) $this->noPvm) << 2;
$this->flags |= ((int) $this->noMvp) << 3;
$this->flags |= ((int) $this->autoJump) << 5;
$this->flags |= ((int) $this->allowFlight) << 6;
$this->flags |= ((int) $this->noClip) << 7;
$this->flags |= ((int) $this->worldBuilder) << 8;
$this->flags |= ((int) $this->isFlying) << 9;
$this->flags |= ((int) $this->muted) << 10;
$this->putUnsignedVarInt($this->flags); $this->putUnsignedVarInt($this->flags);
$this->putUnsignedVarInt($this->userPermission); $this->putUnsignedVarInt($this->commandPermission);
$this->putUnsignedVarInt($this->flags2);
$this->putUnsignedVarInt($this->playerPermission);
$this->putLLong($this->long1);
}
public function getFlag(int $flag) : bool{
if($flag & self::BITFLAG_SECOND_SET){
return ($this->flags2 & $flag) !== 0;
}
return ($this->flags & $flag) !== 0;
}
public function setFlag(int $flag, bool $value){
if($flag & self::BITFLAG_SECOND_SET){
$flagSet =& $this->flags2;
}else{
$flagSet =& $this->flags;
}
if($value){
$flagSet |= $flag;
}else{
$flagSet &= ~$flag;
}
} }
public function handle(NetworkSession $session) : bool{ public function handle(NetworkSession $session) : bool{

View File

@ -48,6 +48,22 @@ class BatchPacket extends DataPacket{
return true; return true;
} }
public function decode(){
$this->offset = 1;
$this->decodePayload();
}
public function encode(){
$this->reset();
$this->encodePayload();
$this->isEncoded = true;
}
public function reset(){
$this->buffer = "\xfe";
$this->offset = 0;
}
public function decodePayload(){ public function decodePayload(){
$data = $this->getRemaining(); $data = $this->getRemaining();
try{ try{

View File

@ -35,15 +35,18 @@ class BlockPickRequestPacket extends DataPacket{
public $tileX; public $tileX;
public $tileY; public $tileY;
public $tileZ; public $tileZ;
public $addUserData = false;
public $hotbarSlot; public $hotbarSlot;
public function decodePayload(){ public function decodePayload(){
$this->getSignedBlockPosition($this->tileX, $this->tileY, $this->tileZ); $this->getSignedBlockPosition($this->tileX, $this->tileY, $this->tileZ);
$this->addUserData = $this->getBool();
$this->hotbarSlot = $this->getByte(); $this->hotbarSlot = $this->getByte();
} }
public function encodePayload(){ public function encodePayload(){
$this->putSignedBlockPosition($this->tileX, $this->tileY, $this->tileZ); $this->putSignedBlockPosition($this->tileX, $this->tileY, $this->tileZ);
$this->putBool($this->addUserData);
$this->putByte($this->hotbarSlot); $this->putByte($this->hotbarSlot);
} }

View File

@ -0,0 +1,115 @@
<?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 BookEditPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::BOOK_EDIT_PACKET;
const TYPE_REPLACE_PAGE = 0;
const TYPE_ADD_PAGE = 1;
const TYPE_DELETE_PAGE = 2;
const TYPE_SWAP_PAGES = 3;
const TYPE_SIGN_BOOK = 4;
/** @var int */
public $type;
/** @var int */
public $inventorySlot;
/** @var int */
public $pageNumber;
/** @var int */
public $secondaryPageNumber;
/** @var string */
public $content1;
/** @var string */
public $content2;
/** @var string */
public $title;
/** @var string */
public $author;
public function decodePayload(){
$this->type = $this->getByte();
$this->inventorySlot = $this->getByte();
switch($this->type){
case self::TYPE_REPLACE_PAGE:
case self::TYPE_ADD_PAGE:
$this->pageNumber = $this->getByte();
$this->content1 = $this->getString();
$this->content2 = $this->getString();
break;
case self::TYPE_DELETE_PAGE:
$this->pageNumber = $this->getByte();
break;
case self::TYPE_SWAP_PAGES:
$this->pageNumber = $this->getByte();
$this->secondaryPageNumber = $this->getByte();
break;
case self::TYPE_SIGN_BOOK:
$this->title = $this->getString();
$this->author = $this->getString();
break;
default:
throw new \UnexpectedValueException("Unknown book edit type $this->type!");
}
}
public function encodePayload(){
$this->putByte($this->type);
$this->putByte($this->inventorySlot);
switch($this->type){
case self::TYPE_REPLACE_PAGE:
case self::TYPE_ADD_PAGE:
$this->putByte($this->pageNumber);
$this->putString($this->content1);
$this->putString($this->content2);
break;
case self::TYPE_DELETE_PAGE:
$this->putByte($this->pageNumber);
break;
case self::TYPE_SWAP_PAGES:
$this->putByte($this->pageNumber);
$this->putByte($this->secondaryPageNumber);
break;
case self::TYPE_SIGN_BOOK:
$this->putString($this->title);
$this->putString($this->author);
break;
default:
throw new \UnexpectedValueException("Unknown book edit type $this->type!");
}
}
public function handle(NetworkSession $session) : bool{
return $session->handleBookEdit($this);
}
}

View File

@ -25,24 +25,20 @@ namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h> #include <rules/DataPacket.h>
use pocketmine\network\mcpe\NetworkSession; use pocketmine\network\mcpe\NetworkSession;
class AddItemPacket extends DataPacket{ class CommandOutputPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::ADD_ITEM_PACKET; const NETWORK_ID = ProtocolInfo::COMMAND_OUTPUT_PACKET;
public $item;
public function decodePayload(){ public function decodePayload(){
$this->item = $this->getSlot(); //TODO
} }
public function encodePayload(){ public function encodePayload(){
$this->putSlot($this->item); //TODO
} }
public function handle(NetworkSession $session) : bool{ public function handle(NetworkSession $session) : bool{
return $session->handleAddItem($this); return $session->handleCommandOutput($this);
} }
} }

View File

@ -27,46 +27,22 @@ namespace pocketmine\network\mcpe\protocol;
use pocketmine\network\mcpe\NetworkSession; use pocketmine\network\mcpe\NetworkSession;
class CommandStepPacket extends DataPacket{ class CommandRequestPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::COMMAND_STEP_PACKET; const NETWORK_ID = ProtocolInfo::COMMAND_REQUEST_PACKET;
public $command; public $command;
public $overload;
public $uvarint1;
public $currentStep;
public $done;
public $clientId;
public $inputJson;
public $outputJson;
public function decodePayload(){ public function decodePayload(){
$this->command = $this->getString(); $this->command = $this->getString();
$this->overload = $this->getString(); //TODO: everything else
$this->uvarint1 = $this->getUnsignedVarInt();
$this->currentStep = $this->getUnsignedVarInt();
$this->done = $this->getBool();
$this->clientId = $this->getUnsignedVarLong();
$this->inputJson = json_decode($this->getString());
$this->outputJson = json_decode($this->getString());
$this->getRemaining(); //TODO: read command origin data
} }
public function encodePayload(){ public function encodePayload(){
$this->putString($this->command); $this->putString($this->command);
$this->putString($this->overload); //TODO
$this->putUnsignedVarInt($this->uvarint1);
$this->putUnsignedVarInt($this->currentStep);
$this->putBool($this->done);
$this->putUnsignedVarLong($this->clientId);
$this->putString(json_encode($this->inputJson));
$this->putString(json_encode($this->outputJson));
$this->put("\x00\x00\x00"); //TODO: command origin data
} }
public function handle(NetworkSession $session) : bool{ public function handle(NetworkSession $session) : bool{
return $session->handleCommandStep($this); return $session->handleCommandRequest($this);
} }
} }

View File

@ -28,6 +28,9 @@ namespace pocketmine\network\mcpe\protocol;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\network\mcpe\NetworkSession; use pocketmine\network\mcpe\NetworkSession;
/**
* @removed
*/
class ContainerSetSlotPacket extends DataPacket{ class ContainerSetSlotPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::CONTAINER_SET_SLOT_PACKET; const NETWORK_ID = ProtocolInfo::CONTAINER_SET_SLOT_PACKET;

View File

@ -29,6 +29,7 @@ use pocketmine\entity\Attribute;
use pocketmine\entity\Entity; use pocketmine\entity\Entity;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\network\mcpe\NetworkSession; use pocketmine\network\mcpe\NetworkSession;
use pocketmine\utils\Binary;
use pocketmine\utils\BinaryStream; use pocketmine\utils\BinaryStream;
use pocketmine\utils\Utils; use pocketmine\utils\Utils;
@ -56,7 +57,7 @@ abstract class DataPacket extends BinaryStream{
} }
public function decode(){ public function decode(){
$this->offset = 1; $this->offset = 3;
$this->decodePayload(); $this->decodePayload();
} }
@ -69,6 +70,7 @@ abstract class DataPacket extends BinaryStream{
public function encode(){ public function encode(){
$this->reset(); $this->reset();
$this->put("\x00\x00");
$this->encodePayload(); $this->encodePayload();
$this->isEncoded = true; $this->isEncoded = true;
} }
@ -93,7 +95,7 @@ abstract class DataPacket extends BinaryStream{
abstract public function handle(NetworkSession $session) : bool; abstract public function handle(NetworkSession $session) : bool;
public function reset(){ public function reset(){
$this->buffer = chr($this::NETWORK_ID); $this->buffer = Binary::writeUnsignedVarInt(static::NETWORK_ID);
$this->offset = 0; $this->offset = 0;
} }
@ -440,4 +442,22 @@ abstract class DataPacket extends BinaryStream{
} }
} }
} }
/**
* @return array
*/
protected function getEntityLink() : array{
return [$this->getEntityUniqueId(), $this->getEntityUniqueId(), $this->getByte(), $this->getByte()];
}
/**
* @param array $link
*/
protected function putEntityLink(array $link){
$this->putEntityUniqueId($link[0]);
$this->putEntityUniqueId($link[1]);
$this->putByte($link[2]);
$this->putByte($link[3]);
}
} }

View File

@ -29,6 +29,9 @@ namespace pocketmine\network\mcpe\protocol;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\network\mcpe\NetworkSession; use pocketmine\network\mcpe\NetworkSession;
/**
* @removed
*/
class DropItemPacket extends DataPacket{ class DropItemPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::DROP_ITEM_PACKET; const NETWORK_ID = ProtocolInfo::DROP_ITEM_PACKET;

View File

@ -0,0 +1,49 @@
<?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 EntityPickRequestPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::ENTITY_PICK_REQUEST_PACKET;
public $entityTypeId;
public $hotbarSlot;
public function decodePayload(){
$this->entityTypeId = $this->getLLong();
$this->hotbarSlot = $this->getByte();
}
public function encodePayload(){
$this->putLLong($this->entityTypeId);
$this->putByte($this->hotbarSlot);
}
public function handle(NetworkSession $session) : bool{
return $session->handleEntityPickRequest($this);
}
}

View File

@ -0,0 +1,47 @@
<?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 GuiDataPickItemPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::GUI_DATA_PICK_ITEM_PACKET;
/** @var int */
public $hotbarSlot;
public function decodePayload(){
$this->hotbarSlot = $this->getLInt();
}
public function encodePayload(){
$this->putLInt($this->hotbarSlot);
}
public function handle(NetworkSession $session) : bool{
return $session->handleGuiDataPickItem($this);
}
}

View File

@ -38,17 +38,38 @@ class InteractPacket extends DataPacket{
const ACTION_OPEN_INVENTORY = 6; const ACTION_OPEN_INVENTORY = 6;
/** @var int */
public $action; public $action;
/** @var int */
public $target; public $target;
/** @var float */
public $x;
/** @var float */
public $y;
/** @var float */
public $z;
public function decodePayload(){ public function decodePayload(){
$this->action = $this->getByte(); $this->action = $this->getByte();
$this->target = $this->getEntityRuntimeId(); $this->target = $this->getEntityRuntimeId();
if($this->action === self::ACTION_MOUSEOVER){
$this->x = $this->getLFloat();
$this->y = $this->getLFloat();
$this->z = $this->getLFloat();
}
} }
public function encodePayload(){ public function encodePayload(){
$this->putByte($this->action); $this->putByte($this->action);
$this->putEntityRuntimeId($this->target); $this->putEntityRuntimeId($this->target);
if($this->action === self::ACTION_MOUSEOVER){
$this->putLFloat($this->x);
$this->putLFloat($this->y);
$this->putLFloat($this->z);
}
} }
public function handle(NetworkSession $session) : bool{ public function handle(NetworkSession $session) : bool{

View File

@ -0,0 +1,58 @@
<?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\item\Item;
use pocketmine\network\mcpe\NetworkSession;
class InventoryContentPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::INVENTORY_CONTENT_PACKET;
/** @var int */
public $windowId;
/** @var Item[] */
public $items = [];
public function decodePayload(){
$this->windowId = $this->getUnsignedVarInt();
$count = $this->getUnsignedVarInt();
for($i = 0; $i < $count; ++$i){
$this->items[] = $this->getSlot();
}
}
public function encodePayload(){
$this->putUnsignedVarInt($this->windowId);
$this->putUnsignedVarInt(count($this->items));
foreach($this->items as $item){
$this->putSlot($item);
}
}
public function handle(NetworkSession $session) : bool{
return $session->handleInventoryContent($this);
}
}

View File

@ -25,34 +25,32 @@ namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h> #include <rules/DataPacket.h>
use pocketmine\item\Item;
use pocketmine\network\mcpe\NetworkSession; use pocketmine\network\mcpe\NetworkSession;
class InventoryActionPacket extends DataPacket{ class InventorySlotPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::INVENTORY_ACTION_PACKET; const NETWORK_ID = ProtocolInfo::INVENTORY_SLOT_PACKET;
const ACTION_GIVE_ITEM = 0; /** @var int */
const ACTION_ENCHANT_ITEM = 2; public $windowId;
/** @var int */
public $actionId; public $slotIndex;
/** @var Item */
public $item; public $item;
public $enchantmentId = 0;
public $enchantmentLevel = 0;
public function decodePayload(){ public function decodePayload(){
$this->actionId = $this->getUnsignedVarInt(); $this->windowId = $this->getUnsignedVarInt();
$this->slotIndex = $this->getUnsignedVarInt();
$this->item = $this->getSlot(); $this->item = $this->getSlot();
$this->enchantmentId = $this->getVarInt();
$this->enchantmentLevel = $this->getVarInt();
} }
public function encodePayload(){ public function encodePayload(){
$this->putUnsignedVarInt($this->actionId); $this->putUnsignedVarInt($this->windowId);
$this->putUnsignedVarInt($this->slotIndex);
$this->putSlot($this->item); $this->putSlot($this->item);
$this->putVarInt($this->enchantmentId);
$this->putVarInt($this->enchantmentLevel);
} }
public function handle(NetworkSession $session) : bool{ public function handle(NetworkSession $session) : bool{
return $session->handleInventoryAction($this); return $session->handleInventorySlot($this);
} }
} }

View File

@ -0,0 +1,53 @@
<?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 InventoryTransactionPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::INVENTORY_TRANSACTION_PACKET;
const TYPE_USE_ITEM = 2;
const TYPE_USE_ITEM_ON_ENTITY = 3;
const TYPE_RELEASE_ITEM = 4;
public function decodePayload(){
$type = $this->getUnsignedVarInt();
//TODO
}
public function encodePayload(){
//TODO
}
public function handle(NetworkSession $session) : bool{
return $session->handleInventoryTransaction($this);
}
}

View File

@ -33,111 +33,164 @@ class LevelSoundEventPacket extends DataPacket{
const SOUND_ITEM_USE_ON = 0; const SOUND_ITEM_USE_ON = 0;
const SOUND_HIT = 1; const SOUND_HIT = 1;
const SOUND_STEP = 2; const SOUND_STEP = 2;
const SOUND_JUMP = 3; const SOUND_FLY = 3;
const SOUND_BREAK = 4; const SOUND_JUMP = 4;
const SOUND_PLACE = 5; const SOUND_BREAK = 5;
const SOUND_HEAVY_STEP = 6; const SOUND_PLACE = 6;
const SOUND_GALLOP = 7; const SOUND_HEAVY_STEP = 7;
const SOUND_FALL = 8; const SOUND_GALLOP = 8;
const SOUND_AMBIENT = 9; const SOUND_FALL = 9;
const SOUND_AMBIENT_BABY = 10; const SOUND_AMBIENT = 10;
const SOUND_AMBIENT_IN_WATER = 11; const SOUND_AMBIENT_BABY = 11;
const SOUND_BREATHE = 12; const SOUND_AMBIENT_IN_WATER = 12;
const SOUND_DEATH = 13; const SOUND_BREATHE = 13;
const SOUND_DEATH_IN_WATER = 14; const SOUND_DEATH = 14;
const SOUND_DEATH_TO_ZOMBIE = 15; const SOUND_DEATH_IN_WATER = 15;
const SOUND_HURT = 16; const SOUND_DEATH_TO_ZOMBIE = 16;
const SOUND_HURT_IN_WATER = 17; const SOUND_HURT = 17;
const SOUND_MAD = 18; const SOUND_HURT_IN_WATER = 18;
const SOUND_BOOST = 19; const SOUND_MAD = 19;
const SOUND_BOW = 20; const SOUND_BOOST = 20;
const SOUND_SQUISH_BIG = 21; const SOUND_BOW = 21;
const SOUND_SQUISH_SMALL = 22; const SOUND_SQUISH_BIG = 22;
const SOUND_FALL_BIG = 23; const SOUND_SQUISH_SMALL = 23;
const SOUND_FALL_SMALL = 24; const SOUND_FALL_BIG = 24;
const SOUND_SPLASH = 25; const SOUND_FALL_SMALL = 25;
const SOUND_FIZZ = 26; const SOUND_SPLASH = 26;
const SOUND_FLAP = 27; const SOUND_FIZZ = 27;
const SOUND_SWIM = 28; const SOUND_FLAP = 28;
const SOUND_DRINK = 29; const SOUND_SWIM = 29;
const SOUND_EAT = 30; const SOUND_DRINK = 30;
const SOUND_TAKEOFF = 31; const SOUND_EAT = 31;
const SOUND_SHAKE = 32; const SOUND_TAKEOFF = 32;
const SOUND_PLOP = 33; const SOUND_SHAKE = 33;
const SOUND_LAND = 34; const SOUND_PLOP = 34;
const SOUND_SADDLE = 35; const SOUND_LAND = 35;
const SOUND_ARMOR = 36; const SOUND_SADDLE = 36;
const SOUND_ADD_CHEST = 37; const SOUND_ARMOR = 37;
const SOUND_THROW = 38; const SOUND_ADD_CHEST = 38;
const SOUND_ATTACK = 39; const SOUND_THROW = 39;
const SOUND_ATTACK_NODAMAGE = 40; const SOUND_ATTACK = 40;
const SOUND_WARN = 41; const SOUND_ATTACK_NODAMAGE = 41;
const SOUND_SHEAR = 42; const SOUND_WARN = 42;
const SOUND_MILK = 43; const SOUND_SHEAR = 43;
const SOUND_THUNDER = 44; const SOUND_MILK = 44;
const SOUND_EXPLODE = 45; const SOUND_THUNDER = 45;
const SOUND_FIRE = 46; const SOUND_EXPLODE = 46;
const SOUND_IGNITE = 47; const SOUND_FIRE = 47;
const SOUND_FUSE = 48; const SOUND_IGNITE = 48;
const SOUND_STARE = 49; const SOUND_FUSE = 49;
const SOUND_SPAWN = 50; const SOUND_STARE = 50;
const SOUND_SHOOT = 51; const SOUND_SPAWN = 51;
const SOUND_BREAK_BLOCK = 52; const SOUND_SHOOT = 52;
const SOUND_REMEDY = 53; const SOUND_BREAK_BLOCK = 53;
const SOUND_UNFECT = 54; const SOUND_LAUNCH = 54;
const SOUND_LEVELUP = 55; const SOUND_BLAST = 55;
const SOUND_BOW_HIT = 56; const SOUND_LARGE_BLAST = 56;
const SOUND_BULLET_HIT = 57; const SOUND_TWINKLE = 57;
const SOUND_EXTINGUISH_FIRE = 58; const SOUND_REMEDY = 58;
const SOUND_ITEM_FIZZ = 59; const SOUND_UNFECT = 59;
const SOUND_CHEST_OPEN = 60; const SOUND_LEVELUP = 60;
const SOUND_CHEST_CLOSED = 61; const SOUND_BOW_HIT = 61;
const SOUND_SHULKERBOX_OPEN = 62; const SOUND_BULLET_HIT = 62;
const SOUND_SHULKERBOX_CLOSED = 63; const SOUND_EXTINGUISH_FIRE = 63;
const SOUND_POWER_ON = 64; const SOUND_ITEM_FIZZ = 64;
const SOUND_POWER_OFF = 65; const SOUND_CHEST_OPEN = 65;
const SOUND_ATTACH = 66; const SOUND_CHEST_CLOSED = 66;
const SOUND_DETACH = 67; const SOUND_SHULKERBOX_OPEN = 67;
const SOUND_DENY = 68; const SOUND_SHULKERBOX_CLOSED = 68;
const SOUND_TRIPOD = 69; const SOUND_POWER_ON = 69;
const SOUND_POP = 70; const SOUND_POWER_OFF = 70;
const SOUND_DROP_SLOT = 71; const SOUND_ATTACH = 71;
const SOUND_NOTE = 72; const SOUND_DETACH = 72;
const SOUND_THORNS = 73; const SOUND_DENY = 73;
const SOUND_PISTON_IN = 74; const SOUND_TRIPOD = 74;
const SOUND_PISTON_OUT = 75; const SOUND_POP = 75;
const SOUND_PORTAL = 76; const SOUND_DROP_SLOT = 76;
const SOUND_WATER = 77; const SOUND_NOTE = 77;
const SOUND_LAVA_POP = 78; const SOUND_THORNS = 78;
const SOUND_LAVA = 79; const SOUND_PISTON_IN = 79;
const SOUND_BURP = 80; const SOUND_PISTON_OUT = 80;
const SOUND_BUCKET_FILL_WATER = 81; const SOUND_PORTAL = 81;
const SOUND_BUCKET_FILL_LAVA = 82; const SOUND_WATER = 82;
const SOUND_BUCKET_EMPTY_WATER = 83; const SOUND_LAVA_POP = 83;
const SOUND_BUCKET_EMPTY_LAVA = 84; const SOUND_LAVA = 84;
const SOUND_GUARDIAN_FLOP = 85; const SOUND_BURP = 85;
const SOUND_ELDERGUARDIAN_CURSE = 86; const SOUND_BUCKET_FILL_WATER = 86;
const SOUND_MOB_WARNING = 87; const SOUND_BUCKET_FILL_LAVA = 87;
const SOUND_MOB_WARNING_BABY = 88; const SOUND_BUCKET_EMPTY_WATER = 88;
const SOUND_TELEPORT = 89; const SOUND_BUCKET_EMPTY_LAVA = 89;
const SOUND_SHULKER_OPEN = 90; const SOUND_RECORD_13 = 90;
const SOUND_SHULKER_CLOSE = 91; const SOUND_RECORD_CAT = 91;
const SOUND_HAGGLE = 92; const SOUND_RECORD_BLOCKS = 92;
const SOUND_HAGGLE_YES = 93; const SOUND_RECORD_CHIRP = 93;
const SOUND_HAGGLE_NO = 94; const SOUND_RECORD_FAR = 94;
const SOUND_HAGGLE_IDLE = 95; const SOUND_RECORD_MALL = 95;
const SOUND_CHORUSGROW = 96; const SOUND_RECORD_MELLOHI = 96;
const SOUND_CHORUSDEATH = 97; const SOUND_RECORD_STAL = 97;
const SOUND_GLASS = 98; const SOUND_RECORD_STRAD = 98;
const SOUND_CAST_SPELL = 99; const SOUND_RECORD_WARD = 99;
const SOUND_PREPARE_ATTACK = 100; const SOUND_RECORD_11 = 100;
const SOUND_PREPARE_SUMMON = 101; const SOUND_RECORD_WAIT = 101;
const SOUND_PREPARE_WOLOLO = 102; const SOUND_GUARDIAN_FLOP = 103;
const SOUND_FANG = 103; const SOUND_ELDERGUARDIAN_CURSE = 104;
const SOUND_CHARGE = 104; const SOUND_MOB_WARNING = 105;
const SOUND_CAMERA_TAKE_PICTURE = 105; const SOUND_MOB_WARNING_BABY = 106;
const SOUND_DEFAULT = 106; const SOUND_TELEPORT = 107;
const SOUND_UNDEFINED = 107; const SOUND_SHULKER_OPEN = 108;
const SOUND_SHULKER_CLOSE = 109;
const SOUND_HAGGLE = 110;
const SOUND_HAGGLE_YES = 111;
const SOUND_HAGGLE_NO = 112;
const SOUND_HAGGLE_IDLE = 113;
const SOUND_CHORUSGROW = 114;
const SOUND_CHORUSDEATH = 115;
const SOUND_GLASS = 116;
const SOUND_CAST_SPELL = 117;
const SOUND_PREPARE_ATTACK = 118;
const SOUND_PREPARE_SUMMON = 119;
const SOUND_PREPARE_WOLOLO = 120;
const SOUND_FANG = 121;
const SOUND_CHARGE = 122;
const SOUND_CAMERA_TAKE_PICTURE = 123;
const SOUND_LEASHKNOT_PLACE = 124;
const SOUND_LEASHKNOT_BREAK = 125;
const SOUND_GROWL = 126;
const SOUND_WHINE = 127;
const SOUND_PANT = 128;
const SOUND_PURR = 129;
const SOUND_PURREOW = 130;
const SOUND_DEATH_MIN_VOLUME = 131;
const SOUND_DEATH_MID_VOLUME = 132;
const SOUND_IMITATE_BLAZE = 133;
const SOUND_IMITATE_CAVE_SPIDER = 134;
const SOUND_IMITATE_CREEPER = 135;
const SOUND_IMITATE_ELDER_GUARDIAN = 136;
const SOUND_IMITATE_ENDER_DRAGON = 137;
const SOUND_IMITATE_ENDERMAN = 138;
const SOUND_IMITATE_EVOCATION_ILLAGER = 140;
const SOUND_IMITATE_GHAST = 141;
const SOUND_IMITATE_HUSK = 142;
const SOUND_IMITATE_ILLUSION_ILLAGER = 143;
const SOUND_IMITATE_MAGMA_CUBE = 144;
const SOUND_IMITATE_POLAR_BEAR = 145;
const SOUND_IMITATE_SHULKER = 146;
const SOUND_IMITATE_SILVERFISH = 147;
const SOUND_IMITATE_SKELETON = 148;
const SOUND_IMITATE_SLIME = 149;
const SOUND_IMITATE_SPIDER = 150;
const SOUND_IMITATE_STRAY = 151;
const SOUND_IMITATE_VEX = 152;
const SOUND_IMITATE_VINDICATION_ILLAGER = 153;
const SOUND_IMITATE_WITCH = 154;
const SOUND_IMITATE_WITHER = 155;
const SOUND_IMITATE_WITHER_SKELETON = 156;
const SOUND_IMITATE_WOLF = 157;
const SOUND_IMITATE_ZOMBIE = 158;
const SOUND_IMITATE_ZOMBIE_PIGMAN = 159;
const SOUND_IMITATE_ZOMBIE_VILLAGER = 160;
const SOUND_DEFAULT = 161;
const SOUND_UNDEFINED = 162;
public $sound; public $sound;
public $x; public $x;

View File

@ -27,6 +27,7 @@ namespace pocketmine\network\mcpe\protocol;
use pocketmine\network\mcpe\NetworkSession; use pocketmine\network\mcpe\NetworkSession;
use pocketmine\utils\Utils;
class LoginPacket extends DataPacket{ class LoginPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::LOGIN_PACKET; const NETWORK_ID = ProtocolInfo::LOGIN_PACKET;
@ -35,7 +36,6 @@ class LoginPacket extends DataPacket{
public $username; public $username;
public $protocol; public $protocol;
public $gameEdition;
public $clientUUID; public $clientUUID;
public $clientId; public $clientId;
public $identityPublicKey; public $identityPublicKey;
@ -63,13 +63,11 @@ class LoginPacket extends DataPacket{
return; //Do not attempt to decode for non-accepted protocols return; //Do not attempt to decode for non-accepted protocols
} }
$this->gameEdition = $this->getByte();
$this->setBuffer($this->getString(), 0); $this->setBuffer($this->getString(), 0);
$this->chainData = json_decode($this->get($this->getLInt()), true); $this->chainData = json_decode($this->get($this->getLInt()), true);
foreach($this->chainData["chain"] as $chain){ foreach($this->chainData["chain"] as $chain){
$webtoken = $this->decodeToken($chain); $webtoken = Utils::decodeJWT($chain);
if(isset($webtoken["extraData"])){ if(isset($webtoken["extraData"])){
if(isset($webtoken["extraData"]["displayName"])){ if(isset($webtoken["extraData"]["displayName"])){
$this->username = $webtoken["extraData"]["displayName"]; $this->username = $webtoken["extraData"]["displayName"];
@ -84,7 +82,7 @@ class LoginPacket extends DataPacket{
} }
$this->clientDataJwt = $this->get($this->getLInt()); $this->clientDataJwt = $this->get($this->getLInt());
$this->clientData = $this->decodeToken($this->clientDataJwt); $this->clientData = Utils::decodeJWT($this->clientDataJwt);
$this->clientId = $this->clientData["ClientRandomId"] ?? null; $this->clientId = $this->clientData["ClientRandomId"] ?? null;
$this->serverAddress = $this->clientData["ServerAddress"] ?? null; $this->serverAddress = $this->clientData["ServerAddress"] ?? null;
@ -99,12 +97,6 @@ class LoginPacket extends DataPacket{
//TODO //TODO
} }
public function decodeToken($token){
list($headB64, $payloadB64, $sigB64) = explode(".", $token);
return json_decode(base64_decode($payloadB64), true);
}
public function handle(NetworkSession $session) : bool{ public function handle(NetworkSession $session) : bool{
return $session->handleLogin($this); return $session->handleLogin($this);
} }

View File

@ -0,0 +1,49 @@
<?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 ModalFormRequestPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::MODAL_FORM_REQUEST_PACKET;
/** @var int */
public $uvarint1;
/** @var string */
public $string1;
public function decodePayload(){
//TODO
}
public function encodePayload(){
//TODO
}
public function handle(NetworkSession $session) : bool{
return $session->handleModalFormRequest($this);
}
}

View File

@ -25,23 +25,20 @@ namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h> #include <rules/DataPacket.h>
use pocketmine\network\mcpe\NetworkSession; use pocketmine\network\mcpe\NetworkSession;
class ReplaceItemInSlotPacket extends DataPacket{ class ModalFormResponsePacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::REPLACE_ITEM_IN_SLOT_PACKET; const NETWORK_ID = ProtocolInfo::MODAL_FORM_RESPONSE_PACKET;
public $item;
public function decodePayload(){ public function decodePayload(){
$this->item = $this->getSlot(); //TODO
} }
public function encodePayload(){ public function encodePayload(){
$this->putSlot($this->item); //TODO
} }
public function handle(NetworkSession $session) : bool{ public function handle(NetworkSession $session) : bool{
return $session->handleReplaceItemInSlot($this); return $session->handleModalFormResponse($this);
} }
} }

View File

@ -0,0 +1,59 @@
<?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 NpcRequestPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::NPC_REQUEST_PACKET;
/** @var int */
public $entityRuntimeId;
/** @var int */
public $requestType;
/** @var string */
public $commandString;
/** @var int */
public $actionType;
public function decodePayload(){
$this->entityRuntimeId = $this->getEntityRuntimeId();
$this->requestType = $this->getByte();
$this->commandString = $this->getString();
$this->actionType = $this->getByte();
}
public function encodePayload(){
$this->putEntityRuntimeId($this->entityRuntimeId);
$this->putByte($this->requestType);
$this->putString($this->commandString);
$this->putByte($this->actionType);
}
public function handle(NetworkSession $session) : bool{
return $session->handleNpcRequest($this);
}
}

View File

@ -51,7 +51,6 @@ class PacketPool{
static::registerPacket(new MoveEntityPacket()); static::registerPacket(new MoveEntityPacket());
static::registerPacket(new MovePlayerPacket()); static::registerPacket(new MovePlayerPacket());
static::registerPacket(new RiderJumpPacket()); static::registerPacket(new RiderJumpPacket());
static::registerPacket(new RemoveBlockPacket());
static::registerPacket(new UpdateBlockPacket()); static::registerPacket(new UpdateBlockPacket());
static::registerPacket(new AddPaintingPacket()); static::registerPacket(new AddPaintingPacket());
static::registerPacket(new ExplodePacket()); static::registerPacket(new ExplodePacket());
@ -61,11 +60,12 @@ class PacketPool{
static::registerPacket(new EntityEventPacket()); static::registerPacket(new EntityEventPacket());
static::registerPacket(new MobEffectPacket()); static::registerPacket(new MobEffectPacket());
static::registerPacket(new UpdateAttributesPacket()); static::registerPacket(new UpdateAttributesPacket());
static::registerPacket(new InventoryTransactionPacket());
static::registerPacket(new MobEquipmentPacket()); static::registerPacket(new MobEquipmentPacket());
static::registerPacket(new MobArmorEquipmentPacket()); static::registerPacket(new MobArmorEquipmentPacket());
static::registerPacket(new InteractPacket()); static::registerPacket(new InteractPacket());
static::registerPacket(new BlockPickRequestPacket()); static::registerPacket(new BlockPickRequestPacket());
static::registerPacket(new UseItemPacket()); static::registerPacket(new EntityPickRequestPacket());
static::registerPacket(new PlayerActionPacket()); static::registerPacket(new PlayerActionPacket());
static::registerPacket(new EntityFallPacket()); static::registerPacket(new EntityFallPacket());
static::registerPacket(new HurtArmorPacket()); static::registerPacket(new HurtArmorPacket());
@ -76,15 +76,15 @@ class PacketPool{
static::registerPacket(new SetSpawnPositionPacket()); static::registerPacket(new SetSpawnPositionPacket());
static::registerPacket(new AnimatePacket()); static::registerPacket(new AnimatePacket());
static::registerPacket(new RespawnPacket()); static::registerPacket(new RespawnPacket());
static::registerPacket(new DropItemPacket());
static::registerPacket(new InventoryActionPacket());
static::registerPacket(new ContainerOpenPacket()); static::registerPacket(new ContainerOpenPacket());
static::registerPacket(new ContainerClosePacket()); static::registerPacket(new ContainerClosePacket());
static::registerPacket(new ContainerSetSlotPacket()); static::registerPacket(new PlayerHotbarPacket());
static::registerPacket(new InventoryContentPacket());
static::registerPacket(new InventorySlotPacket());
static::registerPacket(new ContainerSetDataPacket()); static::registerPacket(new ContainerSetDataPacket());
static::registerPacket(new ContainerSetContentPacket());
static::registerPacket(new CraftingDataPacket()); static::registerPacket(new CraftingDataPacket());
static::registerPacket(new CraftingEventPacket()); static::registerPacket(new CraftingEventPacket());
static::registerPacket(new GuiDataPickItemPacket());
static::registerPacket(new AdventureSettingsPacket()); static::registerPacket(new AdventureSettingsPacket());
static::registerPacket(new BlockEntityDataPacket()); static::registerPacket(new BlockEntityDataPacket());
static::registerPacket(new PlayerInputPacket()); static::registerPacket(new PlayerInputPacket());
@ -102,15 +102,14 @@ class PacketPool{
static::registerPacket(new RequestChunkRadiusPacket()); static::registerPacket(new RequestChunkRadiusPacket());
static::registerPacket(new ChunkRadiusUpdatedPacket()); static::registerPacket(new ChunkRadiusUpdatedPacket());
static::registerPacket(new ItemFrameDropItemPacket()); static::registerPacket(new ItemFrameDropItemPacket());
static::registerPacket(new ReplaceItemInSlotPacket());
static::registerPacket(new GameRulesChangedPacket()); static::registerPacket(new GameRulesChangedPacket());
static::registerPacket(new CameraPacket()); static::registerPacket(new CameraPacket());
static::registerPacket(new AddItemPacket());
static::registerPacket(new BossEventPacket()); static::registerPacket(new BossEventPacket());
static::registerPacket(new ShowCreditsPacket()); static::registerPacket(new ShowCreditsPacket());
static::registerPacket(new AvailableCommandsPacket()); static::registerPacket(new AvailableCommandsPacket());
static::registerPacket(new CommandStepPacket()); static::registerPacket(new CommandRequestPacket());
static::registerPacket(new CommandBlockUpdatePacket()); static::registerPacket(new CommandBlockUpdatePacket());
static::registerPacket(new CommandOutputPacket());
static::registerPacket(new UpdateTradePacket()); static::registerPacket(new UpdateTradePacket());
static::registerPacket(new UpdateEquipPacket()); static::registerPacket(new UpdateEquipPacket());
static::registerPacket(new ResourcePackDataInfoPacket()); static::registerPacket(new ResourcePackDataInfoPacket());
@ -124,6 +123,17 @@ class PacketPool{
static::registerPacket(new StructureBlockUpdatePacket()); static::registerPacket(new StructureBlockUpdatePacket());
static::registerPacket(new ShowStoreOfferPacket()); static::registerPacket(new ShowStoreOfferPacket());
static::registerPacket(new PurchaseReceiptPacket()); static::registerPacket(new PurchaseReceiptPacket());
static::registerPacket(new PlayerSkinPacket());
static::registerPacket(new SubClientLoginPacket());
static::registerPacket(new WSConnectPacket());
static::registerPacket(new SetLastHurtByPacket());
static::registerPacket(new BookEditPacket());
static::registerPacket(new NpcRequestPacket());
static::registerPacket(new PhotoTransferPacket());
static::registerPacket(new ModalFormRequestPacket());
static::registerPacket(new ModalFormResponsePacket());
static::registerPacket(new ServerSettingsRequestPacket());
static::registerPacket(new ServerSettingsResponsePacket());
static::registerPacket(new BatchPacket()); static::registerPacket(new BatchPacket());
} }

View File

@ -0,0 +1,55 @@
<?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 PhotoTransferPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::PHOTO_TRANSFER_PACKET;
/** @var string */
public $string1;
/** @var string */
public $string2;
/** @var string */
public $string3;
public function decodePayload(){
$this->string1 = $this->getString();
$this->string2 = $this->getString();
$this->string3 = $this->getString();
}
public function encodePayload(){
$this->putString($this->string1);
$this->putString($this->string2);
$this->putString($this->string3);
}
public function handle(NetworkSession $session) : bool{
return $session->handlePhotoTransfer($this);
}
}

View File

@ -34,22 +34,25 @@ class PlayerActionPacket extends DataPacket{
const ACTION_START_BREAK = 0; const ACTION_START_BREAK = 0;
const ACTION_ABORT_BREAK = 1; const ACTION_ABORT_BREAK = 1;
const ACTION_STOP_BREAK = 2; const ACTION_STOP_BREAK = 2;
const ACTION_GET_UPDATED_BLOCK = 3;
const ACTION_DROP_ITEM = 4;
const ACTION_STOP_SLEEPING = 5;
const ACTION_RESPAWN = 6;
const ACTION_JUMP = 7;
const ACTION_START_SPRINT = 8;
const ACTION_STOP_SPRINT = 9;
const ACTION_START_SNEAK = 10;
const ACTION_STOP_SNEAK = 11;
const ACTION_DIMENSION_CHANGE_REQUEST = 12; //sent when dying in different dimension
const ACTION_DIMENSION_CHANGE_ACK = 13; //sent when spawning in a different dimension to tell the server we spawned
const ACTION_START_GLIDE = 14;
const ACTION_STOP_GLIDE = 15;
const ACTION_BUILD_DENIED = 16;
const ACTION_CONTINUE_BREAK = 17;
const ACTION_SET_ENCHANTMENT_SEED = 19;
const ACTION_RELEASE_ITEM = 5; const ACTION_RELEASE_ITEM = 99999; //TODO REMOVE
const ACTION_STOP_SLEEPING = 6;
const ACTION_RESPAWN = 7;
const ACTION_JUMP = 8;
const ACTION_START_SPRINT = 9;
const ACTION_STOP_SPRINT = 10;
const ACTION_START_SNEAK = 11;
const ACTION_STOP_SNEAK = 12;
const ACTION_DIMENSION_CHANGE = 13; //TODO: correct these
const ACTION_START_GLIDE = 15;
const ACTION_STOP_GLIDE = 16;
const ACTION_BUILD_DENIED = 17;
const ACTION_CONTINUE_BREAK = 18;
public $entityRuntimeId; public $entityRuntimeId;
public $action; public $action;

View File

@ -25,57 +25,38 @@ namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h> #include <rules/DataPacket.h>
use pocketmine\network\mcpe\NetworkSession; use pocketmine\network\mcpe\NetworkSession;
use pocketmine\network\mcpe\protocol\types\ContainerIds; use pocketmine\network\mcpe\protocol\types\ContainerIds;
class ContainerSetContentPacket extends DataPacket{ class PlayerHotbarPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::CONTAINER_SET_CONTENT_PACKET; const NETWORK_ID = ProtocolInfo::PLAYER_HOTBAR_PACKET;
public $windowid; /** @var int */
public $targetEid; public $selectedSlot;
/** @var int */
public $windowId = ContainerIds::INVENTORY;
/** @var int[] */
public $slots = []; public $slots = [];
public $hotbar = [];
public function clean(){
$this->slots = [];
$this->hotbar = [];
return parent::clean();
}
public function decodePayload(){ public function decodePayload(){
$this->windowid = $this->getUnsignedVarInt(); $this->selectedSlot = $this->getUnsignedVarInt();
$this->targetEid = $this->getEntityUniqueId(); $this->windowId = $this->getByte();
$count = $this->getUnsignedVarInt(); $count = $this->getUnsignedVarInt();
for($s = 0; $s < $count and !$this->feof(); ++$s){ for($i = 0; $i < $count; ++$i){
$this->slots[$s] = $this->getSlot(); $this->slots[$i] = $this->getUnsignedVarInt();
}
$hotbarCount = $this->getUnsignedVarInt(); //MCPE always sends this, even when it's not a player inventory
for($s = 0; $s < $hotbarCount and !$this->feof(); ++$s){
$this->hotbar[$s] = $this->getVarInt();
} }
} }
public function encodePayload(){ public function encodePayload(){
$this->putUnsignedVarInt($this->windowid); $this->putUnsignedVarInt($this->selectedSlot);
$this->putEntityUniqueId($this->targetEid); $this->putByte($this->windowId);
$this->putUnsignedVarInt(count($this->slots)); $this->putUnsignedVarInt(count($this->slots));
foreach($this->slots as $slot){ foreach($this->slots as $slot){
$this->putSlot($slot); $this->putUnsignedVarInt($slot);
}
if($this->windowid === ContainerIds::INVENTORY and count($this->hotbar) > 0){
$this->putUnsignedVarInt(count($this->hotbar));
foreach($this->hotbar as $slot){
$this->putVarInt($slot);
}
}else{
$this->putUnsignedVarInt(0);
} }
} }
public function handle(NetworkSession $session) : bool{ public function handle(NetworkSession $session) : bool{
return $session->handleContainerSetContent($this); return $session->handlePlayerHotbar($this);
} }
} }

View File

@ -34,7 +34,7 @@ class PlayerListPacket extends DataPacket{
const TYPE_ADD = 0; const TYPE_ADD = 0;
const TYPE_REMOVE = 1; const TYPE_REMOVE = 1;
//REMOVE: UUID, ADD: UUID, entity id, name, skinId, skin //REMOVE: UUID, ADD: UUID, entity id, name, skinId, skin, geometric model, geometry data
/** @var array[] */ /** @var array[] */
public $entries = []; public $entries = [];
public $type; public $type;
@ -51,9 +51,12 @@ class PlayerListPacket extends DataPacket{
if($this->type === self::TYPE_ADD){ if($this->type === self::TYPE_ADD){
$this->entries[$i][0] = $this->getUUID(); $this->entries[$i][0] = $this->getUUID();
$this->entries[$i][1] = $this->getEntityUniqueId(); $this->entries[$i][1] = $this->getEntityUniqueId();
$this->entries[$i][2] = $this->getString(); $this->entries[$i][2] = $this->getString(); //name
$this->entries[$i][3] = $this->getString(); $this->entries[$i][3] = $this->getString(); //skin id
$this->entries[$i][4] = $this->getString(); $this->entries[$i][4] = $this->getString(); //skin data
$this->entries[$i][5] = $this->getString(); //geometric model
$this->entries[$i][6] = $this->getString(); //geometry data (json)
$this->entries[$i][7] = $this->getString(); //???
}else{ }else{
$this->entries[$i][0] = $this->getUUID(); $this->entries[$i][0] = $this->getUUID();
} }
@ -67,9 +70,12 @@ class PlayerListPacket extends DataPacket{
if($this->type === self::TYPE_ADD){ if($this->type === self::TYPE_ADD){
$this->putUUID($d[0]); $this->putUUID($d[0]);
$this->putEntityUniqueId($d[1]); $this->putEntityUniqueId($d[1]);
$this->putString($d[2]); $this->putString($d[2]); //name
$this->putString($d[3]); $this->putString($d[3]); //skin id
$this->putString($d[4]); $this->putString($d[4]); //skin data
$this->putString($d[5] ?? ""); //geometric model
$this->putString($d[6] ?? ""); //geometry data (json)
$this->putString($d[7] ?? ""); //???
}else{ }else{
$this->putUUID($d[0]); $this->putUUID($d[0]);
} }

View File

@ -0,0 +1,73 @@
<?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\utils\UUID;
class PlayerSkinPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::PLAYER_SKIN_PACKET;
/** @var UUID */
public $uuid;
/** @var string */
public $skinId;
/** @var string */
public $skinName;
/** @var string */
public $serializeName;
/** @var string */
public $skinData;
/** @var string */
public $geometryModel;
/** @var string */
public $geometryData;
public function decodePayload(){
$this->uuid = $this->getUUID();
$this->skinId = $this->getString();
$this->skinName = $this->getString();
$this->serializeName = $this->getString();
$this->skinData = $this->getString();
$this->geometryModel = $this->getString();
$this->geometryData = $this->getString();
}
public function encodePayload(){
$this->putUUID($this->uuid);
$this->putString($this->skinId);
$this->putString($this->skinName);
$this->putString($this->serializeName);
$this->putString($this->skinData);
$this->putString($this->geometryModel);
$this->putString($this->geometryData);
}
public function handle(NetworkSession $session) : bool{
return $session->handlePlayerSkin($this);
}
}

View File

@ -39,15 +39,15 @@ interface ProtocolInfo{
/** /**
* Actual Minecraft: PE protocol version * Actual Minecraft: PE protocol version
*/ */
const CURRENT_PROTOCOL = 113; const CURRENT_PROTOCOL = 130;
/** /**
* Current Minecraft PE version reported by the server. This is usually the earliest currently supported version. * Current Minecraft PE version reported by the server. This is usually the earliest currently supported version.
*/ */
const MINECRAFT_VERSION = 'v1.1.0.55'; const MINECRAFT_VERSION = 'v1.2.0.2 beta';
/** /**
* Version number sent to clients in ping responses. * Version number sent to clients in ping responses.
*/ */
const MINECRAFT_VERSION_NETWORK = '1.1.0.55'; const MINECRAFT_VERSION_NETWORK = '1.2.0.2';
const LOGIN_PACKET = 0x01; const LOGIN_PACKET = 0x01;
const PLAY_STATUS_PACKET = 0x02; const PLAY_STATUS_PACKET = 0x02;
@ -69,21 +69,21 @@ interface ProtocolInfo{
const MOVE_ENTITY_PACKET = 0x12; const MOVE_ENTITY_PACKET = 0x12;
const MOVE_PLAYER_PACKET = 0x13; const MOVE_PLAYER_PACKET = 0x13;
const RIDER_JUMP_PACKET = 0x14; const RIDER_JUMP_PACKET = 0x14;
const REMOVE_BLOCK_PACKET = 0x15; const UPDATE_BLOCK_PACKET = 0x15;
const UPDATE_BLOCK_PACKET = 0x16; const ADD_PAINTING_PACKET = 0x16;
const ADD_PAINTING_PACKET = 0x17; const EXPLODE_PACKET = 0x17;
const EXPLODE_PACKET = 0x18; const LEVEL_SOUND_EVENT_PACKET = 0x18;
const LEVEL_SOUND_EVENT_PACKET = 0x19; const LEVEL_EVENT_PACKET = 0x19;
const LEVEL_EVENT_PACKET = 0x1a; const BLOCK_EVENT_PACKET = 0x1a;
const BLOCK_EVENT_PACKET = 0x1b; const ENTITY_EVENT_PACKET = 0x1b;
const ENTITY_EVENT_PACKET = 0x1c; const MOB_EFFECT_PACKET = 0x1c;
const MOB_EFFECT_PACKET = 0x1d; const UPDATE_ATTRIBUTES_PACKET = 0x1d;
const UPDATE_ATTRIBUTES_PACKET = 0x1e; const INVENTORY_TRANSACTION_PACKET = 0x1e;
const MOB_EQUIPMENT_PACKET = 0x1f; const MOB_EQUIPMENT_PACKET = 0x1f;
const MOB_ARMOR_EQUIPMENT_PACKET = 0x20; const MOB_ARMOR_EQUIPMENT_PACKET = 0x20;
const INTERACT_PACKET = 0x21; const INTERACT_PACKET = 0x21;
const BLOCK_PICK_REQUEST_PACKET = 0x22; const BLOCK_PICK_REQUEST_PACKET = 0x22;
const USE_ITEM_PACKET = 0x23; const ENTITY_PICK_REQUEST_PACKET = 0x23;
const PLAYER_ACTION_PACKET = 0x24; const PLAYER_ACTION_PACKET = 0x24;
const ENTITY_FALL_PACKET = 0x25; const ENTITY_FALL_PACKET = 0x25;
const HURT_ARMOR_PACKET = 0x26; const HURT_ARMOR_PACKET = 0x26;
@ -94,15 +94,15 @@ interface ProtocolInfo{
const SET_SPAWN_POSITION_PACKET = 0x2b; const SET_SPAWN_POSITION_PACKET = 0x2b;
const ANIMATE_PACKET = 0x2c; const ANIMATE_PACKET = 0x2c;
const RESPAWN_PACKET = 0x2d; const RESPAWN_PACKET = 0x2d;
const DROP_ITEM_PACKET = 0x2e; const CONTAINER_OPEN_PACKET = 0x2e;
const INVENTORY_ACTION_PACKET = 0x2f; const CONTAINER_CLOSE_PACKET = 0x2f;
const CONTAINER_OPEN_PACKET = 0x30; const PLAYER_HOTBAR_PACKET = 0x30;
const CONTAINER_CLOSE_PACKET = 0x31; const INVENTORY_CONTENT_PACKET = 0x31;
const CONTAINER_SET_SLOT_PACKET = 0x32; const INVENTORY_SLOT_PACKET = 0x32;
const CONTAINER_SET_DATA_PACKET = 0x33; const CONTAINER_SET_DATA_PACKET = 0x33;
const CONTAINER_SET_CONTENT_PACKET = 0x34; const CRAFTING_DATA_PACKET = 0x34;
const CRAFTING_DATA_PACKET = 0x35; const CRAFTING_EVENT_PACKET = 0x35;
const CRAFTING_EVENT_PACKET = 0x36; const GUI_DATA_PICK_ITEM_PACKET = 0x36;
const ADVENTURE_SETTINGS_PACKET = 0x37; const ADVENTURE_SETTINGS_PACKET = 0x37;
const BLOCK_ENTITY_DATA_PACKET = 0x38; const BLOCK_ENTITY_DATA_PACKET = 0x38;
const PLAYER_INPUT_PACKET = 0x39; const PLAYER_INPUT_PACKET = 0x39;
@ -120,27 +120,37 @@ interface ProtocolInfo{
const REQUEST_CHUNK_RADIUS_PACKET = 0x45; const REQUEST_CHUNK_RADIUS_PACKET = 0x45;
const CHUNK_RADIUS_UPDATED_PACKET = 0x46; const CHUNK_RADIUS_UPDATED_PACKET = 0x46;
const ITEM_FRAME_DROP_ITEM_PACKET = 0x47; const ITEM_FRAME_DROP_ITEM_PACKET = 0x47;
const REPLACE_ITEM_IN_SLOT_PACKET = 0x48; const GAME_RULES_CHANGED_PACKET = 0x48;
const GAME_RULES_CHANGED_PACKET = 0x49; const CAMERA_PACKET = 0x49;
const CAMERA_PACKET = 0x4a; const BOSS_EVENT_PACKET = 0x4a;
const ADD_ITEM_PACKET = 0x4b; const SHOW_CREDITS_PACKET = 0x4b;
const BOSS_EVENT_PACKET = 0x4c; const AVAILABLE_COMMANDS_PACKET = 0x4c;
const SHOW_CREDITS_PACKET = 0x4d; const COMMAND_REQUEST_PACKET = 0x4d;
const AVAILABLE_COMMANDS_PACKET = 0x4e; const COMMAND_BLOCK_UPDATE_PACKET = 0x4e;
const COMMAND_STEP_PACKET = 0x4f; const COMMAND_OUTPUT_PACKET = 0x4f;
const COMMAND_BLOCK_UPDATE_PACKET = 0x50; const UPDATE_TRADE_PACKET = 0x50;
const UPDATE_TRADE_PACKET = 0x51; const UPDATE_EQUIP_PACKET = 0x51;
const UPDATE_EQUIP_PACKET = 0x52; const RESOURCE_PACK_DATA_INFO_PACKET = 0x52;
const RESOURCE_PACK_DATA_INFO_PACKET = 0x53; const RESOURCE_PACK_CHUNK_DATA_PACKET = 0x53;
const RESOURCE_PACK_CHUNK_DATA_PACKET = 0x54; const RESOURCE_PACK_CHUNK_REQUEST_PACKET = 0x54;
const RESOURCE_PACK_CHUNK_REQUEST_PACKET = 0x55; const TRANSFER_PACKET = 0x55;
const TRANSFER_PACKET = 0x56; const PLAY_SOUND_PACKET = 0x56;
const PLAY_SOUND_PACKET = 0x57; const STOP_SOUND_PACKET = 0x57;
const STOP_SOUND_PACKET = 0x58; const SET_TITLE_PACKET = 0x58;
const SET_TITLE_PACKET = 0x59; const ADD_BEHAVIOR_TREE_PACKET = 0x59;
const ADD_BEHAVIOR_TREE_PACKET = 0x5a; const STRUCTURE_BLOCK_UPDATE_PACKET = 0x5a;
const STRUCTURE_BLOCK_UPDATE_PACKET = 0x5b; const SHOW_STORE_OFFER_PACKET = 0x5b;
const SHOW_STORE_OFFER_PACKET = 0x5c; const PURCHASE_RECEIPT_PACKET = 0x5c;
const PURCHASE_RECEIPT_PACKET = 0x5d; const PLAYER_SKIN_PACKET = 0x5d;
const SUB_CLIENT_LOGIN_PACKET = 0x5e;
const W_S_CONNECT_PACKET = 0x5f;
const SET_LAST_HURT_BY_PACKET = 0x60;
const BOOK_EDIT_PACKET = 0x61;
const NPC_REQUEST_PACKET = 0x62;
const PHOTO_TRANSFER_PACKET = 0x63;
const MODAL_FORM_REQUEST_PACKET = 0x64;
const MODAL_FORM_RESPONSE_PACKET = 0x65;
const SERVER_SETTINGS_REQUEST_PACKET = 0x66;
const SERVER_SETTINGS_RESPONSE_PACKET = 0x67;
} }

View File

@ -28,6 +28,9 @@ namespace pocketmine\network\mcpe\protocol;
use pocketmine\network\mcpe\NetworkSession; use pocketmine\network\mcpe\NetworkSession;
/**
* @removed
*/
class RemoveBlockPacket extends DataPacket{ class RemoveBlockPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::REMOVE_BLOCK_PACKET; const NETWORK_ID = ProtocolInfo::REMOVE_BLOCK_PACKET;

View File

@ -65,12 +65,14 @@ class ResourcePackStackPacket extends DataPacket{
foreach($this->behaviorPackStack as $entry){ foreach($this->behaviorPackStack as $entry){
$this->putString($entry->getPackId()); $this->putString($entry->getPackId());
$this->putString($entry->getPackVersion()); $this->putString($entry->getPackVersion());
$this->putString(""); //TODO
} }
$this->putUnsignedVarInt(count($this->resourcePackStack)); $this->putUnsignedVarInt(count($this->resourcePackStack));
foreach($this->resourcePackStack as $entry){ foreach($this->resourcePackStack as $entry){
$this->putString($entry->getPackId()); $this->putString($entry->getPackId());
$this->putString($entry->getPackVersion()); $this->putString($entry->getPackVersion());
$this->putString(""); //TODO
} }
} }

View File

@ -69,6 +69,7 @@ class ResourcePacksInfoPacket extends DataPacket{
$this->putString($entry->getPackVersion()); $this->putString($entry->getPackVersion());
$this->putLLong($entry->getPackSize()); $this->putLLong($entry->getPackSize());
$this->putString(""); //TODO $this->putString(""); //TODO
$this->putString(""); //TODO
} }
$this->putLShort(count($this->resourcePackEntries)); $this->putLShort(count($this->resourcePackEntries));
foreach($this->resourcePackEntries as $entry){ foreach($this->resourcePackEntries as $entry){
@ -76,6 +77,7 @@ class ResourcePacksInfoPacket extends DataPacket{
$this->putString($entry->getPackVersion()); $this->putString($entry->getPackVersion());
$this->putLLong($entry->getPackSize()); $this->putLLong($entry->getPackSize());
$this->putString(""); //TODO $this->putString(""); //TODO
$this->putString(""); //TODO
} }
} }

View File

@ -0,0 +1,44 @@
<?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 ServerSettingsRequestPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::SERVER_SETTINGS_REQUEST_PACKET;
public function decodePayload(){
//TODO
}
public function encodePayload(){
//TODO
}
public function handle(NetworkSession $session) : bool{
return $session->handleServerSettingsRequest($this);
}
}

View File

@ -0,0 +1,44 @@
<?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 ServerSettingsResponsePacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::SERVER_SETTINGS_RESPONSE_PACKET;
public function decodePayload(){
//TODO
}
public function encodePayload(){
//TODO
}
public function handle(NetworkSession $session) : bool{
return $session->handleServerSettingsResponse($this);
}
}

View File

@ -31,21 +31,22 @@ use pocketmine\network\mcpe\NetworkSession;
class ServerToClientHandshakePacket extends DataPacket{ class ServerToClientHandshakePacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::SERVER_TO_CLIENT_HANDSHAKE_PACKET; const NETWORK_ID = ProtocolInfo::SERVER_TO_CLIENT_HANDSHAKE_PACKET;
public $publicKey; /**
public $serverToken; * @var string
* Server pubkey and token is contained in the JWT.
*/
public $jwt;
public function canBeSentBeforeLogin() : bool{ public function canBeSentBeforeLogin() : bool{
return true; return true;
} }
public function decodePayload(){ public function decodePayload(){
$this->publicKey = $this->getString(); $this->jwt = $this->getString();
$this->serverToken = $this->getString();
} }
public function encodePayload(){ public function encodePayload(){
$this->putString($this->publicKey); $this->putString($this->jwt);
$this->putString($this->serverToken);
} }
public function handle(NetworkSession $session) : bool{ public function handle(NetworkSession $session) : bool{

View File

@ -31,20 +31,15 @@ use pocketmine\network\mcpe\NetworkSession;
class SetEntityLinkPacket extends DataPacket{ class SetEntityLinkPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::SET_ENTITY_LINK_PACKET; const NETWORK_ID = ProtocolInfo::SET_ENTITY_LINK_PACKET;
public $from; /** @var array [from, to, type, unknown byte] */
public $to; public $link = [];
public $type;
public function decodePayload(){ public function decodePayload(){
$this->from = $this->getEntityUniqueId(); $this->link = $this->getEntityLink();
$this->to = $this->getEntityUniqueId();
$this->type = $this->getByte();
} }
public function encodePayload(){ public function encodePayload(){
$this->putEntityUniqueId($this->from); $this->putEntityLink($this->link);
$this->putEntityUniqueId($this->to);
$this->putByte($this->type);
} }
public function handle(NetworkSession $session) : bool{ public function handle(NetworkSession $session) : bool{

View File

@ -0,0 +1,46 @@
<?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 SetLastHurtByPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::SET_LAST_HURT_BY_PACKET;
public $entityTypeId;
public function decodePayload(){
$this->entityTypeId = $this->getVarInt();
}
public function encodePayload(){
$this->putVarInt($this->entityTypeId);
}
public function handle(NetworkSession $session) : bool{
return $session->handleSetLastHurtBy($this);
}
}

View File

@ -27,6 +27,7 @@ namespace pocketmine\network\mcpe\protocol;
use pocketmine\network\mcpe\NetworkSession; use pocketmine\network\mcpe\NetworkSession;
use pocketmine\network\mcpe\protocol\types\PlayerPermissions;
class StartGamePacket extends DataPacket{ class StartGamePacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::START_GAME_PACKET; const NETWORK_ID = ProtocolInfo::START_GAME_PACKET;
@ -34,11 +35,14 @@ class StartGamePacket extends DataPacket{
public $entityUniqueId; public $entityUniqueId;
public $entityRuntimeId; public $entityRuntimeId;
public $playerGamemode; public $playerGamemode;
public $x; public $x;
public $y; public $y;
public $z; public $z;
public $pitch; public $pitch;
public $yaw; public $yaw;
public $seed; public $seed;
public $dimension; public $dimension;
public $generator = 1; //default infinite - 0 old, 1 infinite, 2 flat public $generator = 1; //default infinite - 0 old, 1 infinite, 2 flat
@ -48,26 +52,40 @@ class StartGamePacket extends DataPacket{
public $spawnY; public $spawnY;
public $spawnZ; public $spawnZ;
public $hasAchievementsDisabled = true; public $hasAchievementsDisabled = true;
public $dayCycleStopTime = -1; //-1 = not stopped, any positive value = stopped at that time public $time = -1;
public $eduMode = false; public $eduMode = false;
public $rainLevel; public $rainLevel;
public $lightningLevel; public $lightningLevel;
public $isMultiplayerGame = true;
public $hasLANBroadcast = true;
public $hasXboxLiveBroadcast = false;
public $commandsEnabled; public $commandsEnabled;
public $isTexturePacksRequired = true; public $isTexturePacksRequired = true;
public $gameRules = []; //TODO: implement this public $gameRules = []; //TODO: implement this
public $hasBonusChestEnabled = false;
public $hasTrustPlayersEnabled = false;
public $defaultPlayerPermission = PlayerPermissions::MEMBER; //TODO
public $xboxLiveBroadcastMode = 0; //TODO: find values
public $levelId = ""; //base64 string, usually the same as world folder name in vanilla public $levelId = ""; //base64 string, usually the same as world folder name in vanilla
public $worldName; public $worldName;
public $premiumWorldTemplateId = ""; public $premiumWorldTemplateId = "";
public $unknownBool = false; public $unknownBool = false;
public $currentTick = 0; public $currentTick = 0;
public $unknownVarInt = 0;
public function decodePayload(){ public function decodePayload(){
$this->entityUniqueId = $this->getEntityUniqueId(); $this->entityUniqueId = $this->getEntityUniqueId();
$this->entityRuntimeId = $this->getEntityRuntimeId(); $this->entityRuntimeId = $this->getEntityRuntimeId();
$this->playerGamemode = $this->getVarInt(); $this->playerGamemode = $this->getVarInt();
$this->getVector3f($this->x, $this->y, $this->z); $this->getVector3f($this->x, $this->y, $this->z);
$this->pitch = $this->getLFloat(); $this->pitch = $this->getLFloat();
$this->yaw = $this->getLFloat(); $this->yaw = $this->getLFloat();
//Level settings
$this->seed = $this->getVarInt(); $this->seed = $this->getVarInt();
$this->dimension = $this->getVarInt(); $this->dimension = $this->getVarInt();
$this->generator = $this->getVarInt(); $this->generator = $this->getVarInt();
@ -75,28 +93,41 @@ class StartGamePacket extends DataPacket{
$this->difficulty = $this->getVarInt(); $this->difficulty = $this->getVarInt();
$this->getBlockPosition($this->spawnX, $this->spawnY, $this->spawnZ); $this->getBlockPosition($this->spawnX, $this->spawnY, $this->spawnZ);
$this->hasAchievementsDisabled = $this->getBool(); $this->hasAchievementsDisabled = $this->getBool();
$this->dayCycleStopTime = $this->getVarInt(); $this->time = $this->getVarInt();
$this->eduMode = $this->getBool(); $this->eduMode = $this->getBool();
$this->rainLevel = $this->getLFloat(); $this->rainLevel = $this->getLFloat();
$this->lightningLevel = $this->getLFloat(); $this->lightningLevel = $this->getLFloat();
$this->isMultiplayerGame = $this->getBool();
$this->hasLANBroadcast = $this->getBool();
$this->hasXboxLiveBroadcast = $this->getBool();
$this->commandsEnabled = $this->getBool(); $this->commandsEnabled = $this->getBool();
$this->isTexturePacksRequired = $this->getBool(); $this->isTexturePacksRequired = $this->getBool();
$this->gameRules = $this->getGameRules(); $this->gameRules = $this->getGameRules();
$this->hasBonusChestEnabled = $this->getBool();
$this->hasTrustPlayersEnabled = $this->getBool();
$this->defaultPlayerPermission = $this->getVarInt();
$this->xboxLiveBroadcastMode = $this->getVarInt();
$this->levelId = $this->getString(); $this->levelId = $this->getString();
$this->worldName = $this->getString(); $this->worldName = $this->getString();
$this->premiumWorldTemplateId = $this->getString(); $this->premiumWorldTemplateId = $this->getString();
$this->unknownBool = $this->getBool(); $this->unknownBool = $this->getBool();
$this->currentTick = $this->getLLong(); $this->currentTick = $this->getLLong();
$this->unknownVarInt = $this->getVarInt();
} }
public function encodePayload(){ public function encodePayload(){
$this->putEntityUniqueId($this->entityUniqueId); $this->putEntityUniqueId($this->entityUniqueId);
$this->putEntityRuntimeId($this->entityRuntimeId); $this->putEntityRuntimeId($this->entityRuntimeId);
$this->putVarInt($this->playerGamemode); $this->putVarInt($this->playerGamemode);
$this->putVector3f($this->x, $this->y, $this->z); $this->putVector3f($this->x, $this->y, $this->z);
$this->putLFloat($this->pitch); $this->putLFloat($this->pitch);
$this->putLFloat($this->yaw); $this->putLFloat($this->yaw);
//Level settings
$this->putVarInt($this->seed); $this->putVarInt($this->seed);
$this->putVarInt($this->dimension); $this->putVarInt($this->dimension);
$this->putVarInt($this->generator); $this->putVarInt($this->generator);
@ -104,18 +135,28 @@ class StartGamePacket extends DataPacket{
$this->putVarInt($this->difficulty); $this->putVarInt($this->difficulty);
$this->putBlockPosition($this->spawnX, $this->spawnY, $this->spawnZ); $this->putBlockPosition($this->spawnX, $this->spawnY, $this->spawnZ);
$this->putBool($this->hasAchievementsDisabled); $this->putBool($this->hasAchievementsDisabled);
$this->putVarInt($this->dayCycleStopTime); $this->putVarInt($this->time);
$this->putBool($this->eduMode); $this->putBool($this->eduMode);
$this->putLFloat($this->rainLevel); $this->putLFloat($this->rainLevel);
$this->putLFloat($this->lightningLevel); $this->putLFloat($this->lightningLevel);
$this->putBool($this->isMultiplayerGame);
$this->putBool($this->hasLANBroadcast);
$this->putBool($this->hasXboxLiveBroadcast);
$this->putBool($this->commandsEnabled); $this->putBool($this->commandsEnabled);
$this->putBool($this->isTexturePacksRequired); $this->putBool($this->isTexturePacksRequired);
$this->putGameRules($this->gameRules); $this->putGameRules($this->gameRules);
$this->putBool($this->hasBonusChestEnabled);
$this->putBool($this->hasTrustPlayersEnabled);
$this->putVarInt($this->defaultPlayerPermission);
$this->putVarInt($this->xboxLiveBroadcastMode);
$this->putString($this->levelId); $this->putString($this->levelId);
$this->putString($this->worldName); $this->putString($this->worldName);
$this->putString($this->premiumWorldTemplateId); $this->putString($this->premiumWorldTemplateId);
$this->putBool($this->unknownBool); $this->putBool($this->unknownBool);
$this->putLLong($this->currentTick); $this->putLLong($this->currentTick);
$this->putVarInt($this->unknownVarInt);
} }
public function handle(NetworkSession $session) : bool{ public function handle(NetworkSession $session) : bool{

View File

@ -0,0 +1,44 @@
<?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 SubClientLoginPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::SUB_CLIENT_LOGIN_PACKET;
public function decodePayload(){
//TODO
}
public function encodePayload(){
//TODO
}
public function handle(NetworkSession $session) : bool{
return $session->handleSubClientLogin($this);
}
}

View File

@ -41,12 +41,14 @@ class TextPacket extends DataPacket{
const TYPE_ANNOUNCEMENT = 7; const TYPE_ANNOUNCEMENT = 7;
public $type; public $type;
public $unknownBool = false;
public $source; public $source;
public $message; public $message;
public $parameters = []; public $parameters = [];
public function decodePayload(){ public function decodePayload(){
$this->type = $this->getByte(); $this->type = $this->getByte();
$this->unknownBool = $this->getBool();
switch($this->type){ switch($this->type){
case self::TYPE_POPUP: case self::TYPE_POPUP:
case self::TYPE_CHAT: case self::TYPE_CHAT:
@ -71,6 +73,7 @@ class TextPacket extends DataPacket{
public function encodePayload(){ public function encodePayload(){
$this->putByte($this->type); $this->putByte($this->type);
$this->putBool($this->unknownBool);
switch($this->type){ switch($this->type){
case self::TYPE_POPUP: case self::TYPE_POPUP:
case self::TYPE_CHAT: case self::TYPE_CHAT:

View File

@ -29,6 +29,9 @@ namespace pocketmine\network\mcpe\protocol;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\network\mcpe\NetworkSession; use pocketmine\network\mcpe\NetworkSession;
/**
* @removed
*/
class UseItemPacket extends DataPacket{ class UseItemPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::USE_ITEM_PACKET; const NETWORK_ID = ProtocolInfo::USE_ITEM_PACKET;

View File

@ -0,0 +1,47 @@
<?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 WSConnectPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::W_S_CONNECT_PACKET;
/** @var string */
public $string1;
public function decodePayload(){
$this->string1 = $this->getString();
}
public function encodePayload(){
$this->putString($this->string1);
}
public function handle(NetworkSession $session) : bool{
return $session->handleWSConnect($this);
}
}

View File

@ -0,0 +1,32 @@
<?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\types;
interface PlayerPermissions{
const OPERATOR = 2;
const MEMBER = 1;
const VISITOR = 0;
}

View File

@ -537,4 +537,10 @@ class Utils{
return proc_close($process); return proc_close($process);
} }
public static function decodeJWT(string $token) : array{
list($headB64, $payloadB64, $sigB64) = explode(".", $token);
return json_decode(base64_decode($payloadB64), true);
}
} }