Create a LinkedHashSet directly in ClickBox.kt and make a TreeSet instance instead of using sortedSetOf()

This commit is contained in:
Username404 2021-06-23 20:17:59 +02:00
parent 1d22337e5d
commit cd4d25951c
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
1 changed files with 6 additions and 1 deletions

View File

@ -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<ButtonImpl> = if (sortAlphabetically) sortedSetOf(compareBy(String.CASE_INSENSITIVE_ORDER) { it.title }) else mutableSetOf()
val buttons: MutableSet<ButtonImpl> =
if (sortAlphabetically)
TreeSet(compareBy(String.CASE_INSENSITIVE_ORDER) { it.title })
else LinkedHashSet()
override fun display(stack: PoseStack?) {
hidden = buttons.isEmpty() || hidden
super.display(stack)