Compare commits

..

20 Commits

Author SHA1 Message Date
2034caf71c Merge branch 'mcpe-1.4.0-alpha12' into release/alpha12 2018-05-17 18:38:58 +01:00
89ccac7a8c updated blockIDs table 2018-05-17 16:17:26 +01:00
f6e71d8296 Protocol changes for 1.4.0 release
this is nearly the same as 1.5.0.0, except the skin packet premium boolean has been dropped.

This isn't production ready yet because the blockID table needs updating (waiting on MrARM to fix his script for that).
2018-05-17 10:36:16 +01:00
b333a0e24c PlayStatusPacket: add new constant 2018-05-17 10:33:18 +01:00
5b6762d0d5 Fixed lang submodule version 2018-05-09 14:53:22 +01:00
68638f9779 Fixed translations
Apparently the translation type doesn't translate unless this flag is set now...
2018-05-04 22:14:02 +01:00
8228774ad4 Remove extra data, this time without API breaks
this is necessary because the next MCPE release will probably be made before the next PM release.
2018-05-02 12:08:44 +01:00
2a54726905 Updated runtimeIDs table
from https://github.com/MCMrARM/minecraft-block-ids/blob/master/blocks_270.json
2018-05-02 12:03:29 +01:00
8b225fc4ef New entity metadata flags and properties 2018-05-02 12:03:29 +01:00
a014b44b69 New PlayerActionPacket constants
anyone know what these are for? something to do with riptide but I didn't manage to find out what...
2018-05-02 12:03:29 +01:00
c7544c1d25 AvailableCommandsPacket: update arg types 2018-05-02 12:03:29 +01:00
eb28622823 Protocol changes for 1.5.0.0
this feels so strange to type... can we ditch the versioning system already?
2018-05-02 12:03:29 +01:00
68494f1c0d CraftingDataPacket: decode chemistry recipes correctly 2018-05-02 12:03:29 +01:00
27ea0d360f updated block IDs table
minified, from https://github.com/MCMrARM/minecraft-block-ids/blob/master/blocks_260.json
2018-05-02 12:03:29 +01:00
d384df1f2e fixed some mistakes in the protocol 2018-05-02 12:03:29 +01:00
fe8102c062 Silence another stupid spam bug 2018-05-02 12:03:29 +01:00
8b15d85469 bump versions for 1.2.20.1 beta 2018-05-02 12:03:29 +01:00
a5ba716232 Updated block ID mappings for 1.2.14 (thanks again MrARM) 2018-05-02 12:03:29 +01:00
db432bb024 Found some things in new packets 2018-05-02 12:03:29 +01:00
91486a23a5 some changes for 1.2.14.2 beta 2018-05-02 12:03:29 +01:00
22 changed files with 455 additions and 37 deletions

View File

