How to get the F coordinate!

Discussion in 'Resources' started by Eats_Rainbows, Jul 16, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    Eats_Rainbows

    I've always tinkered with this, but never got it... So, I went into the client code and saw how the Mojang Developers did it and converted it over to something you can use in Bukkit.

    Code:
    public int getF(Player player) {
        double d = (player.getLocation().getYaw() * 4.0F / 360.0F) + 0.5D;
        int i = (int) d;
        return d < i ? i - 1 : i;
    }
    This doesn't have very many uses, but I thought it was sorta cool... ;D
     
    DJSkepter, Phasesaber, Jozeth and 2 others like this.
  2. Offline

    chasechocolate

    Ah, I was wondering when this would get posted. I used this in a /compass command before. For anyone who doesn't know, the F coordinate is the direction you are facing; 0 = north, 1 = east, 2 = south, 3 = west (correct me if I am wrong).
     
    Hoolean and Minecrell like this.
  3. Offline

    Eats_Rainbows

    You're correct! I also find it weird that this hasn't been posted before..
     
  4. Offline

    Loogeh

    Eats_Rainbows likes this.
  5. Offline

    chasechocolate

    Loogeh and west/east swapped :p
     
    Eats_Rainbows likes this.
  6. Offline

    Loogeh

  7. Offline

    Zarkopafilis

    Im kindof confused.... An int cast is supposed to floor the number.
    How can d < i be true?
     
  8. Offline

    Deleted user

  9. Offline

    Zarkopafilis

  10. Offline

    AoH_Ruthless

    Zarkopafilis
    It can't. Remember that this code is obfuscated: it's purposely made to look more confusing than it actually is. So, while the code could say 'return (int) d;', which would be more logical, it looks more confusing to define a new integer and a have a ternary operator like that.. you just have to be careful and know your Java stuff when working with obfuscated code. When something looks funky, that's because it most likely is.
     
    Zarkopafilis likes this.
  11. Offline

    Zarkopafilis

    Oh yes.... i forgot that :D
     
Thread Status:
Not open for further replies.

Share This Page