Update Door after changing state of lever

Discussion in 'Plugin Development' started by milli727, Feb 11, 2019 at 8:32 AM.

  1. Offline

    milli727

    Hello,
    I am currently working on a roleplay plugin. There are doors, that can be bought. If you press on your door, a lever behind it will be activated. The lever actually updates but the door won't.
    My code:
    Code:
    Location b1 = block.getLocation(); // block is door
    Location Switch = getSwitch(b1);  // gets the lever position (succesfully)
    [...]
    Block targetSwitch = Switch.getBlock();
    BlockState state = targetSwitch.getState();
    Lever lever = (Lever) state.getData();
    lever.setPowered(true);
    state.setData(lever);
    state.update(true);
    [...]

    I've tried following so far:
    1. Door update
      Code:
      block.getState().update(true);
    2. Update the block under the upper door block
    3. Get the Door as door and set it to "open(true)" and then update it
    Sadly, none of these tries open the door and keep it open.
    (The lever opens the door if you press it ingame)

    Thank you for any help
     
  2. Offline

    DerDonut

    Take a look at this thread.
     
  3. Offline

    milli727

    This does not work. No errors appear, door still does not open.
     
  4. Offline

    DerDonut

    with block.setData((byte) someDigitHere);
    you can modify the door. But there are many possible states so doing it this way works but you have to find a good way to do it. (Try it you'll see what I mean)
     

Share This Page