From 578a0b7454c772b4546677ed4518d5acc95e54d1 Mon Sep 17 00:00:00 2001 From: thesefer <20844000+thesefer@users.noreply.github.com> Date: Sat, 29 Apr 2023 16:49:04 +0200 Subject: Adjustable Pitch and Yaw settings (#77) --- .../hannibal2/skyhanni/config/features/Garden.java | 56 ++++++++++++++++++---- .../skyhanni/features/garden/GardenYawAndPitch.kt | 31 ++++++------ 2 files changed, 63 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java b/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java index c07806d80..3c659f52a 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java @@ -986,6 +986,54 @@ public class Garden { @ConfigAccordionId(id = 20) public int cropTooltipFortune = 1; + @Expose + @ConfigOption(name = "Yaw and Pitch", desc = "") + @Accordion + public YawPitchDisplay yawPitchDisplay = new YawPitchDisplay(); + + public static class YawPitchDisplay { + + @Expose + @ConfigOption(name = "Enable", desc = "Displays yaw and pitch while holding a farming tool. Automatically fades out if there is no movement.") + @ConfigEditorBoolean + public boolean enabled = false; + + @Expose + @ConfigOption(name = "Yaw Precision", desc = "Yaw precision up to specified decimal.") + @ConfigEditorSlider( + minValue = 1, + maxValue = 10, + minStep = 1 + ) + public int yawPrecision = 4; + + @Expose + @ConfigOption(name = "Pitch Precision", desc = "Pitch precision up to specified decimal.") + @ConfigEditorSlider( + minValue = 1, + maxValue = 10, + minStep = 1 + ) + public int pitchPrecision = 4; + + @Expose + @ConfigOption(name = "Display Timeout", desc = "Duration in seconds for which the overlay is being displayed after moving.") + @ConfigEditorSlider( + minValue = 1, + maxValue = 20, + minStep = 1 + ) + public int timeout = 5; + + @Expose + @ConfigOption(name = "Always Shown", desc = "Always show the Yaw and Pitch overlay, ignoring the timeout.") + @ConfigEditorBoolean + public boolean showAlways = false; + + @Expose + public Position pos = new Position(445, 225, false, true); + } + @Expose @ConfigOption(name = "Plot Price", desc = "Show the price of the plot in coins when inside the Configure Plots inventory.") @ConfigEditorBoolean @@ -1023,14 +1071,6 @@ public class Garden { @Expose public Position farmingFortuneForContestPos = new Position(180, 156, false, true); - @Expose - @ConfigOption(name = "Yaw / Pitch", desc = "Displays yaw and pitch with 4-digit accuracy while holding a farming tool. Automatically fades out if there is no movement for 3 seconds.") - @ConfigEditorBoolean - public boolean showYawAndPitch = false; - - @Expose - public Position YawAndPitchDisplayPos = new Position(445, 225, false, true); - @Expose @ConfigOption(name = "Always Finnegan", desc = "Forcefully set the Finnegan Farming Simulator perk to be active. This is useful if the auto mayor detection fails.") @ConfigEditorBoolean 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() 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 } -- cgit