Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Iron Door Orientation?

Comments in 'Plugin Development' started by Jazzwhistle, Jun 13, 2016.

  1. Jazzwhistle
    Offline

    Jazzwhistle Notable Member

    Joined:
    Dec 27, 2014
    Posts:
    364
    Minecraft User:
    Awzaw
    Hi, I'm writing a plugin that needs to close iron doors, and to close a door I'm setting the original block to a new iron door. It works, but only for one door orientation.

    $this->block is the door when opened, passed as a Block to my delayed task when it is instantiated. In the task I'm running:

    PHP:
    $this->block->getLevel()->setBlock($this->blockBlock::get(Item::IRON_DOOR_BLOCK));
    or

    PHP:
    $this->block->getLevel()->setBlock(new Vector3($this->block->getX(), $this->block->getY(), $this->block->getZ()), Block::get(Item::IRON_DOOR_BLOCK));
    but it only works for one orientation, for the other it places the door at 90 degrees :-/

    UPDATE: Looking at PM source, is getDamage() the answer? getSide()??

    Thanks for any help, the full code is now at https://github.com/Awzaw/LockIt
    Last edited: Jun 13, 2016
  2. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
  3. Jazzwhistle
    Offline

    Jazzwhistle Notable Member

    Joined:
    Dec 27, 2014
    Posts:
    364
    Minecraft User:
    Awzaw
    I tried using getDamage() to no avail, but I'd like to know how it should be done, and there's no examples I can find.

    Eventually I noticed that if I force players to use the top panel to open the iron door, I can replace the bottom panel in the delayed task and it effectively puts the door back to its initial state. Feels like a hack... but at least it's now working perfectly, in any orientation :)
  4. SOFe
    Offline

    SOFe Banned

    Joined:
    May 28, 2016
    Posts:
    386
    Minecraft User:
    Herobrine
    $block->getSide($side, $steps = 1) returns the Block object that holds information for the block $steps at the $side of $block
    for example, $block->getSide(Vector3::SIDE_NORTH, 2) returns the Block object that holds information for the block 2 blocks at the north of $block

    For a door's damage values, refer to http://minecraft.gamepedia.com/Data_values#Door. However, this may be about PC edition. For Pocket Edition, refer to PocketMine source as @Primus pointed out.
    Jazzwhistle likes this.
  5. Jazzwhistle
    Offline

    Jazzwhistle Notable Member

    Joined:
    Dec 27, 2014
    Posts:
    364
    Minecraft User:
    Awzaw
    Thank you!

Share This Page

Advertisement