aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features/misc
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/misc')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabLine.kt24
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabListReader.kt30
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabListRenderer.kt14
3 files changed, 48 insertions, 20 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabLine.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabLine.kt
index 315ea1556..96b89ce17 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabLine.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabLine.kt
@@ -1,12 +1,14 @@
package at.hannibal2.skyhanni.features.misc.compacttablist
import net.minecraft.client.Minecraft
+import net.minecraft.client.network.NetworkPlayerInfo
+import net.minecraft.entity.player.EntityPlayer
-class TabLine(var text: String, var type: TabStringType) {
+class TabLine(val text: String, val type: TabStringType, val customName: String = text) {
fun getWidth(): Int {
val mc = Minecraft.getMinecraft()
- var width = mc.fontRendererObj.getStringWidth(text)
+ var width = mc.fontRendererObj.getStringWidth(customName)
if (type === TabStringType.PLAYER) {
width += 8 + 2 // Player head
}
@@ -15,4 +17,22 @@ class TabLine(var text: String, var type: TabStringType) {
}
return width
}
+
+ fun getInfo(): NetworkPlayerInfo? {
+ val minecraft = Minecraft.getMinecraft()
+ val usernameFromLine = TabStringType.usernameFromLine(text)
+ return minecraft.netHandler.getPlayerInfo(usernameFromLine)
+ }
+
+ private var entity: EntityPlayer? = null
+
+ fun getEntity(pLayerInfo: NetworkPlayerInfo): EntityPlayer? {
+ entity?.let {
+ return it
+ }
+ val minecraft = Minecraft.getMinecraft()
+ val entity = minecraft.theWorld.getPlayerEntityByUUID(pLayerInfo.gameProfile.id)
+ this.entity = entity
+ return entity
+ }
} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabListReader.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabListReader.kt
index 3d0275f28..b9d4ffb53 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabListReader.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabListReader.kt
@@ -29,6 +29,7 @@ object TabListReader {
private val dungeonBuffPattern = "Dungeon Buffs(?:§.)*(?:\\n(§.)*§7.+)*".toPattern()
private val upgradesPattern = "(?<firstPart>§e[A-Za-z ]+)(?<secondPart> §f[\\w ]+)".toPattern()
private val tabListSPattern = "(?i)§S".toPattern()
+ private var playerDatas = mutableMapOf<String, PlayerData>()
val renderColumns = mutableListOf<RenderColumn>()
@@ -83,9 +84,11 @@ object TabListReader {
if (LorenzUtils.inKuudraFight) return original
if (LorenzUtils.inDungeons) return original
+ if (LorenzUtils.isControlKeyDown()) return original
+
val pattern = ".*\\[(?<level>.*)] (?<name>.*)".toPattern()
val newList = mutableListOf<String>()
- val playerDatas = mutableMapOf<String, PlayerData>()
+ val currentData = mutableMapOf<String, PlayerData>()
newList.add(original.first())
var extraTitles = 0
@@ -104,7 +107,7 @@ object TabListReader {
val removeColor = levelText.removeColor()
try {
val playerData = PlayerData(removeColor.toInt())
- playerDatas[line] = playerData
+ currentData[line] = playerData
val fullName = group("name")
val name = fullName.split(" ")
@@ -131,7 +134,8 @@ object TabListReader {
}
}
}
- val prepare = playerDatas.entries
+ playerDatas = currentData
+ val prepare = currentData.entries
val sorted = when (config.playerSortOrder) {
@@ -153,7 +157,7 @@ object TabListReader {
else -> prepare
}
- var newPlayerList = sorted.map { buildName(it.value) }.toMutableList()
+ var newPlayerList = sorted.map { it.key }.toMutableList()
if (config.reverseSort) {
newPlayerList = newPlayerList.reversed().toMutableList()
}
@@ -167,7 +171,7 @@ object TabListReader {
return newList
}
- private fun buildName(data: PlayerData): String {
+ private fun createCustomName(data: PlayerData): String {
val playerName = if (config.useLevelColorForName) {
val c = data.levelText[3]
"§$c" + data.name
@@ -341,13 +345,13 @@ object TabListReader {
currentCount = 1
} else {
if (firstColumnCopy.size() > 0) {
- firstColumnCopy.addLine(TabLine("", TabStringType.TEXT))
+ firstColumnCopy.addLine(createTabLine("", TabStringType.TEXT))
}
}
if (needsTitle) {
lastTitle = section.columnValue.columnTitle
- firstColumnCopy.addLine(TabLine(lastTitle, TabStringType.TITLE))
+ firstColumnCopy.addLine(createTabLine(lastTitle, TabStringType.TITLE))
currentCount++
}
@@ -357,7 +361,7 @@ object TabListReader {
currentCount = 1
}
- firstColumnCopy.addLine(TabLine(line, TabStringType.fromLine(line)))
+ firstColumnCopy.addLine(createTabLine(line, TabStringType.fromLine(line)))
currentCount++
}
} else {
@@ -365,20 +369,24 @@ object TabListReader {
renderColumns.add(RenderColumn().also { firstColumnCopy = it })
} else {
if (firstColumnCopy.size() > 0) {
- firstColumnCopy.addLine(TabLine("", TabStringType.TEXT))
+ firstColumnCopy.addLine(createTabLine("", TabStringType.TEXT))
}
}
if (needsTitle) {
lastTitle = section.columnValue.columnTitle
- firstColumnCopy.addLine(TabLine(lastTitle, TabStringType.TITLE))
+ firstColumnCopy.addLine(createTabLine(lastTitle, TabStringType.TITLE))
}
for (line in section.lines) {
- firstColumnCopy.addLine(TabLine(line, TabStringType.fromLine(line)))
+ firstColumnCopy.addLine(createTabLine(line, TabStringType.fromLine(line)))
}
}
}
}
}
+
+ private fun createTabLine(text: String, type: TabStringType) = playerDatas[text]?.let {
+ TabLine(text, type, createCustomName(it))
+ } ?: TabLine(text, type)
} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabListRenderer.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabListRenderer.kt
index ea850f6e2..8c4640603 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabListRenderer.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabListRenderer.kt
@@ -106,13 +106,13 @@ object TabListRenderer {
val savedX = middleX
if (tabLine.type == TabStringType.PLAYER) {
- val pLayerInfo = minecraft.netHandler.getPlayerInfo(TabStringType.usernameFromLine(tabLine.text))
- if (pLayerInfo != null) {
- val player = minecraft.theWorld.getPlayerEntityByUUID(pLayerInfo.gameProfile.id)
-
- minecraft.textureManager.bindTexture(pLayerInfo.locationSkin)
+ val playerInfo = tabLine.getInfo()
+ if (playerInfo != null) {
+ minecraft.textureManager.bindTexture(playerInfo.locationSkin)
GlStateManager.color(1f, 1f, 1f, 1f)
Gui.drawScaledCustomSizeModalRect(middleX, middleY, 8f, 8f, 8, 8, 8, 8, 64.0f, 64.0f)
+
+ val player = tabLine.getEntity(playerInfo)
if (player != null && player.isWearing(EnumPlayerModelParts.HAT)) {
Gui.drawScaledCustomSizeModalRect(middleX, middleY, 40.0f, 8f, 8, 8, 8, 8, 64.0f, 64.0f)
}
@@ -122,14 +122,14 @@ object TabListRenderer {
if (tabLine.type == TabStringType.TITLE) {
minecraft.fontRendererObj.drawStringWithShadow(
- tabLine.text,
+ tabLine.customName,
middleX + column.getMaxWidth() / 2f - tabLine.getWidth() / 2f,
middleY.toFloat(),
0xFFFFFF
)
} else {
minecraft.fontRendererObj.drawStringWithShadow(
- tabLine.text,
+ tabLine.customName,
middleX.toFloat(),
middleY.toFloat(),
0xFFFFFF