blob: 20cf553b802cdc4abd875f09d79c2c8cfa3fc18c (
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
package at.hannibal2.skyhanni.features.event.diana
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.data.ClickType
import at.hannibal2.skyhanni.events.BurrowGuessEvent
import at.hannibal2.skyhanni.events.ItemClickEvent
import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent
import at.hannibal2.skyhanni.events.SecondPassedEvent
import at.hannibal2.skyhanni.features.event.diana.DianaAPI.isDianaSpade
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.test.command.ErrorManager
import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.HypixelCommands
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import kotlin.time.Duration.Companion.minutes
import kotlin.time.Duration.Companion.seconds
@SkyHanniModule
object DianaFixChat {
private val config get() = SkyHanniMod.feature.event.diana
private var hasSetParticleQuality = false
private var hasSetToggleMusic = false
private var lastParticleQualityPrompt = SimpleTimeMark.farPast()
private var lastToggleMusicPrompt = SimpleTimeMark.farPast()
private var errorCounter = 0
private var successfulCounter = 0
private var lastSpadeUse = SimpleTimeMark.farPast()
private var lastErrorTime = SimpleTimeMark.farPast()
private var lastGuessPoint = SimpleTimeMark.farPast()
private var foundGuess = false
@SubscribeEvent
fun onSecondPassed(event: SecondPassedEvent) {
if (!isEnabled()) return
if (lastSpadeUse.passedSince() > 1.minutes) return
if (foundGuess) {
lastErrorTime = SimpleTimeMark.farPast()
return
}
// particles don't work if a valid target point is close
if (GriffinBurrowHelper.targetLocation != null) return
val spadeUse = lastSpadeUse.passedSince()
if (spadeUse <= 3.seconds) return
if (lastErrorTime == lastSpadeUse) return
lastErrorTime = lastSpadeUse
noGuessFound()
}
private fun noGuessFound() {
errorCounter++
if (errorCounter == 1) {
if (successfulCounter < 5) {
ChatUtils.chat("Could not find Diana Guess using sound and particles, please try again. (Was this a funny sound easter egg?)")
}
return
}
println("error")
if (!hasSetParticleQuality) {
if (lastParticleQualityPrompt.passedSince() > 30.seconds) {
lastParticleQualityPrompt = SimpleTimeMark.now()
ChatUtils.clickableChat(
"§cError detecting Diana Guess! §eClick here to set the particle quality to high!",
onClick = {
hasSetParticleQuality = true
HypixelCommands.particleQuality("high")
errorCounter = 0
ChatUtils.chat("Now try again!")
})
}
} else {
if (!hasSetToggleMusic) {
if (lastToggleMusicPrompt.passedSince() > 30.seconds) {
lastToggleMusicPrompt = SimpleTimeMark.now()
ChatUtils.clickableChat(
"§cError detecting Diana Guess! Changing the Particle Quality has not worked :( " +
"§eClick here to disable hypixel music!",
onClick = {
hasSetToggleMusic = true
HypixelCommands.toggleMusic()
errorCounter = 0
ChatUtils.chat("Now try again, please!")
})
}
} else {
ErrorManager.logErrorStateWithData(
"Could not find diana guess point",
"diana guess point failed to load after /pq and /togglemusic",
"errorCounter" to errorCounter,
"successfulCounter" to successfulCounter,
)
}
}
}
@SubscribeEvent
fun onItemClick(event: ItemClickEvent) {
if (!isEnabled()) return
if (event.clickType != ClickType.RIGHT_CLICK) return
val item = event.itemInHand ?: return
if (!item.isDianaSpade) return
if (lastSpadeUse.passedSince() > 5.seconds) {
lastSpadeUse = SimpleTimeMark.now()
foundGuess = false
}
}
@SubscribeEvent
fun onBurrowGuess(event: BurrowGuessEvent) {
foundGuess = true
if (hasSetToggleMusic) {
ChatUtils.chat("Toggling the hypixel music has worked, good job!")
} else if (hasSetParticleQuality) {
ChatUtils.chat("Changing the particle quality has worked, good job!")
}
hasSetParticleQuality = false
hasSetToggleMusic = false
errorCounter = 0
// This ensures we only count successes after new spade clicks, not the repeated moved guess locations
if (lastGuessPoint != lastSpadeUse) {
lastGuessPoint = lastSpadeUse
lastGuessPoint = SimpleTimeMark.now()
successfulCounter++
}
}
@SubscribeEvent
fun onWorldChange(event: LorenzWorldChangeEvent) {
successfulCounter = 0
}
private fun isEnabled() = DianaAPI.isDoingDiana() && config.burrowsSoopyGuess
}
|