diff --git a/core/src/mindustry/mod/Mods.java b/core/src/mindustry/mod/Mods.java index c31f648637..3ece15b1d9 100644 --- a/core/src/mindustry/mod/Mods.java +++ b/core/src/mindustry/mod/Mods.java @@ -728,8 +728,10 @@ public class Mods implements Loadable{ Seq runs = new Seq<>(); for(LoadedMod mod : orderedMods()){ - ObjectMap currentRun = new ObjectMap<>(); + Seq unorderedContent = new Seq<>(); + ObjectMap orderedContent = new ObjectMap<>(); String[] contentOrder = mod.meta.contentOrder; + ObjectSet orderSet = contentOrder == null ? null : ObjectSet.with(contentOrder); if(mod.root.child("content").exists()){ Fi contentRoot = mod.root.child("content"); @@ -738,30 +740,32 @@ public class Mods implements Loadable{ Fi folder = contentRoot.child(lower + (lower.endsWith("s") ? "" : "s")); if(folder.exists()){ for(Fi file : folder.findAll(f -> f.extension().equals("json") || f.extension().equals("hjson"))){ - if(contentOrder == null){ - runs.add(new LoadRun(type, file, mod)); + + //if this is part of the ordered content, put it aside to be dealt with later + if(orderSet != null && orderSet.contains(file.nameWithoutExtension())){ + orderedContent.put(file.nameWithoutExtension(), new LoadRun(type, file, mod)); }else{ - currentRun.put(file.nameWithoutExtension(), new LoadRun(type, file, mod)); + unorderedContent.add(new LoadRun(type, file, mod)); } } } } } - Seq left = currentRun.keys().toSeq(); + //ordered content will be loaded first, if it exists if(contentOrder != null){ - for (String contentName : contentOrder){ - LoadRun run = currentRun.get(contentName); + for(String contentName : contentOrder){ + LoadRun run = orderedContent.get(contentName); if(run != null){ runs.add(run); - left.remove(contentName); }else{ Log.warn("Cannot find content defined in contentOrder: @", contentName); } } } - runs.addAll(left.map(name -> currentRun.get(name)).sort()); + //unordered content is sorted alphabetically per mod + runs.addAll(unorderedContent.sort()); } for(LoadRun l : runs){