Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

__Flight HUD__ is a client side Fabric Minecraft Mod that adds a flight style HUD like one you would see in a flight simulator.

This is an unofficial branch of Forge FlightHUD.

![HUD Screenshot](images/hud2020-07-07.png?raw=true "HUD Screenshot")

## Features
Expand All @@ -26,6 +28,5 @@ __Flight HUD__ is a client side Fabric Minecraft Mod that adds a flight style HU
![HUD Components](images/hud-diagram.png?raw=true "HUD Components")

## Requirements
- Minecraft 1.16.1
- Fabric Mod Loader
- Fabric API Mod
- Minecraft 1.19+
- Forge 40.1.93+
408 changes: 230 additions & 178 deletions build.gradle

Large diffs are not rendered by default.

10 changes: 9 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
# Sets default memory used for gradle commands. Can be overridden by user or command line properties.
# This is required to provide enough memory for the Minecraft decompilation process.
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false
org.gradle.daemon=true
org.gradle.configureondemand=true
org.gradle.parallel=true

artifact_minecraft_version = 1.19
mc_version=1.19.2
forge_version = 43.1.10
mod_version=HTony_test
forgegradle_version = 5.1.53
10 changes: 10 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* This file was generated by the Gradle 'init' task.
*
* The settings file is used to specify which projects to include in your build.
*
* Detailed information about configuring a multi-project build in Gradle can be found
* in the user manual at https://docs.gradle.org/7.4/userguide/multi_project_builds.html
*/

rootProject.name = 'FlightHUD'
6 changes: 3 additions & 3 deletions src/main/java/net/torocraft/flighthud/ClientEventHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import net.minecraft.client.Minecraft;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.client.event.RenderGuiOverlayEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;

