Get ItemFrame's location?

Discussion in 'Plugin Development' started by Door Knob, Aug 17, 2013.

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

    Door Knob

    Hi there! I've been having lots of trouble with logging broken item frames. I can log the frame itself and the data, but not the location. getLocation() logs the location of the block in front of the ItemFrame. That's not a correct position for the block... Any help?
    Here's the code that I use to log ItemFrame locations:
    Code:java
    1. @EventHandler
    2. public void onPlayerDestroyFrame(HangingBreakByEntityEvent e) {
    3. Hanging block = e.getEntity();
    4. System.out.println("broke a hanging thingy (" + block.getType().getName() + ")");
    5. if (block instanceof ItemFrame) {
    6. System.out.println("actually, broke an item frame.");
    7. ItemFrame item = (ItemFrame)e.getEntity();
    8. if (matchStarted) {
    9. System.out.println("Match was started");
    10. brokenIF.add(item);
    11. System.out.println("LOGGED ITEM FRAME");
    12. locIF.add(item.getLocation());
    13. System.out.println("LOGGED LOCATION");
    14. }
    15. }
    16. }


    I debugged to the max to see if there was anything wrong, but nope.
     
  2. Offline

    Lactem

    .getLocation().toString()?
     
  3. Offline

    Door Knob

    No, .getLocation() gets the literal block that the itemframe is IN, not ON. I need to get the block behind the itemframe.
     
  4. Offline

    Lactem

    .getLocation().add(-1, 0, 0); will get the block that is one behind it in the x direction. (That or there might be a .subtract().)
     
  5. Offline

    Door Knob

    there is a .substract(), but I'm not only looking for one position. Please, read my post. I have a multitude of ItemFrames, and I need them to be logged when they get broken.
     
  6. Offline

    Lactem

    So you're saying that getting the location of the ItemFrame actually gets the location of another block? Sounds like a bug to me.
     
  7. Offline

    Door Knob

    No, it doesn't get the location of another block. It gets the block that the item frame is IN and not hanging ON...

    edit;
    thinking about it, yes, it does get the location of another block.
    I think I could figure out some clever way to detect which way I should substract from the ItemFrame pos.
    Like, if the frame's facing direction is north, remove like 1 from Z or something idk something like that
     
  8. Offline

    Lactem

    Well if it's not getting the location of the ItemFrame, then I don't know what to tell you.
     
  9. Offline

    Door Knob

    Exactly, I'm looking for someone who knows what to tell me :)

    It seems like I'm the only one having trouble with getting ItemFrame locations.. god damn it
     
Thread Status:
Not open for further replies.

Share This Page