diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt index 662261ad6..065c99865 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterManager.kt @@ -15,6 +15,7 @@ import it.unimi.dsi.fastutil.io.FastByteArrayOutputStream import it.unimi.dsi.fastutil.objects.Object2BooleanFunction import it.unimi.dsi.fastutil.objects.Object2BooleanOpenHashMap import it.unimi.dsi.fastutil.objects.Object2IntArrayMap +import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap import it.unimi.dsi.fastutil.objects.ObjectLinkedOpenHashSet import it.unimi.dsi.fastutil.objects.Reference2BooleanFunction import it.unimi.dsi.fastutil.objects.Reference2BooleanOpenHashMap @@ -339,8 +340,21 @@ object MatterManager { val addOrReplace = ArrayList>() val update = ArrayList>() val delete = ArrayList>() + val sortedKeys = ArrayList(map.keys) + val inverse = Object2IntOpenHashMap() + inverse.defaultReturnValue(Int.MAX_VALUE) // выталкиваем неизвестные имена в самый конец + + for ((i, info) in ModList.get().mods.withIndex()) { + inverse[info.namespace] = i + } + + inverse[OverdriveThatMatters.MOD_ID] = -1 // загружаем файлы самого мода всегда раньше, чем всё остальное + + sortedKeys.sortWith { a, b -> inverse.getInt(a.namespace).compareTo(inverse.getInt(b.namespace)) } + + for (key in sortedKeys) { + val json = map[key]!! - for ((key, json) in map) { if (json !is JsonObject) { throw JsonParseException("Matter value $key has invalid type: ${json::class.qualifiedName} ($json)") }