diff --git a/src/main/java/carpet/script/utils/ShapeDispatcher.java b/src/main/java/carpet/script/utils/ShapeDispatcher.java index d514bf19..28f836cd 100644 --- a/src/main/java/carpet/script/utils/ShapeDispatcher.java +++ b/src/main/java/carpet/script/utils/ShapeDispatcher.java @@ -382,6 +382,14 @@ public class ShapeDispatcher if (fa != 0.0) { hash = 31*hash + fillColor; hash *= 1099511628211L; } return hash; } + private static final double xdif = new Random().nextDouble(); + private static final double ydif = new Random().nextDouble(); + private static final double zdif = new Random().nextDouble(); + int vec3dhash(Vec3d vec) + { + return vec.add(xdif, ydif, zdif).hashCode(); + } + // list of params that need to be there private final Set required = ImmutableSet.of("duration", "shape", "dim"); private final Map optional = ImmutableMap.of( @@ -504,7 +512,7 @@ public class ShapeDispatcher { long hash = super.calcKey(); hash ^= 5; hash *= 1099511628211L; - hash ^= pos.hashCode(); hash *= 1099511628211L; + hash ^= vec3dhash(pos); hash *= 1099511628211L; hash ^= text.hashCode(); hash *= 1099511628211L; if (facing!= null) hash ^= facing.hashCode(); hash *= 1099511628211L; hash ^= Float.hashCode(raise); hash *= 1099511628211L; @@ -567,8 +575,8 @@ public class ShapeDispatcher { long hash = super.calcKey(); hash ^= 1; hash *= 1099511628211L; - hash ^= from.hashCode(); hash *= 1099511628211L; - hash ^= to.hashCode(); hash *= 1099511628211L; + hash ^= vec3dhash(from); hash *= 1099511628211L; + hash ^= vec3dhash(to); hash *= 1099511628211L; return hash; } @@ -647,8 +655,8 @@ public class ShapeDispatcher { long hash = super.calcKey(); hash ^= 2; hash *= 1099511628211L; - hash ^= from.hashCode(); hash *= 1099511628211L; - hash ^= to.hashCode(); hash *= 1099511628211L; + hash ^= vec3dhash(from); hash *= 1099511628211L; + hash ^= vec3dhash(to); hash *= 1099511628211L; return hash; } } @@ -719,7 +727,7 @@ public class ShapeDispatcher { long hash = super.calcKey(); hash ^= 3; hash *= 1099511628211L; - hash ^= center.hashCode(); hash *= 1099511628211L; + hash ^= vec3dhash(center); hash *= 1099511628211L; hash ^= Double.hashCode(radius); hash *= 1099511628211L; hash ^= level; hash *= 1099511628211L; return hash; @@ -821,7 +829,7 @@ public class ShapeDispatcher { long hash = super.calcKey(); hash ^= 4; hash *= 1099511628211L; - hash ^= center.hashCode(); hash *= 1099511628211L; + hash ^= vec3dhash(center); hash *= 1099511628211L; hash ^= Double.hashCode(radius); hash *= 1099511628211L; hash ^= Double.hashCode(height); hash *= 1099511628211L; hash ^= level; hash *= 1099511628211L;