mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 09:56:06 +00:00
Merge branch 'stable'
This commit is contained in:
@ -74,6 +74,7 @@ use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\LevelSoundEventPacketV1;
|
||||
use pocketmine\network\mcpe\protocol\LevelSoundEventPacketV2;
|
||||
use pocketmine\network\mcpe\protocol\LoginPacket;
|
||||
use pocketmine\network\mcpe\protocol\MapCreateLockedCopyPacket;
|
||||
use pocketmine\network\mcpe\protocol\MapInfoRequestPacket;
|
||||
use pocketmine\network\mcpe\protocol\MobArmorEquipmentPacket;
|
||||
use pocketmine\network\mcpe\protocol\MobEffectPacket;
|
||||
@ -86,6 +87,7 @@ use pocketmine\network\mcpe\protocol\MovePlayerPacket;
|
||||
use pocketmine\network\mcpe\protocol\NetworkChunkPublisherUpdatePacket;
|
||||
use pocketmine\network\mcpe\protocol\NetworkStackLatencyPacket;
|
||||
use pocketmine\network\mcpe\protocol\NpcRequestPacket;
|
||||
use pocketmine\network\mcpe\protocol\OnScreenTextureAnimationPacket;
|
||||
use pocketmine\network\mcpe\protocol\PhotoTransferPacket;
|
||||
use pocketmine\network\mcpe\protocol\PlayerActionPacket;
|
||||
use pocketmine\network\mcpe\protocol\PlayerHotbarPacket;
|
||||
@ -650,4 +652,12 @@ abstract class SessionHandler{
|
||||
public function handleVideoStreamConnect(VideoStreamConnectPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleMapCreateLockedCopy(MapCreateLockedCopyPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleOnScreenTextureAnimation(OnScreenTextureAnimationPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
@ -50,6 +50,8 @@ class ClientboundMapItemDataPacket extends DataPacket implements ClientboundPack
|
||||
public $type;
|
||||
/** @var int */
|
||||
public $dimensionId = DimensionIds::OVERWORLD;
|
||||
/** @var bool */
|
||||
public $isLocked = false;
|
||||
|
||||
/** @var int[] */
|
||||
public $eids = [];
|
||||
@ -76,6 +78,7 @@ class ClientboundMapItemDataPacket extends DataPacket implements ClientboundPack
|
||||
$this->mapId = $this->getEntityUniqueId();
|
||||
$this->type = $this->getUnsignedVarInt();
|
||||
$this->dimensionId = $this->getByte();
|
||||
$this->isLocked = $this->getBool();
|
||||
|
||||
if(($this->type & 0x08) !== 0){
|
||||
$count = $this->getUnsignedVarInt();
|
||||
@ -148,6 +151,7 @@ class ClientboundMapItemDataPacket extends DataPacket implements ClientboundPack
|
||||
|
||||
$this->putUnsignedVarInt($type);
|
||||
$this->putByte($this->dimensionId);
|
||||
$this->putBool($this->isLocked);
|
||||
|
||||
if(($type & 0x08) !== 0){ //TODO: find out what these are for
|
||||
$this->putUnsignedVarInt($eidsCount);
|
||||
|
@ -78,6 +78,7 @@ class CraftingDataPacket extends DataPacket implements ClientboundPacket{
|
||||
$entry["output"][] = $this->getSlot();
|
||||
}
|
||||
$entry["uuid"] = $this->getUUID()->toString();
|
||||
$entry["block"] = $this->getString();
|
||||
|
||||
break;
|
||||
case self::ENTRY_SHAPED:
|
||||
@ -95,6 +96,8 @@ class CraftingDataPacket extends DataPacket implements ClientboundPacket{
|
||||
$entry["output"][] = $this->getSlot();
|
||||
}
|
||||
$entry["uuid"] = $this->getUUID()->toString();
|
||||
$entry["block"] = $this->getString();
|
||||
|
||||
break;
|
||||
case self::ENTRY_FURNACE:
|
||||
case self::ENTRY_FURNACE_DATA:
|
||||
@ -103,6 +106,8 @@ class CraftingDataPacket extends DataPacket implements ClientboundPacket{
|
||||
$entry["inputDamage"] = $this->getVarInt();
|
||||
}
|
||||
$entry["output"] = $this->getSlot();
|
||||
$entry["block"] = $this->getString();
|
||||
|
||||
break;
|
||||
case self::ENTRY_MULTI:
|
||||
$entry["uuid"] = $this->getUUID()->toString();
|
||||
@ -141,6 +146,7 @@ class CraftingDataPacket extends DataPacket implements ClientboundPacket{
|
||||
}
|
||||
|
||||
$stream->put(str_repeat("\x00", 16)); //Null UUID
|
||||
$stream->putString("crafting_table"); //TODO: blocktype (no prefix) (this might require internal API breaks)
|
||||
|
||||
return CraftingDataPacket::ENTRY_SHAPELESS;
|
||||
}
|
||||
@ -162,23 +168,21 @@ class CraftingDataPacket extends DataPacket implements ClientboundPacket{
|
||||
}
|
||||
|
||||
$stream->put(str_repeat("\x00", 16)); //Null UUID
|
||||
$stream->putString("crafting_table"); //TODO: blocktype (no prefix) (this might require internal API breaks)
|
||||
|
||||
return CraftingDataPacket::ENTRY_SHAPED;
|
||||
}
|
||||
|
||||
private static function writeFurnaceRecipe(FurnaceRecipe $recipe, NetworkBinaryStream $stream) : int{
|
||||
private static function writeFurnaceRecipe(FurnaceRecipe $recipe, NetworkBinaryStream $stream){
|
||||
$stream->putVarInt($recipe->getInput()->getId());
|
||||
$result = CraftingDataPacket::ENTRY_FURNACE;
|
||||
if(!$recipe->getInput()->hasAnyDamageValue()){ //Data recipe
|
||||
$stream->putVarInt($recipe->getInput()->getId());
|
||||
$stream->putVarInt($recipe->getInput()->getMeta());
|
||||
$stream->putSlot($recipe->getResult());
|
||||
|
||||
return CraftingDataPacket::ENTRY_FURNACE_DATA;
|
||||
}else{
|
||||
$stream->putVarInt($recipe->getInput()->getId());
|
||||
$stream->putSlot($recipe->getResult());
|
||||
|
||||
return CraftingDataPacket::ENTRY_FURNACE;
|
||||
$result = CraftingDataPacket::ENTRY_FURNACE_DATA;
|
||||
}
|
||||
$stream->putSlot($recipe->getResult());
|
||||
$stream->putString("furnace"); //TODO: blocktype (no prefix) (this might require internal API breaks)
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function addShapelessRecipe(ShapelessRecipe $recipe) : void{
|
||||
|
@ -33,6 +33,8 @@ class LecternUpdatePacket extends DataPacket implements ServerboundPacket{
|
||||
/** @var int */
|
||||
public $page;
|
||||
/** @var int */
|
||||
public $totalPages;
|
||||
/** @var int */
|
||||
public $x;
|
||||
/** @var int */
|
||||
public $y;
|
||||
@ -43,12 +45,14 @@ class LecternUpdatePacket extends DataPacket implements ServerboundPacket{
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->page = $this->getByte();
|
||||
$this->totalPages = $this->getByte();
|
||||
$this->getBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->dropBook = $this->getBool();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putByte($this->page);
|
||||
$this->putByte($this->totalPages);
|
||||
$this->putBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->putBool($this->dropBook);
|
||||
}
|
||||
|
@ -218,7 +218,7 @@ class LevelSoundEventPacket extends DataPacket implements ClientboundPacket, Ser
|
||||
public const SOUND_ITEM_TRIDENT_THUNDER = 184;
|
||||
public const SOUND_ITEM_TRIDENT_HIT_GROUND = 185;
|
||||
public const SOUND_DEFAULT = 186;
|
||||
|
||||
public const SOUND_BLOCK_FLETCHING_TABLE_USE = 187;
|
||||
public const SOUND_ELEMCONSTRUCT_OPEN = 188;
|
||||
public const SOUND_ICEBOMB_HIT = 189;
|
||||
public const SOUND_BALLOONPOP = 190;
|
||||
@ -283,7 +283,26 @@ class LevelSoundEventPacket extends DataPacket implements ClientboundPacket, Ser
|
||||
public const SOUND_AMBIENT_AGGRESSIVE = 252;
|
||||
public const SOUND_AMBIENT_WORRIED = 253;
|
||||
public const SOUND_CANT_BREED = 254;
|
||||
public const SOUND_UNDEFINED = 255;
|
||||
public const SOUND_ITEM_SHIELD_BLOCK = 255;
|
||||
public const SOUND_ITEM_BOOK_PUT = 256;
|
||||
public const SOUND_BLOCK_GRINDSTONE_USE = 257;
|
||||
public const SOUND_BLOCK_BELL_HIT = 258;
|
||||
public const SOUND_BLOCK_CAMPFIRE_CRACKLE = 259;
|
||||
public const SOUND_ROAR = 260;
|
||||
public const SOUND_STUN = 261;
|
||||
public const SOUND_BLOCK_SWEET_BERRY_BUSH_HURT = 262;
|
||||
public const SOUND_BLOCK_SWEET_BERRY_BUSH_PICK = 263;
|
||||
public const SOUND_UI_CARTOGRAPHY_TABLE_TAKE_RESULT = 264;
|
||||
public const SOUND_UI_STONECUTTER_TAKE_RESULT = 265;
|
||||
public const SOUND_BLOCK_COMPOSTER_EMPTY = 266;
|
||||
public const SOUND_BLOCK_COMPOSTER_FILL = 267;
|
||||
public const SOUND_BLOCK_COMPOSTER_FILL_SUCCESS = 268;
|
||||
public const SOUND_BLOCK_COMPOSTER_READY = 269;
|
||||
public const SOUND_BLOCK_BARREL_OPEN = 270;
|
||||
public const SOUND_BLOCK_BARREL_CLOSE = 271;
|
||||
public const SOUND_RAID_HORN = 272;
|
||||
public const SOUND_BLOCK_LOOM_USE = 273;
|
||||
public const SOUND_UNDEFINED = 274;
|
||||
|
||||
public static function create(int $sound, ?Vector3 $pos, int $extraData = -1, string $entityType = ":", bool $isBabyMob = false) : self{
|
||||
$result = new self;
|
||||
|
@ -0,0 +1,51 @@
|
||||
<?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\handler\SessionHandler;
|
||||
|
||||
class MapCreateLockedCopyPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::MAP_CREATE_LOCKED_COPY_PACKET;
|
||||
|
||||
/** @var int */
|
||||
public $originalMapId;
|
||||
/** @var int */
|
||||
public $newMapId;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->originalMapId = $this->getEntityUniqueId();
|
||||
$this->newMapId = $this->getEntityUniqueId();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putEntityUniqueId($this->originalMapId);
|
||||
$this->putEntityUniqueId($this->newMapId);
|
||||
}
|
||||
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleMapCreateLockedCopy($this);
|
||||
}
|
||||
}
|
@ -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\handler\SessionHandler;
|
||||
|
||||
class OnScreenTextureAnimationPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::ON_SCREEN_TEXTURE_ANIMATION_PACKET;
|
||||
|
||||
/** @var int */
|
||||
public $effectId;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->effectId = $this->getLInt(); //unsigned
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putLInt($this->effectId);
|
||||
}
|
||||
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleOnScreenTextureAnimation($this);
|
||||
}
|
||||
}
|
@ -156,6 +156,8 @@ class PacketPool{
|
||||
static::registerPacket(new LevelSoundEventPacket());
|
||||
static::registerPacket(new LecternUpdatePacket());
|
||||
static::registerPacket(new VideoStreamConnectPacket());
|
||||
static::registerPacket(new MapCreateLockedCopyPacket());
|
||||
static::registerPacket(new OnScreenTextureAnimationPacket());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -39,15 +39,15 @@ interface ProtocolInfo{
|
||||
/**
|
||||
* Actual Minecraft: PE protocol version
|
||||
*/
|
||||
public const CURRENT_PROTOCOL = 340;
|
||||
public const CURRENT_PROTOCOL = 354;
|
||||
/**
|
||||
* Current Minecraft PE version reported by the server. This is usually the earliest currently supported version.
|
||||
*/
|
||||
public const MINECRAFT_VERSION = 'v1.10.0';
|
||||
public const MINECRAFT_VERSION = 'v1.11.0';
|
||||
/**
|
||||
* Version number sent to clients in ping responses.
|
||||
*/
|
||||
public const MINECRAFT_VERSION_NETWORK = '1.10.0';
|
||||
public const MINECRAFT_VERSION_NETWORK = '1.11.0';
|
||||
|
||||
public const LOGIN_PACKET = 0x01;
|
||||
public const PLAY_STATUS_PACKET = 0x02;
|
||||
@ -174,5 +174,7 @@ interface ProtocolInfo{
|
||||
public const LEVEL_SOUND_EVENT_PACKET = 0x7b;
|
||||
public const LECTERN_UPDATE_PACKET = 0x7c;
|
||||
public const VIDEO_STREAM_CONNECT_PACKET = 0x7d;
|
||||
public const MAP_CREATE_LOCKED_COPY_PACKET = 0x7e;
|
||||
public const ON_SCREEN_TEXTURE_ANIMATION_PACKET = 0x7f;
|
||||
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ class StartGamePacket extends DataPacket implements ClientboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::START_GAME_PACKET;
|
||||
|
||||
/** @var string|null */
|
||||
private static $runtimeIdTable;
|
||||
private static $runtimeIdTableCache;
|
||||
|
||||
/** @var int */
|
||||
public $entityUniqueId;
|
||||
@ -138,6 +138,9 @@ class StartGamePacket extends DataPacket implements ClientboundPacket{
|
||||
/** @var string */
|
||||
public $multiplayerCorrelationId = ""; //TODO: this should be filled with a UUID of some sort
|
||||
|
||||
/** @var array|null each entry must have a "name" (string) and "data" (int16) element */
|
||||
public $runtimeIdTable = null;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->entityUniqueId = $this->getEntityUniqueId();
|
||||
$this->entityRuntimeId = $this->getEntityRuntimeId();
|
||||
@ -189,10 +192,14 @@ class StartGamePacket extends DataPacket implements ClientboundPacket{
|
||||
$this->enchantmentSeed = $this->getVarInt();
|
||||
|
||||
$count = $this->getUnsignedVarInt();
|
||||
$table = [];
|
||||
for($i = 0; $i < $count; ++$i){
|
||||
$this->getString();
|
||||
$this->getLShort();
|
||||
$id = $this->getString();
|
||||
$data = $this->getLShort();
|
||||
|
||||
$table[$i] = ["name" => $id, "data" => $data];
|
||||
}
|
||||
$this->runtimeIdTable = $table;
|
||||
|
||||
$this->multiplayerCorrelationId = $this->getString();
|
||||
}
|
||||
@ -247,22 +254,29 @@ class StartGamePacket extends DataPacket implements ClientboundPacket{
|
||||
|
||||
$this->putVarInt($this->enchantmentSeed);
|
||||
|
||||
if(self::$runtimeIdTable === null){
|
||||
//this is a really nasty hack, but it'll do for now
|
||||
$stream = new NetworkBinaryStream();
|
||||
$data = RuntimeBlockMapping::getBedrockKnownStates();
|
||||
$stream->putUnsignedVarInt(count($data));
|
||||
foreach($data as $v){
|
||||
$stream->putString($v["name"]);
|
||||
$stream->putLShort($v["data"]);
|
||||
if($this->runtimeIdTable === null){
|
||||
if(self::$runtimeIdTableCache === null){
|
||||
//this is a really nasty hack, but it'll do for now
|
||||
self::$runtimeIdTableCache = self::serializeBlockTable(RuntimeBlockMapping::getBedrockKnownStates());
|
||||
}
|
||||
self::$runtimeIdTable = $stream->getBuffer();
|
||||
$this->put(self::$runtimeIdTableCache);
|
||||
}else{
|
||||
$this->put(self::serializeBlockTable($this->runtimeIdTable));
|
||||
}
|
||||
$this->put(self::$runtimeIdTable);
|
||||
|
||||
$this->putString($this->multiplayerCorrelationId);
|
||||
}
|
||||
|
||||
private static function serializeBlockTable(array $table) : string{
|
||||
$stream = new NetworkBinaryStream();
|
||||
$stream->putUnsignedVarInt(count($table));
|
||||
foreach($table as $v){
|
||||
$stream->putString($v["name"]);
|
||||
$stream->putLShort($v["data"]);
|
||||
}
|
||||
return $stream->getBuffer();
|
||||
}
|
||||
|
||||
public function handle(SessionHandler $handler) : bool{
|
||||
return $handler->handleStartGame($this);
|
||||
}
|
||||
|
@ -40,45 +40,45 @@ class UpdateTradePacket extends DataPacket implements ClientboundPacket{
|
||||
/** @var int */
|
||||
public $windowType = WindowTypes::TRADING; //Mojang hardcoded this -_-
|
||||
/** @var int */
|
||||
public $varint1;
|
||||
public $thisIsAlwaysZero = 0; //hardcoded to 0
|
||||
/** @var int */
|
||||
public $varint2;
|
||||
/** @var int */
|
||||
public $varint3;
|
||||
/** @var bool */
|
||||
public $isWilling;
|
||||
public $tradeTier;
|
||||
/** @var int */
|
||||
public $traderEid;
|
||||
/** @var int */
|
||||
public $playerEid;
|
||||
/** @var string */
|
||||
public $displayName;
|
||||
/** @var bool */
|
||||
public $isWilling;
|
||||
/** @var bool */
|
||||
public $isV2Trading;
|
||||
/** @var string */
|
||||
public $offers;
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->windowId = $this->getByte();
|
||||
$this->windowType = $this->getByte();
|
||||
$this->varint1 = $this->getVarInt();
|
||||
$this->varint2 = $this->getVarInt();
|
||||
$this->varint3 = $this->getVarInt();
|
||||
$this->isWilling = $this->getBool();
|
||||
$this->thisIsAlwaysZero = $this->getVarInt();
|
||||
$this->tradeTier = $this->getVarInt();
|
||||
$this->traderEid = $this->getEntityUniqueId();
|
||||
$this->playerEid = $this->getEntityUniqueId();
|
||||
$this->displayName = $this->getString();
|
||||
$this->isWilling = $this->getBool();
|
||||
$this->isV2Trading = $this->getBool();
|
||||
$this->offers = $this->getRemaining();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putByte($this->windowId);
|
||||
$this->putByte($this->windowType);
|
||||
$this->putVarInt($this->varint1);
|
||||
$this->putVarInt($this->varint2);
|
||||
$this->putVarInt($this->varint3);
|
||||
$this->putBool($this->isWilling);
|
||||
$this->putVarInt($this->thisIsAlwaysZero);
|
||||
$this->putVarInt($this->tradeTier);
|
||||
$this->putEntityUniqueId($this->traderEid);
|
||||
$this->putEntityUniqueId($this->playerEid);
|
||||
$this->putString($this->displayName);
|
||||
$this->putBool($this->isWilling);
|
||||
$this->putBool($this->isV2Trading);
|
||||
$this->put($this->offers);
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,8 @@ namespace pocketmine\network\mcpe\protocol\types;
|
||||
|
||||
interface WindowTypes{
|
||||
|
||||
public const NONE = -9;
|
||||
|
||||
public const INVENTORY = -1;
|
||||
public const CONTAINER = 0;
|
||||
public const WORKBENCH = 1;
|
||||
@ -47,4 +49,13 @@ interface WindowTypes{
|
||||
public const COMMAND_BLOCK = 16;
|
||||
public const JUKEBOX = 17;
|
||||
|
||||
public const COMPOUND_CREATOR = 20;
|
||||
public const ELEMENT_CONSTRUCTOR = 21;
|
||||
public const MATERIAL_REDUCER = 22;
|
||||
public const LAB_TABLE = 23;
|
||||
|
||||
public const BLAST_FURNACE = 27;
|
||||
public const SMOKER = 28;
|
||||
public const STONECUTTER = 29;
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user