mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 08:44:01 +00:00
StructureBlockUpdatePacket: Added encode/decode (#3148)
This commit is contained in:
parent
0d5164af02
commit
a5ba570fdf
@ -40,6 +40,7 @@ use pocketmine\network\mcpe\protocol\types\EntityLink;
|
||||
use pocketmine\network\mcpe\protocol\types\SkinAnimation;
|
||||
use pocketmine\network\mcpe\protocol\types\SkinData;
|
||||
use pocketmine\network\mcpe\protocol\types\SkinImage;
|
||||
use pocketmine\network\mcpe\protocol\types\StructureEditorData;
|
||||
use pocketmine\network\mcpe\protocol\types\StructureSettings;
|
||||
use pocketmine\utils\BinaryStream;
|
||||
use pocketmine\utils\UUID;
|
||||
@ -655,6 +656,7 @@ class NetworkBinaryStream extends BinaryStream{
|
||||
$result->mirror = $this->getByte();
|
||||
$result->integrityValue = $this->getFloat();
|
||||
$result->integritySeed = $this->getInt();
|
||||
$result->pivot = $this->getVector3();
|
||||
|
||||
return $result;
|
||||
}
|
||||
@ -673,5 +675,34 @@ class NetworkBinaryStream extends BinaryStream{
|
||||
$this->putByte($structureSettings->mirror);
|
||||
$this->putFloat($structureSettings->integrityValue);
|
||||
$this->putInt($structureSettings->integritySeed);
|
||||
$this->putVector3($structureSettings->pivot);
|
||||
}
|
||||
|
||||
protected function getStructureEditorData() : StructureEditorData{
|
||||
$result = new StructureEditorData();
|
||||
|
||||
$result->structureName = $this->getString();
|
||||
$result->structureDataField = $this->getString();
|
||||
|
||||
$result->includePlayers = $this->getBool();
|
||||
$result->showBoundingBox = $this->getBool();
|
||||
|
||||
$result->structureBlockType = $this->getVarInt();
|
||||
$result->structureSettings = $this->getStructureSettings();
|
||||
$result->structureRedstoneSaveMove = $this->getVarInt();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function putStructureEditorData(StructureEditorData $structureEditorData) : void{
|
||||
$this->putString($structureEditorData->structureName);
|
||||
$this->putString($structureEditorData->structureDataField);
|
||||
|
||||
$this->putBool($structureEditorData->includePlayers);
|
||||
$this->putBool($structureEditorData->showBoundingBox);
|
||||
|
||||
$this->putVarInt($structureEditorData->structureBlockType);
|
||||
$this->putStructureSettings($structureEditorData->structureSettings);
|
||||
$this->putVarInt($structureEditorData->structureRedstoneSaveMove);
|
||||
}
|
||||
}
|
||||
|
@ -26,16 +26,32 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\protocol\types\StructureEditorData;
|
||||
|
||||
class StructureBlockUpdatePacket extends DataPacket{
|
||||
class StructureBlockUpdatePacket extends DataPacket/* implements ServerboundPacket*/{
|
||||
public const NETWORK_ID = ProtocolInfo::STRUCTURE_BLOCK_UPDATE_PACKET;
|
||||
|
||||
/** @var int */
|
||||
public $x;
|
||||
/** @var int */
|
||||
public $y;
|
||||
/** @var int */
|
||||
public $z;
|
||||
/** @var StructureEditorData */
|
||||
public $structureEditorData;
|
||||
/** @var bool */
|
||||
public $isPowered;
|
||||
|
||||
protected function decodePayload(){
|
||||
//TODO
|
||||
$this->getBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->structureEditorData = $this->getStructureEditorData();
|
||||
$this->isPowered = $this->getBool();
|
||||
}
|
||||
|
||||
protected function encodePayload(){
|
||||
//TODO
|
||||
$this->putBlockPosition($this->x, $this->y, $this->z);
|
||||
$this->putStructureEditorData($this->structureEditorData);
|
||||
$this->putBool($this->isPowered);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
|
@ -0,0 +1,48 @@
|
||||
<?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;
|
||||
|
||||
class StructureEditorData{
|
||||
public const TYPE_DATA = 0;
|
||||
public const TYPE_SAVE = 1;
|
||||
public const TYPE_LOAD = 2;
|
||||
public const TYPE_CORNER = 3;
|
||||
public const TYPE_INVALID = 4;
|
||||
public const TYPE_EXPORT = 5;
|
||||
|
||||
/** @var string */
|
||||
public $structureName;
|
||||
/** @var string */
|
||||
public $structureDataField;
|
||||
/** @var bool */
|
||||
public $includePlayers;
|
||||
/** @var bool */
|
||||
public $showBoundingBox;
|
||||
/** @var int */
|
||||
public $structureBlockType;
|
||||
/** @var StructureSettings */
|
||||
public $structureSettings;
|
||||
/** @var int */
|
||||
public $structureRedstoneSaveMove;
|
||||
}
|
@ -23,6 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol\types;
|
||||
|
||||
use pocketmine\math\Vector3;
|
||||
|
||||
class StructureSettings{
|
||||
/** @var string */
|
||||
public $paletteName;
|
||||
@ -52,4 +54,6 @@ class StructureSettings{
|
||||
public $integrityValue;
|
||||
/** @var int */
|
||||
public $integritySeed;
|
||||
/** @var Vector3 */
|
||||
public $pivot;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user