From bcc678c3d85f683f05206d7564ba9aea91d70e68 Mon Sep 17 00:00:00 2001 From: Bibi Reden Date: Fri, 4 Oct 2024 02:26:41 -0500 Subject: [PATCH] [fix] Force unknowns to have priority render --- CHANGELOG.md | 2 +- .../ui/config/providers/AttributeFunctionProvider.kt | 7 +++++-- .../ui/config/providers/AttributeOverrideProvider.kt | 7 +++++-- .../ui/config/providers/EntityTypesProvider.kt | 9 ++++++--- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e049813..7107536 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ ## Overview -**There are breaking changes in this release. Ensure you back up your config(s) if possible.** +**There are breaking changes in this release. Ensure you back up your config(s) if possible. Mods relying on the beta version will have to be updated.** *Welcome to the release of the new Data Attributes. This has taken a considerable amount of time to complete.* diff --git a/src/main/kotlin/com/bibireden/data_attributes/ui/config/providers/AttributeFunctionProvider.kt b/src/main/kotlin/com/bibireden/data_attributes/ui/config/providers/AttributeFunctionProvider.kt index 4d581a6..fd9528c 100644 --- a/src/main/kotlin/com/bibireden/data_attributes/ui/config/providers/AttributeFunctionProvider.kt +++ b/src/main/kotlin/com/bibireden/data_attributes/ui/config/providers/AttributeFunctionProvider.kt @@ -86,7 +86,8 @@ class AttributeFunctionProvider(val option: Option) : F } ) - child(cf) + if (id.toString() == "minecraft:unknown" && children.size > 1) child(1, cf) + else child(cf) } } @@ -196,7 +197,9 @@ class AttributeFunctionProvider(val option: Option) : F child(SearchAnchorComponent(titleLayout(), Option.Key.ROOT, { id.toString() }, { Text.translatable(id.toTranslationKey()).toString() })) } - parent.child(container) + if (id.toString() == "minecraft:unknown" && parent.children().size > 1) parent.child(1, container) + else parent.child(container) + entryComponents[id] = container // force a rearrangement to bring the dock up top~ diff --git a/src/main/kotlin/com/bibireden/data_attributes/ui/config/providers/AttributeOverrideProvider.kt b/src/main/kotlin/com/bibireden/data_attributes/ui/config/providers/AttributeOverrideProvider.kt index d0df291..32e5487 100644 --- a/src/main/kotlin/com/bibireden/data_attributes/ui/config/providers/AttributeOverrideProvider.kt +++ b/src/main/kotlin/com/bibireden/data_attributes/ui/config/providers/AttributeOverrideProvider.kt @@ -224,14 +224,17 @@ class AttributeOverrideProvider(val option: Option 1) child(1, it) + else child(it) + } .also { trackedContainers[id] = it } } init { child( Components.button(Text.translatable("text.config.data_attributes.buttons.add")) { - backing[Identifier.of("unresolved", "id")!!] = AttributeOverride() + backing[Identifier("unknown")] = AttributeOverride() refreshAndDisplayAttributes() } .renderer(ButtonRenderers.STANDARD) diff --git a/src/main/kotlin/com/bibireden/data_attributes/ui/config/providers/EntityTypesProvider.kt b/src/main/kotlin/com/bibireden/data_attributes/ui/config/providers/EntityTypesProvider.kt index f88b43a..9c871be 100644 --- a/src/main/kotlin/com/bibireden/data_attributes/ui/config/providers/EntityTypesProvider.kt +++ b/src/main/kotlin/com/bibireden/data_attributes/ui/config/providers/EntityTypesProvider.kt @@ -57,7 +57,7 @@ class EntityTypesProvider(val option: Option>) : fl.child(Components.button(Text.translatable("text.config.data_attributes.data_entry.edit")) { if (ct.childById(FlowLayout::class.java, "edit-field") == null) { val field = FieldComponents.identifier( - { newId, field -> + { newId, _ -> if (backing.containsKey(newId) || !Registries.ENTITY_TYPE.containsId(newId)) return@identifier // ensured that this exists and is possible to swap backing.remove(id)?.let { backing[newId] = it } @@ -92,7 +92,9 @@ class EntityTypesProvider(val option: Option>) : child(SearchAnchorComponent(ct.titleLayout(), Option.Key.ROOT, id::toString, { Text.translatable(id.toTranslationKey()).toString() })) - child(ct) + + if (id.toString() == "minecraft:unknown" && children.size > 1) child(1, ct) + else child(ct) } for ((entryId, entry) in types) { @@ -192,7 +194,8 @@ class EntityTypesProvider(val option: Option>) : entryComponents[id] = ct - parent.child(ct) + if (id.toString() == "minecraft:unknown" && parent.children().size > 1) parent.child(1, ct) + else parent.child(ct) } // force a rearrangement to bring the dock up top~