blob: 32f4cafdf317f714fd18722a01d2f4eaef2476e8 (
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
|
package at.hannibal2.skyhanni.features.garden
import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
import at.hannibal2.skyhanni.config.enums.OutsideSbFeature
import at.hannibal2.skyhanni.events.GardenToolChangeEvent
import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.round
import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import net.minecraft.client.Minecraft
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import kotlin.time.Duration.Companion.seconds
class GardenYawAndPitch {
private val config get() = GardenAPI.config.yawPitchDisplay
private var lastChange = SimpleTimeMark.farPast()
private var lastYaw = 0f
private var lastPitch = 0f
@SubscribeEvent
fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) {
if (!LorenzUtils.onHypixel) return
if (!isEnabled()) return
if (GardenAPI.hideExtraGuis()) return
if (GardenAPI.toolInHand == null && !config.showWithoutTool) return
val player = Minecraft.getMinecraft().thePlayer
var yaw = player.rotationYaw % 360
if (yaw < 0) yaw += 360
if (yaw > 180) yaw -= 360
val pitch = player.rotationPitch
if (yaw != lastYaw || pitch != lastPitch) {
lastChange = SimpleTimeMark.now()
}
lastYaw = yaw
lastPitch = pitch
if (!config.showAlways && lastChange.passedSince() > config.timeout.seconds) return
val yawText = yaw.round(config.yawPrecision).toBigDecimal().toPlainString()
val pitchText = pitch.round(config.pitchPrecision).toBigDecimal().toPlainString()
val displayList = listOf(
"§aYaw: §f$yawText",
"§aPitch: §f$pitchText",
)
if (GardenAPI.inGarden()) {
config.pos.renderStrings(displayList, posLabel = "Yaw and Pitch")
} else {
config.posOutside.renderStrings(displayList, posLabel = "Yaw and Pitch")
}
}
@SubscribeEvent
fun onGardenToolChange(event: GardenToolChangeEvent) {
lastChange = SimpleTimeMark.farPast()
}
private fun isEnabled() =
config.enabled && ((OutsideSbFeature.YAW_AND_PITCH.isSelected() && !LorenzUtils.inSkyBlock) ||
(LorenzUtils.inSkyBlock && (GardenAPI.inGarden() || config.showOutsideGarden)))
@SubscribeEvent
fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) {
event.move(18, "garden.yawPitchDisplay.showEverywhere", "garden.yawPitchDisplay.showOutsideGarden")
}
}
|