Negative value in vector

Discussion in 'Plugin Development' started by Heroiik, Jun 15, 2014.

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

    Heroiik

    Hi, i have a problem with the worldedit api, when i create my vector (maxVector.subtract(minVector)), the X size of maxVector is negative, because my first location X is -905and the second -900, and the result is -4, how fix it ?

    Code:java
    1. Vector minVector = new Vector(min.getBlockX(), min.getBlockY(), min.getBlockZ());
    2. Vector maxVector = new Vector(max.getBlockX(), max.getBlockY(), max.getBlockZ());
    3.  
    4. getLogger().info(maxVector.subtract(minVector).add(new Vector(1, 1, 1)).toString());
    5.  
    6. CuboidClipboard clipboard = new CuboidClipboard(maxVector.subtract(minVector).add(new Vector(1, 1, 1)));
    7.  
    8. EditSession session = new EditSession(new BukkitWorld(min.getWorld()), 999999999);
    9. clipboard.copy(session);
     
  2. Offline

    1Rogue

    -897 - -894 + 1 = -4

    We can't fix math for you.
     
    ferrybig and Smerfa like this.
  3. Offline

    Nghtmr9999

    Heroiik likes this.
  4. Offline

    Smerfa

    what are you trying to do? maybe just use add?
     
  5. Offline

    Heroiik

  6. Offline

    Heroiik

    hi ^^
    sorry but this is not normal to give "java.lang.NegativeArraySizeException" error ?

    Thank you

    Code:java
    1. Vector minVector = new Vector(min.getBlockX(), min.getBlockY(), min.getBlockZ());
    2. Vector maxVector = new Vector(max.getBlockX(), max.getBlockY(), max.getBlockZ());
     
  7. Offline

    Smerfa

    try check if min.getBlockX() is smaller that max.getBlockX() and this same with Y and Z.
    And with line giving error?
     
  8. Offline

    Heroiik

    if i change the min (-600) to min (600) i have not the error and the line are on my last post.
     
  9. Offline

    AoH_Ruthless

  10. Offline

    Heroiik

    Who can help me ? :(
     
  11. Offline

    Smerfa

    paste actual code and write what you want to do
     
  12. Offline

    Heroiik

    This is my actual code :

    Code:java
    1. Vector minVector = new Vector(min.getBlockX(), min.getBlockY(), min.getBlockZ());
    2. Vector maxVector = new Vector(max.getBlockX(), max.getBlockY(), max.getBlockZ());
    3.  
    4. CuboidClipboard clipboard = new CuboidClipboard(maxVector.subtract(minVector).add(new Vector(1, 1, 1)), maxVector);


    And if my vector parameters are negative i have an NegativeArraySizeExeception.
     
  13. Offline

    Smerfa

    why you need that
    Code:
    new CuboidClipboard(maxVector.subtract(minVector).add(new Vector(1, 1, 1)), maxVector);
    And maybe try
    Code:
    new CuboidClipboard(minVector.add(maxVector).add(new Vector(1, 1, 1)), maxVector);
     
  14. Offline

    Heroiik

    The errors are here

    Code:java
    1. Vector minVector = new Vector(min.getBlockX(), min.getBlockY(), min.getBlockZ());
    2. Vector maxVector = new Vector(max.getBlockX(), max.getBlockY(), max.getBlockZ());
     
  15. Offline

    Smerfa

  16. Offline

    Heroiik

    Oh yes sorry.
     
Thread Status:
Not open for further replies.

Share This Page