aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features
diff options
context:
space:
mode:
authorthesefer <20844000+thesefer@users.noreply.github.com>2023-04-29 16:49:04 +0200
committerGitHub <noreply@github.com>2023-04-29 16:49:04 +0200
commit578a0b7454c772b4546677ed4518d5acc95e54d1 (patch)
treeab87e4602d67d95bbe51c12697694c0acab4a4b0 /src/main/java/at/hannibal2/skyhanni/features
parent5e273444ac192d1e10c48618de72c517c6b52c45 (diff)
downloadskyhanni-578a0b7454c772b4546677ed4518d5acc95e54d1.tar.gz
skyhanni-578a0b7454c772b4546677ed4518d5acc95e54d1.tar.bz2
skyhanni-578a0b7454c772b4546677ed4518d5acc95e54d1.zip
Adjustable Pitch and Yaw settings (#77)
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
-rwxr-xr-xsrc/main/java/at/hannibal2/skyhanni/features/garden/GardenYawAndPitch.kt31
1 files changed, 15 insertions, 16 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenYawAndPitch.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenYawAndPitch.kt
index a6738aa16..59356f30d 100755
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenYawAndPitch.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenYawAndPitch.kt
@@ -9,7 +9,7 @@ import net.minecraft.client.Minecraft
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
class GardenYawAndPitch {
- private val config get() = SkyHanniMod.feature.garden
+ private val config get() = SkyHanniMod.feature.garden.yawPitchDisplay
private var lastChange = 0L
private var lastYaw = 0f
private var lastPitch = 0f
@@ -19,27 +19,26 @@ class GardenYawAndPitch {
if (!isEnabled()) return
if (GardenAPI.toolInHand == null) return
- val ypList = mutableListOf<String>()
val player = Minecraft.getMinecraft().thePlayer
- var pYaw = player.rotationYaw % 360
- if (pYaw < 0) pYaw += 360
- if (pYaw > 180) pYaw -= 360
- val pPitch = player.rotationPitch
+ var yaw = player.rotationYaw % 360
+ if (yaw < 0) yaw += 360
+ if (yaw > 180) yaw -= 360
+ val pitch = player.rotationPitch
- if (pYaw != lastYaw || pPitch != lastPitch) {
+ if (yaw != lastYaw || pitch != lastPitch) {
lastChange = System.currentTimeMillis()
}
- lastYaw = pYaw
- lastPitch = pPitch
+ lastYaw = yaw
+ lastPitch = pitch
- if (System.currentTimeMillis() > lastChange + 3_000) return
+ if (!config.showAlways && System.currentTimeMillis() > lastChange + (config.timeout * 1000)) return
- ypList.add("§aYaw: §f${pYaw.toDouble().round(4)}")
-
- ypList.add("§aPitch: §f${pPitch.toDouble().round(4)}")
-
- config.YawAndPitchDisplayPos.renderStrings(ypList, posLabel = "Yaw and Pitch")
+ val displayList = listOf(
+ "§aYaw: §f${yaw.toDouble().round(config.yawPrecision)}",
+ "§aPitch: §f${pitch.toDouble().round(config.pitchPrecision)}",
+ )
+ config.pos.renderStrings(displayList, posLabel = "Yaw and Pitch")
}
@SubscribeEvent
@@ -47,5 +46,5 @@ class GardenYawAndPitch {
lastChange = System.currentTimeMillis()
}
- private fun isEnabled() = GardenAPI.inGarden() && config.showYawAndPitch
+ private fun isEnabled() = GardenAPI.inGarden() && config.enabled
}