PS will complain on weird values. Reason being GSON cant serialize weird stuff.

This commit is contained in:
Olof Larsson 2013-11-12 22:02:53 +01:00
parent 86db5a6bdd
commit 0cca530a60

View File

@ -247,16 +247,32 @@ public final class PS implements Cloneable, Serializable, Comparable<PS>
this.blockX = blockX; this.blockX = blockX;
this.blockY = blockY; this.blockY = blockY;
this.blockZ = blockZ; this.blockZ = blockZ;
this.locationX = locationX; this.locationX = throwIfStrange(locationX, NAME_VERBOOSE_LOCATIONX);
this.locationY = locationY; this.locationY = throwIfStrange(locationY, NAME_VERBOOSE_LOCATIONY);
this.locationZ = locationZ; this.locationZ = throwIfStrange(locationZ, NAME_VERBOOSE_LOCATIONZ);
this.chunkX = chunkX; this.chunkX = chunkX;
this.chunkZ = chunkZ; this.chunkZ = chunkZ;
this.pitch = pitch; this.pitch = throwIfStrange(pitch, NAME_VERBOOSE_PITCH);
this.yaw = yaw; this.yaw = throwIfStrange(yaw, NAME_VERBOOSE_YAW);
this.velocityX = velocityX; this.velocityX = throwIfStrange(velocityX, NAME_VERBOOSE_VELOCITYX);
this.velocityY = velocityY; this.velocityY = throwIfStrange(velocityY, NAME_VERBOOSE_VELOCITYY);
this.velocityZ = velocityZ; this.velocityZ = throwIfStrange(velocityZ, NAME_VERBOOSE_VELOCITYZ);
}
public static Double throwIfStrange(Double d, String name)
{
if (d == null) return null;
if (d.isInfinite()) throw new IllegalArgumentException(name + " should not be Infinite!");
if (d.isNaN()) throw new IllegalArgumentException(name + " should not be NaN!");
return d;
}
public static Float throwIfStrange(Float f, String name)
{
if (f == null) return null;
if (f.isInfinite()) throw new IllegalArgumentException(name + " should not be Infinite!");
if (f.isNaN()) throw new IllegalArgumentException(name + " should not be NaN!");
return f;
} }
// -------------------------------------------- // // -------------------------------------------- //