aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features
diff options
context:
space:
mode:
authorThunderblade73 <85900443+Thunderblade73@users.noreply.github.com>2023-10-28 19:31:28 +0200
committerGitHub <noreply@github.com>2023-10-28 19:31:28 +0200
commit5987dd18a6fc7709d079c81e2062c67b7e62581b (patch)
treef0cc0fa846efd6516f8c161377433c210f0b63ad /src/main/java/at/hannibal2/skyhanni/features
parente316790f7132430c6d4e7621734999244fb2d34d (diff)
downloadskyhanni-5987dd18a6fc7709d079c81e2062c67b7e62581b.tar.gz
skyhanni-5987dd18a6fc7709d079c81e2062c67b7e62581b.tar.bz2
skyhanni-5987dd18a6fc7709d079c81e2062c67b7e62581b.zip
Feature: Arrow Trail (#601)
Added Arrow Trail Cosmetic #601
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/cosmetics/ArrowTrail.kt75
1 files changed, 75 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/cosmetics/ArrowTrail.kt b/src/main/java/at/hannibal2/skyhanni/features/cosmetics/ArrowTrail.kt
new file mode 100644
index 000000000..031ea9eb2
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/cosmetics/ArrowTrail.kt
@@ -0,0 +1,75 @@
+package at.hannibal2.skyhanni.features.cosmetics
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.events.IslandChangeEvent
+import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent
+import at.hannibal2.skyhanni.events.LorenzTickEvent
+import at.hannibal2.skyhanni.utils.EntityUtils
+import at.hannibal2.skyhanni.utils.LorenzDebug
+import at.hannibal2.skyhanni.utils.LorenzVec
+import at.hannibal2.skyhanni.utils.getLorenzVec
+import at.hannibal2.skyhanni.utils.getPrevLorenzVec
+import net.minecraft.client.Minecraft
+import net.minecraft.entity.projectile.EntityArrow
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.LorenzUtils.toChromaColor
+import at.hannibal2.skyhanni.utils.RenderUtils.draw3DLine
+import at.hannibal2.skyhanni.utils.SimpleTimeMark
+import at.hannibal2.skyhanni.utils.TimeUtils
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import java.util.LinkedList
+import kotlin.concurrent.thread
+import kotlin.time.Duration
+import kotlin.time.DurationUnit
+import kotlin.time.toDuration
+
+class ArrowTrail {
+
+ private val config get() = SkyHanniMod.feature.misc.cosmeticConfig.arrowTrailConfig
+
+ private data class Line(val start: LorenzVec, val end: LorenzVec, val deathTime: SimpleTimeMark)
+
+ private val listAllArrow: MutableList<Line> = LinkedList<Line>()
+ private val listYourArrow: MutableList<Line> = LinkedList<Line>()
+
+ @SubscribeEvent
+ fun onTick(event: LorenzTickEvent) {
+ if (!LorenzUtils.inSkyBlock) return
+ if (!config.enabled) return
+ val secondsAlive = config.secondsAlive.toDouble().toDuration(DurationUnit.SECONDS)
+ val time = SimpleTimeMark.now()
+ val deathTime = time.plus(secondsAlive)
+ listAllArrow.removeIf { it.deathTime.isInPast()}
+ listYourArrow.removeIf { it.deathTime.isInPast()}
+ EntityUtils.getEntities<EntityArrow>().forEach {
+ if (it.shootingEntity == Minecraft.getMinecraft().thePlayer) {
+ listYourArrow.add(Line(it.getPrevLorenzVec(), it.getLorenzVec(), deathTime))
+ } else {
+ listAllArrow.add(Line(it.getPrevLorenzVec(), it.getLorenzVec(), deathTime))
+ }
+ }
+ }
+
+ @SubscribeEvent
+ fun onWorldRender(event: LorenzRenderWorldEvent) {
+ if (!LorenzUtils.inSkyBlock) return
+ if (!config.enabled) return
+ val playerArrowColor = if (config.handlePlayerArrowsDifferently) config.playerArrowColor.toChromaColor() else
+ config.arrowColor.toChromaColor()
+ val arrowColor = config.arrowColor.toChromaColor()
+ listYourArrow.forEach {
+ event.draw3DLine(it.start, it.end, playerArrowColor, config.lineWidth, true)
+ }
+ if (!config.hideOtherArrows) {
+ listAllArrow.forEach {
+ event.draw3DLine(it.start, it.end, arrowColor, config.lineWidth, true)
+ }
+ }
+ }
+
+ @SubscribeEvent
+ fun onIslandChange(event: IslandChangeEvent){
+ listAllArrow.clear()
+ listYourArrow.clear()
+ }
+} \ No newline at end of file