3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-03 01:50:07 +01:00

Vector and BlockVector should use the same hashCode

For example, the getChunks method returns a Set<Vector2D> which is
actually comprised of BlockVector2D, so using set.contains(some vector)
will always return false.

There's unlikely to be multiple entities on the same block, or above
y=256, so using the int coords is better.
Dieser Commit ist enthalten in:
Jesse Boyd 2017-01-10 16:03:10 +11:00
Ursprung 9f24f84c2b
Commit ad7fdd19fb
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 59F1DE6293AF6E1F
4 geänderte Dateien mit 2 neuen und 21 gelöschten Zeilen

Datei anzeigen

@ -84,13 +84,6 @@ public class BlockVector extends Vector {
}
@Override
public int hashCode() {
return ((int) x << 19) ^
((int) y << 12) ^
(int) z;
}
@Override
public BlockVector toBlockVector() {
return this;

Datei anzeigen

@ -80,12 +80,6 @@ public class BlockVector2D extends Vector2D {
}
@Override
public int hashCode() {
return (Integer.valueOf((int) x).hashCode() >> 13) ^
Integer.valueOf((int) z).hashCode();
}
@Override
public BlockVector2D toBlockVector2D() {
return this;

Datei anzeigen

@ -789,12 +789,7 @@ public class Vector implements Comparable<Vector> {
@Override
public int hashCode() {
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;
return ((int) x ^ ((int) z << 12)) ^ ((int) y << 24);
}
@Override

Datei anzeigen

@ -627,8 +627,7 @@ public class Vector2D {
@Override
public int hashCode() {
return ((new Double(x)).hashCode() >> 13) ^
(new Double(z)).hashCode();
return ((int) x << 16) ^ (int) z;
}
@Override