aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-06-24 21:08:57 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-06-24 21:08:57 +0200
commit99a5940e339353cda6f1db845751d44bbea8e3f1 (patch)
treee14d1d3c871e44ee023bed5fde170d73f5c74794 /src/main
parent4726b8a54a6f326291de09d8dbfd17db3f2f890d (diff)
downloadskyhanni-99a5940e339353cda6f1db845751d44bbea8e3f1.tar.gz
skyhanni-99a5940e339353cda6f1db845751d44bbea8e3f1.tar.bz2
skyhanni-99a5940e339353cda6f1db845751d44bbea8e3f1.zip
Showed lightning timer above volts instead of as title
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/rift/VoltHighlighter.kt29
1 files changed, 18 insertions, 11 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/VoltHighlighter.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/VoltHighlighter.kt
index 2538fb8ff..4b03e9b6c 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/rift/VoltHighlighter.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/rift/VoltHighlighter.kt
@@ -1,15 +1,18 @@
package at.hannibal2.skyhanni.features.rift
import at.hannibal2.skyhanni.SkyHanniMod
-import at.hannibal2.skyhanni.data.TitleUtils
import at.hannibal2.skyhanni.events.EntityEquipmentChangeEvent
import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper
import at.hannibal2.skyhanni.utils.ItemUtils.getSkullTexture
+import at.hannibal2.skyhanni.utils.LorenzUtils.editCopy
import at.hannibal2.skyhanni.utils.RenderUtils
+import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText
+import at.hannibal2.skyhanni.utils.RenderUtils.exactLocation
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import at.hannibal2.skyhanni.utils.SpecialColour
import at.hannibal2.skyhanni.utils.TimeUtils
import net.minecraft.client.Minecraft
+import net.minecraft.entity.Entity
import net.minecraft.entity.EntityLivingBase
import net.minecraft.entity.item.EntityArmorStand
import net.minecraft.item.ItemStack
@@ -25,7 +28,7 @@ class VoltHighlighter {
private val LIGHTNING_DISTANCE = 7F
private val ARMOR_SLOT_HEAD = 3
private val CHARGE_TIME = 12.seconds
- private var dischargingSince = SimpleTimeMark.farPast()
+ private var chargingSince = mapOf<Entity, SimpleTimeMark>()
@SubscribeEvent
fun onArmorChange(event: EntityEquipmentChangeEvent) {
@@ -34,20 +37,15 @@ class VoltHighlighter {
if (event.isHead && getVoltState(event.entity) == VoltState.DOING_LIGHTNING
&& event.entity.positionVector.squareDistanceTo(player.positionVector) <= LIGHTNING_DISTANCE * LIGHTNING_DISTANCE
) {
- dischargingSince = SimpleTimeMark.now()
+ chargingSince = chargingSince.editCopy {
+ this[event.entity] = SimpleTimeMark.now()
+ }
}
}
@SubscribeEvent
fun onRender(event: RenderWorldLastEvent) {
if (!RiftAPI.inRift() || !(config.voltRange || config.voltMoodMeter)) return
- val dischargeTimeLeft = CHARGE_TIME - dischargingSince.passedSince()
- if (dischargeTimeLeft > Duration.ZERO) {
- TitleUtils.sendTitle(
- "§eLightning: ${TimeUtils.formatDuration(dischargeTimeLeft, showMilliSeconds = true)}",
- 50
- )
- }
val list = Minecraft.getMinecraft().theWorld?.loadedEntityList ?: return
for (entity in list) {
if (entity !is EntityLivingBase) continue
@@ -73,6 +71,15 @@ class VoltHighlighter {
partialTicks = event.partialTicks,
height = 20F
)
+ val dischargingSince = chargingSince.getOrDefault(entity, SimpleTimeMark.farPast())
+ val dischargeTimeLeft = CHARGE_TIME - dischargingSince.passedSince()
+ if (dischargeTimeLeft > Duration.ZERO) {
+ event.drawDynamicText(
+ event.exactLocation(entity).add(0.0, 2.5, 0.0),
+ "§eLightning: ${TimeUtils.formatDuration(dischargeTimeLeft, showMilliSeconds = true)}",
+ 2.5
+ )
+ }
}
}
}
@@ -104,7 +111,7 @@ class VoltHighlighter {
}
- private fun getVoltState(entity: net.minecraft.entity.Entity): VoltState {
+ private fun getVoltState(entity: Entity): VoltState {
if (entity !is EntityArmorStand) return VoltState.NO_VOLT
val helmet = entity.getCurrentArmor(ARMOR_SLOT_HEAD) ?: return VoltState.NO_VOLT
return getVoltState(helmet)