Checking if a block is at a location

Discussion in 'Plugin Development' started by inventorman101, Aug 8, 2013.

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

    inventorman101

    How do I find out if a certain block exists in a certain location?

    Code:java
    1. if(b.getX()-1 == Block???)
     
  2. Offline

    rguz10

    Sorry this is not in code tags, on tapatalk.

    Location loc = new Location(w, x, y, z);

    public void onBreak(BlockBreakEvent event){
    if (event.getBlock().getLocation() == loc){
    Event.setCancelled(true);
    }
     
  3. Offline

    Dyprex

    Always compare objects with .equals() method to make sure it works correctly. So in your case:
    if (event.getBlock().getLocation().equals(loc))
     
    teozfrank likes this.
  4. Offline

    kg9dh

    Code:java
    1. public boolean isBlockNotAirAt(Location block){
    2. if(block.getBlock().getTypeId() == 0){
    3. return false;
    4. }
    5. return true;
    6. }
     
Thread Status:
Not open for further replies.

Share This Page