Expand All @@ -12,7 +12,7 @@ public class ClientEventHandler {
private static final HudRenderer hud = new HudRenderer();

@SubscribeEvent
public static void onRenderGui(RenderGameOverlayEvent.Post event) {
hud.render(event.getMatrixStack(), event.getPartialTicks(), Minecraft.getInstance());
public static void onRenderGui(RenderGuiOverlayEvent.Post event) {
hud.render(event.getPoseStack(), event.getPartialTick(), Minecraft.getInstance());
}
}
4 changes: 2 additions & 2 deletions src/main/java/net/torocraft/flighthud/Dimensions.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public void update(Minecraft client) {
hScreen = hScreen * c.scale;
wScreen = wScreen * c.scale;
}

degreesPerPixel = (float) (hScreen / client.options.fov);
float fov = client.options.fov().get().floatValue();
degreesPerPixel = (float) (hScreen / fov);
xMid = wScreen / 2;
yMid = hScreen / 2;

Expand Down
33 changes: 27 additions & 6 deletions src/main/java/net/torocraft/flighthud/FlightHud.java
Original file line number Diff line number Diff line change
@@ -1,25 +1,33 @@
package net.torocraft.flighthud;

import net.minecraft.client.KeyMapping;
import net.minecraftforge.client.event.InputEvent.KeyInputEvent;
import net.minecraft.client.Minecraft;
import net.minecraft.client.Options;
import net.minecraftforge.client.event.InputEvent;
import net.minecraftforge.client.event.RegisterKeyMappingsEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.fmlclient.registry.ClientRegistry;
import net.torocraft.flighthud.config.HudConfig;
import net.torocraft.flighthud.config.SettingsConfig;
import net.torocraft.flighthud.config.loader.ConfigLoader;
import org.lwjgl.glfw.GLFW;




@Mod(FlightHud.MODID)
public class FlightHud {
public static final String MODID = "flighthud";

public static SettingsConfig CONFIG_SETTINGS = new SettingsConfig();
public static HudConfig CONFIG_MIN = new HudConfig();
public static HudConfig CONFIG_FULL = new HudConfig();


public static IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus();

public static ConfigLoader<SettingsConfig> CONFIG_LOADER_SETTINGS = new ConfigLoader<>(
new SettingsConfig(),
FlightHud.MODID + ".settings.json",
Expand All @@ -38,6 +46,9 @@ public class FlightHud {
config -> FlightHud.CONFIG_MIN = config);

private static KeyMapping keyBinding;
static Options options = Minecraft.getInstance().options;



public FlightHud() {
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
Expand All @@ -46,22 +57,32 @@ public FlightHud() {
}

private void setup(final FMLCommonSetupEvent event) {
keyBinding = new KeyMapping("key.flighthud.toggleDisplayModed", GLFW.GLFW_KEY_GRAVE_ACCENT, "category.flighthud.toggleDisplayMode");
keyBinding = new KeyMapping("key.flighthud.toggleDisplayMode", GLFW.GLFW_KEY_GRAVE_ACCENT, "category.flighthud.toggleDisplayMode");
CONFIG_LOADER_SETTINGS.load();
CONFIG_LOADER_FULL.load();
CONFIG_LOADER_MIN.load();
setupKeycCode();
setupCommand();
}

private void onKeyInput(KeyInputEvent event) {
private void onKeyInput(InputEvent event) {
if (keyBinding.consumeClick()) {
CONFIG_SETTINGS.toggleDisplayMode();
}
}


//@SubscribeEvent
private static void testsetup(RegisterKeyMappingsEvent event){
event.register(keyBinding);
}
private static void setupKeycCode() {
ClientRegistry.registerKeyBinding(keyBinding);
//RegisterKeyMappingsEvent.register(keyBinding);
//RegisterKeyMappingsEvent registerKeyMappingsEvent = options;
testsetup(new RegisterKeyMappingsEvent(options));
//RegisterKeyMappingsEvent(options);

//lightHud.register(keyBinding);
}

private static void setupCommand() {
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/net/torocraft/flighthud/HudComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,11 @@ private static void fill(Matrix4f matrix, float x1, float y1, float x2, float y2
bufferBuilder.vertex(matrix, x2, y2, 0.0F).color(r, g, b, alpha).endVertex();
bufferBuilder.vertex(matrix, x2, y1, 0.0F).color(r, g, b, alpha).endVertex();
bufferBuilder.vertex(matrix, x1, y1, 0.0F).color(r, g, b, alpha).endVertex();
bufferBuilder.end();
BufferUploader.end(bufferBuilder);
//bufferBuilder.end();

//BufferUploader.end(bufferBuilder);
BufferUploader.drawWithShader(bufferBuilder.end());

RenderSystem.enableTexture();
RenderSystem.disableBlend();
}
Expand Down
41 changes: 31 additions & 10 deletions src/main/java/net/torocraft/flighthud/HudRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,23 @@
import net.torocraft.flighthud.components.LocationIndicator;
import net.torocraft.flighthud.components.PitchIndicator;
import net.torocraft.flighthud.components.SpeedIndicator;
import net.torocraft.flighthud.config.HudConfig;
import net.torocraft.flighthud.config.SettingsConfig.DisplayMode;

public class HudRenderer extends HudComponent {

public class HudRenderer extends HudComponent {
private final Dimensions dim = new Dimensions();
private final FlightComputer computer = new FlightComputer();
private static final String FULL = DisplayMode.FULL.toString();
private static final String MIN = DisplayMode.MIN.toString();


HudConfig config = HudComponent.CONFIG;

int frames;
public int allframes = 0;


private final HudComponent[] components =
new HudComponent[] {new FlightPathIndicator(computer, dim), new LocationIndicator(dim),
new HeadingIndicator(computer, dim), new SpeedIndicator(computer, dim),
Expand Down Expand Up @@ -50,20 +58,33 @@ public void render(PoseStack m, float partial, Minecraft client) {
}

try {
m.pushPose();

if (HudComponent.CONFIG.scale != 1d) {
float scale = 1 / (float) HudComponent.CONFIG.scale;
m.scale(scale, scale, scale);
try{
frames = config.refreshing_rate;
} catch (Exception e2){
e2.printStackTrace();
frames = 8;
}
if (allframes % frames == 0 ){
m.pushPose();

computer.update(client, partial);
dim.update(client);
if (HudComponent.CONFIG.scale != 1d) {
float scale = 1 / (float) HudComponent.CONFIG.scale;
m.scale(scale, scale, scale);
}

for (HudComponent component : components) {
component.render(m, partial, client);
computer.update(client, partial);
dim.update(client);

for (HudComponent component : components) {
component.render(m, partial, client);
}
m.popPose();
}
allframes = ++allframes;
if (allframes == 100){
allframes = 0;
}
m.popPose();
} catch (Exception e) {
e.printStackTrace();
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/net/torocraft/flighthud/config/HudConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ public class HudConfig implements IConfig {
public boolean heading_showReadout = true;
public boolean heading_showOrdinals = true;

public int refreshing_rate = 6;

@Override
public void update() {
updateThickness();
Expand Down
12 changes: 6 additions & 6 deletions src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
modLoader="javafml" #mandatory

# A version range to match for said mod loader - for regular FML @Mod it will be the forge version
loaderVersion="[32,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
loaderVersion="[41,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.

license="GPL3"

Expand All @@ -24,13 +24,13 @@ modId="flighthud" #mandatory
version="${file.jarVersion}" #mandatory

# A display name for the mod
displayName="FlightHUD" #mandatory
displayName="FlightHUD reloaded" #mandatory

# A URL to query for updates for this mod. See the JSON update specification <here>
#updateJSONURL="http://myurl.me/" #optional

# A URL for the "homepage" for this mod, displayed in the mod UI
displayURL="https://www.curseforge.com/minecraft/mc-mods/flighthud" #optional
displayURL="https://www.mcmod.cn/class/10172.html" #optional

# A file name (in the root of the mod JAR) containing a logo for display
#logoFile="flighthud.png" #optional
Expand All @@ -39,7 +39,7 @@ displayURL="https://www.curseforge.com/minecraft/mc-mods/flighthud" #optional
#credits="Thanks for this example mod goes to Java" #optional

# A text field displayed in the mod UI
authors="frodare" #optional
authors="frodare,HTony03" #optional

# The description text for the mod (multi line!) (#mandatory)
description='''
Expand All @@ -52,7 +52,7 @@ Displays a flight styled hud while flying with elytra.
# Does this dependency have to exist - if not, ordering below must be specified
mandatory=true #mandatory
# The version range of the dependency
versionRange="[32,)" #mandatory
versionRange="[41,)" #mandatory
# An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory
ordering="NONE"
# Side this dependency is applied on - BOTH, CLIENT or SERVER
Expand All @@ -62,6 +62,6 @@ Displays a flight styled hud while flying with elytra.
[[dependencies.flighthud]]
modId="minecraft"
mandatory=true
versionRange="[1.17.1]"
versionRange="[1.19,1.19.2]"
ordering="NONE"
side="BOTH"
4 changes: 4 additions & 0 deletions src/main/resources/assets/flighthud/lang/zh_cn.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"key.flighthud.toggleDisplayMode": "切换HUD模式",
"category.flighthud.toggleDisplayMode": "Flight HUD"
}