-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Stall warning, protection and automatic recovery
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
- Loading branch information
1 parent
2ee44e7
commit 2390a93
Showing
28 changed files
with
246 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
src/main/java/net/torocraft/flighthud/alerts/StallAlert.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package net.torocraft.flighthud.alerts; | ||
|
||
import net.minecraft.client.font.TextRenderer; | ||
import net.minecraft.client.gui.DrawContext; | ||
import net.minecraft.sound.SoundEvent; | ||
import net.minecraft.text.Text; | ||
import net.minecraft.util.Identifier; | ||
import net.torocraft.flighthud.HudComponent; | ||
import net.torocraft.flighthud.computers.FlightComputer; | ||
import net.torocraft.flighthud.computers.GPWSComputer; | ||
import net.torocraft.flighthud.computers.StallComputer; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import static net.torocraft.flighthud.HudComponent.CONFIG; | ||
|
||
public class StallAlert implements IAlert { | ||
private static final AlertSoundData STALL = new AlertSoundData( | ||
SoundEvent.of(new Identifier("flighthud:stall")), | ||
0, | ||
0.75f, | ||
true | ||
); | ||
private final FlightComputer computer; | ||
|
||
public StallAlert(FlightComputer computer) { | ||
this.computer = computer; | ||
} | ||
|
||
@Override | ||
public boolean isTriggered() { | ||
return computer.stall.stalling >= StallComputer.STATUS_APPROACHING_STALL; | ||
} | ||
|
||
@Override | ||
public @NotNull AlertSoundData getAlertSoundData() { | ||
return STALL; | ||
} | ||
|
||
@Override | ||
public boolean renderCentered(TextRenderer textRenderer, DrawContext context, float width, float y, boolean highlight) { | ||
Text text = Text.translatable("alerts.flighthud.stall"); | ||
float startX = (width - textRenderer.getWidth(text)) * 0.5f; | ||
HudComponent.drawHighlightedFont(textRenderer, context, startX, y, text, | ||
-computer.velocityPerSecond.y >= GPWSComputer.MAX_SAFE_SINK_RATE ? | ||
CONFIG.alertColor : | ||
CONFIG.amberColor, highlight); | ||
|
||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.