From 72153ec78a94bcedd26e9087b4f5713f2bcf69c7 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 18 Jan 2024 16:12:47 +0100 Subject: Changed griffin burrow guess text to a centered title instead of a odd line that goes down. --- .../at/hannibal2/skyhanni/data/TitleManager.kt | 9 ++++++++ .../features/event/diana/BurrowWarpHelper.kt | 7 +++++- .../features/event/diana/GriffinBurrowHelper.kt | 27 ++++++++++++++-------- 3 files changed, 32 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/main/java/at/hannibal2/skyhanni/data/TitleManager.kt b/src/main/java/at/hannibal2/skyhanni/data/TitleManager.kt index 8cd45d76d..275a6f9f7 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/TitleManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/TitleManager.kt @@ -11,23 +11,32 @@ import net.minecraft.client.renderer.GlStateManager import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration +import kotlin.time.Duration.Companion.milliseconds import kotlin.time.Duration.Companion.seconds class TitleManager { companion object { + private var originalText = "" private var display = "" private var endTime = SimpleTimeMark.farPast() private var heightModifier = 1.8 private var fontSizeModifier = 4f fun sendTitle(text: String, duration: Duration, height: Double, fontSize: Float) { + originalText = text display = "§f$text" endTime = SimpleTimeMark.now() + duration heightModifier = height fontSizeModifier = fontSize } + fun optionalResetTitle(condition: (String) -> Boolean) { + if (condition(originalText)) { + sendTitle("", 1.milliseconds, 1.8, 4f) + } + } + fun command(args: Array) { if (args.size < 4) { LorenzUtils.userError("Usage: /shsendtitle ") diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/BurrowWarpHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/BurrowWarpHelper.kt index 64219be36..1125b8c8c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/BurrowWarpHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/BurrowWarpHelper.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.features.event.diana import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.data.TitleManager import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzKeyPressEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent @@ -31,6 +32,10 @@ class BurrowWarpHelper { lastWarpTime = SimpleTimeMark.now() LorenzUtils.sendCommandToServer("warp " + currentWarp?.name) lastWarp = currentWarp + GriffinBurrowHelper.lastTitleSentTime = SimpleTimeMark.now() + 2.seconds + TitleManager.optionalResetTitle { + it.startsWith("§bWarp to ") + } } } } @@ -88,7 +93,7 @@ class BurrowWarpHelper { enum class WarpPoint( val displayName: String, - private val location: LorenzVec, + val location: LorenzVec, private val extraBlocks: Int, val ignored: () -> Boolean = { false }, var unlocked: Boolean = true, diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowHelper.kt index da26ce43f..a940403fb 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowHelper.kt @@ -24,8 +24,8 @@ import at.hannibal2.skyhanni.utils.LorenzVec import at.hannibal2.skyhanni.utils.RenderUtils.draw3DLine import at.hannibal2.skyhanni.utils.RenderUtils.drawColor import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText -import at.hannibal2.skyhanni.utils.RenderUtils.drawString import at.hannibal2.skyhanni.utils.RenderUtils.exactPlayerEyeLocation +import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.TimeUtils.format import net.minecraft.client.Minecraft import net.minecraft.init.Blocks @@ -41,6 +41,7 @@ object GriffinBurrowHelper { private var particleBurrows = mapOf() private var lastGuessTime = 0L + var lastTitleSentTime = SimpleTimeMark.farPast() @SubscribeEvent fun onTick(event: LorenzTickEvent) { @@ -153,7 +154,7 @@ object GriffinBurrowHelper { @SubscribeEvent fun onRenderWorld(event: LorenzRenderWorldEvent) { if (!isEnabled()) return - sendTip(event) + showWarpSuggestions() val playerLocation = LocationUtils.playerLocation() if (config.inquisitorSharing.enabled) { @@ -180,13 +181,14 @@ object GriffinBurrowHelper { } } + val currentWarp = BurrowWarpHelper.currentWarp if (config.lineToNext) { val player = event.exactPlayerEyeLocation() var color: LorenzColor? - val renderLocation = if (BurrowWarpHelper.currentWarp != null) { + val renderLocation = if (currentWarp != null) { color = LorenzColor.AQUA - player.add(y = -5) + currentWarp.location } else { color = LorenzColor.WHITE targetLocation?.add(0.5, 0.5, 0.5) ?: return @@ -196,7 +198,9 @@ object GriffinBurrowHelper { color = particleBurrows[targetLocation]!!.color 3 } else 2 - event.draw3DLine(player, renderLocation, color.toColor(), lineWidth, false) + if (currentWarp == null) { + event.draw3DLine(player, renderLocation, color.toColor(), lineWidth, false) + } } if (InquisitorWaypointShare.waypoints.isNotEmpty() && config.inquisitorSharing.focusInquisitor) { @@ -218,7 +222,7 @@ object GriffinBurrowHelper { val guessLocation = findBlock(it) val distance = guessLocation.distance(playerLocation) event.drawColor(guessLocation, LorenzColor.WHITE, distance > 10) - val color = if (BurrowWarpHelper.currentWarp == null) "§f" else "§b" + val color = if (currentWarp == null) "§f" else "§b" event.drawDynamicText(guessLocation.add(y = 1), "${color}Guess", 1.5) if (distance > 5) { val formattedDistance = LorenzUtils.formatInteger(distance.toInt()) @@ -233,18 +237,20 @@ object GriffinBurrowHelper { event.move(2, "diana", "event.diana") } - private fun sendTip(event: LorenzRenderWorldEvent) { - + private fun showWarpSuggestions() { if (!config.burrowNearestWarp) return val warp = BurrowWarpHelper.currentWarp ?: return - val location = event.exactPlayerEyeLocation().add(y = -5) + val text = "§bWarp to " + warp.displayName val keybindSuffix = if (config.keyBindWarp != Keyboard.KEY_NONE) { val keyname = KeyboardManager.getKeyName(config.keyBindWarp) " §7(§ePress $keyname§7)" } else "" - event.drawString(location, text + keybindSuffix, true) + if (lastTitleSentTime.passedSince() > 2.seconds) { + lastTitleSentTime = SimpleTimeMark.now() + LorenzUtils.sendTitle(text + keybindSuffix, 2.seconds, fontSize = 3f) + } } private fun isEnabled() = DianaAPI.isDoingDiana() @@ -276,6 +282,7 @@ object GriffinBurrowHelper { LorenzUtils.chat("Manually reset all burrow waypoints.") return } + "1", "start" -> BurrowType.START "2", "mob" -> BurrowType.MOB "3", "treasure" -> BurrowType.TREASURE -- cgit