Replaced Vector.hashCode with a more reliable method

By: Dinnerbone <dinnerbone@dinnerbone.com>
This commit is contained in:
Bukkit/Spigot
2011-02-19 23:11:56 +00:00
parent 6203fc2652
commit 08fd2073ce

View File

@@ -526,16 +526,17 @@ public class Vector implements Cloneable {
}
/**
* Returns a hash code for this vector. Due to floating point errors, this
* hash code should not be used in hash tables of any sort.
* Returns a hash code for this vector
*
* @return hash code
*/
@Override
public int hashCode() {
return ((int)Double.doubleToLongBits(x) >> 13) ^
((int)Double.doubleToLongBits(y) >> 7) ^
(int)Double.doubleToLongBits(z);
int hash = 7;
hash = 79 * hash + (int) (Double.doubleToLongBits(this.x) ^ (Double.doubleToLongBits(this.x) >>> 32));
hash = 79 * hash + (int) (Double.doubleToLongBits(this.y) ^ (Double.doubleToLongBits(this.y) >>> 32));
hash = 79 * hash + (int) (Double.doubleToLongBits(this.z) ^ (Double.doubleToLongBits(this.z) >>> 32));
return hash;
}
/**