diff --git a/src/Player.php b/src/Player.php index 5b7b3ac0..79a86ac6 100644 --- a/src/Player.php +++ b/src/Player.php @@ -963,7 +963,7 @@ class Player{ break; }elseif($target->class === ENTITY_PLAYER and ($this->server->api->getProperty("pvp") == false or $this->server->difficulty <= 0 or ($target->player->gamemode & 0x01) === 0x01)){ break; - }elseif($this->handle("player.interact", $data) !== false){ + }elseif($this->server->handle("player.interact", $data) !== false){ switch($this->equipment->getID()){ case WOODEN_SWORD: case GOLD_SWORD: @@ -1223,7 +1223,7 @@ class Player{ }*/ $inv = array(); foreach($this->inventory as $s => $data){ - if($data[0] > 0 and $data[2] >= 0){ + if($data[0] > AIR and $data[2] >= 0){ $inv[] = BlockAPI::getItem($data[0], $data[1], $data[2]); }else{ $inv[] = BlockAPI::getItem(AIR, 0, 0); diff --git a/src/network/CustomPacketHandler.php b/src/network/CustomPacketHandler.php index fffe9056..079a5981 100644 --- a/src/network/CustomPacketHandler.php +++ b/src/network/CustomPacketHandler.php @@ -32,7 +32,7 @@ class CustomPacketHandler{ public $data; public $name = ""; - private function get($len = true, $check = true){ + public function get($len = true, $check = true){ if($len === true){ $data = substr($this->raw, $this->offset); if($check === true){ @@ -600,14 +600,14 @@ class CustomPacketHandler{ $this->data["count"] = Utils::readShort($this->get(2), false); $this->data["slots"] = array(); for($s = 0; $s < $this->data["count"]; ++$s){ - $this->data["slots"][$s] = Utils::readSlot($this->get(5)); + $this->data["slots"][$s] = Utils::readSlot($this); } if($this->data["windowid"] === 1){ //Armor is also sent $this->data["armor"] = array( - Utils::readSlot($this->get(5)), - Utils::readSlot($this->get(5)), - Utils::readSlot($this->get(5)), - Utils::readSlot($this->get(5)) + Utils::readSlot($this), + Utils::readSlot($this), + Utils::readSlot($this), + Utils::readSlot($this) ); } }else{ @@ -681,7 +681,7 @@ class CustomPacketHandler{ $this->data["count"] = Utils::readShort($this->get(2), false); $this->data["slots"] = array(); for($s = 0; $s < $this->data["count"]; ++$s){ - $this->data["slots"][$s] = Utils::readSlot($this->get(5)); + $this->data["slots"][$s] = Utils::readSlot($this); } }else{ $this->raw .= chr($this->data["windowid"]); diff --git a/src/utils/Utils.php b/src/utils/Utils.php index c6ccb8b1..a38f53c0 100644 --- a/src/utils/Utils.php +++ b/src/utils/Utils.php @@ -155,11 +155,13 @@ class Utils{ return Utils::writeShort($item->getID()).chr($item->count).Utils::writeShort($item->getMetadata()); } - public static function readSlot($str){ + public static function readSlot($ob){ + $id = Utils::readShort($ob->get(2)); + $cnt = ord($ob->get(1)); return BlockAPI::getItem( - Utils::readShort(substr($str, 0, 2), false), - Utils::readShort(substr($str, 3, 2), false), - ord($str{2}) + $id, + Utils::readShort($ob->get(2)), + $cnt ); }