change to stable hash

This commit is contained in:
mcrcortex
2025-06-07 16:10:46 +10:00
parent f252fa3a7a
commit 3bfc0c266d

View File

@@ -27,7 +27,7 @@ public class WorldIdentifier {
this.key = key;
this.biomeSeed = biomeSeed;
this.dimension = dimension;
this.hashCode = mixStafford13(key.hashCode()^biomeSeed)^mixStafford13(dimension.hashCode()^biomeSeed);
this.hashCode = mixStafford13(registryKeyHashCode(key))^mixStafford13(registryKeyHashCode(dimension))^mixStafford13(biomeSeed);
}
@Override
@@ -105,4 +105,12 @@ public class WorldIdentifier {
public long getLongHash() {
return this.hashCode;
}
private static long registryKeyHashCode(RegistryKey<?> key) {
var A = key.getRegistry();
var B = key.getValue();
int a = A==null?0:A.hashCode();
int b = B==null?0:B.hashCode();
return (Integer.toUnsignedLong(a)<<32)|Integer.toUnsignedLong(b);
}
}