diff options
Diffstat (limited to 'src/main')
3 files changed, 60 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 885a8093e..e1efbc052 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -261,6 +261,7 @@ class SkyHanniMod { loadModule(GardenBurrowingSporesNotifier()) loadModule(WildStrawberryDyeNotification()) loadModule(JacobContestFFNeededDisplay()) + loadModule(GardenYawAndPitch()) init() loadModule(LorenzTest()) loadModule(ButtonOnPause()) 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 825b2b3bf..bfe47798b 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java @@ -1024,6 +1024,14 @@ 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 new file mode 100755 index 000000000..a6738aa16 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenYawAndPitch.kt @@ -0,0 +1,51 @@ +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.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 + private var lastChange = 0L + private var lastYaw = 0f + private var lastPitch = 0f + + @SubscribeEvent + fun onRenderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) { + 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 + + if (pYaw != lastYaw || pPitch != lastPitch) { + lastChange = System.currentTimeMillis() + } + lastYaw = pYaw + lastPitch = pPitch + + if (System.currentTimeMillis() > lastChange + 3_000) 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") + } + + @SubscribeEvent + fun onGardenToolChange(event: GardenToolChangeEvent) { + lastChange = System.currentTimeMillis() + } + + private fun isEnabled() = GardenAPI.inGarden() && config.showYawAndPitch +} |