mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-14 09:49:50 +00:00
Merge commit '259f0425a9657befcc8ef5f474ecc24ec78042fa'
This commit is contained in:
commit
5be45dd793
@ -28,6 +28,7 @@ namespace pocketmine\network\mcpe\protocol;
|
|||||||
use pocketmine\network\BadPacketException;
|
use pocketmine\network\BadPacketException;
|
||||||
use pocketmine\network\mcpe\handler\PacketHandler;
|
use pocketmine\network\mcpe\handler\PacketHandler;
|
||||||
use pocketmine\network\mcpe\protocol\types\DimensionIds;
|
use pocketmine\network\mcpe\protocol\types\DimensionIds;
|
||||||
|
use pocketmine\network\mcpe\protocol\types\MapDecoration;
|
||||||
use pocketmine\network\mcpe\protocol\types\MapTrackedObject;
|
use pocketmine\network\mcpe\protocol\types\MapTrackedObject;
|
||||||
use pocketmine\utils\Color;
|
use pocketmine\utils\Color;
|
||||||
use function assert;
|
use function assert;
|
||||||
@ -58,7 +59,7 @@ class ClientboundMapItemDataPacket extends DataPacket implements ClientboundPack
|
|||||||
|
|
||||||
/** @var MapTrackedObject[] */
|
/** @var MapTrackedObject[] */
|
||||||
public $trackedEntities = [];
|
public $trackedEntities = [];
|
||||||
/** @var array */
|
/** @var MapDecoration[] */
|
||||||
public $decorations = [];
|
public $decorations = [];
|
||||||
|
|
||||||
/** @var int */
|
/** @var int */
|
||||||
@ -104,13 +105,13 @@ class ClientboundMapItemDataPacket extends DataPacket implements ClientboundPack
|
|||||||
}
|
}
|
||||||
|
|
||||||
for($i = 0, $count = $this->getUnsignedVarInt(); $i < $count; ++$i){
|
for($i = 0, $count = $this->getUnsignedVarInt(); $i < $count; ++$i){
|
||||||
$this->decorations[$i]["img"] = $this->getByte();
|
$icon = $this->getByte();
|
||||||
$this->decorations[$i]["rot"] = $this->getByte();
|
$rotation = $this->getByte();
|
||||||
$this->decorations[$i]["xOffset"] = $this->getByte();
|
$xOffset = $this->getByte();
|
||||||
$this->decorations[$i]["yOffset"] = $this->getByte();
|
$yOffset = $this->getByte();
|
||||||
$this->decorations[$i]["label"] = $this->getString();
|
$label = $this->getString();
|
||||||
|
$color = Color::fromRGBA(Binary::flipIntEndianness($this->getUnsignedVarInt()));
|
||||||
$this->decorations[$i]["color"] = Color::fromRGBA(Binary::flipIntEndianness($this->getUnsignedVarInt()));
|
$this->decorations[] = new MapDecoration($icon, $rotation, $xOffset, $yOffset, $label, $color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,14 +178,12 @@ class ClientboundMapItemDataPacket extends DataPacket implements ClientboundPack
|
|||||||
|
|
||||||
$this->putUnsignedVarInt($decorationCount);
|
$this->putUnsignedVarInt($decorationCount);
|
||||||
foreach($this->decorations as $decoration){
|
foreach($this->decorations as $decoration){
|
||||||
$this->putByte($decoration["img"]);
|
$this->putByte($decoration->getIcon());
|
||||||
$this->putByte($decoration["rot"]);
|
$this->putByte($decoration->getRotation());
|
||||||
$this->putByte($decoration["xOffset"]);
|
$this->putByte($decoration->getXOffset());
|
||||||
$this->putByte($decoration["yOffset"]);
|
$this->putByte($decoration->getYOffset());
|
||||||
$this->putString($decoration["label"]);
|
$this->putString($decoration->getLabel());
|
||||||
|
$this->putUnsignedVarInt(Binary::flipIntEndianness($decoration->getColor()->toRGBA()));
|
||||||
assert($decoration["color"] instanceof Color);
|
|
||||||
$this->putUnsignedVarInt(Binary::flipIntEndianness($decoration["color"]->toRGBA()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
74
src/network/mcpe/protocol/types/MapDecoration.php
Normal file
74
src/network/mcpe/protocol/types/MapDecoration.php
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
<?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\Color;
|
||||||
|
|
||||||
|
class MapDecoration{
|
||||||
|
/** @var int */
|
||||||
|
private $icon;
|
||||||
|
/** @var int */
|
||||||
|
private $rotation;
|
||||||
|
/** @var int */
|
||||||
|
private $xOffset;
|
||||||
|
/** @var int */
|
||||||
|
private $yOffset;
|
||||||
|
/** @var string */
|
||||||
|
private $label;
|
||||||
|
/** @var Color */
|
||||||
|
private $color;
|
||||||
|
|
||||||
|
public function __construct(int $icon, int $rotation, int $xOffset, int $yOffset, string $label, Color $color){
|
||||||
|
$this->icon = $icon;
|
||||||
|
$this->rotation = $rotation;
|
||||||
|
$this->xOffset = $xOffset;
|
||||||
|
$this->yOffset = $yOffset;
|
||||||
|
$this->label = $label;
|
||||||
|
$this->color = $color;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getIcon() : int{
|
||||||
|
return $this->icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getRotation() : int{
|
||||||
|
return $this->rotation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getXOffset() : int{
|
||||||
|
return $this->xOffset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getYOffset() : int{
|
||||||
|
return $this->yOffset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getLabel() : string{
|
||||||
|
return $this->label;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getColor() : Color{
|
||||||
|
return $this->color;
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user