Grasscutters/Grasscutter · error · IllegalArgumentException
Range passed minimum higher than maximum - >
Error message
Range passed minimum higher than maximum - >
What it means
SparseSet's inner Range validates that min <= max; constructing a Range with min > max throws this IllegalArgumentException. It surfaces when a range token in a SparseSet initializer is written in descending order, e.g. '50-10'.
Source
Thrown at src/main/java/emu/grasscutter/utils/objects/SparseSet.java:53
for (Range range : this.rangeEntries) {
if (range.check(i)) {
return true;
}
}
return this.denseEntries.contains(i);
}
/*
* A convenience class for constructing integer sets out of large ranges
* Designed to be fed literal strings from this project only -
* can and will throw exceptions to tell you to fix your code if you feed it garbage. :)
*/
private static class Range {
private final int min, max;
public Range(int min, int max) {
if (min > max) {
throw new IllegalArgumentException(
"Range passed minimum higher than maximum - " + min + " > " + max);
}
this.min = min;
this.max = max;
}
public boolean check(int value) {
return value >= this.min && value <= this.max;
}
}
}
View on GitHub (pinned to f373827a83)
Solutions
- Swap the endpoints in the spec so it reads smaller-largest, e.g. '10-50' instead of '50-10'
- Sort range endpoints in any generator that emits SparseSet specs
- If ranges must be accepted either way, normalize at parse time by using Math.min/Math.max before constructing Range
Example fix
// before
new SparseSet("100-50");
// after
new SparseSet("50-100"); Defensive patterns
Strategy: validation
Validate before calling
void validateRangeOrder(String spec) {
for (String token : spec.split(",")) {
String[] p = token.split("-");
if (p.length == 2 && Integer.parseInt(p[0]) > Integer.parseInt(p[1]))
throw new IllegalArgumentException("Descending range: " + token);
}
} Type guard
boolean isAscendingRange(String token) {
String[] p = token.split("-");
return p.length != 2 || Integer.parseInt(p[0]) <= Integer.parseInt(p[1]);
} Try / catch
try {
SparseSet set = new SparseSet(spec);
} catch (IllegalArgumentException e) {
logger.error("Range order problem: {}", e.getMessage());
} Prevention
- Always write ranges ascending: smaller value first
- Sort endpoints in generators before emitting 'min-max' tokens
- Normalize with Math.min/Math.max if input order is uncontrolled
- Spot-check hand-edited range specs before loading
When it happens
Trigger: new SparseSet("50-10") or any token where the first integer is greater than the second; the exception message shows the two parsed values, e.g. 'Range passed minimum higher than maximum - 50 > 10'.
Common situations: Hand-written range specs with swapped endpoints; generated specs from unsorted data; typos when editing id exclusion/include lists.
Related errors
AI-assisted analysis of Grasscutters/Grasscutter@f373827a83 (2026-09-03).
Data as JSON: /api/errors/d2e270e5836c0401.
Report an issue: GitHub.