Solved Debug switch case

Discussion in 'Plugin Development' started by ChazSchmidt, Mar 29, 2016.

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

    ChazSchmidt

    I'm trying to figure out the direction for a vector but the only cases that are facing NORTH and WEST. Facing EAST and SOUTH are not working and default. I've added a few debugging messages to check if the strings are matching up and they are. Any idea why this isn't working?

    OR if there is a simpler way to check the direction a chest is facing feel free to tell me I'm wrong :p


    Code:
     public Vector findVector(Chest c) {
            String s = c.getData().toString();
            s = s.substring(s.length() - 5).trim();
            log.info("Direction: ." + s +".");
            Vector v = new Vector(0,0.5,0);
            switch (s) {
            case "EAST" :
                v.add(new Vector(1,0,0));
              
            case "WEST" :
                v.add(new Vector(-1,0,0));
          
            case "SOUTH" :
                v.add(new Vector(0,0,1));
              
            case "NORTH" :
                v.add(new Vector(0,0,-1));
              
            default:
                log.info("DEFAULTED");
                break;
            }
            log.info("Launch vector: " + v.toString());
            return v;
        }
     
    Last edited: Mar 29, 2016
  2. Code:
    switch (foo) {
    
    case bar:
          // do stuff
          break;
    
    default:
          // do stuff
          break;
    }
    (Break after each case or it will run through)
     
    Kilorbine and Zombie_Striker like this.
  3. Offline

    ChazSchmidt

    OMG... Thanks.. Sorry I'm a bit rusty because I haven't programmed in a while. Amateur hour over here lol
     
Thread Status:
Not open for further replies.

Share This Page