Cuberite Forum
m_Player->GetRotation(): always returns 0.000000 - Printable Version

+- Cuberite Forum (https://forum.cuberite.org)
+-- Forum: Cuberite (https://forum.cuberite.org/forum-4.html)
+--- Forum: Development (https://forum.cuberite.org/forum-13.html)
+--- Thread: m_Player->GetRotation(): always returns 0.000000 (/thread-209.html)



m_Player->GetRotation(): always returns 0.000000 - rs2k - 11-03-2011

I'm playing around with getting redstone going and while adding the redstone repeater I noticed that m_Player->GetRotation() always returns 0.000000

I started tracing the problem back and can see that when the PLAYERLOOK and PLAYERMOVELOOK packets are sent, m_Rotation is always 0. I don't know if the client is always sending a 0 or something's wrong with how the program's reading the packets.

right now it's not possible to place redstone repeaters or stairs in the direction you face.


RE: m_Player->GetRotation(): always returns 0.000000 - FakeTruth - 11-04-2011

Let me guess, you were running the game under Linux? I've encountered this before, this is a really weird bug. Minecraft seems to always send 0 for player rotation when running under Linux.


RE: m_Player->GetRotation(): always returns 0.000000 - rs2k - 11-04-2011

(11-04-2011, 12:03 AM)FakeTruth Wrote: Let me guess, you were running the game under Linux? I've encountered this before, this is a really weird bug. Minecraft seems to always send 0 for player rotation when running under Linux.

Yup, 64 bit linux.


RE: m_Player->GetRotation(): always returns 0.000000 - FakeTruth - 11-04-2011

So it has nothing to do with MCServer I think


RE: m_Player->GetRotation(): always returns 0.000000 - rs2k - 11-04-2011

(11-04-2011, 02:26 AM)FakeTruth Wrote: So it has nothing to do with MCServer I think
I found a "fix" for it, but I don't understand it.




adding this to Endianness.h allowed it to read the packet correctly:
(void)printf("",(unsigned long)buf);

Code:
inline float NetworkToHostFloat4( void* a_Value )
{
        u_long buf = *(u_long*)a_Value;
        buf = ntohl( (unsigned long)buf );
        (void)printf("",(unsigned long)buf);
        return *(float*)reinterpret_cast<float *>(&buf);
}


Any ideas? It works, but I don't like not knowing why.


RE: m_Player->GetRotation(): always returns 0.000000 - FakeTruth - 11-04-2011

Interesting, I have no clue why that would fix it


RE: m_Player->GetRotation(): always returns 0.000000 - FakeTruth - 11-05-2011

I changed it again, please try if it works now.
I think it screws up because of optimizations, but this should prevent that from happening.


RE: m_Player->GetRotation(): always returns 0.000000 - rs2k - 11-05-2011

Downloaded and recompiled. Seems to be working just fine. Redstone repeaters and stairs are going the right direction.Big Grin