diff options
3 files changed, 39 insertions, 18 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/DianaConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/DianaConfig.java index 3d90a4f54..99437bb83 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/DianaConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/DianaConfig.java @@ -58,6 +58,11 @@ public class DianaConfig { @ConfigOption(name = "Share Key", desc = "Press this key to share your Inquisitor Waypoint.") @ConfigEditorKeybind(defaultKey = Keyboard.KEY_Y) public int keyBindShare = Keyboard.KEY_Y; + + @Expose + @ConfigOption(name = "Show Despawn Time", desc = "Show the time until the shared Inquisitor will despawn.") + @ConfigEditorBoolean + public boolean showDespawnTime = true; } @Expose 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 99aa135bb..d3c6038f2 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 @@ -3,13 +3,10 @@ package at.hannibal2.skyhanni.features.event.diana import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.EntityMovementData import at.hannibal2.skyhanni.events.* +import at.hannibal2.skyhanni.utils.* import at.hannibal2.skyhanni.utils.BlockUtils.getBlockAt -import at.hannibal2.skyhanni.utils.LocationUtils 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.editCopy -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 @@ -18,6 +15,7 @@ import net.minecraft.client.Minecraft import net.minecraft.init.Blocks import net.minecraftforge.client.event.RenderWorldLastEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import kotlin.time.Duration.Companion.seconds object GriffinBurrowHelper { private val config get() = SkyHanniMod.feature.diana @@ -139,19 +137,29 @@ object GriffinBurrowHelper { sendTip(event) val playerLocation = LocationUtils.playerLocation() - for ((playerName, location) in InquisitorWaypointShare.waypoints) { - event.drawColor(location, LorenzColor.LIGHT_PURPLE) - val distance = location.distance(playerLocation) - if (distance > 10) { - val formattedDistance = LorenzUtils.formatInteger(distance.toInt()) - event.drawDynamicText(location.add(0, 1, 0), "§d§lInquisitor §e${formattedDistance}m", 1.7) - } else { - event.drawDynamicText(location.add(0, 1, 0), "§d§lInquisitor", 1.7) - } - if (distance < 5) { - InquisitorWaypointShare.maybeRemove(playerName) + if (SkyHanniMod.feature.diana.inquisitorSharing.enabled) { + for (inquis in InquisitorWaypointShare.waypoints.values) { + val playerName = inquis.fromPlayer + val location = inquis.location + event.drawColor(location, LorenzColor.LIGHT_PURPLE) + val distance = location.distance(playerLocation) + if (distance > 10) { + val formattedDistance = LorenzUtils.formatInteger(distance.toInt()) + event.drawDynamicText(location.add(0, 1, 0), "§d§lInquisitor §e${formattedDistance}m", 1.7) + } else { + event.drawDynamicText(location.add(0, 1, 0), "§d§lInquisitor", 1.7) + } + if (distance < 5) { + InquisitorWaypointShare.maybeRemove(playerName) + } + event.drawDynamicText(location.add(0, 1, 0), "§eFrom §b$playerName", 1.6, yOff = 9f) + + if (config.inquisitorSharing.showDespawnTime) { + val spawnTime = inquis.spawnTime + val format = TimeUtils.formatDuration(75.seconds - spawnTime.passedSince()) + event.drawDynamicText(location.add(0, 1, 0), "§eDespawns in §b$format", 1.6, yOff = 18f) + } } - event.drawDynamicText(location.add(0, 1, 0), "§eFrom §b$playerName", 1.6, yOff = 9f) } if (InquisitorWaypointShare.waypoints.isNotEmpty()) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt index 7d88dced4..9347d1580 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt @@ -18,6 +18,7 @@ import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import net.minecraftforge.fml.common.gameevent.InputEvent import org.lwjgl.input.Keyboard +import kotlin.time.Duration.Companion.seconds object InquisitorWaypointShare { private val config get() = SkyHanniMod.feature.diana.inquisitorSharing @@ -35,7 +36,9 @@ object InquisitorWaypointShare { private val logger = LorenzLogger("diana/waypoints") - var waypoints = mapOf<String, LorenzVec>() + var waypoints = mapOf<String, SharedInquisitor>() + + class SharedInquisitor(val fromPlayer: String, val location: LorenzVec, val spawnTime: SimpleTimeMark) private var test = false @@ -51,6 +54,9 @@ object InquisitorWaypointShare { if (event.repeatSeconds(3)) { inquisitorsNearby = inquisitorsNearby.editCopy { removeIf { it.isDead } } } + if (event.repeatSeconds(1)) { + waypoints = waypoints.editCopy { values.removeIf { it.spawnTime.passedSince() > 75.seconds } } + } } @SubscribeEvent @@ -124,6 +130,7 @@ object InquisitorWaypointShare { inquisitor = inquisId if (config.instantShare) { + // add repo kill switch sendInquisitor() } else { val keyName = KeybindHelper.getKeyName(config.keyBindShare) @@ -222,7 +229,8 @@ object InquisitorWaypointShare { SoundUtils.playBeepSound() } } - waypoints = waypoints.editCopy { this[cleanName] = location } + val inquis = SharedInquisitor(cleanName, location, SimpleTimeMark.now()) + waypoints = waypoints.editCopy { this[cleanName] = inquis } if (config.focusInquisitor) { GriffinBurrowHelper.setTargetLocation(location.add(0, 1, 0)) GriffinBurrowHelper.animationLocation = LocationUtils.playerLocation() |