blob: f569a0f217ee084f9694435b9f24f3e78d911630 (
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
|
package at.hannibal2.skyhanni.features.garden
import at.hannibal2.skyhanni.SkyHanniMod
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 net.minecraft.client.Minecraft
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
class GardenYawAndPitch {
private val config get() = SkyHanniMod.feature.garden.yawPitchDisplay
private var lastChange = 0L
private var lastYaw = 0f
private var lastPitch = 0f
@SubscribeEvent
fun onRenderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) {
if (!LorenzUtils.inSkyBlock) return
if (!config.enabled) return
if (!GardenAPI.inGarden() && !config.showEverywhere) 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 = System.currentTimeMillis()
}
lastYaw = yaw
lastPitch = pitch
if (!config.showAlways && System.currentTimeMillis() > lastChange + (config.timeout * 1000)) return
val displayList = listOf(
"§aYaw: §f${yaw.toDouble().round(config.yawPrecision)}",
"§aPitch: §f${pitch.toDouble().round(config.pitchPrecision)}",
)
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 = System.currentTimeMillis()
}
}
|