diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-06-22 23:56:13 +0200 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-06-22 23:56:13 +0200 |
commit | 11443e506b17bc60c86fec5297b86d5a2fd0a4da (patch) | |
tree | d6f063cdeeeadc8c9e3cfd95e43091640fb7ee6c | |
parent | cc5e3b78f881e034f2bd4806ff4264fd2514be1d (diff) | |
download | skyhanni-11443e506b17bc60c86fec5297b86d5a2fd0a4da.tar.gz skyhanni-11443e506b17bc60c86fec5297b86d5a2fd0a4da.tar.bz2 skyhanni-11443e506b17bc60c86fec5297b86d5a2fd0a4da.zip |
Added Agaricus Cap countdown
-rw-r--r-- | CHANGELOG.md | 2 | ||||
-rw-r--r-- | FEATURES.md | 2 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt | 1 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/config/features/RiftConfig.java | 5 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt | 2 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/rift/RiftAgaricusCap.kt | 76 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/BlockUtils.kt | 14 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt | 4 |
8 files changed, 105 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 99a8c50d6..7166899d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,8 @@ + Added **Odonatas Highlighter** + Highlight the small Odonatas flying around the trees while holding a Empty Odonata Bottle in the hand. + Customize the color ++ Added **Agaricus Cap** countdown + + Counts down the time until Agaricus Cap (Mushroom) changes color from brown to red and is breakable. ### Changes + Option to show the yaw and pitch display outside garden or while not holding a farming tool (Contributed by CalMWolfs) diff --git a/FEATURES.md b/FEATURES.md index e38d8da5e..b9c199e3f 100644 --- a/FEATURES.md +++ b/FEATURES.md @@ -284,6 +284,8 @@ + Added **Odonatas Highlighter** + Highlight the small Odonatas flying around the trees while holding a Empty Odonata Bottle in the hand. + Customize the color ++ Added **Agaricus Cap** countdown + + Counts down the time until Agaricus Cap (Mushroom) changes color from brown to red and is breakable. ## Commands + **/wiki <search term>** - using hypixel-skyblock.fandom.com instead of Hypixel wiki. diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 047f20060..76b0b88ff 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -307,6 +307,7 @@ class SkyHanniMod { loadModule(CruxWarnings()) loadModule(RiftLarva()) loadModule(RiftOdonata()) + loadModule(RiftAgaricusCap()) init() diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/RiftConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/RiftConfig.java index 3a634639f..8cff848fd 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/RiftConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/RiftConfig.java @@ -91,4 +91,9 @@ public class RiftConfig { @ConfigOption(name = "Highlight Guide", desc = "Highlight things to do in the Rift Guide.") @ConfigEditorBoolean public boolean highlightGuide = true; + + @Expose + @ConfigOption(name = "Agaricus Cap", desc = "Counts down the time until §eAgaricus Cap (Mushroom) §7changes color from brown to red and is breakable.") + @ConfigEditorBoolean + public boolean agaricusCap = true; } diff --git a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt index 2877c843c..4d0cce395 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt @@ -30,7 +30,7 @@ class HypixelData { fun readSkyBlockArea(): String { return ScoreboardData.sidebarLinesFormatted - .firstOrNull { it.startsWith(" §7⏣ ") } + .firstOrNull { it.startsWith(" §7⏣ ") || it.startsWith(" §5ф ") } ?.substring(5)?.removeColor() ?: "invalid" } 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 +} diff --git a/src/main/java/at/hannibal2/skyhanni/utils/BlockUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/BlockUtils.kt index e16df26e9..a35d0de06 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/BlockUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/BlockUtils.kt @@ -39,4 +39,18 @@ object BlockUtils { return false } + + fun rayTrace(start: LorenzVec, direction: LorenzVec, distance: Double = 50.0): LorenzVec? { + val help = direction.normalize().multiply(distance) + val target = start.add(help) + val result = Minecraft.getMinecraft().theWorld.rayTraceBlocks(start.toVec3(), target.toVec3()) + + return result?.blockPos?.toLorenzVec() + } + + fun getBlockLookingAt(duration: Double = 10.0) = rayTrace( + LocationUtils.playerEyeLocation(), + Minecraft.getMinecraft().thePlayer.lookVec.toLorenzVec(), + duration + ) }
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt index 5bce2d762..4b716964f 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt @@ -64,6 +64,8 @@ data class LorenzVec( fun subtract(other: LorenzVec) = LorenzVec(x - other.x, y - other.y, z - other.z) + fun normalize() = length().let { LorenzVec(x / it, y / it, z / it) } + fun printWithAccuracy(accuracy: Int): String { val x = (round(x * accuracy) / accuracy) val y = (round(y * accuracy) / accuracy) @@ -89,6 +91,8 @@ data class LorenzVec( fun equalsIgnoreY(other: LorenzVec) = x == other.x && z == other.z + fun equals(other: LorenzVec) = x == other.x && y == other.y && z == other.z + fun round(decimals: Int) = LorenzVec(x.round(decimals), y.round(decimals), z.round(decimals)) companion object { |