blob: 2575d4431dfffc84052413c3eabedcfa4972146e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
package at.hannibal2.skyhanni.features.dungeon
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.events.RenderEntityOutlineEvent
import net.minecraft.client.Minecraft
import net.minecraft.client.entity.EntityOtherPlayerMP
import net.minecraft.client.gui.FontRenderer
import net.minecraft.entity.Entity
import net.minecraft.scoreboard.ScorePlayerTeam
import net.minecraft.scoreboard.Team
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
class DungeonTeammateOutlines {
private val config get() = SkyHanniMod.feature.dungeon
@SubscribeEvent
fun onRenderEntityOutlines(event: RenderEntityOutlineEvent) {
if (isEnabled() && event.type === RenderEntityOutlineEvent.Type.XRAY) {
event.queueEntitiesToOutline { entity -> getEntityOutlineColor(entity) }
}
}
private fun isEnabled() = DungeonAPI.inDungeon() && config.highlightTeammates
private fun getEntityOutlineColor(entity: Entity): Int? {
if (entity !is EntityOtherPlayerMP || entity.team == null) return null
// Must be visible on the scoreboard
val team = entity.team as ScorePlayerTeam
if (team.nameTagVisibility == Team.EnumVisible.NEVER) return null
val colorFormat = FontRenderer.getFormatFromString(team.colorPrefix)
return if (colorFormat.length >= 2)
Minecraft.getMinecraft().fontRendererObj.getColorCode(colorFormat[1])
else null
}
}
|