fixing ClientboundMapItemDataPacket

This commit is contained in:
Dylan K. Taylor 2017-09-02 18:22:53 +01:00
parent a6c0f1512c
commit 9f44b2ed75

View File

@ -48,6 +48,9 @@ class ClientboundMapItemDataPacket extends DataPacket{
public $eids = [];
/** @var int */
public $scale;
/** @var int[] */
public $decorationEntityUniqueIds = [];
/** @var array */
public $decorations = [];
@ -79,17 +82,18 @@ class ClientboundMapItemDataPacket extends DataPacket{
}
if(($this->type & self::BITFLAG_DECORATION_UPDATE) !== 0){
$count = $this->getUnsignedVarInt();
for($i = 0; $i < $count; ++$i){
$weird = $this->getVarInt();
$this->decorations[$i]["rot"] = $weird & 0x0f;
$this->decorations[$i]["img"] = $weird >> 4;
for($i = 0, $count = $this->getUnsignedVarInt(); $i < $count; ++$i){
$this->decorationEntityUniqueIds[] = $this->getEntityUniqueId();
}
for($i = 0, $count = $this->getUnsignedVarInt(); $i < $count; ++$i){
$this->decorations[$i]["rot"] = $this->getByte();
$this->decorations[$i]["img"] = $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::fromARGB($this->getLInt()); //already BE, don't need to reverse it again
$this->decorations[$i]["color"] = Color::fromABGR($this->getUnsignedVarInt());
}
}
@ -98,6 +102,10 @@ class ClientboundMapItemDataPacket extends DataPacket{
$this->height = $this->getVarInt();
$this->xOffset = $this->getVarInt();
$this->yOffset = $this->getVarInt();
$count = $this->getUnsignedVarInt();
assert($count === $this->width * $this->height);
for($y = 0; $y < $this->height; ++$y){
for($x = 0; $x < $this->width; ++$x){
$this->colors[$y][$x] = Color::fromABGR($this->getUnsignedVarInt());
@ -135,14 +143,21 @@ class ClientboundMapItemDataPacket extends DataPacket{
}
if(($type & self::BITFLAG_DECORATION_UPDATE) !== 0){
$this->putUnsignedVarInt(count($this->decorationEntityUniqueIds));
foreach($this->decorationEntityUniqueIds as $id){
$this->putEntityUniqueId($id);
}
$this->putUnsignedVarInt($decorationCount);
foreach($this->decorations as $decoration){
$this->putVarInt(($decoration["rot"] & 0x0f) | ($decoration["img"] << 4));
$this->putByte($decoration["rot"]);
$this->putByte($decoration["img"]);
$this->putByte($decoration["xOffset"]);
$this->putByte($decoration["yOffset"]);
$this->putString($decoration["label"]);
assert($decoration["color"] instanceof Color);
$this->putLInt($decoration["color"]->toARGB());
$this->putUnsignedVarInt($decoration["color"]->toABGR());
}
}
@ -151,6 +166,9 @@ class ClientboundMapItemDataPacket extends DataPacket{
$this->putVarInt($this->height);
$this->putVarInt($this->xOffset);
$this->putVarInt($this->yOffset);
$this->putUnsignedVarInt($this->width * $this->height); //list count, but we handle it as a 2D array... thanks for the confusion mojang
for($y = 0; $y < $this->height; ++$y){
for($x = 0; $x < $this->width; ++$x){
$this->putUnsignedVarInt($this->colors[$y][$x]->toABGR());