From cd4d25951c4bfb2aa2f6d2babf0e8d2769e90119 Mon Sep 17 00:00:00 2001 From: Username404 Date: Wed, 23 Jun 2021 20:17:59 +0200 Subject: [PATCH] Create a LinkedHashSet directly in ClickBox.kt and make a TreeSet instance instead of using sortedSetOf() --- .../fr/username404/snowygui/gui/elements/ClickBox.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/common/src/main/kotlin/fr/username404/snowygui/gui/elements/ClickBox.kt b/common/src/main/kotlin/fr/username404/snowygui/gui/elements/ClickBox.kt index 27b2e68..30ca61a 100644 --- a/common/src/main/kotlin/fr/username404/snowygui/gui/elements/ClickBox.kt +++ b/common/src/main/kotlin/fr/username404/snowygui/gui/elements/ClickBox.kt @@ -20,6 +20,8 @@ import net.minecraft.client.Minecraft import net.minecraft.network.chat.TranslatableComponent import org.jetbrains.annotations.ApiStatus import org.lwjgl.opengl.GL20 +import java.util.TreeSet +import kotlin.collections.LinkedHashSet @ApiStatus.Internal class ClickBox( @@ -28,7 +30,10 @@ class ClickBox( val name: TranslatableComponent = MissingComponent ): ColoredElement(x, y, 80, 10, color, 0.5F) { fun isCategory(c: Category): Boolean = (name.key == c.translationKey) - val buttons: MutableSet = if (sortAlphabetically) sortedSetOf(compareBy(String.CASE_INSENSITIVE_ORDER) { it.title }) else mutableSetOf() + val buttons: MutableSet = + if (sortAlphabetically) + TreeSet(compareBy(String.CASE_INSENSITIVE_ORDER) { it.title }) + else LinkedHashSet() override fun display(stack: PoseStack?) { hidden = buttons.isEmpty() || hidden super.display(stack)