Merge branch 'release/alpha12'

This commit is contained in:
Dylan K. Taylor
2018-05-17 18:40:24 +01:00
21 changed files with 454 additions and 36 deletions

View File

@ -35,7 +35,7 @@ class AvailableCommandsPacket extends DataPacket{
/**
* This flag is set on all types EXCEPT the TEMPLATE type. Not completely sure what this is for, but it is required
* This flag is set on all types EXCEPT the POSTFIX type. Not completely sure what this is for, but it is required
* for the argtype to work correctly. VALID seems as good a name as any.
*/
public const ARG_FLAG_VALID = 0x100000;
@ -44,21 +44,23 @@ class AvailableCommandsPacket extends DataPacket{
* Basic parameter types. These must be combined with the ARG_FLAG_VALID constant.
* ARG_FLAG_VALID | (type const)
*/
public const ARG_TYPE_INT = 0x01;
public const ARG_TYPE_FLOAT = 0x02;
public const ARG_TYPE_VALUE = 0x03;
public const ARG_TYPE_TARGET = 0x04;
public const ARG_TYPE_INT = 0x01;
public const ARG_TYPE_FLOAT = 0x02;
public const ARG_TYPE_VALUE = 0x03;
public const ARG_TYPE_WILDCARD_INT = 0x04;
public const ARG_TYPE_TARGET = 0x05;
public const ARG_TYPE_WILDCARD_TARGET = 0x06;
public const ARG_TYPE_STRING = 0x0d;
public const ARG_TYPE_POSITION = 0x0e;
public const ARG_TYPE_STRING = 0x0f;
public const ARG_TYPE_POSITION = 0x10;
public const ARG_TYPE_RAWTEXT = 0x11;
public const ARG_TYPE_MESSAGE = 0x13;
public const ARG_TYPE_TEXT = 0x13;
public const ARG_TYPE_RAWTEXT = 0x15;
public const ARG_TYPE_JSON = 0x16;
public const ARG_TYPE_JSON = 0x18;
public const ARG_TYPE_COMMAND = 0x1d;
public const ARG_TYPE_COMMAND = 0x1f;
/**
* Enums are a little different: they are composed as follows:
@ -67,7 +69,7 @@ class AvailableCommandsPacket extends DataPacket{
public const ARG_FLAG_ENUM = 0x200000;
/**
* This is used for /xp <level: int>L.
* This is used for /xp <level: int>L. It can only be applied to integer parameters.
*/
public const ARG_FLAG_POSTFIX = 0x1000000;
@ -255,9 +257,9 @@ class AvailableCommandsPacket extends DataPacket{
return "string";
case self::ARG_TYPE_POSITION:
return "xyz";
case self::ARG_TYPE_MESSAGE:
return "message";
case self::ARG_TYPE_RAWTEXT:
return "rawtext";
case self::ARG_TYPE_TEXT:
return "text";
case self::ARG_TYPE_JSON:
return "json";

View File

@ -87,8 +87,8 @@ class ClientboundMapItemDataPacket extends DataPacket{
}
for($i = 0, $count = $this->getUnsignedVarInt(); $i < $count; ++$i){
$this->decorations[$i]["rot"] = $this->getByte();
$this->decorations[$i]["img"] = $this->getByte();
$this->decorations[$i]["rot"] = $this->getByte();
$this->decorations[$i]["xOffset"] = $this->getByte();
$this->decorations[$i]["yOffset"] = $this->getByte();
$this->decorations[$i]["label"] = $this->getString();
@ -150,8 +150,8 @@ class ClientboundMapItemDataPacket extends DataPacket{
$this->putUnsignedVarInt($decorationCount);
foreach($this->decorations as $decoration){
$this->putByte($decoration["rot"]);
$this->putByte($decoration["img"]);
$this->putByte($decoration["rot"]);
$this->putByte($decoration["xOffset"]);
$this->putByte($decoration["yOffset"]);
$this->putString($decoration["label"]);

View File

@ -42,6 +42,8 @@ class CraftingDataPacket extends DataPacket{
public const ENTRY_FURNACE_DATA = 3;
public const ENTRY_MULTI = 4; //TODO
public const ENTRY_SHULKER_BOX = 5; //TODO
public const ENTRY_SHAPELESS_CHEMISTRY = 6; //TODO
public const ENTRY_SHAPED_CHEMISTRY = 7; //TODO
/** @var object[] */
public $entries = [];
@ -66,6 +68,7 @@ class CraftingDataPacket extends DataPacket{
switch($recipeType){
case self::ENTRY_SHAPELESS:
case self::ENTRY_SHULKER_BOX:
case self::ENTRY_SHAPELESS_CHEMISTRY:
$ingredientCount = $this->getUnsignedVarInt();
/** @var Item */
$entry["input"] = [];
@ -81,6 +84,7 @@ class CraftingDataPacket extends DataPacket{
break;
case self::ENTRY_SHAPED:
case self::ENTRY_SHAPED_CHEMISTRY:
$entry["width"] = $this->getVarInt();
$entry["height"] = $this->getVarInt();
$count = $entry["width"] * $entry["height"];

View File

@ -0,0 +1,61 @@
<?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 LabTablePacket extends DataPacket{
public const NETWORK_ID = ProtocolInfo::LAB_TABLE_PACKET;
/** @var int */
public $uselessByte; //0 for client -> server, 1 for server -> client. Seems useless.
/** @var int */
public $x;
/** @var int */
public $y;
/** @var int */
public $z;
/** @var int */
public $reactionType;
protected function decodePayload(){
$this->uselessByte = $this->getByte();
$this->getSignedBlockPosition($this->x, $this->y, $this->z);
$this->reactionType = $this->getByte();
}
protected function encodePayload(){
$this->putByte($this->uselessByte);
$this->putSignedBlockPosition($this->x, $this->y, $this->z);
$this->putByte($this->reactionType);
}
public function handle(NetworkSession $session) : bool{
return $session->handleLabTable($this);
}
}

View File

@ -136,6 +136,11 @@ class PacketPool{
static::registerPacket(new ServerSettingsResponsePacket());
static::registerPacket(new ShowProfilePacket());
static::registerPacket(new SetDefaultGameTypePacket());
static::registerPacket(new RemoveObjectivePacket());
static::registerPacket(new SetDisplayObjectivePacket());
static::registerPacket(new SetScorePacket());
static::registerPacket(new LabTablePacket());
static::registerPacket(new UpdateBlockSyncedPacket());
static::registerPacket(new BatchPacket());
}

View File

@ -38,6 +38,7 @@ class PlayStatusPacket extends DataPacket{
public const LOGIN_FAILED_INVALID_TENANT = 4;
public const LOGIN_FAILED_VANILLA_EDU = 5;
public const LOGIN_FAILED_EDU_VANILLA = 6;
public const LOGIN_FAILED_SERVER_FULL = 7;
/** @var int */
public $status;

View File

@ -52,6 +52,10 @@ class PlayerActionPacket extends DataPacket{
public const ACTION_CONTINUE_BREAK = 18;
public const ACTION_SET_ENCHANTMENT_SEED = 20;
public const ACTION_START_SWIMMING = 21;
public const ACTION_STOP_SWIMMING = 22;
public const ACTION_START_SPIN_ATTACK = 23;
public const ACTION_STOP_SPIN_ATTACK = 24;
/** @var int */
public $entityRuntimeId;

View File

@ -39,15 +39,15 @@ interface ProtocolInfo{
/**
* Actual Minecraft: PE protocol version
*/
public const CURRENT_PROTOCOL = 223;
public const CURRENT_PROTOCOL = 261;
/**
* Current Minecraft PE version reported by the server. This is usually the earliest currently supported version.
*/
public const MINECRAFT_VERSION = 'v1.2.13';
public const MINECRAFT_VERSION = 'v1.4.0';
/**
* Version number sent to clients in ping responses.
*/
public const MINECRAFT_VERSION_NETWORK = '1.2.13';
public const MINECRAFT_VERSION_NETWORK = '1.4.0';
public const LOGIN_PACKET = 0x01;
public const PLAY_STATUS_PACKET = 0x02;
@ -154,5 +154,10 @@ interface ProtocolInfo{
public const SERVER_SETTINGS_RESPONSE_PACKET = 0x67;
public const SHOW_PROFILE_PACKET = 0x68;
public const SET_DEFAULT_GAME_TYPE_PACKET = 0x69;
public const REMOVE_OBJECTIVE_PACKET = 0x6a;
public const SET_DISPLAY_OBJECTIVE_PACKET = 0x6b;
public const SET_SCORE_PACKET = 0x6c;
public const LAB_TABLE_PACKET = 0x6d;
public const UPDATE_BLOCK_SYNCED_PACKET = 0x6e;
}

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 RemoveObjectivePacket extends DataPacket{
public const NETWORK_ID = ProtocolInfo::REMOVE_OBJECTIVE_PACKET;
/** @var string */
public $objectiveName;
protected function decodePayload(){
$this->objectiveName = $this->getString();
}
protected function encodePayload(){
$this->putString($this->objectiveName);
}
public function handle(NetworkSession $session) : bool{
return $session->handleRemoveObjective($this);
}
}

View File

@ -0,0 +1,63 @@
<?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 SetDisplayObjectivePacket extends DataPacket{
public const NETWORK_ID = ProtocolInfo::SET_DISPLAY_OBJECTIVE_PACKET;
/** @var string */
public $displaySlot;
/** @var string */
public $objectiveName;
/** @var string */
public $displayName;
/** @var string */
public $criteriaName;
/** @var int */
public $sortOrder;
protected function decodePayload(){
$this->displaySlot = $this->getString();
$this->objectiveName = $this->getString();
$this->displayName = $this->getString();
$this->criteriaName = $this->getString();
$this->sortOrder = $this->getVarInt();
}
protected function encodePayload(){
$this->putString($this->displaySlot);
$this->putString($this->objectiveName);
$this->putString($this->displayName);
$this->putString($this->criteriaName);
$this->putVarInt($this->sortOrder);
}
public function handle(NetworkSession $session) : bool{
return $session->handleSetDisplayObjective($this);
}
}

View File

@ -0,0 +1,65 @@
<?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\network\mcpe\protocol\types\ScorePacketEntry;
class SetScorePacket extends DataPacket{
public const NETWORK_ID = ProtocolInfo::SET_SCORE_PACKET;
public const TYPE_MODIFY_SCORE = 0;
public const TYPE_RESET_SCORE = 1;
/** @var int */
public $type;
/** @var ScorePacketEntry[] */
public $entries = [];
protected function decodePayload(){
$this->type = $this->getByte();
for($i = 0, $i2 = $this->getUnsignedVarInt(); $i < $i2; ++$i){
$entry = new ScorePacketEntry();
$entry->uuid = $this->getUUID();
$entry->objectiveName = $this->getString();
$entry->score = $this->getLInt();
}
}
protected function encodePayload(){
$this->putByte($this->type);
$this->putUnsignedVarInt(count($this->entries));
foreach($this->entries as $entry){
$this->putUUID($entry->uuid);
$this->putString($entry->objectiveName);
$this->putLInt($entry->score);
}
}
public function handle(NetworkSession $session) : bool{
return $session->handleSetScore($this);
}
}

View File

@ -70,6 +70,8 @@ class StartGamePacket extends DataPacket{
public $time = -1;
/** @var bool */
public $eduMode = false;
/** @var bool */
public $hasEduFeaturesEnabled = false;
/** @var float */
public $rainLevel;
/** @var float */
@ -104,6 +106,12 @@ class StartGamePacket extends DataPacket{
public $platformBroadcastMode = 0;
/** @var bool */
public $xboxLiveBroadcastIntent = false;
/** @var bool */
public $hasLockedBehaviorPack = false;
/** @var bool */
public $hasLockedResourcePack = false;
/** @var bool */
public $isFromLockedWorldTemplate = false;
/** @var string */
public $levelId = ""; //base64 string, usually the same as world folder name in vanilla
@ -138,6 +146,7 @@ class StartGamePacket extends DataPacket{
$this->hasAchievementsDisabled = $this->getBool();
$this->time = $this->getVarInt();
$this->eduMode = $this->getBool();
$this->hasEduFeaturesEnabled = $this->getBool();
$this->rainLevel = $this->getLFloat();
$this->lightningLevel = $this->getLFloat();
$this->isMultiplayerGame = $this->getBool();
@ -153,8 +162,11 @@ class StartGamePacket extends DataPacket{
$this->xboxLiveBroadcastMode = $this->getVarInt();
$this->serverChunkTickRadius = $this->getLInt();
$this->hasPlatformBroadcast = $this->getBool();
$this->platformBroadcastMode = $this->getUnsignedVarInt();
$this->platformBroadcastMode = $this->getVarInt();
$this->xboxLiveBroadcastIntent = $this->getBool();
$this->hasLockedBehaviorPack = $this->getBool();
$this->hasLockedResourcePack = $this->getBool();
$this->isFromLockedWorldTemplate = $this->getBool();
$this->levelId = $this->getString();
$this->worldName = $this->getString();
@ -185,6 +197,7 @@ class StartGamePacket extends DataPacket{
$this->putBool($this->hasAchievementsDisabled);
$this->putVarInt($this->time);
$this->putBool($this->eduMode);
$this->putBool($this->hasEduFeaturesEnabled);
$this->putLFloat($this->rainLevel);
$this->putLFloat($this->lightningLevel);
$this->putBool($this->isMultiplayerGame);
@ -200,8 +213,11 @@ class StartGamePacket extends DataPacket{
$this->putVarInt($this->xboxLiveBroadcastMode);
$this->putLInt($this->serverChunkTickRadius);
$this->putBool($this->hasPlatformBroadcast);
$this->putUnsignedVarInt($this->platformBroadcastMode);
$this->putVarInt($this->platformBroadcastMode);
$this->putBool($this->xboxLiveBroadcastIntent);
$this->putBool($this->hasLockedBehaviorPack);
$this->putBool($this->hasLockedResourcePack);
$this->putBool($this->isFromLockedWorldTemplate);
$this->putString($this->levelId);
$this->putString($this->worldName);

View File

@ -40,6 +40,9 @@ class UpdateBlockPacket extends DataPacket{
public const FLAG_ALL = self::FLAG_NEIGHBORS | self::FLAG_NETWORK;
public const FLAG_ALL_PRIORITY = self::FLAG_ALL | self::FLAG_PRIORITY;
public const DATA_LAYER_NORMAL = 0;
public const DATA_LAYER_LIQUID = 1;
/** @var int */
public $x;
/** @var int */
@ -50,17 +53,21 @@ class UpdateBlockPacket extends DataPacket{
public $blockRuntimeId;
/** @var int */
public $flags;
/** @var int */
public $dataLayerId = self::DATA_LAYER_NORMAL;
protected function decodePayload(){
$this->getBlockPosition($this->x, $this->y, $this->z);
$this->blockRuntimeId = $this->getUnsignedVarInt();
$this->flags = $this->getUnsignedVarInt();
$this->dataLayerId = $this->getUnsignedVarInt();
}
protected function encodePayload(){
$this->putBlockPosition($this->x, $this->y, $this->z);
$this->putUnsignedVarInt($this->blockRuntimeId);
$this->putUnsignedVarInt($this->flags);
$this->putUnsignedVarInt($this->dataLayerId);
}
public function handle(NetworkSession $session) : bool{

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 UpdateBlockSyncedPacket extends UpdateBlockPacket{
public const NETWORK_ID = ProtocolInfo::UPDATE_BLOCK_SYNCED_PACKET;
/** @var int */
protected $uvarint64_1 = 0;
/** @var int */
protected $uvarint64_2 = 0;
protected function decodePayload(){
parent::decodePayload();
$this->uvarint64_1 = $this->getUnsignedVarLong();
$this->uvarint64_2 = $this->getUnsignedVarLong();
}
protected function encodePayload(){
parent::encodePayload();
$this->putUnsignedVarLong($this->uvarint64_1);
$this->putUnsignedVarLong($this->uvarint64_2);
}
public function handle(NetworkSession $session) : bool{
return $session->handleUpdateBlockSynced($this);
}
}

View File

@ -0,0 +1,35 @@
<?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;
use pocketmine\utils\UUID;
class ScorePacketEntry{
/** @var UUID */
public $uuid;
/** @var string */
public $objectiveName;
/** @var int */
public $score;
}