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

getBlockAgainst

Comments in 'Plugin Development' started by udwarf, Jun 5, 2016.

  1. udwarf
    Offline

    udwarf Active Member

    Joined:
    Apr 17, 2016
    Posts:
    61
    Minecraft User:
    1Zaza
    Can anyone please explain what returns getBlockAgainst method in onBlockPlaceEvent handler?
    I'm understand that if I'm placing stone block instead of water block then
    $event->getBlock() will be Stone,
    $event->getBlockReplaced() will be Water,
    but what the meaning of $event->getBlockAgainst() ?
  2. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    Just var_dump it to see what it returns
    PHP:
    var_dump($event->getBlockAgainst())
    I assuime it would return the block you tapped when placing the block.
    Primus likes this.
  3. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    True, function will return a instance of Block which player tapped in order to place the block.

    Theoretically the return should be equal to
    PHP:
    PlayerInteractEvent::getBlock()
    and (If you are not using "Split controls")
    PHP:
    // 6 is how far player can break blocks (not sure about place, yet).
    Player::getTargetBlock(6, [0])

Share This Page

Advertisement