Anuken/Mindustry · error · IllegalArgumentException
Unknown object type:
Error message
Unknown object type:
What it means
readObject()'s switch covers object type bytes 0–23. Any other type byte falls through to the default and throws IllegalArgumentException. There is no valid handler for that byte, meaning the stream is corrupt, from an incompatible version, or deliberately malformed.
Source
Thrown at core/src/mindustry/io/TypeIO.java:269
for(int i = 0; i < len; i ++) out[i] = new Vec2(read.f(), read.f());
yield out;
}
case 19 -> new Vec2(read.f(), read.f());
case 20 -> Team.all[read.ub()];
case 21 -> readInts(read);
case 22 -> {
if(!allowArrays) throw new RuntimeException("Nested arrays are not allowed");
int len = read.i();
if(len > maxArraySize) throw new RuntimeException("Invalid array size: " + len);
Object[] objs = new Object[len];
for(int i = 0; i < len; i++){
objs[i] = readObject(read, box, mapper, safe, false);
}
yield objs;
}
case 23 -> content.unitCommand(read.us());
default -> throw new IllegalArgumentException("Unknown object type: " + type);
};
}
public static void writeUiBuilder(Writes writes, NodeBuilder<?> node){
node.write(writes);
}
public static NodeBuilder<?> readUiBuilder(Reads reads){
return NodeBuilder.read(reads);
}
public static void writeMenuResult(Writes writes, MenuResult result){
writes.l(result.token);
writeString(writes, result.result);
writes.s(Math.min(MenuResult.maxTotalValues, result.values.size));
int i = 0;View on GitHub (pinned to f695ad7e60)
Solutions
- Ensure both peers run the same game and mod versions.
- Server: catch IllegalArgumentException and kick the sender.
- If you added a new type in a fork, extend the switch on both sides consistently.
Defensive patterns
Strategy: try-catch
Try / catch
try { TypeIO.readObject(read); }
catch(IllegalArgumentException e){ Log.err("Unknown object type in packet", e); con.kick("Protocol mismatch."); } Prevention
- Keep client and server on identical game and mod builds.
- Treat unknown-type errors as a desync, not a transient fault.
- If you fork the protocol, extend the type switch on both ends.
When it happens
Trigger: The first byte of an object read is outside the range 0..23.
Common situations: Client/server version mismatch (a newer protocol wrote a type the reader does not know); stream desync/corruption; packet fuzzing.
Related errors
- Unknown UI entry type:
- Unknown plan config object type:
- Unknown save version: {}. Are you trying to load a save from
- Invalid asset type ID: {}. You are likely loading trying to
- Nested arrays are not allowed
AI-assisted analysis of Anuken/Mindustry@f695ad7e60 (2026-08-14).
Data as JSON: /api/errors/57f9e4d471ace5db.
Report an issue: GitHub.