Solved Get location where a block would be placed.

Discussion in 'Plugin Development' started by DIB1206, Jul 9, 2015.

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

    DIB1206

    Hey there, I'm trying to make a plugin where right clicking with a stick will place a water block much in the same way as a bucket would.

    My problem is the only thing I've managed to do so far is replace the block I'm currently looking at and I need to place the block against the block face I'm looking at. Please help me! :D

    EDIT:
    Ah, I found a solution to this.

    Code:
    BlockFace blockFace = e.getBlockFace();
    e.getClickedBlock().getRelative(blockFace).setType(Material.GLASS);
    
    Using .getRelative with the blockface you clicked it gets the block I was looking for. I'm suprised that I couldn't find this anywhere else on the forums!
     
    Last edited: Jul 9, 2015
  2. Moved to Plugin Development and marked as Solved.
     
Thread Status:
Not open for further replies.

Share This Page