[SOLVED] Cant Create 2 Location Variables In Nest

Discussion in 'Plugin Development' started by XDemonic25, Apr 19, 2012.

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

    XDemonic25

    Alright, Time To Elaborate a little.
    It seems I cant have 2 Location Variables in the same Nest. Can someone tell me why?

    Code:
                                double SignX = IlistOfX.get(0);
                                double SignY = IlistOfY.get(0);
                                double SignZ = IlistOfZ.get(0);
                                Location IsSign = evt.getRespawnLocation();
                                IsSign.setWorld(Main);
                                IsSign.setX(SignX);
                                IsSign.setY(SignY);
                                IsSign.setZ(SignZ);
                                Location IsIron = evt.getRespawnLocation();
                                double BlockX = IlistOfX.get(0);
                                double BlockY = IlistOfY.get(0);
                                double BlockZ = IlistOfZ.get(0);
                                IsIron.setWorld(Main);
                                IsIron.setX(BlockX);
                                IsIron.setY(BlockY - 1.0);
                                IsIron.setZ(BlockZ);
    
    As you see "IsSign" Is one block
    and "IsIron" Is the block UNDER the Sign

    For some reason, When I edit the coordinates for "IsIron" Its editing "IsSign" Why is that?

    ex. For "IsIron" I Took Y and subtracted by 1 (under the sign)
    But for some reason its also Subtracting Y by 1 for IsSign as well.
     
  2. Offline

    Alectriciti

    Hmm, I'm not too sure. I suppose it depends on how you're using these coordinates in your code. Here's an example of how I set my Y coordinate using Location loc. Of course, it's referring from it's current location.

    loc.setY(loc.getY() + 1);
     
  3. Offline

    XDemonic25

    Bump, Renamed, Re-Elaborated Thread.
     
  4. Offline

    Njol

    I would write this chunk of code like this:
    Code:java
    1. Location IsSign = Ilist.get(0).toLocation(Main);
    2. Location IsIron = IsSign.getRelative(Blockface.DOWN, 1);

    where Ilist is a list of Vectors, not 3 lists of doubles.

    btw: by convention variables start with a lowercase letter to distinguish them from classes, which start with a capital letter.
     
  5. Offline

    XDemonic25

    Solved Thanks
     
Thread Status:
Not open for further replies.

Share This Page