Anuken/Mindustry · error · RuntimeException
Overwriting existing sectors is not allowed.
Error message
Overwriting existing sectors is not allowed.
What it means
When NOT patching (allowPatching false or preset not located) and the chosen sector index is > 0, the parser checks whether planet.sectors.get(sector).preset is already set. If another preset already claims that sector, throwing prevents silently overwriting an existing sector preset. Sector 0 is exempt.
Source
Thrown at core/src/mindustry/mod/ContentParser.java:778
currentContent = preset;
read(() -> {
Planet planet = preset.planet == null ? Planets.serpulo : preset.planet;
if(value.has("planet")){
planet = locate(ContentType.planet, value.getString("planet", "serpulo"));
if(planet == null) throw new RuntimeException("Planet '" + value.getString("planet") + "' not found.");
}
if(value.has("sector")){
//clear old value
Sector prev = preset.sector;
if(prev != null && prev.preset == preset){
prev.preset = null;
}
int sector = value.getInt("sector", 0) % planet.sectors.size;
if(!allowPatching && sector > 0 && planet.sectors.get(sector).preset != null){
throw new RuntimeException("Overwriting existing sectors is not allowed.");
}
preset.initialize(planet, sector, true);
}
value.remove("sector");
value.remove("planet");
if(value.has("rules")){
JsonValue r = value.remove("rules");
if(!r.isObject()) throw new RuntimeException("Rules must be an object!");
preset.rules = rules -> {
try{
//Use standard JSON, this is not content-parser relevant
JsonIO.json.readFields(rules, r);
}catch(Throwable e){ //Try not to crash here, as that would be catastrophic and confusing
Log.err(e);
}
};View on GitHub (pinned to f695ad7e60)
Solutions
- Assign each preset a distinct, unused sector number.
- If you intend to replace a preset, enable patching and reference the existing preset by name.
- Audit the planet's sector list to find a free slot.
Example fix
// before (two files both use sector 4) "sector": 4 // after "sector": 7 // an unoccupied slot
Defensive patterns
Strategy: validation
Validate before calling
// Detect sector collisions before parse (non-patch mode).
if(!allowPatching && value.has("sector")){
int s = value.getInt("sector", 0);
if(s > 0){
Planet p = /* resolved planet */;
if(p.sectors.get(s).preset != null) throw new IllegalStateException("Sector " + s + " already claimed");
}
} Prevention
- Audit planet sector occupancy when assigning preset numbers.
- Use patch mode to intentionally replace presets.
When it happens
Trigger: Two sector preset JSONs target the same non-zero sector number on the same planet, and the second is not a patch. The first preset occupies the slot; the second trips the guard.
Common situations: Duplicate sector numbers across mod files; overriding a vanilla sector preset without enabling patch mode.
Related errors
- SectorPresets must have a sector number.
- Planet '${value.getString("planet")}' not found.
- Rules must be an object!
- Unknown consumption type: '${child.name}' for block '${block
- Blocks cannot be larger than ${maxBlockSize}
AI-assisted analysis of Anuken/Mindustry@f695ad7e60 (2026-08-14).
Data as JSON: /api/errors/b6ef21a575ccb5b1.
Report an issue: GitHub.