if (cache == null || coords.x > cacheWidth || coords.y > cacheHeight) {
int index = (coords.y * cacheWidth) + coords.x; if (cache == null || coords.x > cacheWidth || index < 0 || index >= cache.length) {
    public static IdealHex get(Coords coords) {        if (cache == null || coords.x > cacheWidth || coords.y > cacheHeight) {            return new IdealHex(coords);        }        // okay, check cache        int index = (coords.y * cacheWidth) + coords.x;        IdealHex hex = cache[index];        if (hex != null) {            return hex;        } else {            hex = new IdealHex(coords);            cache[index] = hex;            return hex;        }    }