Solved Dispenser Facing Problem

Discussion in 'Plugin Development' started by ChessIndustries, Oct 21, 2017.

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

    ChessIndustries

    Hey everyone, I am currently making a multiblock plugin and wanted to make a altar for creating items. Basically, it's is a crafting table sorrounded with iron blocks with a dispenser on top and a fence on top of the dispenser. I've already implanted an 'Omni Wrench' and a custom crafting recipe for it so it works by right clicking the . The problem that I have is that I want the dispenser to face up. I tried the
    Code:
    getFace() 
    method but it didn't exactly work. Are there any other alternatives to test if the dispenser is facing up? (I want the function, not an entire plugin)
    Thanks in advance!

    P.S. I'm on mobile right now so just ask if you need an image of what the multiblock looks like, or the error on Eclipse.
    P.S..S How so you display code in java format?
     
  2. @ChessIndustries
    Can you show us the code?

    Also, you can get syntax highlighting using [syntax=java]<your code here>[/syntax]
     
  3. Offline

    ChessIndustries

    Code:java
    1.  
    2. MaterialData d = clicked.getState().getData();
    3. Dispenser disp = (Dispenser) d;
    4. BlockFace face = disp.getFacing();
    5.  
    6.  
    7. if (clicked != null && !clicked.getType().equals(Material.DISPENSER))
    8. return;
    9. if (!e.getAction().equals(Action.RIGHT_CLICK_BLOCK))
    10. return;
    11. if (!p.getItemInHand().equals(Material.STICK))
    12. return;
    13. if (!p.getItemInHand().equals(omniwrench))
    14. return;
    15. if (clicked.getRelative(BlockFace.EAST).getRelative(BlockFace.EAST).getRelative(BlockFace.EAST).getType().equals(Material.RED_ROSE)
    16. && clicked.getRelative(BlockFace.WEST).getRelative(BlockFace.WEST).getRelative(BlockFace.WEST).getType().equals(Material.RED_ROSE))
    17. {
    18. if (clicked.getLocation().subtract(0, 1, 0) == null)
    19. return;
    20.  
    21. Block below = clicked.getLocation().subtract(0, 1, 0).getBlock();
    22. Block above = clicked.getLocation().add(0, 1, 0).getBlock();
    23. if ((below.getType().equals(Material.DISPENSER)) && (face.equals("NORTH")) && ((above.getType().equals(Material.CHEST))));
    24. {
    25.  
    26. {
    27.  

    The face.equals("North") is the issue but I'm not sure how to fix it. I also tried
    Code:
    (clicked.getFace(NORTH))
    
    (clicked is the block that was right clicked on the event)
     
    Last edited: Oct 21, 2017
  4. @ChessIndustries
    Well, use BlockFace.NORTH? so it would be 'face == BlockFace.NORTH' (you can use '==' for enum constants).
     
  5. Offline

    ChessIndustries

    Oh, i thought the getFacing returned just NORTH SOUTH etc. thanks for fixing this!
     
Thread Status:
Not open for further replies.

Share This Page