aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/com/ambientaddons/utils/TabListUtils.kt
diff options
context:
space:
mode:
authorAppability <appable@icloud.com>2022-10-11 23:59:37 -0700
committerAppability <appable@icloud.com>2022-10-11 23:59:37 -0700
commit2c0e73deb53f54d78bd5594786313ac82151be1a (patch)
tree97fc2f389cc99d8f9e078a1cd7b0c6a5859a3f34 /src/main/kotlin/com/ambientaddons/utils/TabListUtils.kt
parent363b2426f8d9e45e52c472750c798dcaceb05a88 (diff)
downloadAmbientAddons-2c0e73deb53f54d78bd5594786313ac82151be1a.tar.gz
AmbientAddons-2c0e73deb53f54d78bd5594786313ac82151be1a.tar.bz2
AmbientAddons-2c0e73deb53f54d78bd5594786313ac82151be1a.zip
added chest qol features (complete, i think)
Diffstat (limited to 'src/main/kotlin/com/ambientaddons/utils/TabListUtils.kt')
-rw-r--r--src/main/kotlin/com/ambientaddons/utils/TabListUtils.kt38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/main/kotlin/com/ambientaddons/utils/TabListUtils.kt b/src/main/kotlin/com/ambientaddons/utils/TabListUtils.kt
new file mode 100644
index 0000000..6fd7fef
--- /dev/null
+++ b/src/main/kotlin/com/ambientaddons/utils/TabListUtils.kt
@@ -0,0 +1,38 @@
+package com.ambientaddons.utils
+
+import AmbientAddons.Companion.mc
+import com.google.common.collect.ComparisonChain
+import com.google.common.collect.Ordering
+import net.minecraft.client.network.NetworkPlayerInfo
+import net.minecraft.world.WorldSettings
+
+// From SkytilsMod/Skytils, under AGPL 3.0
+val NetworkPlayerInfo.text: String
+ get() = mc.ingameGUI.tabList.getPlayerName(this)
+
+object TabListUtils {
+ private val playerInfoOrdering = object : Ordering<NetworkPlayerInfo>() {
+ override fun compare(p_compare_1_: NetworkPlayerInfo?, p_compare_2_: NetworkPlayerInfo?): Int {
+ val scorePlayerTeam = p_compare_1_?.playerTeam
+ val scorePlayerTeam1 = p_compare_2_?.playerTeam
+ if (p_compare_1_ != null) {
+ if (p_compare_2_ != null) {
+ return ComparisonChain.start().compareTrueFirst(
+ p_compare_1_.gameType != WorldSettings.GameType.SPECTATOR,
+ p_compare_2_.gameType != WorldSettings.GameType.SPECTATOR
+ ).compare(
+ if (scorePlayerTeam != null) scorePlayerTeam.registeredName else "",
+ if (scorePlayerTeam1 != null) scorePlayerTeam1.registeredName else ""
+ ).compare(p_compare_1_.gameProfile.name, p_compare_2_.gameProfile.name).result()
+ }
+ return 0
+ }
+ return -1
+ }
+ }
+
+ fun fetchTabEntries(): List<NetworkPlayerInfo> =
+ if (mc.thePlayer == null) emptyList() else playerInfoOrdering.sortedCopy(
+ mc.thePlayer.sendQueue.playerInfoMap
+ )
+} \ No newline at end of file