diff --git a/src/API/BlockAPI.php b/src/API/BlockAPI.php index a46688a71..4238043c7 100644 --- a/src/API/BlockAPI.php +++ b/src/API/BlockAPI.php @@ -204,7 +204,7 @@ class BlockAPI{ $data["x"] += mt_rand(2, 8) / 10; $data["y"] += 0.19; $data["z"] += mt_rand(2, 8) / 10; - if($this->server->api->handle("item.drop", $data) !== false){ + if($this->server->api->handle("block.drop", $data) !== false){ for($count = $stack; $count > 0; ){ $data["stack"] = min(64, $count); $count -= $data["stack"]; diff --git a/src/classes/Entity.class.php b/src/classes/Entity.class.php index 7754f72e2..93191cd54 100644 --- a/src/classes/Entity.class.php +++ b/src/classes/Entity.class.php @@ -77,7 +77,7 @@ class Entity extends stdClass{ public function update(){ if($this->class === ENTITY_ITEM and $this->closed === false){ - $this->server->api->dhandle("entity.move", $this->eid); + $this->server->api->dhandle("entity.move", $this); $player = $this->server->query("SELECT EID FROM entities WHERE class == ".ENTITY_PLAYER." AND abs(x - {$this->x}) <= 1.5 AND abs(y - {$this->y}) <= 1.5 AND abs(z - {$this->z}) <= 1.5 LIMIT 1;", true); if($player !== true and $player !== false){ if($this->server->api->dhandle("player.item.pick", array( @@ -163,8 +163,8 @@ class Entity extends stdClass{ public function close(){ if($this->closed === false){ - $this->server->query("DELETE FROM entities WHERE EID = ".$this->eid.";"); - $this->server->api->dhandle("entity.remove", $this->eid); + $this->server->query("DELETE FROM entities WHERE EID = ".$this.";"); + $this->server->api->dhandle("entity.remove", $this); $this->closed = true; $this->__destruct(); } diff --git a/src/classes/Player.class.php b/src/classes/Player.class.php index b4cde1a5b..b1bed3eec 100644 --- a/src/classes/Player.class.php +++ b/src/classes/Player.class.php @@ -129,17 +129,16 @@ class Player{ $this->dataPacket(MC_UPDATE_BLOCK, $data); break; case "entity.move": - if($data === $this->eid){ + if($data->eid === $this->eid){ break; } - $entity = $this->server->entities[$data]; $this->dataPacket(MC_MOVE_ENTITY_POSROT, array( - "eid" => $data, - "x" => $entity->x, - "y" => $entity->y, - "z" => $entity->z, - "yaw" => $entity->yaw, - "pitch" => $entity->pitch, + "eid" => $data->eid, + "x" => $data->x, + "y" => $data->y, + "z" => $data->z, + "yaw" => $data->yaw, + "pitch" => $data->pitch, )); break; case "entity.remove": @@ -241,6 +240,13 @@ class Player{ $this->send(0xc0, array(1, true, $data[0])); } switch($data["id"]){ + + case MC_KEEP_ALIVE: + + break; + case 0x03: + + break; case MC_DISCONNECT: $this->connected = false; $this->close("client disconnect"); @@ -328,7 +334,7 @@ class Player{ case MC_MOVE_PLAYER: if(is_object($this->entity)){ $this->entity->setPosition($data["x"], $data["y"], $data["z"], $data["yaw"], $data["pitch"]); - $this->server->api->dhandle("entity.move", $this->eid); + $this->server->api->dhandle("entity.move", $this->entity); } break; case MC_PLAYER_EQUIPMENT: @@ -359,9 +365,6 @@ class Player{ break; } $this->server->handle("player.block.action", $data); - break; - case MC_PLACE_BLOCK: - break; case MC_REMOVE_BLOCK: $data["eid"] = $this->eid; @@ -388,7 +391,9 @@ class Player{ case MC_DROP_ITEM: $this->server->api->block->drop($this->entity->x, $this->entity->y, $this->entity->z, $data["block"], $data["meta"], $data["stack"]); break; - + default: + console("[INTERNAL] Unhandled 0x".dechex($data["id"])." Data Packet for Client ID ".$this->clientID.": ".print_r($data), true, true, 3); + break; } break; } diff --git a/src/classes/PocketMinecraftServer.class.php b/src/classes/PocketMinecraftServer.class.php index 9673b9a02..c3c500b4a 100644 --- a/src/classes/PocketMinecraftServer.class.php +++ b/src/classes/PocketMinecraftServer.class.php @@ -156,7 +156,7 @@ class PocketMinecraftServer extends stdClass{ $this->chat(false, "Stopping server..."); $this->save(true); $this->stop = true; - $this->trigger("server.close"); + $this->trigger("server.close", $reason); $this->interface->close(); } } diff --git a/src/pstruct/protocol.php b/src/pstruct/protocol.php index b906ca0e2..45ca0d35c 100644 --- a/src/pstruct/protocol.php +++ b/src/pstruct/protocol.php @@ -28,8 +28,6 @@ the Free Software Foundation, either version 3 of the License, or //Protocol Version: 5 -define("MC_KEEP_ALIVE", 0x00); - define("MC_KEEP_ALIVE", 0x00); define("MC_CLIENT_CONNECT", 0x09);