aboutsummaryrefslogtreecommitdiff
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
parent5e273444ac192d1e10c48618de72c517c6b52c45 (diff)
downloadskyhanni-578a0b7454c772b4546677ed4518d5acc95e54d1.tar.gz
skyhanni-578a0b7454c772b4546677ed4518d5acc95e54d1.tar.bz2
skyhanni-578a0b7454c772b4546677ed4518d5acc95e54d1.zip
Adjustable Pitch and Yaw settings (#77)
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/Garden.java56
-rwxr-xr-xsrc/main/java/at/hannibal2/skyhanni/features/garden/GardenYawAndPitch.kt31
2 files changed, 63 insertions, 24 deletions
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
@@ -987,6 +987,54 @@ public class Garden {
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
public boolean plotPrice = true;
@@ -1024,14 +1072,6 @@ public class Garden {
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
public boolean forcefullyEnabledAlwaysFinnegan = false;
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
}