aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/firmament/features
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-05-18 17:33:19 +0200
committerLinnea Gräf <nea@nea.moe>2024-05-18 17:33:19 +0200
commit8c66016bb3041793961375178d470546519e0e69 (patch)
treed8b65a2727619766856f7a865665303cccc444a2 /src/main/kotlin/moe/nea/firmament/features
parenta39f6e9bec3318b2be251570ea7aea29d58b49cb (diff)
downloadFirmament-8c66016bb3041793961375178d470546519e0e69.tar.gz
Firmament-8c66016bb3041793961375178d470546519e0e69.tar.bz2
Firmament-8c66016bb3041793961375178d470546519e0e69.zip
Add more screens at once
[no changelog]
Diffstat (limited to 'src/main/kotlin/moe/nea/firmament/features')
-rw-r--r--src/main/kotlin/moe/nea/firmament/features/texturepack/CustomGlobalTextures.kt14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/main/kotlin/moe/nea/firmament/features/texturepack/CustomGlobalTextures.kt b/src/main/kotlin/moe/nea/firmament/features/texturepack/CustomGlobalTextures.kt
index 2eb4ee1..c2a003a 100644
--- a/src/main/kotlin/moe/nea/firmament/features/texturepack/CustomGlobalTextures.kt
+++ b/src/main/kotlin/moe/nea/firmament/features/texturepack/CustomGlobalTextures.kt
@@ -33,6 +33,7 @@ import moe.nea.firmament.events.subscription.SubscriptionOwner
import moe.nea.firmament.features.FirmamentFeature
import moe.nea.firmament.util.IdentifierSerializer
import moe.nea.firmament.util.MC
+import moe.nea.firmament.util.json.SingletonSerializableList
import moe.nea.firmament.util.runNull
object CustomGlobalTextures : SinglePreparationResourceReloader<CustomGlobalTextures.CustomGuiTextureOverride>(),
@@ -46,7 +47,7 @@ object CustomGlobalTextures : SinglePreparationResourceReloader<CustomGlobalText
@Serializable
data class GlobalItemOverride(
- val screen: Identifier,
+ val screen: @Serializable(SingletonSerializableList::class) List<Identifier>,
val model: Identifier,
val predicate: FirmamentModelPredicate,
)
@@ -107,7 +108,8 @@ object CustomGlobalTextures : SinglePreparationResourceReloader<CustomGlobalText
}
}
- val byGuiClass = overrideResources.groupBy { it.screen }
+ val byGuiClass = overrideResources.flatMap { override -> override.screen.toSet().map { it to override } }
+ .groupBy { it.first }
val guiClasses = byGuiClass.entries
.mapNotNull {
val key = it.key
@@ -123,7 +125,7 @@ object CustomGlobalTextures : SinglePreparationResourceReloader<CustomGlobalText
logger.error("Failed to load screen filter at $key", ex)
return@mapNotNull null
}
- ItemOverrideCollection(screenFilter, it.value)
+ ItemOverrideCollection(screenFilter, it.value.map { it.second })
}
logger.info("Loaded ${overrideResources.size} global item overrides")
return CustomGuiTextureOverride(guiClasses)
@@ -131,14 +133,14 @@ object CustomGlobalTextures : SinglePreparationResourceReloader<CustomGlobalText
var guiClassOverrides = CustomGuiTextureOverride(listOf())
- var matchingOverrides: List<ItemOverrideCollection> = listOf()
+ var matchingOverrides: Set<ItemOverrideCollection> = setOf()
@Subscribe
fun onOpenGui(event: ScreenChangeEvent) {
val newTitle = event.new?.title
matchingOverrides =
- if (newTitle == null) listOf()
- else guiClassOverrides.classes.filter { it.screenFilter.title.matches(newTitle) }
+ if (newTitle == null) setOf()
+ else guiClassOverrides.classes.filterTo(mutableSetOf()) { it.screenFilter.title.matches(newTitle) }
}
@JvmStatic