From 129e099f88102cf87718f749ffe2f912492c440c Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Fri, 7 Jun 2013 20:32:38 +0200 Subject: [PATCH] Fixed Entity metadata sending, sheeps on fire --- src/network/CustomPacketHandler.php | 12 ++++++++++++ src/utils/Utils.php | 2 +- src/world/Entity.php | 2 ++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/network/CustomPacketHandler.php b/src/network/CustomPacketHandler.php index 81cf29af0e..d1cc1bcb72 100644 --- a/src/network/CustomPacketHandler.php +++ b/src/network/CustomPacketHandler.php @@ -223,6 +223,8 @@ class CustomPacketHandler{ $this->data["x"] = Utils::readFloat($this->get(4)); $this->data["y"] = Utils::readFloat($this->get(4)); $this->data["z"] = Utils::readFloat($this->get(4)); + $this->data["pitch"] = Utils::readByte($this->get(1)); + $this->data["yaw"] = Utils::readByte($this->get(1)); $this->data["metadata"] = Utils::readMetadata($this->get(true)); }else{ $this->raw .= Utils::writeInt($this->data["eid"]); @@ -230,6 +232,8 @@ class CustomPacketHandler{ $this->raw .= Utils::writeFloat($this->data["x"]); $this->raw .= Utils::writeFloat($this->data["y"]); $this->raw .= Utils::writeFloat($this->data["z"]); + $this->raw .= Utils::writeByte($this->data["pitch"]); + $this->raw .= Utils::writeByte($this->data["yaw"]); $this->raw .= Utils::writeMetadata($this->data["metadata"]); } break; @@ -241,6 +245,10 @@ class CustomPacketHandler{ $this->data["x"] = Utils::readFloat($this->get(4)); $this->data["y"] = Utils::readFloat($this->get(4)); $this->data["z"] = Utils::readFloat($this->get(4)); + $this->data["pitch"] = Utils::readByte($this->get(1)); + $this->data["yaw"] = Utils::readByte($this->get(1)); + $this->data["unknown1"] = Utils::readShort($this->get(2)); + $this->data["unknown2"] = Utils::readShort($this->get(2)); $this->data["metadata"] = Utils::readMetadata($this->get(true)); }else{ $this->raw .= Utils::writeLong($this->data["clientID"]); @@ -249,6 +257,10 @@ class CustomPacketHandler{ $this->raw .= Utils::writeFloat($this->data["x"]); $this->raw .= Utils::writeFloat($this->data["y"]); $this->raw .= Utils::writeFloat($this->data["z"]); + $this->raw .= Utils::writeByte($this->data["pitch"]); + $this->raw .= Utils::writeByte($this->data["yaw"]); + $this->raw .= Utils::writeShort($this->data["unknown1"]); + $this->raw .= Utils::writeShort($this->data["unknown2"]); $this->raw .= Utils::writeMetadata($this->data["metadata"]); } break; diff --git a/src/utils/Utils.php b/src/utils/Utils.php index ccada9bb83..8479035558 100644 --- a/src/utils/Utils.php +++ b/src/utils/Utils.php @@ -115,7 +115,7 @@ class Utils{ public static function writeMetadata($data){ $m = ""; foreach($data as $bottom => $d){ - $m .= chr(($d["type"] << 5) & (0xE0 | $bottom)); + $m .= chr(($d["type"] << 5) | ($bottom & 0b00011111)); switch($d["type"]){ case 0: $m .= Utils::writeByte($d["value"]); diff --git a/src/world/Entity.php b/src/world/Entity.php index 5ad8fdcf79..42123f2eb9 100644 --- a/src/world/Entity.php +++ b/src/world/Entity.php @@ -603,6 +603,8 @@ class Entity extends Position{ "x" => $this->x, "y" => $this->y, "z" => $this->z, + "yaw" => 0, + "pitch" => 0, "metadata" => $this->getMetadata(), )); $player->dataPacket(MC_SET_ENTITY_MOTION, array(