aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-03-06 03:32:24 +0100
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-03-06 03:32:24 +0100
commitcc9d2e1b3a285a21d9c85884a7741439f3a90e31 (patch)
treedc80cf269a10793372abef9172f272077f4afac1 /src/main/java
parent97d8742e1e14385ddec929a35eb0b77180c501c6 (diff)
downloadskyhanni-cc9d2e1b3a285a21d9c85884a7741439f3a90e31.tar.gz
skyhanni-cc9d2e1b3a285a21d9c85884a7741439f3a90e31.tar.bz2
skyhanni-cc9d2e1b3a285a21d9c85884a7741439f3a90e31.zip
Added Chicken head Timer
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java1
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/Features.java5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/Misc.java17
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/ChickenHeadTimer.kt65
4 files changed, 88 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
index dc0ed523b..6e44421e8 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
@@ -213,6 +213,7 @@ public class SkyHanniMod {
loadModule(new GardenNextPlotPrice());
loadModule(new GardenCropMilestoneDisplay());
loadModule(new GardenCustomKeybinds());
+ loadModule(new ChickenHeadTimer());
Commands.INSTANCE.init();
diff --git a/src/main/java/at/hannibal2/skyhanni/config/Features.java b/src/main/java/at/hannibal2/skyhanni/config/Features.java
index 9eb7554cf..cf5f62502 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/Features.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/Features.java
@@ -193,6 +193,11 @@ public class Features extends Config {
Minecraft.getMinecraft().thePlayer.closeScreen();
return;
}
+
+ if (runnableId.equals("chickenHeadTimer")) {
+ editOverlay(activeConfigCategory, 200, 16, misc.chickenHeadTimerPosition);
+ return;
+ }
}
@Expose
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java b/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java
index 3b54afd09..b72565cfa 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java
@@ -202,6 +202,23 @@ public class Misc {
public boolean hideCloseRedstoneparticles = true;
@Expose
+ @ConfigOption(name = "Chicken Head Timer", desc = "")
+ @ConfigEditorAccordion(id = 10)
+ public boolean chickenHeadTimer = false;
+
+ @Expose
+ @ConfigOption(name = "Enabled", desc = "Show the cooldown until the next time you can lay an egg with the chicken head.")
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 10)
+ public boolean chickenHeadTimerDisplay = false;
+
+ @Expose
+ @ConfigOption(name = "Timer Position", desc = "")
+ @ConfigEditorButton(runnableId = "chickenHeadTimer", buttonText = "Edit")
+ @ConfigAccordionId(id = 10)
+ public Position chickenHeadTimerPosition = new Position(-372, 73, false, true);
+
+ @Expose
@ConfigOption(name = "Exp Bottles", desc = "Hides all the experience bottles lying on the ground.")
@ConfigEditorBoolean
public boolean hideExpBottles = false;
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/ChickenHeadTimer.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/ChickenHeadTimer.kt
new file mode 100644
index 000000000..d9e68a1e3
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/ChickenHeadTimer.kt
@@ -0,0 +1,65 @@
+package at.hannibal2.skyhanni.features.misc
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.events.GuiRenderEvent
+import at.hannibal2.skyhanni.events.LorenzChatEvent
+import at.hannibal2.skyhanni.utils.ItemUtils.name
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.RenderUtils.renderString
+import at.hannibal2.skyhanni.utils.TimeUtils
+import net.minecraft.client.Minecraft
+import net.minecraftforge.event.world.WorldEvent
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import net.minecraftforge.fml.common.gameevent.TickEvent
+
+class ChickenHeadTimer {
+
+ private var tick = 0
+ private var hasChickenHead = false
+ private var lastTime = 0L
+
+ @SubscribeEvent
+ fun onTick(event: TickEvent.ClientTickEvent) {
+ if (!isEnabled()) return
+ if (tick++ % 5 != 0) return
+
+ val itemStack = Minecraft.getMinecraft().thePlayer.inventory.armorInventory[3]
+ val name = itemStack?.name ?: ""
+ hasChickenHead = name.contains("Chicken Head")
+ }
+
+ @SubscribeEvent
+ fun onWorldLoad(event: WorldEvent.Load) {
+ lastTime = System.currentTimeMillis()
+ }
+
+ @SubscribeEvent
+ fun onChatMessage(event: LorenzChatEvent) {
+ if (!isEnabled()) return
+ if (!hasChickenHead) return
+ if (event.message == "§aYou laid an egg!") {
+ lastTime = System.currentTimeMillis()
+ }
+ }
+
+ @SubscribeEvent
+ fun onRenderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) {
+ if (!isEnabled()) return
+ if (!hasChickenHead) return
+
+ val sinceLastTime = System.currentTimeMillis() - lastTime
+ val cooldown = 20_000
+ val remainingTime = cooldown - sinceLastTime
+
+ val displayText = if (remainingTime < 0) {
+ "Chicken Head Timer: §aNow"
+ } else {
+ val formatDuration = TimeUtils.formatDuration(remainingTime)
+ "Chicken Head Timer: §b$formatDuration"
+ }
+
+ SkyHanniMod.feature.misc.chickenHeadTimerPosition.renderString(displayText)
+ }
+
+ fun isEnabled() = LorenzUtils.inSkyBlock && SkyHanniMod.feature.misc.chickenHeadTimerDisplay
+} \ No newline at end of file