Solved Interact with blocks

Discussion in 'Plugin Development' started by Hellborn5456, May 15, 2014.

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

    Hellborn5456

    i want player to stop interacting with block so that they cant even hit or break a block
    Code:
    @EventHandler
    public void playerInteract(PlayerInteractEvent e){
    Player p = e.getPlayer();
    if(e.getAction().equals(Action.LEFT_CLICK_BLOCK)
    && p.getItemInHand().equals(Material.AIR)){
    Block b = e.getClickedBlock();
    if(b.equals(Material.GRASS)){
    e.setCancelled(true);
    }
    }
     
    }
     
  2. Offline

    xTrollxDudex

    Hellborn5456
    You cannot prevent block damage, this event fires after the block is broken, and the cancellation of the real BlockDamage will not cancel the player hit, only the block break. Your best bet is to edit some NBT tags to add items which can break adventure mode blocks.
     
  3. Offline

    Hellborn5456

Thread Status:
Not open for further replies.

Share This Page