From 4fa9b95a280515b1fa71425e8e1c61d5b4a009f6 Mon Sep 17 00:00:00 2001 From: Brandon Date: Fri, 8 Dec 2023 11:36:38 -0400 Subject: Fix duplicate water hydra catch title, add shadows to titles (#749) Better looking titles, added test command /shsendtitle and fixed Water Hydra warning showing up multiple times. #749 --- .../hannibal2/skyhanni/config/commands/Commands.kt | 5 +++++ .../at/hannibal2/skyhanni/data/TitleManager.kt | 26 ++++++++++++++++++---- .../features/fishing/SeaCreatureFeatures.kt | 7 ++++-- 3 files changed, 32 insertions(+), 6 deletions(-) (limited to 'src/main') diff --git a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt index bd8cea0e7..910f938d0 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt @@ -7,6 +7,7 @@ import at.hannibal2.skyhanni.data.ChatManager import at.hannibal2.skyhanni.data.GardenCropMilestonesCommunityFix import at.hannibal2.skyhanni.data.GuiEditManager import at.hannibal2.skyhanni.data.PartyAPI +import at.hannibal2.skyhanni.data.TitleManager import at.hannibal2.skyhanni.features.bingo.card.BingoCardDisplay import at.hannibal2.skyhanni.features.bingo.card.nextstephelper.BingoNextStepHelper import at.hannibal2.skyhanni.features.chat.Translator @@ -318,6 +319,10 @@ object Commands { "shplaysound", "Play the specified sound effect at the given pitch and volume." ) { SoundUtils.command(it) } + registerCommand( + "shsendtitle", + "Display a title on the screen with the specified settings." + ) { TitleManager.command(it) } registerCommand( "shconfigmanagerreset", "Reloads the config manager and rendering processors of MoulConfig. This §cWILL RESET §7your config, but also updating the java config files (names, description, orderings and stuff)." diff --git a/src/main/java/at/hannibal2/skyhanni/data/TitleManager.kt b/src/main/java/at/hannibal2/skyhanni/data/TitleManager.kt index 4fa661562..383600ff9 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/TitleManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/TitleManager.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.data import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.PreProfileSwitchEvent +import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.SimpleTimeMark import io.github.moulberry.moulconfig.internal.TextRenderUtils import net.minecraft.client.Minecraft @@ -9,6 +10,7 @@ import net.minecraft.client.gui.ScaledResolution import net.minecraft.client.renderer.GlStateManager import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration +import kotlin.time.Duration.Companion.seconds class TitleManager { @@ -16,11 +18,27 @@ class TitleManager { private var display = "" private var endTime = SimpleTimeMark.farPast() private var heightModifier = 1.8 + private var fontSizeModifier = 4.0 - fun sendTitle(text: String, duration: Duration, height: Double = 1.8) { + fun sendTitle(text: String, duration: Duration, height: Double = 1.8, fontSize: Double = 4.0) { display = "§f$text" endTime = SimpleTimeMark.now() + duration heightModifier = height + fontSizeModifier = fontSize + } + + fun command(args: Array) { + if (args.size < 4) { + LorenzUtils.userError("Specify title text to test") + return + } + + val duration = args[0].toInt().seconds + val height = args[1].toDouble() + val fontSize = args[2].toDouble() + val title = "§6" + args.drop(3).joinToString(" ") + + sendTitle(title, duration, height, fontSize) } } @@ -43,8 +61,8 @@ class TitleManager { GlStateManager.pushMatrix() GlStateManager.translate((width / 2).toFloat(), (height / heightModifier).toFloat(), 0.0f) - GlStateManager.scale(4.0f, 4.0f, 4.0f) - TextRenderUtils.drawStringCenteredScaledMaxWidth(display, renderer, 0f, 0f, false, 75, 0) + GlStateManager.scale(fontSizeModifier, fontSizeModifier, fontSizeModifier) + TextRenderUtils.drawStringCenteredScaledMaxWidth(display, renderer, 0f, 0f, true, 75, 0) GlStateManager.popMatrix() } -} \ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureFeatures.kt index da0d9a950..cdb990afe 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureFeatures.kt @@ -15,6 +15,7 @@ import at.hannibal2.skyhanni.utils.EntityUtils.hasNameTagWith import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.LorenzUtils.baseMaxHealth import at.hannibal2.skyhanni.utils.LorenzUtils.editCopy import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.SoundUtils @@ -50,9 +51,11 @@ class SeaCreatureFeatures { RenderLivingEntityHelper.setEntityColor(entity, LorenzColor.RED.toColor().withAlpha(50)) { config.highlight } RenderLivingEntityHelper.setNoHurtTime(entity) { config.highlight } + + if (creatureType == RareSeaCreatureType.WATER_HYDRA && entity.health == (entity.baseMaxHealth.toFloat() / 2)) continue; // Water hydra splitting in two if (config.alertOtherCatches && lastRareCatch.passedSince() > 1.seconds) { val creature = SeaCreatureManager.allFishingMobs[creatureType.nametag] - TitleManager.sendTitle("${creature?.rarity?.chatColorCode ?: "§6"}RARE SEA CREATURE!", 1.5.seconds, 3.6) + TitleManager.sendTitle("${creature?.rarity?.chatColorCode ?: "§6"}RARE SEA CREATURE!", 1.5.seconds, 3.6, 7.0) if (config.playSound) SoundUtils.playBeepSound() } } @@ -64,7 +67,7 @@ class SeaCreatureFeatures { if (!config.alertOwnCatches) return if (event.seaCreature.rare) { - TitleManager.sendTitle("${event.seaCreature.rarity.chatColorCode}RARE CATCH!", 3.seconds, 3.6) + TitleManager.sendTitle("${event.seaCreature.rarity.chatColorCode}RARE CATCH!", 3.seconds, 2.8, 7.0) if (config.playSound) SoundUtils.playBeepSound() lastRareCatch = SimpleTimeMark.now() } -- cgit