aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-06-22 23:56:13 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-06-22 23:56:13 +0200
commit11443e506b17bc60c86fec5297b86d5a2fd0a4da (patch)
treed6f063cdeeeadc8c9e3cfd95e43091640fb7ee6c /src/main/java/at/hannibal2/skyhanni/features
parentcc5e3b78f881e034f2bd4806ff4264fd2514be1d (diff)
downloadskyhanni-11443e506b17bc60c86fec5297b86d5a2fd0a4da.tar.gz
skyhanni-11443e506b17bc60c86fec5297b86d5a2fd0a4da.tar.bz2
skyhanni-11443e506b17bc60c86fec5297b86d5a2fd0a4da.zip
Added Agaricus Cap countdown
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/rift/RiftAgaricusCap.kt76
1 files changed, 76 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/RiftAgaricusCap.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/RiftAgaricusCap.kt
new file mode 100644
index 000000000..02eff13f6
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/rift/RiftAgaricusCap.kt
@@ -0,0 +1,76 @@
+package at.hannibal2.skyhanni.features.rift
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.events.LorenzTickEvent
+import at.hannibal2.skyhanni.utils.*
+import at.hannibal2.skyhanni.utils.BlockUtils.getBlockStateAt
+import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
+import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText
+import net.minecraftforge.client.event.RenderWorldLastEvent
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+class RiftAgaricusCap {
+ private val config get() = SkyHanniMod.feature.rift
+ private var startTime = 0L
+ private var location: LorenzVec? = null
+
+ @SubscribeEvent
+ fun onTick(event: LorenzTickEvent) {
+ if (!isEnabled()) return
+ val area = LorenzUtils.skyBlockArea
+ if (area != "West Village" && area != "Dreadfarm") return
+
+ location = updateLocation()
+ }
+
+ private fun updateLocation(): LorenzVec? {
+ if (InventoryUtils.getItemInHand()?.getInternalName() != "FARMING_WAND") return null
+ val currentLocation = BlockUtils.getBlockLookingAt() ?: return null
+
+ when (currentLocation.getBlockStateAt().toString()) {
+ "minecraft:brown_mushroom" -> {
+ return if (location != currentLocation) {
+ startTime = System.currentTimeMillis()
+ currentLocation
+ } else {
+ if (startTime == -1L) {
+ startTime = System.currentTimeMillis()
+ }
+ location
+ }
+ }
+
+ "minecraft:red_mushroom" -> {
+ if (startTime != 0L && startTime != -1L) {
+ val s = System.currentTimeMillis() - startTime
+ LorenzUtils.debug("red mushroom after ${s}ms!")
+ }
+
+ if (location == currentLocation) {
+ startTime = -1L
+ return location
+ }
+ }
+ }
+ return null
+ }
+
+ @SubscribeEvent
+ fun onRenderWorld(event: RenderWorldLastEvent) {
+ if (!isEnabled()) return
+
+ val location = location?.add(0.0, 0.6, 0.0) ?: return
+
+ if (startTime == -1L) {
+ event.drawDynamicText(location, "§cClick!", 1.5)
+ return
+ }
+
+ val countDown = System.currentTimeMillis() - startTime
+ val format = TimeUtils.formatDuration(countDown - 1000, showMilliSeconds = true)
+
+ event.drawDynamicText(location, "§b$format", 1.5)
+ }
+
+ fun isEnabled() = RiftAPI.inRift() && config.agaricusCap
+}