diff options
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils')
5 files changed, 21 insertions, 11 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LocationUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LocationUtils.kt index ba82321f2..34aa3f22f 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/LocationUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/LocationUtils.kt @@ -8,7 +8,11 @@ import kotlin.math.min object LocationUtils { - fun canSee(a: LorenzVec, b: LorenzVec) = + fun canSee(a: LorenzVec, b: LorenzVec, offset: Double? = null): Boolean { + return canSee0(a, b) && offset?.let { canSee0(a.add(y = it), b.add(y = it)) } ?: true + } + + private fun canSee0(a: LorenzVec, b: LorenzVec) = Minecraft.getMinecraft().theWorld.rayTraceBlocks(a.toVec3(), b.toVec3(), false, true, false) == null fun playerLocation() = Minecraft.getMinecraft().thePlayer.getLorenzVec() @@ -38,10 +42,10 @@ object LocationUtils { fun AxisAlignedBB.isPlayerInside() = isInside(playerLocation()) - fun LorenzVec.canBeSeen(radius: Double = 150.0): Boolean { + fun LorenzVec.canBeSeen(radius: Double = 150.0, offset: Double? = null): Boolean { val a = playerEyeLocation() val b = this - val noBlocks = canSee(a, b) + val noBlocks = canSee(a, b, offset) val notTooFar = a.distance(b) < radius val inFov = true // TODO add Frustum "Frustum().isBoundingBoxInFrustum(entity.entityBoundingBox)" return noBlocks && notTooFar && inFov diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt index 4a50d79f3..51bb8b72c 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt @@ -74,13 +74,13 @@ data class LorenzVec( override fun toString() = "LorenzVec{x=$x, y=$y, z=$z}" - @Deprecated("Use operator fun times instead", ReplaceWith("this * LorenzVec(x, y, z)")) + @Deprecated("Use operator fun times instead", ReplaceWith("this * d")) fun multiply(d: Double): LorenzVec = LorenzVec(x * d, y * d, z * d) - @Deprecated("Use operator fun times instead", ReplaceWith("this * LorenzVec(x, y, z)")) + @Deprecated("Use operator fun times instead", ReplaceWith("this * d")) fun multiply(d: Int): LorenzVec = LorenzVec(x * d, y * d, z * d) - @Deprecated("Use operator fun times instead", ReplaceWith("this * LorenzVec(x, y, z)")) + @Deprecated("Use operator fun times instead", ReplaceWith("this * v")) fun multiply(v: LorenzVec) = LorenzVec(x * v.x, y * v.y, z * v.z) fun dotProduct(other: LorenzVec): Double = (x * other.x) + (y * other.y) + (z * other.z) diff --git a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt index 3442032e6..08532e0c4 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt @@ -1269,6 +1269,7 @@ object RenderUtils { waypointColor: Color = (path.lastOrNull()?.name?.getFirstColorCode()?.toLorenzColor() ?: LorenzColor.WHITE).toColor(), bezierPoint: Double = 1.0, + showNoteNames: Boolean = false ) { if (path.isEmpty()) return val points = if (startAtEye) { @@ -1290,8 +1291,10 @@ object RenderUtils { bezierPoint, ) } - path.filter { it.name?.isNotEmpty() == true }.forEach { - this.drawDynamicText(it.position, it.name!!, textSize) + if (showNoteNames) { + path.filter { it.name?.isNotEmpty() == true }.forEach { + this.drawDynamicText(it.position, it.name!!, textSize) + } } val last = path.last() drawWaypointFilled(last.position, waypointColor, seeThroughBlocks = true) diff --git a/src/main/java/at/hannibal2/skyhanni/utils/renderables/Searchable.kt b/src/main/java/at/hannibal2/skyhanni/utils/renderables/Searchable.kt index 8ce7c5ec2..4a81830a8 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/renderables/Searchable.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/renderables/Searchable.kt @@ -10,8 +10,9 @@ fun Searchable.toRenderable() = renderable fun List<Searchable>.toRenderable() = map { it.toRenderable() } fun List<Searchable>.toMap() = associate { it.renderable to it.string } val searchPrefix = "§eSearch: §7" -fun List<Searchable>.buildSearchBox(): Renderable { - val textInput = TextInput() +fun List<Searchable>.buildSearchBox( + textInput: TextInput, +): Renderable { val key = 0 return Renderable.searchBox( Renderable.verticalSearchableContainer(toMap(), textInput = textInput, key = key + 1), diff --git a/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniTracker.kt b/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniTracker.kt index 7810c1ee6..a6d42839c 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniTracker.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.config.core.config.Position import at.hannibal2.skyhanni.config.storage.ProfileSpecificStorage import at.hannibal2.skyhanni.data.ProfileStorageData import at.hannibal2.skyhanni.data.TrackerManager +import at.hannibal2.skyhanni.data.model.TextInput import at.hannibal2.skyhanni.features.misc.items.EstimatedItemValue import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.ChatUtils @@ -36,6 +37,7 @@ open class SkyHanniTracker<Data : TrackerData>( private var display = emptyList<Renderable>() private var sessionResetTime = SimpleTimeMark.farPast() private var dirty = false + private val textInput = TextInput() companion object { @@ -85,7 +87,7 @@ open class SkyHanniTracker<Data : TrackerData>( display = getSharedTracker()?.let { val data = it.get(getDisplayMode()) val searchables = drawDisplay(data) - buildFinalDisplay(searchables.buildSearchBox()) + buildFinalDisplay(searchables.buildSearchBox(textInput)) } ?: emptyList() dirty = false } |