aboutsummaryrefslogtreecommitdiff
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
parente316790f7132430c6d4e7621734999244fb2d34d (diff)
downloadskyhanni-5987dd18a6fc7709d079c81e2062c67b7e62581b.tar.gz
skyhanni-5987dd18a6fc7709d079c81e2062c67b7e62581b.tar.bz2
skyhanni-5987dd18a6fc7709d079c81e2062c67b7e62581b.zip
Feature: Arrow Trail (#601)
Added Arrow Trail Cosmetic #601
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/MiscConfig.java45
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/cosmetics/ArrowTrail.kt75
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt1
4 files changed, 123 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
index 7002ff0f5..2501d0905 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
@@ -76,6 +76,7 @@ import at.hannibal2.skyhanni.features.commands.tabcomplete.GetFromSacksTabComple
import at.hannibal2.skyhanni.features.commands.tabcomplete.PlayerTabComplete
import at.hannibal2.skyhanni.features.commands.tabcomplete.WarpTabComplete
import at.hannibal2.skyhanni.features.cosmetics.CosmeticFollowingLine
+import at.hannibal2.skyhanni.features.cosmetics.ArrowTrail
import at.hannibal2.skyhanni.features.dungeon.CroesusUnopenedChestTracker
import at.hannibal2.skyhanni.features.dungeon.DungeonAPI
import at.hannibal2.skyhanni.features.dungeon.DungeonBossHideDamageSplash
@@ -609,6 +610,7 @@ class SkyHanniMod {
loadModule(SkyBlockKickDuration())
loadModule(LimboTimeTracker())
loadModule(PartyMemberOutlines())
+ loadModule(ArrowTrail())
loadModule(ShiftClickEquipment())
loadModule(LockMouseLook)
loadModule(DungeonFinderFeatures())
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/MiscConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/MiscConfig.java
index c55c7b3d1..5f21de197 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/MiscConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/MiscConfig.java
@@ -490,6 +490,51 @@ public class MiscConfig {
@ConfigEditorBoolean
public boolean behindBlocks = false;
}
+
+ @Expose
+ @ConfigOption(name = "Arrow Trail", desc = "")
+ @Accordion
+ public ArrowTrailConfig arrowTrailConfig = new ArrowTrailConfig();
+
+ public static class ArrowTrailConfig{
+ @Expose
+ @ConfigOption(name = "Enabled", desc = "Draw a colored line behind the player.")
+ @ConfigEditorBoolean
+ @FeatureToggle
+ public boolean enabled = false;
+
+ @Expose
+ @ConfigOption(name = "Hide Nonplayer Arrows", desc = "Only shows the arrows the player has shot")
+ @ConfigEditorBoolean
+ @FeatureToggle
+ public boolean hideOtherArrows = true;
+
+ @Expose
+ @ConfigOption(name = "Arrow Color", desc = "Color of the line.")
+ @ConfigEditorColour
+ public String arrowColor = "0:200:85:255:85";
+
+ @Expose
+ @ConfigOption(name = "Player Arrows", desc = "Different Color for arrow that you have shot")
+ @ConfigEditorBoolean
+ @FeatureToggle
+ public boolean handlePlayerArrowsDifferently = false;
+
+ @Expose
+ @ConfigOption(name = "Player Arrow Color", desc = "Color of the line.")
+ @ConfigEditorColour
+ public String playerArrowColor = "0:200:85:255:255";
+
+ @Expose
+ @ConfigOption(name = "Time Alive", desc = "Time in seconds until the trail fades out.")
+ @ConfigEditorSlider(minStep = 0.1f, minValue = 0.1f, maxValue = 30)
+ public float secondsAlive = 0.5f;
+
+ @Expose
+ @ConfigOption(name = "Line Width", desc = "Width of the line.")
+ @ConfigEditorSlider(minStep = 1, minValue = 1, maxValue = 10)
+ public int lineWidth = 4;
+ }
}
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
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt
index bdab17b3b..339a16efc 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt
@@ -159,6 +159,7 @@ private infix fun Double.multiplyZeroSave(other: Double): Double {
fun BlockPos.toLorenzVec(): LorenzVec = LorenzVec(x, y, z)
fun Entity.getLorenzVec(): LorenzVec = LorenzVec(posX, posY, posZ)
+fun Entity.getPrevLorenzVec(): LorenzVec = LorenzVec(prevPosX, prevPosY, prevPosZ)
fun Vec3.toLorenzVec(): LorenzVec = LorenzVec(xCoord, yCoord, zCoord)