Getting the ItemFrame a player is looking at.

Discussion in 'Plugin Development' started by nuno1212sss, Mar 2, 2014.

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

    nuno1212sss

    Hi I would like to know If you can find out what is the ItemFrame a player is looking at(REMEMBER ITEMFRAMES ARE ENTITYS NOT BLOCKS SO .getTargetBlock() DOES NOT WORK!(sorry for caps, just making shore everyone understands)) just need that besides I have everything covered, every single post I found related to this was unsolved so, yhea .
     
  2. Offline

    The Fancy Whale

    just use the getTargetBlock() add or subtract 1 to whatever direction they are looking and check if there is an itemframe there
     
    NathanWolf likes this.
  3. Offline

    nuno1212sss

    The Fancy Whale well that's the thing, I can't do that because I have more than 200 item frames to display and I can't just hard code each and everyone of them, that would take a year ...
     
  4. Offline

    The Fancy Whale

    nuno1212sss I am now very confused. Just get the direction they are looking (Lets say they are at x = 1 looking at the block x = -1) then get the targetblock (Which happens to be at x=-1) then add 1 to that (x=0) and check if there is an itemframe at the x=0 coordinate
     
  5. Offline

    nuno1212sss

    The Fancy Whale Ok I can do that, just 1 problem I forgot how to get the entitys at a certain location ...
     
  6. Offline

    The Fancy Whale

    nuno1212sss Well because the target block is after it you can just do if the block isn't air it must be an item frame
     
  7. Offline

    nuno1212sss

  8. Use getTargetBlock() and keep adding 1 in the direction they are looking using a for loop. Make sure to set a limit so that it doesn't go on forever, something like 8 blocks or so should do. That's basically what The Fancy Whale was trying to say
     
  9. Offline

    NathanWolf

    First get the list of entities in the world or chunk, and when you find the block (as given to you above), then search your list for an item frame entity at that location.
     
    The Fancy Whale likes this.
  10. Offline

    nuno1212sss

    NathanWolf Ty, I sleeped over it and I found that out, good to know that someone get's that ItemFrames are entitys not blocks .-.
     
  11. Offline

    The Fancy Whale

    nuno1212sss I think everyone here understood that...
     
  12. Offline

    Barinade

    Iterate through the blocks, check if there is an entity within a 0.5 range, if there is and it's an itemframe, set an entity variable to that item frame, return the variable after iteration (to get the closest, incase there are more)
     
Thread Status:
Not open for further replies.

Share This Page