Solved Deprecated Door alternative

Discussion in 'Plugin Development' started by Benedikt Wüller, Jul 31, 2013.

Thread Status:
Not open for further replies.
  1. Hey there!
    I want to create a plugin that allows you to open an iron door with a rightclick.
    But I saw that the Door class is deprecated. Is there any other way to set a door's state?
    Maybe manually opening a door or something like that?

    Thank you for answering!
    Please notice I'm not a native speaker.
     
  2. Offline

    Samthelord1

    You can use it although its deprecated. It just doesnt look as appealing in the code
     
  3. From Javadocs: Deprecated. No longer functions. Do not use.

    Benedikt Wüller
    I believe you have to use door halves now.
     
  4. Offline

    Samthelord1

  5. Offline

    kreashenz

    Samthelord1 No longer functions. Do not use.
    No longer functions. Do not use.
    Now can you see it?
     
  6. Offline

    Samthelord1

    Last edited by a moderator: Jun 3, 2016
  7. How to use door halves? I never did that before...
     
  8. Offline

    fromgate

    Works fine for me. Opens/closes doors, fence gates and trapdoors....
    Code:java
    1.  
    2. public static boolean setOpen (Block b, boolean open){
    3. BlockState state = b.getState();
    4. if (!(state.getData() instanceof Openable)) return false;
    5. Openable om = (Openable) state.getData();
    6. om.setOpen(open);
    7. state.setData((MaterialData) om);
    8. state.update();
    9. return true;
    10. }
    11.  
     
  9. Offline

    clienthax

    I did run into this a while back
    Code:java
    1. Block doorBlock = event.getBlock();
    2. BlockState blockState = doorBlock.getState();
    3. Door door = (Door) blockState.getData();
    4.  
    5. if(door.isTopHalf())
    6. {
    7. //getLogger().info("Need to set flag on bottom half of door, seting block to one down");
    8. doorBlock = event.getEntity().getWorld().getBlockAt(event.getBlock().getLocation().add(0, -1, 0));
    9. blockState = doorBlock.getState();
    10. door = (Door) blockState.getData();
    11. }
    12.  
    13. door.setOpen(true);
    14. blockState.update();
     
Thread Status:
Not open for further replies.

Share This Page