aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorCalMWolfs <94038482+CalMWolfs@users.noreply.github.com>2023-06-23 00:24:24 +1000
committerGitHub <noreply@github.com>2023-06-22 16:24:24 +0200
commit06aa3dbd0a32b0f2d9d92d30adeec46289428a7e (patch)
tree6b57f7e453f3ef5a451c0b0fb6e09093fd5a5265 /src/main
parentb3e289dbec40cdd0632bac41f510d94af545983c (diff)
downloadskyhanni-06aa3dbd0a32b0f2d9d92d30adeec46289428a7e.tar.gz
skyhanni-06aa3dbd0a32b0f2d9d92d30adeec46289428a7e.tar.bz2
skyhanni-06aa3dbd0a32b0f2d9d92d30adeec46289428a7e.zip
Shy Warning (#251)
Shy Warning
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/RiftConfig.java13
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/rift/CruxWarnings.kt34
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/LocationUtils.kt3
4 files changed, 52 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
index e4a9d682c..b61e79d1d 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
@@ -60,6 +60,7 @@ import at.hannibal2.skyhanni.features.mobs.MobHighlight
import at.hannibal2.skyhanni.features.nether.ashfang.*
import at.hannibal2.skyhanni.features.nether.reputationhelper.CrimsonIsleReputationHelper
import at.hannibal2.skyhanni.features.rift.HighlightRiftGuide
+import at.hannibal2.skyhanni.features.rift.CruxWarnings
import at.hannibal2.skyhanni.features.rift.RiftAPI
import at.hannibal2.skyhanni.features.rift.RiftTimer
import at.hannibal2.skyhanni.features.slayer.*
@@ -306,6 +307,7 @@ class SkyHanniMod {
loadModule(GhostCounter)
loadModule(RiftTimer())
loadModule(HighlightRiftGuide())
+ loadModule(CruxWarnings())
init()
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/RiftConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/RiftConfig.java
index 0477920a2..9434305bd 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/RiftConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/RiftConfig.java
@@ -32,7 +32,20 @@ public class RiftConfig {
@Expose
public Position timerPosition = new Position(10, 10, false, true);
+ }
+
+ @ConfigOption(name = "Crux Warnings", desc = "")
+ @Accordion
+ @Expose
+ public CruxWarnings crux = new CruxWarnings();
+ public static class CruxWarnings {
+
+ @Expose
+ @ConfigOption(name = "Shy Warning", desc = "Shows a warning when a shy is going to steal your time. " +
+ "Useful if you play without volume")
+ @ConfigEditorBoolean
+ public boolean shyWarning = true;
}
@Expose
diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/CruxWarnings.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/CruxWarnings.kt
new file mode 100644
index 000000000..509ed4979
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/rift/CruxWarnings.kt
@@ -0,0 +1,34 @@
+package at.hannibal2.skyhanni.features.rift
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.data.TitleUtils
+import at.hannibal2.skyhanni.test.command.CopyErrorCommand
+import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer
+import net.minecraft.client.Minecraft
+import kotlin.concurrent.fixedRateTimer
+
+class CruxWarnings {
+ private val shyNames = arrayOf("I'm ugly! :(", "Eek!", "Don't look at me!", "Look away!")
+
+ init {
+ fixedRateTimer(name = "skyhanni-shywarner-timer", period = 250) {
+ Minecraft.getMinecraft().thePlayer ?: return@fixedRateTimer
+ checkForShy()
+ }
+ }
+
+ private fun checkForShy() {
+ try {
+ if (!(RiftAPI.inRift() || !SkyHanniMod.feature.rift.crux.shyWarning)) return
+ val world = Minecraft.getMinecraft().theWorld ?: return
+ val loadedEntityList = world.getLoadedEntityList() ?: return
+ for (entity in loadedEntityList) {
+ if (entity.name in shyNames && entity.distanceToPlayer() < 8) {
+ TitleUtils.sendTitle("§eLook away!", 250)
+ }
+ }
+ } catch (e: Throwable) {
+ CopyErrorCommand.logError(e, "Check for Shy failed")
+ }
+ }
+} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LocationUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LocationUtils.kt
index efcc8e493..510f631b6 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/LocationUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/LocationUtils.kt
@@ -1,6 +1,7 @@
package at.hannibal2.skyhanni.utils
import net.minecraft.client.Minecraft
+import net.minecraft.entity.Entity
object LocationUtils {
@@ -12,6 +13,8 @@ object LocationUtils {
fun LorenzVec.distanceToPlayer() = distance(playerLocation())
+ fun Entity.distanceToPlayer() = getLorenzVec().distance(playerLocation())
+
fun playerEyeLocation(): LorenzVec {
val player = Minecraft.getMinecraft().thePlayer
val vec = player.getLorenzVec()