Skip to content

Commit f04858d

Browse files
committed
fix(FlightDirectorsDisplay): interpolate final position instead of target to avoid issues due to wrapping
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
1 parent 08a74a9 commit f04858d

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

src/main/kotlin/ru/octol1ttle/flightassistant/impl/display/FlightDirectorsDisplay.kt

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package ru.octol1ttle.flightassistant.impl.display
22

33
import com.mojang.math.Axis
4+
import kotlin.math.roundToInt
45
import net.minecraft.client.gui.GuiGraphics
56
import net.minecraft.network.chat.Component
67
import net.minecraft.resources.ResourceLocation
@@ -16,9 +17,9 @@ import ru.octol1ttle.flightassistant.api.util.extensions.*
1617
import ru.octol1ttle.flightassistant.config.FAConfig
1718

1819
class FlightDirectorsDisplay(computers: ComputerBus) : Display(computers) {
19-
private val pitchTargetLerper: FloatLerper = FloatLerper()
20-
private val headingTargetLerper: FloatLerper = FloatLerper()
21-
20+
private val xLerper: FloatLerper = FloatLerper()
21+
private val yLerper: FloatLerper = FloatLerper()
22+
2223
override fun allowedByConfig(): Boolean {
2324
return FAConfig.display.showFlightDirectors
2425
}
@@ -42,17 +43,15 @@ class FlightDirectorsDisplay(computers: ComputerBus) : Display(computers) {
4243
enableScissor(HudFrame.left, HudFrame.top, HudFrame.right, HudFrame.bottom)
4344

4445
val pitchInput: ControlInput? = computers.pitch.activeInput
45-
val pitchTarget: Float? = pitchTargetLerper.get(pitchInput?.target, FATickCounter.timePassed * 1.5f)
46-
if (pitchTarget != null && pitchInput != null && pitchInput.priority >= ControlInput.Priority.NORMAL) {
47-
ScreenSpace.getY(pitchTarget)?.let {
46+
if (pitchInput != null && pitchInput.priority >= ControlInput.Priority.NORMAL) {
47+
yLerper.get(ScreenSpace.getY(pitchInput.target)?.toFloat(), FATickCounter.timePassed * 1.5f)?.roundToInt()?.let {
4848
hLine(this.centerX - halfWidth, this.centerX + halfWidth, it.coerceIn(HudFrame.top + 1..<HudFrame.bottom - 1), primaryAdvisoryColor)
4949
}
5050
}
5151

5252
val headingInput: ControlInput? = computers.heading.activeInput
53-
val headingTarget: Float? = headingTargetLerper.get(headingInput?.target, FATickCounter.timePassed * 1.5f)
54-
if (headingTarget != null && headingInput != null && headingInput.priority >= ControlInput.Priority.NORMAL) {
55-
ScreenSpace.getX(headingTarget)?.let {
53+
if (headingInput != null && headingInput.priority >= ControlInput.Priority.NORMAL) {
54+
xLerper.get(ScreenSpace.getX(headingInput.target)?.toFloat(), FATickCounter.timePassed * 1.5f)?.roundToInt()?.let {
5655
vLine(it.coerceIn(HudFrame.left + 1..<HudFrame.right - 1), this.centerY - halfWidth, this.centerY + halfWidth, primaryAdvisoryColor)
5756
}
5857
}

0 commit comments

Comments
 (0)