aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-08-03 19:38:08 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-08-03 19:38:08 +0200
commit0ec5e4a3df55c2ce436a11ab95c602feadc8adbf (patch)
treedf71ce9032c5857e0ab5eb1fe21ae1cc6cfa2b0d /src/main/java
parent559cceb47fb24eb7b7ed0a28174c483570f9792a (diff)
downloadskyhanni-0ec5e4a3df55c2ce436a11ab95c602feadc8adbf.tar.gz
skyhanni-0ec5e4a3df55c2ce436a11ab95c602feadc8adbf.tar.bz2
skyhanni-0ec5e4a3df55c2ce436a11ab95c602feadc8adbf.zip
Show the barn fishing timer even for worms or other sea creatures in the crystal hollows.
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/Fishing.java18
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/fishing/BarnFishingTimer.kt42
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureManager.kt4
3 files changed, 49 insertions, 15 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Fishing.java b/src/main/java/at/hannibal2/skyhanni/config/features/Fishing.java
index 2374a9e2f..8ff337693 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/Fishing.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/Fishing.java
@@ -2,7 +2,14 @@ package at.hannibal2.skyhanni.config.features;
import at.hannibal2.skyhanni.config.core.config.Position;
import com.google.gson.annotations.Expose;
-import io.github.moulberry.moulconfig.annotations.*;
+import io.github.moulberry.moulconfig.annotations.Accordion;
+import io.github.moulberry.moulconfig.annotations.ConfigAccordionId;
+import io.github.moulberry.moulconfig.annotations.ConfigEditorAccordion;
+import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean;
+import io.github.moulberry.moulconfig.annotations.ConfigEditorColour;
+import io.github.moulberry.moulconfig.annotations.ConfigEditorDropdown;
+import io.github.moulberry.moulconfig.annotations.ConfigEditorSlider;
+import io.github.moulberry.moulconfig.annotations.ConfigOption;
import io.github.moulberry.moulconfig.observer.Property;
public class Fishing {
@@ -106,6 +113,15 @@ public class Fishing {
public Position barnTimerPos = new Position(10, 10, false, true);
@Expose
+ @ConfigOption(
+ name = "Worm Fishing",
+ desc = "Show the barn fishing timer even for worms or other sea creatures in the crystal hollows."
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 2)
+ public boolean barnTimerCrystalHollows = true;
+
+ @Expose
@ConfigOption(name = "Fishing Timer Alert", desc = "Change the amount of time in seconds until the timer dings.")
@ConfigEditorSlider(
minValue = 240,
diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/BarnFishingTimer.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/BarnFishingTimer.kt
index b1879691d..ed2321058 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/fishing/BarnFishingTimer.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/BarnFishingTimer.kt
@@ -5,25 +5,28 @@ import at.hannibal2.skyhanni.data.IslandType
import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.LorenzTickEvent
import at.hannibal2.skyhanni.utils.*
+import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland
import at.hannibal2.skyhanni.utils.RenderUtils.renderString
import net.minecraft.entity.item.EntityArmorStand
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
class BarnFishingTimer {
-
+ private val config get() = SkyHanniMod.feature.fishing
private val barnLocation = LorenzVec(108, 89, -252)
private var rightLocation = false
private var currentCount = 0
private var startTime = 0L
+ private var inHollows = false
@SubscribeEvent
fun onTick(event: LorenzTickEvent) {
-
if (!LorenzUtils.inSkyBlock) return
- if (!SkyHanniMod.feature.fishing.barnTimer) return
+ if (!config.barnTimer) return
- if (event.repeatSeconds(3)) checkIsland()
+ if (event.repeatSeconds(3)) {
+ rightLocation = isRightLocation()
+ }
if (!rightLocation) return
@@ -35,14 +38,15 @@ class BarnFishingTimer {
if (currentCount == 0) return
val duration = System.currentTimeMillis() - startTime
- val barnTimerAlertTime = SkyHanniMod.feature.fishing.barnTimerAlertTime * 1_000
+ val barnTimerAlertTime = config.barnTimerAlertTime * 1_000
if (duration > barnTimerAlertTime && duration < barnTimerAlertTime + 3_000) {
SoundUtils.playBeepSound()
}
}
private fun checkMobs() {
- val newCount = countMobs()
+ val newCount = if (inHollows) countHollowsMobs() else countMobs()
+
if (currentCount == 0) {
if (newCount > 0) {
startTime = System.currentTimeMillis()
@@ -55,33 +59,43 @@ class BarnFishingTimer {
}
}
+ private fun countHollowsMobs() = EntityUtils.getEntitiesNextToPlayer<EntityArmorStand>(10.0)
+ .count { entity -> SeaCreatureManager.allFishingMobNames.any { entity.name.contains(it) } }
+
private fun countMobs() = EntityUtils.getEntities<EntityArmorStand>()
.map { it.name }
.count { it.endsWith("§c❤") }
- private fun checkIsland() {
- if (LorenzUtils.skyBlockIsland == IslandType.THE_FARMING_ISLANDS) {
- rightLocation = false
- return
+ private fun isRightLocation(): Boolean {
+ if (config.barnTimerCrystalHollows) {
+ if (IslandType.CRYSTAL_HOLLOWS.isInIsland()) {
+ inHollows = true
+ return true
+ }
+ }
+ inHollows = false
+
+ if (IslandType.THE_FARMING_ISLANDS.isInIsland()) {
+ return LocationUtils.playerLocation().distance(barnLocation) < 50
}
- rightLocation = LocationUtils.playerLocation().distance(barnLocation) < 50
+ return false
}
@SubscribeEvent
fun onRenderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) {
if (!LorenzUtils.inSkyBlock) return
- if (!SkyHanniMod.feature.fishing.barnTimer) return
+ if (!config.barnTimer) return
if (!rightLocation) return
if (currentCount == 0) return
val duration = System.currentTimeMillis() - startTime
- val barnTimerAlertTime = SkyHanniMod.feature.fishing.barnTimerAlertTime * 1_000
+ val barnTimerAlertTime = config.barnTimerAlertTime * 1_000
val color = if (duration > barnTimerAlertTime) "§c" else "§e"
val timeFormat = TimeUtils.formatDuration(duration, biggestUnit = TimeUnit.MINUTE)
val name = if (currentCount == 1) "sea creature" else "sea creatures"
val text = "$color$timeFormat §8(§e$currentCount §b$name§8)"
- SkyHanniMod.feature.fishing.barnTimerPos.renderString(text, posLabel = "BarnTimer")
+ config.barnTimerPos.renderString(text, posLabel = "BarnTimer")
}
} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureManager.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureManager.kt
index 9f6527148..73a358e69 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureManager.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureManager.kt
@@ -14,6 +14,7 @@ class SeaCreatureManager {
try {
val data = event.getConstant("SeaCreatures") ?: return
+ val fishingMobNames = mutableListOf<String>()
for (variant in data.entrySet().map { it.value.asJsonObject }) {
val chatColor = variant["chat_color"].asString
for ((displayName, value) in variant["sea_creatures"].asJsonObject.entrySet()) {
@@ -26,9 +27,11 @@ class SeaCreatureManager {
} else false
seaCreatureMap[chatMessage] = SeaCreature(displayName, fishingExperience, chatColor, rare)
+ fishingMobNames.add(displayName)
counter++
}
}
+ allFishingMobNames = fishingMobNames
LorenzUtils.debug("Loaded $counter sea creatures from repo")
} catch (e: Exception) {
@@ -39,6 +42,7 @@ class SeaCreatureManager {
companion object {
private val seaCreatureMap = mutableMapOf<String, SeaCreature>()
+ var allFishingMobNames = emptyList<String>()
fun getSeaCreature(message: String): SeaCreature? {
return seaCreatureMap.getOrDefault(message, null)