aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDungeonHub <177025031+DungeonHub@users.noreply.github.com>2024-10-20 12:55:46 +0200
committerGitHub <noreply@github.com>2024-10-20 12:55:46 +0200
commit834484d949c85bbefb28201202b6467a7270ebfe (patch)
treedf2dd5097f9a084e975c733ed3c12bd909bd66b5
parent5336712212c555f6e8d0f72c94cb7dd8d7504f11 (diff)
downloadSkyHanni-834484d949c85bbefb28201202b6467a7270ebfe.tar.gz
SkyHanni-834484d949c85bbefb28201202b6467a7270ebfe.tar.bz2
SkyHanni-834484d949c85bbefb28201202b6467a7270ebfe.zip
Improvement: Added Flare Expire Sound and Flash Warning (#2705)
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/combat/FlareConfig.java21
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/combat/FlareDisplay.kt30
2 files changed, 50 insertions, 1 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/combat/FlareConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/combat/FlareConfig.java
index 1ebe07b6c..bb97d87a1 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/combat/FlareConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/combat/FlareConfig.java
@@ -6,6 +6,7 @@ import com.google.gson.annotations.Expose;
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean;
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorColour;
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorDropdown;
+import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorSlider;
import io.github.notenoughupdates.moulconfig.annotations.ConfigLink;
import io.github.notenoughupdates.moulconfig.annotations.ConfigOption;
@@ -42,6 +43,26 @@ public class FlareConfig {
}
@Expose
+ @ConfigOption(name = "Expire Sound", desc = "Makes a sound when a flare is about to expire.")
+ @ConfigEditorBoolean
+ public boolean expireSound = false;
+
+ @Expose
+ @ConfigOption(name = "Warn when about to expire", desc = "Select the time in seconds when a flare is about to expire to warn you.")
+ @ConfigEditorSlider(minValue = 1, maxValue = 60, minStep = 1)
+ public int warnWhenAboutToExpire = 5;
+
+ @Expose
+ @ConfigOption(name = "Flash Screen", desc = "Flashes the screen when a flare is about to expire.")
+ @ConfigEditorBoolean
+ public boolean flashScreen = false;
+
+ @Expose
+ @ConfigOption(name = "Flash Color", desc = "Color of the screen when flashing")
+ @ConfigEditorColour
+ public String flashColor = "0:153:159:0:5";
+
+ @Expose
@ConfigOption(name = "Display Type", desc = "Where to show the timer.")
@ConfigEditorDropdown
public DisplayType displayType = DisplayType.GUI;
diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/FlareDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/FlareDisplay.kt
index fe538bb18..61b0d3945 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/combat/FlareDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/combat/FlareDisplay.kt
@@ -10,6 +10,7 @@ import at.hannibal2.skyhanni.events.SecondPassedEvent
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.ColorUtils.toChromaColor
+import at.hannibal2.skyhanni.utils.ColorUtils.toChromaColorInt
import at.hannibal2.skyhanni.utils.EntityUtils
import at.hannibal2.skyhanni.utils.EntityUtils.canBeSeen
import at.hannibal2.skyhanni.utils.EntityUtils.hasSkullTexture
@@ -20,13 +21,18 @@ import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText
import at.hannibal2.skyhanni.utils.RenderUtils.drawSphereInWorld
import at.hannibal2.skyhanni.utils.RenderUtils.drawSphereWireframeInWorld
import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderables
+import at.hannibal2.skyhanni.utils.SoundUtils
import at.hannibal2.skyhanni.utils.TimeUtils.format
import at.hannibal2.skyhanni.utils.TimeUtils.ticks
import at.hannibal2.skyhanni.utils.getLorenzVec
import at.hannibal2.skyhanni.utils.renderables.Renderable
+import net.minecraft.client.Minecraft
+import net.minecraft.client.gui.Gui
+import net.minecraft.client.renderer.GlStateManager
import net.minecraft.entity.item.EntityArmorStand
import net.minecraft.util.EnumParticleTypes
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import kotlin.math.sin
import kotlin.time.Duration
import kotlin.time.Duration.Companion.minutes
import kotlin.time.Duration.Companion.seconds
@@ -38,6 +44,8 @@ object FlareDisplay {
private var display = emptyList<Renderable>()
private var flares = mutableListOf<Flare>()
+ private var activeWarning = false
+
class Flare(val type: FlareType, val entity: EntityArmorStand, val location: LorenzVec = entity.getLorenzVec())
private val MAX_FLARE_TIME = 3.minutes
@@ -85,6 +93,7 @@ object FlareDisplay {
getFlareTypeForTexture(entity)?.let {
flares.add(Flare(it, entity))
}
+ activeWarning = false
}
var newDisplay: List<Renderable>? = null
for (type in FlareType.entries) {
@@ -103,7 +112,8 @@ object FlareDisplay {
}
}
}
- if (remainingTime !in 0.seconds..5.seconds) continue
+ if (remainingTime !in 0.seconds..config.warnWhenAboutToExpire.seconds) continue
+ activeWarning = true
val message = "$name §eexpires in: §b${remainingTime.inWholeSeconds}s"
when (config.alertType) {
FlareConfig.AlertType.CHAT -> {
@@ -121,6 +131,9 @@ object FlareDisplay {
else -> {}
}
+ if (config.expireSound) {
+ SoundUtils.playPlingSound()
+ }
}
display = newDisplay.orEmpty()
}
@@ -180,6 +193,21 @@ object FlareDisplay {
}
@SubscribeEvent
+ fun onRender(event: GuiRenderEvent.GuiOverlayRenderEvent) {
+ if (!isEnabled() || !config.flashScreen || !activeWarning) return
+ val minecraft = Minecraft.getMinecraft()
+ val alpha = ((2 + sin(System.currentTimeMillis().toDouble() / 1000)) * 255 / 4).toInt().coerceIn(0..255)
+ Gui.drawRect(
+ 0,
+ 0,
+ minecraft.displayWidth,
+ minecraft.displayHeight,
+ (alpha shl 24) or (config.flashColor.toChromaColorInt() and 0xFFFFFF),
+ )
+ GlStateManager.color(1F, 1F, 1F, 1F)
+ }
+
+ @SubscribeEvent
fun onReceiveParticle(event: ReceiveParticleEvent) {
if (!isEnabled()) return
if (!config.hideParticles) return