blob: 69b0b85a8c10d0b274a2326736b70455c7fa56d0 (
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
package at.hannibal2.skyhanni.data.mob
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.config.features.dev.DebugMobConfig.HowToShow
import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent
import at.hannibal2.skyhanni.events.MobEvent
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.test.command.CopyNearbyEntitiesCommand.getMobInfo
import at.hannibal2.skyhanni.utils.LocationUtils.getTopCenter
import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzDebug
import at.hannibal2.skyhanni.utils.MobUtils
import at.hannibal2.skyhanni.utils.RenderUtils.drawFilledBoundingBox_nea
import at.hannibal2.skyhanni.utils.RenderUtils.drawString
import at.hannibal2.skyhanni.utils.RenderUtils.expandBlock
import net.minecraft.client.Minecraft
import net.minecraft.client.entity.EntityPlayerSP
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@SkyHanniModule
object MobDebug {
private val config get() = SkyHanniMod.feature.dev.mobDebug.mobDetection
private var lastRayHit: Mob? = null
private fun HowToShow.isHighlight() =
this == HowToShow.ONLY_HIGHLIGHT || this == HowToShow.NAME_AND_HIGHLIGHT
private fun HowToShow.isName() =
this == HowToShow.ONLY_NAME || this == HowToShow.NAME_AND_HIGHLIGHT
private fun Mob.isNotInvisible() = !this.isInvisible() || (config.showInvisible && this == lastRayHit)
private fun MobData.MobSet.highlight(event: LorenzRenderWorldEvent, color: (Mob) -> (LorenzColor)) {
for (mob in filter { it.isNotInvisible() }) {
event.drawFilledBoundingBox_nea(mob.boundingBox.expandBlock(), color.invoke(mob).toColor(), 0.3f)
}
}
private fun MobData.MobSet.showName(event: LorenzRenderWorldEvent) {
val map = filter { it.canBeSeen() && it.isNotInvisible() }
.map { it.boundingBox.getTopCenter() to it.name }
for ((location, text) in map) {
event.drawString(location.add(y = 0.5), "§5$text", seeThroughBlocks = true)
}
}
@SubscribeEvent
fun onWorldRenderDebug(event: LorenzRenderWorldEvent) {
if (config.showRayHit || config.showInvisible) {
lastRayHit = MobUtils.rayTraceForMobs(Minecraft.getMinecraft().thePlayer, event.partialTicks)
?.firstOrNull { it.canBeSeen() && (!config.showInvisible || !it.isInvisible()) }
}
if (config.skyblockMob.isHighlight()) {
MobData.skyblockMobs.highlight(event) { if (it.mobType == Mob.Type.BOSS) LorenzColor.DARK_GREEN else LorenzColor.GREEN }
}
if (config.displayNPC.isHighlight()) {
MobData.displayNPCs.highlight(event) { LorenzColor.RED }
}
if (config.realPlayerHighlight) {
MobData.players.highlight(event) { if (it.baseEntity is EntityPlayerSP) LorenzColor.CHROMA else LorenzColor.BLUE }
}
if (config.summon.isHighlight()) {
MobData.summoningMobs.highlight(event) { LorenzColor.YELLOW }
}
if (config.special.isHighlight()) {
MobData.special.highlight(event) { LorenzColor.AQUA }
}
if (config.skyblockMob.isName()) {
MobData.skyblockMobs.showName(event)
}
if (config.displayNPC.isName()) {
MobData.displayNPCs.showName(event)
}
if (config.summon.isName()) {
MobData.summoningMobs.showName(event)
}
if (config.special.isName()) {
MobData.special.showName(event)
}
if (config.showRayHit) {
lastRayHit?.let {
event.drawFilledBoundingBox_nea(it.boundingBox.expandBlock(), LorenzColor.GOLD.toColor(), 0.5f)
}
}
}
@SubscribeEvent
fun onMobEvent(event: MobEvent) {
if (!config.logEvents) return
val text = "Mob ${if (event is MobEvent.Spawn) "Spawn" else "Despawn"}: ${
getMobInfo(event.mob).joinToString(", ")
}"
MobData.logger.log(text)
LorenzDebug.log(text)
}
}
|