aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorWalker Selby <git@walkerselby.com>2023-12-09 16:25:52 -0800
committerGitHub <noreply@github.com>2023-12-10 01:25:52 +0100
commit61368c57bd36f3d6be3d072cfd9bbb24ca8fa090 (patch)
treec2b48516b1bf5bdefbf8adc8259964715182b695 /src/main
parent6489b04f1e9fa0861985bf8b320bb4660115c2a8 (diff)
downloadskyhanni-61368c57bd36f3d6be3d072cfd9bbb24ca8fa090.tar.gz
skyhanni-61368c57bd36f3d6be3d072cfd9bbb24ca8fa090.tar.bz2
skyhanni-61368c57bd36f3d6be3d072cfd9bbb24ca8fa090.zip
Feature: Refined Jyrre Boost Timer (#783)
Add JyrreTimer for Bottle of Jyrre. #783
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/event/winter/JyrreTimerConfig.java24
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/event/winter/WinterConfig.java5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/winter/JyrreTimer.kt92
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt16
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt18
6 files changed, 144 insertions, 13 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
index bccb25d03..947369f92 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
@@ -116,6 +116,7 @@ import at.hannibal2.skyhanni.features.event.jerry.frozentreasure.FrozenTreasureT
import at.hannibal2.skyhanni.features.event.lobby.waypoints.christmas.PresentWaypoints
import at.hannibal2.skyhanni.features.event.lobby.waypoints.halloween.BasketWaypoints
import at.hannibal2.skyhanni.features.event.spook.TheGreatSpook
+import at.hannibal2.skyhanni.features.event.winter.JyrreTimer
import at.hannibal2.skyhanni.features.event.winter.UniqueGiftCounter
import at.hannibal2.skyhanni.features.fame.AccountUpgradeReminder
import at.hannibal2.skyhanni.features.fame.CityProjectFeatures
@@ -669,6 +670,7 @@ class SkyHanniMod {
loadModule(PestFinder())
loadModule(SprayFeatures())
loadModule(PresentWaypoints())
+ loadModule(JyrreTimer())
init()
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/event/winter/JyrreTimerConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/event/winter/JyrreTimerConfig.java
new file mode 100644
index 000000000..7b1732d4e
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/event/winter/JyrreTimerConfig.java
@@ -0,0 +1,24 @@
+package at.hannibal2.skyhanni.config.features.event.winter;
+
+import at.hannibal2.skyhanni.config.FeatureToggle;
+import at.hannibal2.skyhanni.config.core.config.Position;
+import com.google.gson.annotations.Expose;
+import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean;
+import io.github.moulberry.moulconfig.annotations.ConfigOption;
+
+public class JyrreTimerConfig {
+
+ @Expose
+ @ConfigOption(name = "Enabled", desc = "A timer showing the remaining duration of your intelligence boost.")
+ @ConfigEditorBoolean
+ @FeatureToggle
+ public boolean enabled = false;
+
+ @Expose
+ @ConfigOption(name = "Show when Inactive", desc = "Show the timer when inactive, rather than removing it.")
+ @ConfigEditorBoolean
+ public boolean showInactive = true;
+
+ @Expose
+ public Position pos = new Position(390, 65, false, true);
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/event/winter/WinterConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/event/winter/WinterConfig.java
index 79ac983c2..ae95b62f3 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/event/winter/WinterConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/event/winter/WinterConfig.java
@@ -24,6 +24,11 @@ public class WinterConfig {
@ConfigOption(name = "Unique Gift Counter", desc = "Keep track how many unique players you have given gifts to.")
public UniqueGiftConfig uniqueGiftCounter = new UniqueGiftConfig();
+ @Accordion
+ @Expose
+ @ConfigOption(name = "Refined Bottle of Jyrre Timer", desc = "")
+ public JyrreTimerConfig jyrreTimer = new JyrreTimerConfig();
+
@Expose
@ConfigOption(name = "Island Close Time", desc = "While on the Winter Island, show a timer until Jerry's Workshop closes.")
@ConfigEditorBoolean
diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/winter/JyrreTimer.kt b/src/main/java/at/hannibal2/skyhanni/features/event/winter/JyrreTimer.kt
new file mode 100644
index 000000000..bee0d1b09
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/event/winter/JyrreTimer.kt
@@ -0,0 +1,92 @@
+package at.hannibal2.skyhanni.features.event.winter
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.events.GuiRenderEvent
+import at.hannibal2.skyhanni.events.LorenzChatEvent
+import at.hannibal2.skyhanni.events.PreProfileSwitchEvent
+import at.hannibal2.skyhanni.test.command.ErrorManager
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName
+import at.hannibal2.skyhanni.utils.NEUItems.getItemStack
+import at.hannibal2.skyhanni.utils.RenderUtils.addItemIcon
+import at.hannibal2.skyhanni.utils.RenderUtils.renderSingleLineWithItems
+import at.hannibal2.skyhanni.utils.StringUtils.matches
+import at.hannibal2.skyhanni.utils.TimeUtils
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import kotlin.concurrent.fixedRateTimer
+import kotlin.time.Duration.Companion.minutes
+import kotlin.time.Duration.Companion.seconds
+
+class JyrreTimer {
+ private val config get() = SkyHanniMod.feature.event.winter.jyrreTimer
+ private val drankBottlePattern by RepoPattern.pattern(
+ "event.winter.drank.jyrre",
+ "§aYou drank a §r§6Refined Bottle of Jyrre §r§aand gained §r§b\\+300✎ Intelligence §r§afor §r§b60 minutes§r§a!"
+ )
+ private var display = emptyList<Any>()
+ private var duration = 0.seconds
+
+ init {
+ fixedRateTimer(name = "skyhanni-update-jyrre-display", period = 1000L) {
+ try {
+ updateJyrreDisplay()
+ } catch (error: Throwable) {
+ ErrorManager.logErrorWithData(error, "Error Updating Jyrre Timer")
+ }
+ }
+ }
+
+ @SubscribeEvent
+ fun onPreProfileSwitch(event: PreProfileSwitchEvent) {
+ resetDisplay()
+ }
+
+ private fun resetDisplay() {
+ display = if (config.showInactive) drawDisplay() else emptyList()
+ duration = 0.seconds
+ }
+
+ @SubscribeEvent
+ fun onChat(event: LorenzChatEvent) {
+ if (!isEnabled() || !drankBottlePattern.matches(event.message)) return
+ duration = 60.minutes
+ }
+
+ @SubscribeEvent
+ fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) {
+ if (!isEnabled()) return
+ config.pos.renderSingleLineWithItems(display, posLabel = "Refined Jyrre Timer")
+ }
+
+ private fun updateJyrreDisplay() {
+ if (!isEnabled()) return
+
+ if (display.isNotEmpty() && !config.showInactive && duration <= 0.seconds) {
+ resetDisplay()
+ return
+ }
+
+ display = drawDisplay()
+ }
+
+ private val displayIcon by lazy { "REFINED_BOTTLE_OF_JYRRE".asInternalName().getItemStack() }
+
+ fun drawDisplay(): MutableList<Any> {
+ duration -= 1.seconds
+
+ return mutableListOf<Any>().apply {
+ addItemIcon(displayIcon)
+ add("§aJyrre Boost: ")
+
+ if (duration <= 0.seconds && config.showInactive) {
+ add("§cInactive!")
+ } else {
+ val format = TimeUtils.formatDuration(duration)
+ add("§b$format")
+ }
+ }
+ }
+
+ private fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt
index 6ef4800dc..7fba5b56a 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt
@@ -31,10 +31,10 @@ import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland
import at.hannibal2.skyhanni.utils.LorenzVec
import at.hannibal2.skyhanni.utils.NEUInternalName
+import at.hannibal2.skyhanni.utils.RenderUtils.addItemIcon
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getCultivatingCounter
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getHoeCounter
import net.minecraft.client.Minecraft
-import net.minecraft.enchantment.Enchantment
import net.minecraft.item.ItemStack
import net.minecraft.network.play.client.C09PacketHeldItemChange
import net.minecraft.util.AxisAlignedBB
@@ -143,18 +143,8 @@ object GardenAPI {
fun readCounter(itemStack: ItemStack): Long = itemStack.getHoeCounter() ?: itemStack.getCultivatingCounter() ?: -1L
- fun MutableList<Any>.addCropIcon(crop: CropType, highlight: Boolean = false) {
- try {
- var icon = crop.icon.copy()
- if (highlight) {
- // Hack to add enchant glint, like Hypixel does it
- icon.addEnchantment(Enchantment.protection, 0)
- }
- add(icon)
- } catch (e: NullPointerException) {
- e.printStackTrace()
- }
- }
+ fun MutableList<Any>.addCropIcon(crop: CropType, highlight: Boolean = false) =
+ addItemIcon(crop.icon.copy(), highlight)
fun hideExtraGuis() = ComposterOverlay.inInventory || AnitaMedalProfit.inInventory ||
SkyMartCopperPrice.inInventory || FarmingContestAPI.inInventory || VisitorAPI.inInventory || FFGuideGUI.isInGui()
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt
index 03f552e7a..f9e2b7cdf 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt
@@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.data.GuiEditManager.Companion.getAbsX
import at.hannibal2.skyhanni.data.GuiEditManager.Companion.getAbsY
import at.hannibal2.skyhanni.events.GuiRenderItemEvent
import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent
+import at.hannibal2.skyhanni.test.command.ErrorManager
import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList
import at.hannibal2.skyhanni.utils.renderables.Renderable
import io.github.moulberry.moulconfig.internal.TextRenderUtils
@@ -16,8 +17,10 @@ import net.minecraft.client.gui.Gui
import net.minecraft.client.renderer.GlStateManager
import net.minecraft.client.renderer.Tessellator
import net.minecraft.client.renderer.vertex.DefaultVertexFormats
+import net.minecraft.enchantment.Enchantment
import net.minecraft.entity.Entity
import net.minecraft.inventory.Slot
+import net.minecraft.item.ItemStack
import net.minecraft.util.AxisAlignedBB
import net.minecraft.util.MathHelper
import net.minecraft.util.ResourceLocation
@@ -485,6 +488,21 @@ object RenderUtils {
return offsetX
}
+ fun MutableList<Any>.addItemIcon(item: ItemStack, highlight: Boolean = false) {
+ try {
+ if (highlight) {
+ // Hack to add enchant glint, like Hypixel does it
+ item.addEnchantment(Enchantment.protection, 0)
+ }
+ add(item)
+ } catch (e: NullPointerException) {
+ ErrorManager.logErrorWithData(
+ e, "Add item icon to renderable list",
+ "item" to item
+ )
+ }
+ }
+
// totally not modified Autumn Client's TargetStrafe
fun drawCircle(entity: Entity, partialTicks: Float, rad: Double, color: Color) {
GlStateManager.pushMatrix()