diff --git a/README.md b/README.md index 1188d2618..b0578dec9 100644 --- a/README.md +++ b/README.md @@ -92,7 +92,7 @@ This list is non exhaustive. - Custom GUI creation - Special blocks (workbench, furnace) - Block metadata -- Player model display (currently without rotation nor animation) +- Player model display (without animation) - Dimensions (like the Nether or the Ender in Minecraft) ([#80](https://github.com/Unarelith/OpenMiner/pull/80)) - World loading/saving (using `/save ` and `/load ` commands, see [#26](https://github.com/Unarelith/OpenMiner/issues/26)) - Texture pack system (partially implemented, see [#34](https://github.com/Unarelith/OpenMiner/issues/34)) diff --git a/source/client/graphics/PlayerBox.cpp b/source/client/graphics/PlayerBox.cpp index b23ac3552..73df1e5b1 100644 --- a/source/client/graphics/PlayerBox.cpp +++ b/source/client/graphics/PlayerBox.cpp @@ -274,6 +274,7 @@ void PlayerBox::draw(gk::RenderTarget &target, gk::RenderStates states) const { // Subtract the camera position - see comment in ClientWorld::draw() gk::Vector3d cameraPosition = m_camera.getDPosition(); states.transform.translate(m_x - cameraPosition.x, m_y - cameraPosition.y, m_z - cameraPosition.z); + states.transform.rotate(m_viewAngleH, gk::Vector3{0, 0, 1}); states.transform *= getTransform(); states.texture = &m_texture; diff --git a/source/client/network/ClientCommandHandler.cpp b/source/client/network/ClientCommandHandler.cpp index 823739e2d..8562bd158 100644 --- a/source/client/network/ClientCommandHandler.cpp +++ b/source/client/network/ClientCommandHandler.cpp @@ -227,6 +227,19 @@ void ClientCommandHandler::setupCallbacks() { } }); + m_client.setCommandCallback(Network::Command::PlayerRotUpdate, [this](Network::Packet &packet) { + float yaw, pitch; + u16 clientId; + packet >> clientId; + packet >> yaw >> pitch; + + if (clientId != m_client.id()) { + auto it = m_playerBoxes.find(clientId); + if (it != m_playerBoxes.end()) + it->second.Player::setRotation(yaw, pitch); + } + }); + m_client.setCommandCallback(Network::Command::PlayerSpawn, [this](Network::Packet &packet) { u16 clientId; gk::Vector3d pos;