RightClickEvent -> Delete Placed Block

Discussion in 'Plugin Development' started by immapoint, Jan 26, 2011.

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

    immapoint

    Heya,

    im working on a little plugin vor creative servers(again ;D).
    If the player is in the replace mode and right-clicks on a block, the blocks material changes to the material in the players hand. but - the problem is, the item in the players hand is also placed.
    now my question: how to remove this "unnecessary" and put it back into the players itemstack?

    thanks in advance.
    PS: BlockRightClickEvent has no function called setCancelled etc.. ;)
     
  2. Offline

    darknesschaos

    what about checking to see if there is an item in the player's hand, and if it is you cancel placing the block (you will need an BlockPlaced listener of some sort)
     
  3. Offline

    Vollch

    public void onBlockPlace(BlockPlaceEvent event) {
    if(replaceMode(event.getPlayer()))
    event.setCancelled(true);
    }
     
  4. Offline

    NathanWolf

    You can look at the code for Spells, and Wand, it does a lot of this sort of thing

    My paint spells does exactly what you're trying to do, I think, it fills the target block with the first building material in your active inventory.
     
Thread Status:
Not open for further replies.

Share This Page