Location checking

Discussion in 'Plugin Development' started by chrisman0091, Dec 7, 2013.

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

    chrisman0091

    Right now I'm working with locations. I have gotten it all set up, and I've come to the part where it checks to make sure the block equals air. Im struggling with figuring out how to check if it equals air, and if it doesn't then add 1 to the Y and re-run the check. I try using an if than else and just re-running my code, but that just spit out the same line to my console enough to where I had to check the .txt to see before it.

    Basically, how would I go about checking if it equals something, if not doing something else, then re-running it? I was thinking a while-loop but couldn't figure it out exactly.
     
  2. Offline

    XDSiLeNtKiLlXD

    Code:
    int a = 0;
    int b = 1;
     
    While(a < b)
    {
      if(yourblock.getType() == Material.AIR
      {
          y++;
      }
      else if(your statement to stop loop)
      {
          a = 2;
      }
    }
    
    I assume this would work chrisman0091
     
  3. Offline

    chrisman0091

    Something in my code is making the server freeze with no error log(get kicked, can't join, can't stop or anything).

    Current code:
    Code:
    static Block bb = Utils.cs.getBlock();
    static Block bb2 = Utils.cs2.getBlock();
     
    static int a = 0;
    static int b = 1;
     
    public static void drop(){
    while(a < b){
    if (!bb.getType().equals(Material.AIR) && !bb2.getType().equals(Material.AIR)){
    Utils.y++;
    }
    else{
    a = 2;
    }
    }
    Bukkit.getServer().broadcastMessage("§c§oA §4§oBattle Box§c§o has been dropped! You have 10 minutes to get to it at " + ChatColor.YELLOW + "" + ChatColor.BOLD + "" + ChatColor.ITALIC + "X:" + Utils.x + " Y:" + Utils.y + " Z:" + Utils.z);
     
    }
     
  4. Offline

    XDSiLeNtKiLlXD

  5. Offline

    chrisman0091

    Basically I'm wanting to check if the location and the block under it are not equal to air, and if they aren't than add 1 to the Y. Then it will re-check that and repeat until they DO equal air, when it will then continue on.
     
Thread Status:
Not open for further replies.

Share This Page