Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Cold Overlay #1438

Merged
merged 36 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
966ae20
init
j10a1n15 Apr 13, 2024
5987e0c
Merge branch 'beta' into cold
j10a1n15 Apr 13, 2024
16f7cf1
Update src/main/java/at/hannibal2/skyhanni/features/mining/ColdOverla…
j10a1n15 Apr 13, 2024
75fadd4
fix
j10a1n15 Apr 13, 2024
397cf55
made img transparent
j10a1n15 Apr 13, 2024
de2560d
added miningapi and coldupdateevent
j10a1n15 Apr 13, 2024
a5cd5c6
Merge branch 'beta' into cold
j10a1n15 Apr 13, 2024
683ef64
improve update event
j10a1n15 Apr 13, 2024
ecac91e
Merge remote-tracking branch 'origin/cold' into cold
j10a1n15 Apr 13, 2024
3a954f8
Merge branch 'beta' into fork/cold
hannibal002 Apr 13, 2024
8848e0a
code cleanup
hannibal002 Apr 13, 2024
638d0b7
resolve
j10a1n15 Apr 13, 2024
612587d
Merge remote-tracking branch 'origin/cold' into cold
j10a1n15 Apr 13, 2024
7503324
Merge branch 'beta' into cold
j10a1n15 Apr 13, 2024
10da003
init
ItsEmpa Apr 14, 2024
6604600
fix and improvements
ItsEmpa Apr 14, 2024
28713ed
Merge branch 'beta' into cold-addons
ItsEmpa Apr 15, 2024
0dd7fec
Merge branch 'beta' into fork/cold
hannibal002 Apr 15, 2024
d2fb5f0
fix
ItsEmpa Apr 15, 2024
e83e0da
Merge branch 'cold' into cold-addons
j10a1n15 Apr 15, 2024
48ea40f
Merge branch 'fork/cold' into cold-addons
ItsEmpa Apr 15, 2024
7c61962
Merge remote-tracking branch 'origin/cold-addons' into cold-addons
ItsEmpa Apr 15, 2024
29681aa
whar
ItsEmpa Apr 15, 2024
78c0618
:3
ItsEmpa Apr 15, 2024
1d7b424
change default value
ItsEmpa Apr 15, 2024
45ba2dd
Merge pull request #20 from ItsEmpa/cold-addons
j10a1n15 Apr 15, 2024
c379cce
small
j10a1n15 Apr 15, 2024
dbba2e8
Merge branch 'beta' into cold-addons
ItsEmpa Apr 16, 2024
c88afe6
sowwy
ItsEmpa Apr 16, 2024
b9ee84d
Merge pull request #21 from ItsEmpa/cold-addons
j10a1n15 Apr 16, 2024
59bd34b
make overlay work between world changes
ItsEmpa Apr 17, 2024
fbd2679
Merge branch 'fork/cold' into cold-addons
ItsEmpa Apr 17, 2024
4025660
formatting
ItsEmpa Apr 17, 2024
61fc207
Merge pull request #22 from ItsEmpa/cold-addons
j10a1n15 Apr 17, 2024
5cbc91e
Merge branch 'beta' into fork/cold
hannibal002 Apr 17, 2024
93c17b4
code cleanup
hannibal002 Apr 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import at.hannibal2.skyhanni.data.LocationFixData
import at.hannibal2.skyhanni.data.MaxwellAPI
import at.hannibal2.skyhanni.data.MayorAPI
import at.hannibal2.skyhanni.data.MinecraftData
import at.hannibal2.skyhanni.data.MiningAPI
import at.hannibal2.skyhanni.data.OtherInventoryData
import at.hannibal2.skyhanni.data.OwnInventoryData
import at.hannibal2.skyhanni.data.PartyAPI
Expand Down Expand Up @@ -263,6 +264,7 @@ import at.hannibal2.skyhanni.features.inventory.tiarelay.TiaRelayWaypoints
import at.hannibal2.skyhanni.features.itemabilities.ChickenHeadTimer
import at.hannibal2.skyhanni.features.itemabilities.FireVeilWandParticles
import at.hannibal2.skyhanni.features.itemabilities.abilitycooldown.ItemAbilityCooldown
import at.hannibal2.skyhanni.features.mining.ColdOverlay
import at.hannibal2.skyhanni.features.mining.DeepCavernsParkour
import at.hannibal2.skyhanni.features.mining.HighlightMiningCommissionMobs
import at.hannibal2.skyhanni.features.mining.KingTalismanHelper
Expand Down Expand Up @@ -541,6 +543,7 @@ class SkyHanniMod {
loadModule(LorenzUtils)
loadModule(NEUItems)
loadModule(PestAPI)
loadModule(MiningAPI)
loadModule(FossilExcavatorAPI)

// features
Expand Down Expand Up @@ -841,6 +844,7 @@ class SkyHanniMod {
loadModule(DungeonShadowAssassinNotification())
loadModule(PestProfitTracker)
loadModule(NoBitsWarning())
loadModule(ColdOverlay())
loadModule(QuiverDisplay())
loadModule(QuiverWarning())

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package at.hannibal2.skyhanni.config.features.mining;

import at.hannibal2.skyhanni.config.FeatureToggle;
import com.google.gson.annotations.Expose;
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean;
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorSlider;
import io.github.notenoughupdates.moulconfig.annotations.ConfigOption;

public class ColdOverlayConfig {

@Expose
@ConfigOption(
name = "Toggle Cold Overlay",
desc = "Toggle the cold overlay in Glacite Tunnels."
)
@ConfigEditorBoolean
@FeatureToggle
public boolean enabled = false;

@Expose
@ConfigOption(
name = "Cold Threshold",
desc = "The threshold at which the cold overlay will be shown."
)
@ConfigEditorSlider(
minValue = 0,
maxValue = 100,
minStep = 1
)
public int coldThreshold = 50;
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ public class MiningConfig {
@Accordion
public AreaWallsConfig crystalHollowsAreaWalls = new AreaWallsConfig();

@Expose
@ConfigOption(name = "Cold Overlay", desc = "")
@Accordion
public ColdOverlayConfig coldOverlay = new ColdOverlayConfig();

@Expose
@ConfigOption(name = "Fossil Excavator", desc = "")
@Accordion
Expand Down
38 changes: 38 additions & 0 deletions src/main/java/at/hannibal2/skyhanni/data/MiningAPI.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package at.hannibal2.skyhanni.data

import at.hannibal2.skyhanni.events.ColdUpdateEvent
import at.hannibal2.skyhanni.events.ScoreboardChangeEvent
import at.hannibal2.skyhanni.features.gui.customscoreboard.ScoreboardPattern
import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland
import at.hannibal2.skyhanni.utils.StringUtils.matchFirst
import at.hannibal2.skyhanni.utils.StringUtils.matches
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import kotlin.math.absoluteValue

object MiningAPI {

private val group = RepoPattern.group("data.miningapi")
private val glaciteAreaPattern by group.pattern("area.glacite", "Glacite Tunnels")

private var oldCold = 0


fun inGlaciteArea() = glaciteAreaPattern.matches(HypixelData.skyBlockArea) || IslandType.MINESHAFT.isInIsland()

fun getCold(): Int? = ScoreboardData.sidebarLinesFormatted.matchFirst(ScoreboardPattern.coldPattern) {
j10a1n15 marked this conversation as resolved.
Show resolved Hide resolved
return group("cold").toInt().absoluteValue
}

@SubscribeEvent
fun onScoreboardChangeEvent(event: ScoreboardChangeEvent) {
val newCold = getCold() ?: return

if (newCold - oldCold != 0) {
j10a1n15 marked this conversation as resolved.
Show resolved Hide resolved
ColdUpdateEvent(newCold).postAndCatch()

oldCold = newCold
}
}

}
3 changes: 3 additions & 0 deletions src/main/java/at/hannibal2/skyhanni/events/ColdUpdateEvent.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package at.hannibal2.skyhanni.events

class ColdUpdateEvent (val cold: Int) : LorenzEvent()
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import at.hannibal2.skyhanni.data.HypixelData.Companion.getPlayersOnCurrentServe
import at.hannibal2.skyhanni.data.IslandType
import at.hannibal2.skyhanni.data.MaxwellAPI
import at.hannibal2.skyhanni.data.MayorAPI
import at.hannibal2.skyhanni.data.MiningAPI.getCold
import at.hannibal2.skyhanni.data.PartyAPI
import at.hannibal2.skyhanni.data.PurseAPI
import at.hannibal2.skyhanni.data.QuiverAPI
Expand Down Expand Up @@ -447,11 +448,11 @@ private fun getHeatShowWhen() = inAnyIsland(IslandType.CRYSTAL_HOLLOWS)
&& ScoreboardData.sidebarLinesFormatted.any { ScoreboardPattern.heatPattern.matches(it) }

private fun getColdDisplayPair(): List<ScoreboardElementType> {
val cold = getGroupFromPattern(ScoreboardData.sidebarLinesFormatted, ScoreboardPattern.coldPattern, "cold")
val cold = getCold()

return listOf(
when {
informationFilteringConfig.hideEmptyLines && cold == "0" -> "<hidden>"
informationFilteringConfig.hideEmptyLines && cold == 0 -> "<hidden>"
displayConfig.displayNumbersFirst -> "§b$cold❄ Cold"
else -> "Cold: §b$cold❄"
} to HorizontalAlignment.LEFT
Expand Down
51 changes: 51 additions & 0 deletions src/main/java/at/hannibal2/skyhanni/features/mining/ColdOverlay.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package at.hannibal2.skyhanni.features.mining

import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.data.MiningAPI.getCold
import at.hannibal2.skyhanni.data.MiningAPI.inGlaciteArea
import at.hannibal2.skyhanni.events.GuiRenderEvent
import io.github.moulberry.notenoughupdates.util.Utils
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.ScaledResolution
import net.minecraft.client.renderer.GlStateManager
import net.minecraft.util.ResourceLocation
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import org.lwjgl.opengl.GL11


class ColdOverlay {

private val config get() = SkyHanniMod.feature.mining.coldOverlay
private fun isEnabled() = config.enabled && inGlaciteArea()

@SubscribeEvent
fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) {
if (!isEnabled()) return
val cold = getCold() ?: return
if (cold < config.coldThreshold) return

val mc = Minecraft.getMinecraft()
val textureLocation = ResourceLocation("skyhanni", "cold_overlay.png")
mc.textureManager.bindTexture(textureLocation)

val scaledResolution = ScaledResolution(mc)
val screenWidth = scaledResolution.scaledWidth
val screenHeight = scaledResolution.scaledHeight

GlStateManager.pushMatrix()
GlStateManager.pushAttrib()

GlStateManager.color(1f, 1f, 1f, 1f)

Utils.drawTexturedRect(
0f,
0f,
screenWidth.toFloat(),
screenHeight.toFloat(),
GL11.GL_NEAREST
)

GlStateManager.popMatrix()
GlStateManager.popAttrib()
}
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
package at.hannibal2.skyhanni.features.mining

import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.data.IslandType
import at.hannibal2.skyhanni.data.MiningAPI.getCold
import at.hannibal2.skyhanni.data.MiningAPI.inGlaciteArea
import at.hannibal2.skyhanni.events.ColdUpdateEvent
import at.hannibal2.skyhanni.events.ConfigLoadEvent
import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent
import at.hannibal2.skyhanni.events.ScoreboardChangeEvent
import at.hannibal2.skyhanni.features.gui.customscoreboard.ScoreboardPattern
import at.hannibal2.skyhanni.utils.ConditionalUtils
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import at.hannibal2.skyhanni.utils.SoundUtils
import at.hannibal2.skyhanni.utils.StringUtils.matchFirst
import at.hannibal2.skyhanni.utils.StringUtils.matches
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import kotlin.math.absoluteValue
import kotlin.time.Duration.Companion.milliseconds
import kotlin.time.Duration.Companion.seconds

Expand All @@ -28,9 +26,7 @@ class MiningNotifications {
DIAMOND_GOBLIN("§bDiamond Goblin", "§bDiamond Goblin"),
COLD("§bCold", "§bCold");

override fun toString(): String {
return str
}
override fun toString() = str
}

private val patternGroup = RepoPattern.group("mining.notifications")
Expand All @@ -57,7 +53,6 @@ class MiningNotifications {

private val config get() = SkyHanniMod.feature.mining.notifications

private var cold = 0
private var hasSentCold = false
private var coldResetTimer = SimpleTimeMark.farPast()

Expand All @@ -72,39 +67,33 @@ class MiningNotifications {
goldenGoblinSpawn.matches(message) -> sendNotification(MiningNotificationList.GOLDEN_GOBLIN)
diamondGoblinSpawn.matches(message) -> sendNotification(MiningNotificationList.DIAMOND_GOBLIN)
coldReset.matches(message) -> {
cold = 0
hasSentCold = false
coldResetTimer = SimpleTimeMark.now().plus(1.seconds)
}
}
}

@SubscribeEvent
fun onScoreboardChange(event: ScoreboardChangeEvent) {
if (!LorenzUtils.inAnyIsland(IslandType.DWARVEN_MINES, IslandType.MINESHAFT)) return
fun onColdUpdate(event: ColdUpdateEvent) {
if (!inGlaciteArea()) return
if (!config.enabled) return
val newCold = event.newList.matchFirst(ScoreboardPattern.coldPattern) {
group("cold").toInt().absoluteValue
} ?: 0
if (cold == newCold) return
cold = newCold

if (coldResetTimer.isInFuture()) return
if (cold >= config.coldThreshold.get() && !hasSentCold) {
if (event.cold >= config.coldThreshold.get() && !hasSentCold) {
hasSentCold = true
sendNotification(MiningNotificationList.COLD)
}
}

@SubscribeEvent
fun onWorldChange(event: LorenzWorldChangeEvent) {
cold = 0
hasSentCold = false
}

@SubscribeEvent
fun onConfigLoad(event: ConfigLoadEvent) {
ConditionalUtils.onToggle(config.coldThreshold) {
if (cold != config.coldThreshold.get()) hasSentCold = false
if (getCold() != config.coldThreshold.get()) hasSentCold = false
}
}

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading