Merge branch 'Leo-MathGuy-master'

This commit is contained in:
Anuken 2024-04-28 09:53:11 -04:00
commit 9de04a24fd

View file

@ -728,6 +728,11 @@ public class Mods implements Loadable{
Seq<LoadRun> runs = new Seq<>();
for(LoadedMod mod : orderedMods()){
Seq<LoadRun> unorderedContent = new Seq<>();
ObjectMap<String, LoadRun> orderedContent = new ObjectMap<>();
String[] contentOrder = mod.meta.contentOrder;
ObjectSet<String> orderSet = contentOrder == null ? null : ObjectSet.with(contentOrder);
if(mod.root.child("content").exists()){
Fi contentRoot = mod.root.child("content");
for(ContentType type : ContentType.all){
@ -735,15 +740,34 @@ 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"))){
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{
unorderedContent.add(new LoadRun(type, file, mod));
}
}
}
}
}
//ordered content will be loaded first, if it exists
if(contentOrder != null){
for(String contentName : contentOrder){
LoadRun run = orderedContent.get(contentName);
if(run != null){
runs.add(run);
}else{
Log.warn("Cannot find content defined in contentOrder: @", contentName);
}
}
}
//unordered content is sorted alphabetically per mod
runs.addAll(unorderedContent.sort());
}
//make sure mod content is in proper order
runs.sort();
for(LoadRun l : runs){
Content current = content.getLastAdded();
try{
@ -1210,6 +1234,8 @@ public class Mods implements Loadable{
public float texturescale = 1.0f;
/** If true, bleeding is skipped and no content icons are generated. */
public boolean pregenerated;
/** If set, load the mod content in this order by content names */
public String[] contentOrder;
public String displayName(){
//useless, kept for legacy reasons