Solved Removing a block in a location?

Discussion in 'Plugin Development' started by AstramG, Sep 29, 2012.

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

    AstramG

    How will I check if a block is obsidian, and if it is, if you right click it poof its gone.
     
  2. Offline

    gregthegeek

    Code:
    @EventHandler
    public void playerInteract(PlayerInteractEvent event) {
        if(event.getAction() == Action.RIGHT_CLICK_BLOCK) {
            Block b = event.getClickedBlock();
            if(b.getType() == Material.OBSIDIAN) {
                b.setType(Material.AIR);
            }
        } 
    }
    
     
    kroltan likes this.
  3. Offline

    kroltan

    Adding to @gregthegeek's answer, if you want to drop the obsidian, use the following line:
    Code:java
    1. b.breakNaturally();

    Instead of setType().
     
Thread Status:
Not open for further replies.

Share This Page