diff options
author | alemi <me@alemi.dev> | 2023-03-08 17:24:56 +0100 |
---|---|---|
committer | alemi <me@alemi.dev> | 2023-03-08 17:24:56 +0100 |
commit | 9c296d76dc85d2e7dc355962489b292ca8d65137 (patch) | |
tree | 61d193e3786980e52c130fa2e0041a726c7b8a8e /src/main/java | |
parent | 598c5c8ad388fe7caced581c41305ef7917ab255 (diff) |
feat: hide HUD modules on debug, fix avg speed
Diffstat (limited to 'src/main/java')
5 files changed, 51 insertions, 29 deletions
diff --git a/src/main/java/ftbsc/bscv/modules/hud/ActiveModules.java b/src/main/java/ftbsc/bscv/modules/hud/ActiveModules.java index e2e14cf..60558b5 100644 --- a/src/main/java/ftbsc/bscv/modules/hud/ActiveModules.java +++ b/src/main/java/ftbsc/bscv/modules/hud/ActiveModules.java @@ -16,19 +16,19 @@ import static ftbsc.bscv.tools.Text.TextBuilder; public class ActiveModules extends HudModule implements ICommons { @SubscribeEvent public void onRenderOverlay(RenderGameOverlayEvent event) { - if (event.getType() == ElementType.TEXT) { - int offset = 0; - for (IModule m : Boscovicino.modManager.mods) { - if (m.isEnabled() && !m.getGroup().equalsIgnoreCase("HUD")) { - TextBuilder() - .txt(String.format("%s <", m.getName())) - .anchor(this.anchor.get()) - .x(this.x.get()) - .y(this.y.get() + offset) - .scale(this.scale.get()) - .render(event.getMatrixStack(), event.getWindow()); - offset += MC.font.lineHeight; - } + if (event.getType() != ElementType.TEXT) return; + if (this.shouldHide()) return; + int offset = 0; + for (IModule m : Boscovicino.modManager.mods) { + if (m.isEnabled() && !m.getGroup().equalsIgnoreCase("HUD")) { + TextBuilder() + .txt(String.format("%s <", m.getName())) + .anchor(this.anchor.get()) + .x(this.x.get()) + .y(this.y.get() + offset) + .scale(this.scale.get()) + .render(event.getMatrixStack(), event.getWindow()); + offset += MC.font.lineHeight; } } } diff --git a/src/main/java/ftbsc/bscv/modules/hud/Coordinates.java b/src/main/java/ftbsc/bscv/modules/hud/Coordinates.java index b33726f..258983c 100644 --- a/src/main/java/ftbsc/bscv/modules/hud/Coordinates.java +++ b/src/main/java/ftbsc/bscv/modules/hud/Coordinates.java @@ -15,15 +15,17 @@ import static ftbsc.bscv.tools.Text.TextBuilder; public class Coordinates extends HudModule implements ICommons { @SubscribeEvent public void onRenderOverlay(RenderGameOverlayEvent event) { - if (event.getType() == ElementType.TEXT && MC.player != null) { - Vector3d position = MC.player.position(); - TextBuilder() - .txt(String.format("[ X %.1f | %.1f Z ] %.1f Y", position.x(), position.z(), position.y())) - .anchor(this.anchor.get()) - .x(this.x.get()) - .y(this.y.get()) - .scale(this.scale.get()) - .render(event.getMatrixStack(), event.getWindow()); - } + if (event.getType() != ElementType.TEXT) return; + if (MC.player == null) return; + if (this.shouldHide()) return; + + Vector3d position = MC.player.position(); + TextBuilder() + .txt(String.format("[ X %.1f | %.1f Z ] %.1f Y", position.x(), position.z(), position.y())) + .anchor(this.anchor.get()) + .x(this.x.get()) + .y(this.y.get()) + .scale(this.scale.get()) + .render(event.getMatrixStack(), event.getWindow()); } } diff --git a/src/main/java/ftbsc/bscv/modules/hud/EntityList.java b/src/main/java/ftbsc/bscv/modules/hud/EntityList.java index fcb2132..40423f2 100644 --- a/src/main/java/ftbsc/bscv/modules/hud/EntityList.java +++ b/src/main/java/ftbsc/bscv/modules/hud/EntityList.java @@ -39,6 +39,7 @@ public class EntityList extends HudModule implements ICommons { @SubscribeEvent public void onRenderOverlay(RenderGameOverlayEvent event) { if (event.getType() != ElementType.TEXT) return; + if (this.shouldHide()) return; List<String> entities = new ArrayList<>(); for (Entity e : MC.level.entitiesForRendering()) { diff --git a/src/main/java/ftbsc/bscv/modules/hud/InfoDisplay.java b/src/main/java/ftbsc/bscv/modules/hud/InfoDisplay.java index 42d94b4..757bceb 100644 --- a/src/main/java/ftbsc/bscv/modules/hud/InfoDisplay.java +++ b/src/main/java/ftbsc/bscv/modules/hud/InfoDisplay.java @@ -16,6 +16,8 @@ import net.minecraftforge.event.TickEvent.Phase; import net.minecraftforge.eventbus.api.SubscribeEvent; import java.util.ArrayDeque; +import java.util.LinkedList; +import java.util.Queue; import static ftbsc.bscv.tools.Text.TextBuilder; @@ -25,12 +27,12 @@ public class InfoDisplay extends HudModule implements ICommons { private Vector3d last_position = new Vector3d(0.0, 0.0, 0.0); private double instant_speed = 0.0; private double average_speed = 0.0; - private ArrayDeque<Double> history_speed = new ArrayDeque<>(); + private Queue<Double> history_speed = new LinkedList<>(); public final ForgeConfigSpec.ConfigValue<Boolean> logo; public final ForgeConfigSpec.ConfigValue<Boolean> speed; public final ForgeConfigSpec.ConfigValue<Boolean> time; - // public final ForgeConfigSpec.ConfigValue<Boolean> fps; + public final ForgeConfigSpec.ConfigValue<Boolean> fps; // public final ForgeConfigSpec.ConfigValue<Boolean> biome; // public final ForgeConfigSpec.ConfigValue<Boolean> latency; // public final ForgeConfigSpec.ConfigValue<Boolean> tps; @@ -64,6 +66,12 @@ public class InfoDisplay extends HudModule implements ICommons { .fallback(true) .build(this); + this.fps = Setting.Bool.builder() + .name("fps") + .comment("show current framerate") + .fallback(true) + .build(this); + this.hide_effects = Setting.Bool.builder() .name("hide-effects") .comment("hide effect icons on top right corner") @@ -76,16 +84,15 @@ public class InfoDisplay extends HudModule implements ICommons { if (!this.speed.get()) return; if (event.phase == Phase.END) return; if (MC.player != null) { - this.instant_speed = - this.last_position.distanceTo(MC.player.position()); + this.instant_speed = this.last_position.distanceTo(MC.player.position()); this.last_position = MC.player.position(); } else { this.instant_speed = 0.0; } - this.history_speed.push(this.instant_speed); + this.history_speed.add(this.instant_speed); while (this.history_speed.size() >= 100) { // TODO customize this parameter - this.history_speed.pop(); + this.history_speed.remove(); } double buf = 0.0; @@ -143,5 +150,16 @@ public class InfoDisplay extends HudModule implements ICommons { .render(event.getMatrixStack(), event.getWindow()); offset += MC.font.lineHeight * scale; } + + if (this.fps.get()) { + TextBuilder() + .txt("> " + MC.fpsString) + .anchor(this.anchor.get()) + .x(this.x.get()) + .y(this.y.get() + offset) + .scale(scale) + .render(event.getMatrixStack(), event.getWindow()); + offset += MC.font.lineHeight * scale; + } } } diff --git a/src/main/java/ftbsc/bscv/modules/hud/PlayerList.java b/src/main/java/ftbsc/bscv/modules/hud/PlayerList.java index 6558388..f3bb264 100644 --- a/src/main/java/ftbsc/bscv/modules/hud/PlayerList.java +++ b/src/main/java/ftbsc/bscv/modules/hud/PlayerList.java @@ -18,6 +18,7 @@ public class PlayerList extends HudModule implements ICommons { @SubscribeEvent public void onRenderOverlay(RenderGameOverlayEvent event) { if (event.getType() != ElementType.TEXT) return; + if (this.shouldHide()) return; int offset = 0; for (Entity e : MC.level.entitiesForRendering()) { |