Anuken/Mindustry · error · ArcRuntimeException

Array size too large: {}

Error message

Array size too large: {}

What it means

TypeIO.writeObject rejects an IntSeq whose size exceeds maxArraySize (1000) before serializing it. This is a hard cap on object-typed IntSeq payloads used for build-plan configs and logic/network arguments. An ArcRuntimeException is thrown at write time, before any bytes are emitted, so no partial packet is produced.

Source

Thrown at core/src/mindustry/io/TypeIO.java:64

            write.b((byte)0);
        }else if(object instanceof Integer i){
            write.b((byte)1);
            write.i(i);
        }else if(object instanceof Long l){
            write.b((byte)2);
            write.l(l);
        }else if(object instanceof Float f){
            write.b((byte)3);
            write.f(f);
        }else if(object instanceof String s){
            write.b((byte)4);
            writeString(write, s);
        }else if(object instanceof Content map){
            write.b((byte)5);
            write.b((byte)map.getContentType().ordinal());
            write.s(map.id);
        }else if(object instanceof IntSeq arr){
            if(arr.size > maxArraySize) throw new ArcRuntimeException("Array size too large: " + arr.size);
            write.b((byte)6);
            write.s((short)arr.size);
            for(int i = 0; i < arr.size; i++){
                write.i(arr.items[i]);
            }
        }else if(object instanceof Point2 p){
            write.b((byte)7);
            write.i(p.x);
            write.i(p.y);
        }else if(object instanceof Point2[] p){
            //255 is the limit here, because it's a byte for some reason
            if(p.length > 255) throw new ArcRuntimeException("Array size too large: " + p.length);
            write.b((byte)8);
            write.b(p.length);
            for(Point2 point2 : p){
                write.i(point2.pack());
            }
        }else if(object instanceof TechNode map){

View on GitHub (pinned to f695ad7e60)

Solutions

  1. Cap the IntSeq size before passing it as a config: split into chunks of <= 1000 or downsample.
  2. If the data legitimately needs more than 1000 ints, store it out-of-band (a custom chunk via SaveVersion.addCustomChunk) rather than through writeObject.
  3. For networked configs, apply getMaxPlans-style limiting on the producer side.
  4. Validate size with arr.size <= TypeIO limit before constructing the plan.

Example fix

// before
plan.config = largeIntSeq; // size > 1000 -> ArcRuntimeException at write

// after
if (largeIntSeq.size > 1000) {
    throw new IllegalArgumentException("IntSeq config exceeds network limit (1000): " + largeIntSeq.size);
}
plan.config = largeIntSeq;
Defensive patterns

Strategy: validation

Validate before calling

static final int MAX = 1000;
void setIntSeqConfig(BuildPlan plan, IntSeq seq) {
    if (seq.size > MAX) throw new IllegalArgumentException("IntSeq too large: " + seq.size);
    plan.config = seq;
}

Type guard

static boolean intSeqWithinLimit(IntSeq s) { return s != null && s.size <= 1000; }

Try / catch

try {
    TypeIO.writeObject(write, seq);
} catch (ArcRuntimeException e) {
    // size over limit; trim or reject before retrying
}

Prevention

When it happens

Trigger: writeObject is invoked with an IntSeq > 1000 elements; commonly when a BuildPlan.config is a huge IntSeq (e.g. a processor's large link list, or a sorter config), serialized over the network or into a save via writeClientPlans/writePlans/writeObject.

Common situations: A logic processor or configuration producing an oversized IntSeq; a client plan with too many entries; passing user-controlled arrays into TypeIO.writeObject without sizing.

Related errors


AI-assisted analysis of Anuken/Mindustry@f695ad7e60 (2026-08-14). Data as JSON: /api/errors/cd071b7533dfe7c9. Report an issue: GitHub.