aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md1
-rw-r--r--FEATURES.md3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/Features.java5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/Fishing.java24
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/fishing/BarnFishingTimer.kt95
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt6
7 files changed, 129 insertions, 7 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index bd19924f9..80caf86cd 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,7 @@
### Features
+ Added Bazaar Update Timer - Forrick.
+ Added Crimson Isle Reputation Helper.
++ Added Barn Timer - Shows the time and amount of sea creatures while fishing on the barn via hub.
## Version 0.14
diff --git a/FEATURES.md b/FEATURES.md
index 73aca5573..21934d8ac 100644
--- a/FEATURES.md
+++ b/FEATURES.md
@@ -98,7 +98,8 @@
- Trophy Counter (After fishing a new trophy fish, showing you in chat how many more trophies you have collected in total)
- Hide Bronze Duplicates (Hiding chat message when picking up a duplicate bronze trophy fish)
- Shorten Fishing Message (Replacing the green chat message when fishing a sea creature with a more clean format)
-- Highlight Thunder Sparks after killing a Thunder
+- Highlight Thunder Sparks that spawn after killing a Thunder
+- Barn Timer - Shows the time and amount of sea creatures while fishing on the barn via hub.
## Damage Indicator
- Show the remaining health of selected bosses in the game in a bigger GUI.
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
index 3297cdc3e..b0574d046 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
@@ -21,6 +21,7 @@ import at.hannibal2.skyhanni.features.event.diana.BurrowWarpHelper;
import at.hannibal2.skyhanni.features.event.diana.GriffinBurrowHelper;
import at.hannibal2.skyhanni.features.event.diana.GriffinBurrowParticleFinder;
import at.hannibal2.skyhanni.features.event.diana.SoopyGuessBurrow;
+import at.hannibal2.skyhanni.features.fishing.BarnFishingTimer;
import at.hannibal2.skyhanni.features.fishing.SeaCreatureManager;
import at.hannibal2.skyhanni.features.fishing.SeaCreatureMessageShortener;
import at.hannibal2.skyhanni.features.fishing.TrophyFishMessages;
@@ -172,6 +173,7 @@ public class SkyHanniMod {
loadModule(new CompactBingoChat());
loadModule(new BrewingStandOverlay());
loadModule(new BazaarUpdateTimer());
+ loadModule(new BarnFishingTimer());
loadModule(new CrimsonIsleReputationHelper(this));
diff --git a/src/main/java/at/hannibal2/skyhanni/config/Features.java b/src/main/java/at/hannibal2/skyhanni/config/Features.java
index 61bdf55a1..64bfe9541 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/Features.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/Features.java
@@ -116,6 +116,11 @@ public class Features extends Config {
editOverlay(activeConfigCategory, 200, 16, misc.crimsonIsleReputationHelperPos);
return;
}
+
+ if (runnableId.equals("barnTimer")) {
+ editOverlay(activeConfigCategory, 200, 16, fishing.barnTimerPos);
+ return;
+ }
}
@Expose
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 72fdaff73..e3be3fc00 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/Fishing.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/Fishing.java
@@ -1,5 +1,6 @@
package at.hannibal2.skyhanni.config.features;
+import at.hannibal2.skyhanni.config.core.config.Position;
import at.hannibal2.skyhanni.config.core.config.annotations.*;
import com.google.gson.annotations.Expose;
@@ -10,7 +11,10 @@ public class Fishing {
public boolean trophyFishing = false;
@Expose
- @ConfigOption(name = "Trophy Counter", desc = "Counts every single Trohy message from chat and tells you how many you got already.")
+ @ConfigOption(
+ name = "Trophy Counter",
+ desc = "Counts every single Trohy message from chat and tells you how many you got already."
+ )
@ConfigEditorBoolean
@ConfigAccordionId(id = 0)
public boolean trophyCounter = false;
@@ -37,11 +41,21 @@ public class Fishing {
public boolean thunderSparkHighlight = false;
@Expose
- @ConfigOption(
- name = "Thunder Spark Color",
- desc = "Color of the Thunder Sparks"
- )
+ @ConfigOption(name = "Thunder Spark Color", desc = "Color of the Thunder Sparks")
@ConfigEditorColour
@ConfigAccordionId(id = 1)
public String thunderSparkColor = "0:255:255:255:255";
+
+ @Expose
+ @ConfigOption(
+ name = "Barn Fishing Timer",
+ desc = "Shows the time and amount of sea creatures while fishing on the barn via hub."
+ )
+ @ConfigEditorBoolean
+ public boolean barnTimer = true;
+
+ @Expose
+ @ConfigOption(name = "Fishing Timer Location", desc = "")
+ @ConfigEditorButton(runnableId = "barnTimer", buttonText = "Edit")
+ public Position barnTimerPos = new Position(10, 10, false, true);
} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/BarnFishingTimer.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/BarnFishingTimer.kt
new file mode 100644
index 000000000..1567c52a3
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/BarnFishingTimer.kt
@@ -0,0 +1,95 @@
+package at.hannibal2.skyhanni.features.fishing
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.data.IslandType
+import at.hannibal2.skyhanni.utils.LocationUtils
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.LorenzVec
+import at.hannibal2.skyhanni.utils.RenderUtils.renderString
+import at.hannibal2.skyhanni.utils.StringUtils
+import net.minecraft.client.Minecraft
+import net.minecraft.entity.item.EntityArmorStand
+import net.minecraftforge.client.event.RenderGameOverlayEvent
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import net.minecraftforge.fml.common.gameevent.TickEvent
+
+class BarnFishingTimer {
+
+ private val barnLocation = LorenzVec(108, 89, -252)
+
+ private var tick = 0
+ private var rightLocation = false
+ private var mobsCount = 0
+ private var startTime = 0L
+
+ @SubscribeEvent
+ fun onTick(event: TickEvent.ClientTickEvent) {
+ if (event.phase != TickEvent.Phase.START) return
+
+ if (!LorenzUtils.inSkyBlock) return
+ if (!SkyHanniMod.feature.fishing.barnTimer) return
+
+ tick++
+
+ if (tick % 60 == 0) {
+ checkIsland()
+ }
+// if (tick % 20 == 0) {
+ if (tick % 5 == 0) {
+ checkMobs()
+ }
+ }
+
+ private fun checkMobs() {
+ val newCounter = countMobs()
+
+ if (mobsCount == 0) {
+ if (newCounter > 0) {
+ startTimer()
+ }
+ }
+ mobsCount = newCounter
+
+ if (newCounter == 0) {
+ startTime = 0
+ }
+ }
+
+ private fun countMobs(): Int {
+ val counter = Minecraft.getMinecraft().theWorld.loadedEntityList
+ .filterIsInstance<EntityArmorStand>()
+ .map { it.name }
+ // .count { it.startsWith("§8[§7Lv") && it.endsWith("§c❤") }
+ .count { it.endsWith("§c❤") }
+ return counter
+ }
+
+ private fun startTimer() {
+ startTime = System.currentTimeMillis()
+ }
+
+ private fun checkIsland() {
+ if (LorenzUtils.skyBlockIsland == IslandType.THE_FARMING_ISLANDS) {
+ rightLocation = false
+ return
+ }
+
+ rightLocation = LocationUtils.playerLocation().distance(barnLocation) < 50
+ }
+
+ @SubscribeEvent
+ fun onRenderOverlay(event: RenderGameOverlayEvent.Post) {
+ if (event.type != RenderGameOverlayEvent.ElementType.ALL) return
+ if (!LorenzUtils.inSkyBlock) return
+ if (!SkyHanniMod.feature.fishing.barnTimer) return
+ if (!rightLocation) return
+
+ if (mobsCount == 0) return
+
+ val duration = System.currentTimeMillis() - startTime
+ val format = StringUtils.formatDuration(duration / 1000, decimalFormat = true)
+ val text = "§e$format §8(§e$mobsCount §bsea creatures§8)"
+
+ SkyHanniMod.feature.fishing.barnTimerPos.renderString(text)
+ }
+} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt
index aa4126de1..7c8e68a87 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt
@@ -35,7 +35,7 @@ object StringUtils {
return builder.toString()
}
- fun formatDuration(seconds: Long): String {
+ fun formatDuration(seconds: Long, decimalFormat: Boolean = false): String {
var sec: Long = seconds
var minutes: Long = sec / 60
@@ -52,6 +52,10 @@ object StringUtils {
val formatMinutes = durationFormat.format(minutes)
val formatSeconds = durationFormat.format(sec)
+ if (decimalFormat) {
+ return "$formatMinutes:$formatSeconds"
+ }
+
if (days > 0) {
return "${days}d $formatHours:$formatMinutes:$formatSeconds"
}