feat: hide HUD modules on debug, fix avg speed

This commit is contained in:
əlemi 2023-03-08 17:24:56 +01:00
parent 598c5c8ad3
commit 9c296d76dc
Signed by: alemi
GPG key ID: A4895B84D311642C
5 changed files with 51 additions and 29 deletions

View file

@ -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;
}
}
}

View file

@ -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());
}
}

View file

@ -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()) {

View file

@ -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;
}
}
}

View file

@ -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()) {