@ -2788,6 +2788,11 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
$this->level->broadcastLevelEvent($pos, LevelEventPacket::EVENT_PARTICLE_PUNCH_BLOCK, BlockFactory::toStaticRuntimeId($block->getId(), $block->getDamage()) | ($packet->face << 24));
//TODO: destroy-progress level event
break;
case PlayerActionPacket::ACTION_START_SWIMMING:
break; //TODO
case PlayerActionPacket::ACTION_STOP_SWIMMING:
//TODO: handle this when it doesn't spam every damn tick (yet another spam bug!!)
break;
default:
$this->server->getLogger()->debug("Unhandled/unknown player action type " . $packet->action . " from " . $this->getName());
return false;
@ -3281,6 +3286,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
$pk = new TextPacket();
if(!$this->server->isLanguageForced()){
$pk->type = TextPacket::TYPE_TRANSLATION;
$pk->needsTranslation = true;
$pk->message = $this->server->getLanguage()->translateString($message, $parameters, "pocketmine.");
foreach($parameters as $i => $p){
$parameters[$i] = $this->server->getLanguage()->translateString($p, $parameters, "pocketmine.");

View File

@ -134,9 +134,9 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
public const DATA_URL_TAG = 41; //string
public const DATA_MAX_AIR = 42; //short
public const DATA_MARK_VARIANT = 43; //int
/* 44 (byte) container stuff
* 45 (int) container stuff
* 46 (int) container stuff */
public const DATA_CONTAINER_TYPE = 44; //byte (ContainerComponent)
public const DATA_CONTAINER_BASE_SIZE = 45; //int (ContainerComponent)
public const DATA_CONTAINER_EXTRA_SLOTS_PER_STRENGTH = 46; //int (used for llamas, inventory size is baseSize + thisProp * strength)
public const DATA_BLOCK_TARGET = 47; //block coords (ender crystal)
public const DATA_WITHER_INVULNERABLE_TICKS = 48; //int
public const DATA_WITHER_TARGET_1 = 49; //long
@ -171,6 +171,11 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
public const DATA_ARMOR_STAND_POSE_INDEX = 78; //int
public const DATA_ENDER_CRYSTAL_TIME_OFFSET = 79; //int
/* 80 (byte) something to do with nametag visibility? */
public const DATA_COLOR_2 = 81; //byte
/* 82 (unknown) */
public const DATA_SCORE_TAG = 83; //string
public const DATA_BALLOON_ATTACHED_ENTITY = 84; //int64, entity unique ID of owner
public const DATA_PUFFERFISH_SIZE = 85; //byte
public const DATA_FLAG_ONFIRE = 0;
@ -224,6 +229,12 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
public const DATA_FLAG_FIRE_IMMUNE = 48;
public const DATA_FLAG_DANCING = 49;
public const DATA_FLAG_ENCHANTED = 50;
//51 is something to do with tridents
public const DATA_FLAG_CONTAINER_PRIVATE = 52; //inventory is private, doesn't drop contents when killed if true
//53 TransformationComponent
public const DATA_FLAG_SPIN_ATTACK = 54;
public const DATA_FLAG_SWIMMING = 55;
public const DATA_FLAG_BRIBED = 56; //dolphins have this set when they go to find treasure for the player
public static $entityCount = 1;
/** @var Entity[] */

View File

@ -857,6 +857,16 @@ class Level implements ChunkManager, Metadatable{
$this->sleepTicks = $ticks;
}
/**
* @deprecated
*
* @param int $x
* @param int $y
* @param int $z
* @param int $id
* @param int $data
* @param Player[]|null $targets
*/
public function sendBlockExtraData(int $x, int $y, int $z, int $id, int $data, array $targets = null){
$pk = new LevelEventPacket;
$pk->evid = LevelEventPacket::EVENT_SET_DATA;
@ -2128,6 +2138,8 @@ class Level implements ChunkManager, Metadatable{
}
/**
* @deprecated This functionality no longer produces any effect and will be removed in a future release
*
* Gets the raw block extra data
*
* @param int $x
@ -2141,6 +2153,7 @@ class Level implements ChunkManager, Metadatable{
}
/**
* @deprecated This functionality no longer produces any effect and will be removed in a future release
* Sets the raw block metadata.
*
* @param int $x

View File

@ -98,7 +98,7 @@ class Chunk{
* @param CompoundTag[] $tiles
* @param string $biomeIds
* @param int[] $heightMap
* @param int[] $extraData
* @param int[] $extraData @deprecated
*/
public function __construct(int $chunkX, int $chunkZ, array $subChunks = [], array $entities = [], array $tiles = [], string $biomeIds = "", array $heightMap = [], array $extraData = []){
$this->x = $chunkX;
@ -255,7 +255,7 @@ class Chunk{
}
/**
* Returns the raw block extra data value at the specified chunk block coordinates, or 0 if no data exists
* @deprecated This functionality no longer produces any visible effects and will be removed in a future release
*
* @param int $x 0-15
* @param int $y
@ -268,7 +268,7 @@ class Chunk{
}
/**
* Sets the raw block extra data value at the specified chunk block coordinates
* @deprecated This functionality no longer produces any visible effects and will be removed in a future release
*
* @param int $x 0-15
* @param int $y
@ -780,6 +780,7 @@ class Chunk{
}
/**
* @deprecated
* @return int[]
*/
public function getBlockExtraDataArray() : array{
@ -906,14 +907,6 @@ class Chunk{
. chr(0); //border block array count
//Border block entry format: 1 byte (4 bits X, 4 bits Z). These are however useless since they crash the regular client.
$extraData = new BinaryStream();
$extraData->putVarInt(count($this->extraData)); //WHY, Mojang, WHY
foreach($this->extraData as $key => $value){
$extraData->putVarInt($key);
$extraData->putLShort($value);
}
$result .= $extraData->getBuffer();
foreach($this->tiles as $tile){
if($tile instanceof Spawnable){
$result .= $tile->getSerializedSpawnCompound();
@ -979,6 +972,8 @@ class Chunk{
}
/**
* @deprecated This will be removed in a future release
*
* Creates a block hash from chunk block coordinates. Used for extra data keys in chunk packets.
* @internal
*

View File

@ -66,6 +66,7 @@ use pocketmine\network\mcpe\protocol\InventoryContentPacket;
use pocketmine\network\mcpe\protocol\InventorySlotPacket;
use pocketmine\network\mcpe\protocol\InventoryTransactionPacket;
use pocketmine\network\mcpe\protocol\ItemFrameDropItemPacket;
use pocketmine\network\mcpe\protocol\LabTablePacket;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
use pocketmine\network\mcpe\protocol\LoginPacket;
@ -88,6 +89,7 @@ use pocketmine\network\mcpe\protocol\PlayerListPacket;
use pocketmine\network\mcpe\protocol\PlayerSkinPacket;
use pocketmine\network\mcpe\protocol\PurchaseReceiptPacket;
use pocketmine\network\mcpe\protocol\RemoveEntityPacket;
use pocketmine\network\mcpe\protocol\RemoveObjectivePacket;
use pocketmine\network\mcpe\protocol\RequestChunkRadiusPacket;
use pocketmine\network\mcpe\protocol\ResourcePackChunkDataPacket;
use pocketmine\network\mcpe\protocol\ResourcePackChunkRequestPacket;
@ -103,12 +105,14 @@ use pocketmine\network\mcpe\protocol\ServerToClientHandshakePacket;
use pocketmine\network\mcpe\protocol\SetCommandsEnabledPacket;
use pocketmine\network\mcpe\protocol\SetDefaultGameTypePacket;
use pocketmine\network\mcpe\protocol\SetDifficultyPacket;
use pocketmine\network\mcpe\protocol\SetDisplayObjectivePacket;
use pocketmine\network\mcpe\protocol\SetEntityDataPacket;
use pocketmine\network\mcpe\protocol\SetEntityLinkPacket;
use pocketmine\network\mcpe\protocol\SetEntityMotionPacket;
use pocketmine\network\mcpe\protocol\SetHealthPacket;
use pocketmine\network\mcpe\protocol\SetLastHurtByPacket;
use pocketmine\network\mcpe\protocol\SetPlayerGameTypePacket;
use pocketmine\network\mcpe\protocol\SetScorePacket;
use pocketmine\network\mcpe\protocol\SetSpawnPositionPacket;
use pocketmine\network\mcpe\protocol\SetTimePacket;
use pocketmine\network\mcpe\protocol\SetTitlePacket;
@ -126,6 +130,7 @@ use pocketmine\network\mcpe\protocol\TextPacket;
use pocketmine\network\mcpe\protocol\TransferPacket;
use pocketmine\network\mcpe\protocol\UpdateAttributesPacket;
use pocketmine\network\mcpe\protocol\UpdateBlockPacket;
use pocketmine\network\mcpe\protocol\UpdateBlockSyncedPacket;
use pocketmine\network\mcpe\protocol\UpdateEquipPacket;
use pocketmine\network\mcpe\protocol\UpdateTradePacket;
use pocketmine\network\mcpe\protocol\WSConnectPacket;
@ -554,4 +559,24 @@ abstract class NetworkSession{
return false;
}
public function handleRemoveObjective(RemoveObjectivePacket $packet) : bool{
return false;
}
public function handleSetDisplayObjective(SetDisplayObjectivePacket $packet) : bool{
return false;
}
public function handleSetScore(SetScorePacket $packet) : bool{
return false;
}
public function handleLabTable(LabTablePacket $packet) : bool{
return false;
}
public function handleUpdateBlockSynced(UpdateBlockSyncedPacket $packet) : bool{
return false;
}
}

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;
}

File diff suppressed because one or more lines are too long