How do I get the direction a dispenser is facing?

Discussion in 'Plugin Development' started by MrSnare, Mar 22, 2013.

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

    MrSnare

    I was using this code pre-1.5 but it just returns EAST for every direction now. So im looking for another way.

    PHP:
                MaterialData d block.getState().getData();
                
    Dispenser disp = (Dispenserd;
                
    BlockFace face disp.getFacing();
     
  2. Offline

    gomeow

  3. Offline

    MrSnare

  4. Offline

    Splated

    I also need a work around :(
     
  5. Offline

    WolfGangSen

    For now
    you can do it yourself

    put a dispenser in world and make a temporary way to get its data value
    then compare them for the directions and make a case statement like this

    code

    (keep in mind thos values are probably horribly wrong becasue I am just demonstrating my idea
    etc.

    my bad i didnt read the bug repoert properly

    i thought it was the same bug as that all the directions are were wrong all the time beforehand.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
  6. Offline

    Splated

    I got a dirty fix thats mostly working.

    Code:java
    1.  
    2. Dispenser disp = (Dispenser) event.getBlock().getState().getData();
    3.  
    4. BlockFace face = disp.getFacing();
    5.  
    6.  
    7. if (face == BlockFace.EAST){ //temp fix
    8.  
    9.  
    10. if( event.getBlock().getData() == 8) face = BlockFace.DOWN;
    11. if( event.getBlock().getData() == 9) face = BlockFace.UP;
    12. if( event.getBlock().getData() == 10) face = BlockFace.NORTH;
    13. if( event.getBlock().getData() == 11) face = BlockFace.SOUTH;
    14. if( event.getBlock().getData() == 12) face = BlockFace.WEST;
    15. if( event.getBlock().getData() == 13) face = BlockFace.EAST;
    16.  
    17. if( event.getBlock().getData() < 8 || event.getBlock().getData() > 13)
    18. Smart_Items.info("New Direction! " +event.getBlock().getData());
    19.  
    20. }
    21.  
    22. Block target = event.getBlock().getRelative(face);
    23.  



    Every so often I get a "New Direction! 0" in the log i think the values are different for unpowerd.
     
    MrSnare likes this.
Thread Status:
Not open for further replies.

Share This Page