Dispenser direction on block place

Discussion in 'Plugin Development' started by BR3TON, Feb 7, 2014.

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

    BR3TON

    I am trying to get the direction of a dispenser on block place but the direction is always south on the event. However anytime after this will show the correct direction of the block.

    Any ideas?
     
  2. Offline

    Squid_Boss

    This should get the rotation:
    Code:java
    1. Location dispenser = new Location(Bukkit.getWorld("world"), 1, 1, 1);
    2. BlockState state = leaderhead1.getBlock().getState();
    3. if (state instanceof Dispenser) {
    4. Dispenser d = (Dispenser) state;
    5. String blockface = d.getRotation();
    6. //Use the String blockface however you'd like
    7. }

    Haven't tested, but it should work.
     
  3. Offline

    BR3TON

    This would return the same state as previous. The problem isn't that I can't get the state, the problem is that on block place Bukkit returns its default state rather than the actual state. If I try and get the state of the block on any other event after its placed it returns the correct state.
     
  4. Offline

    xTrollxDudex

    BR3TON
    So what you are saying is that you are trying to prevent the lag that happens when the block is placed to prevent the small "flip" to the correct direction, right?
     
  5. Offline

    BR3TON

    I'm trying to get the direction of the dispenser as it is placed.
     
  6. Offline

    xTrollxDudex

    BR3TON
    The dispenser is updated after BlockPlaceEvent is fired, put your task to a 1 or 2 tick delay.
     
  7. Offline

    BR3TON

    I'll try that thanks.
     
Thread Status:
Not open for further replies.

Share This Page