Getting location of player hand

Discussion in 'Plugin Development' started by DarkBladee12, May 19, 2013.

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

    DarkBladee12

    Hey guys, how can I get the location of the player's hand/item in hand? Or is this not possible?
     
  2. DarkBladee12
    You could loop over their inventory slots (1-9) until you find an itemstack matching that in their hand, if there is not already a method for getting the slot.
     
  3. Offline

    zeddio

    DarkBladee12, I dont know how you can get the location of the players hand.. (Why do you want to do that??)

    Adamki11s Yes there is.. ▼
    PHP:
    player.getInventory().getItemInHand();
    OR...
    player.getItemInHand();
    //zeddio :)
     
  4. Offline

    Cybermaxke

    Adamki11s
    You can get the slot by using this method:
    Code:
    public int getItemInHandIndex(Player player) {
        ((CraftPlayer) player).getHandle().inventory.itemInHandIndex;
    }
     
    iPhysX and Adamki11s like this.
  5. zeddio
    I know that, I mean getting the slot index from that ;).
     
  6. Offline

    DarkBladee12

    Adamki11s zeddio I don't want to get the item in the players' hand or something like this... I want to get the location of it in the world, because I want to play some effects at the location of it!

    Does noone have an idea how this could work?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 1, 2016
  7. DarkBladee12
    I'm not sure what you are asking, if the item is in the players hand then you can just use the players location.
     
  8. Offline

    DarkBladee12

    Adamki11s No, this would give me the location of the players' feet...
     
  9. Offline

    slayr288

    DarkBladee12
    Add 0.5 to the y coordinate of the player location?
     
  10. DarkBladee12
    Well obviously just add 1 to the y coordinate, or whatever delta y makes it the players hand location.
     
  11. Use the pitch and yaw and the length of their arm to calculate the position.
     
    TheTinySpider likes this.
  12. Offline

    iPhysX

    Wouldn't adding 1 to the y coordinate of the player, play an effect in his/her groin?
     
  13. Offline

    DarkBladee12

    Adamki11s iPhysX Yeah it's not exactly the location of the players' hand if you just add 1...
     
Thread Status:
Not open for further replies.

Share This Page