How to get the side of the block I'm looking at

Discussion in 'Plugin Development' started by WarmakerT, Dec 27, 2014.

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

    WarmakerT

    I have a brick block, let's call it BB.
    Show Spoiler
    [​IMG]


    When I right-click my stone brick block, I want a stone brick to spawn next to the brick block, depending on where I'm looking at. So if I'm looking at the North side of the brick block, it'll replace the air block with a stone brick, and the same thing for South, East, West, Up and Down.

    I've tried some things but I've haven't got anywhere. How would I go about doing this?
     
  2. Offline

    Mysticate

    Check for PlayerInteractEvent, make sure the Action is RightClickBlock. Make sure to do your other necessary checks with the itemInHand().

    Code:
    event.getClickedBlock().getRelative().setType[stuff]
     
  3. Offline

    WarmakerT

    It's from afar, so I have to use player.getTargetBlock(null, 80) and Block.getRelative() is missing a parameter, BlockFace.
     
  4. Offline

    Mysticate

    Ohhh sorry; I just assumed you were right clicking the block. I'm not actually sure how to get the targetted face from that :/
     
  5. Offline

    WarmakerT

    In case someone needs it:
    Code:
    player.getLastTwoTargetBlocks(null, 100).get(0);
     
    Last edited: Jan 6, 2015
Thread Status:
Not open for further replies.

Share This Page