Solved Closing a door with a plugin.

Discussion in 'Plugin Development' started by dillyg10, Apr 30, 2013.

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

    dillyg10

    Door class is deprecated.
    Dilly is sad :(.

    Dilly found out how to open doors with this:

    this.rightDoorLoc.getBlock().setData((byte) (this.rightDoorLoc.getBlock().getData() | 0x4));
    Dilly thought logic would dictate that doing the opisite would close the door
    this.rightDoorLoc.getBlock().setData((byte) (this.rightDoorLoc.getBlock().getData() & -0x4));
    Dilly was wrong.
    Dilly is sad :(.

    In all seriousness, I've tried just about everything to get doors to close, anyone have any tricks up their sleve to get this to work?
     
  2. Offline

    gomeow

  3. Offline

    Zach_1919

    dillyg10 I HAVE A SOLUTION

    Code:
    public void onClickDoor(ClickDoorEvent event)
    {
         Use redstone instead...
    }
    
     
  4. Offline

    Tzeentchful

    dillyg10
    I don't think you quite understand fully whats going on here.
    The data for a door is stored in specific bits in a byte. From the minecraft wiki the 0x4 position handles if the door is opened or closed(0 closed, 1 open). So doing an OR bitwise operation on 0x4 will flip into it's open position. So to close it you should try doing an XOR
    Code:java
    1. this.rightDoorLoc.getBlock().setData((byte) (this.rightDoorLoc.getBlock().getData() | 0x4));// Doing an OR will open if it's closed.
    2. this.rightDoorLoc.getBlock().setData((byte) (this.rightDoorLoc.getBlock().getData() ^ 0x4));// Doing an XOR will close if it's open
     
  5. Offline

    dillyg10

    How very specific... how would I power the block though -_-. (and yes this needs to be through a plugin)

    Actually, i did try an XOR

    It ended up only closing 1/2 the door.
    But, I think I just got an idea, maybe an xor on the bottom, and an or on the top will work.

    Also Door class is deprecated, and doesn't work at all :p.

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

    hubeb

    You can get the position of the door then -1 from the y coord and set that block to a redstone block then back to what ever.the previous block was, using bukkit runnables. This should close the opened door
     
  7. Offline

    dillyg10


    That sounds very... buggy and bad...
     
  8. Offline

    hubeb

    Then he could jut get the y and -1 power that block with .setPowered
     
  9. Offline

    dillyg10

    WOOOWOWOWOWOWO Ok, sorry

    I need more sleep, turns out i was setting the wrong data at the wrong loction

    For reference:

    door.getBlock().setData(door.getBlock().getData() ^ 0x4) :).

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 1, 2016
  10. Offline

    hubeb

    Lol gnite
     
Thread Status:
Not open for further replies.

Share This Page