mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 16:51:42 +00:00
ClientboundMapItemDataPacket: replace assoc array with MapDecoration class
I thought I'd done this already, but it appears not.
This commit is contained in:
parent
9cdea43794
commit
259f0425a9
@ -27,6 +27,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\protocol\types\DimensionIds;
|
||||
use pocketmine\network\mcpe\protocol\types\MapDecoration;
|
||||
use pocketmine\network\mcpe\protocol\types\MapTrackedObject;
|
||||
use pocketmine\utils\Color;
|
||||
use function assert;
|
||||
@ -54,7 +55,7 @@ class ClientboundMapItemDataPacket extends DataPacket{
|
||||
|
||||
/** @var MapTrackedObject[] */
|
||||
public $trackedEntities = [];
|
||||
/** @var array */
|
||||
/** @var MapDecoration[] */
|
||||
public $decorations = [];
|
||||
|
||||
/** @var int */
|
||||
@ -100,13 +101,13 @@ class ClientboundMapItemDataPacket extends DataPacket{
|
||||
}
|
||||
|
||||
for($i = 0, $count = $this->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
$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();
|
||||
|
||||
$this->decorations[$i]["color"] = Color::fromABGR($this->getUnsignedVarInt());
|
||||
$icon = $this->getByte();
|
||||
$rotation = $this->getByte();
|
||||
$xOffset = $this->getByte();
|
||||
$yOffset = $this->getByte();
|
||||
$label = $this->getString();
|
||||
$color = Color::fromABGR($this->getUnsignedVarInt());
|
||||
$this->decorations[] = new MapDecoration($icon, $rotation, $xOffset, $yOffset, $label, $color);
|
||||
}
|
||||
}
|
||||
|
||||
@ -173,14 +174,12 @@ class ClientboundMapItemDataPacket extends DataPacket{
|
||||
|
||||
$this->putUnsignedVarInt($decorationCount);
|
||||
foreach($this->decorations as $decoration){
|
||||
$this->putByte($decoration["img"]);
|
||||
$this->putByte($decoration["rot"]);
|
||||
$this->putByte($decoration["xOffset"]);
|
||||
$this->putByte($decoration["yOffset"]);
|
||||
$this->putString($decoration["label"]);
|
||||
|
||||
assert($decoration["color"] instanceof Color);
|
||||
$this->putUnsignedVarInt($decoration["color"]->toABGR());
|
||||
$this->putByte($decoration->getIcon());
|
||||
$this->putByte($decoration->getRotation());
|
||||
$this->putByte($decoration->getXOffset());
|
||||
$this->putByte($decoration->getYOffset());
|
||||
$this->putString($decoration->getLabel());
|
||||
$this->putUnsignedVarInt($decoration->getColor()->toABGR());
|
||||
}
|
||||
}
|
||||
|
||||
|
74
src/pocketmine/network/mcpe/protocol/types/MapDecoration.php
Normal file
74
src/pocketmine/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