Update to 1.20.4 and add fps counter
This commit is contained in:
parent
21c32388a6
commit
563ac4a06e
@ -2,13 +2,13 @@
|
||||
org.gradle.jvmargs=-Xmx1G
|
||||
# Fabric Properties
|
||||
# check these on https://modmuss50.me/fabric.html
|
||||
minecraft_version=1.20.1
|
||||
yarn_mappings=1.20.1+build.10
|
||||
loader_version=0.14.22
|
||||
minecraft_version=1.20.4
|
||||
yarn_mappings=1.20.4+build.3
|
||||
loader_version=0.15.6
|
||||
# Mod Properties
|
||||
mod_version=1.2.0
|
||||
mod_version=1.2.1
|
||||
maven_group=cmods
|
||||
archives_base_name=cmods
|
||||
# Dependencies
|
||||
# check this on https://modmuss50.me/fabric.html
|
||||
fabric_version=0.87.0+1.20.1
|
||||
fabric_version=0.96.1+1.20.4
|
||||
|
@ -90,6 +90,7 @@ public final class CmodsOptions {
|
||||
|
||||
public BooleanOption enabled = new BooleanOption(true);
|
||||
public BooleanOption show_coordinates = new BooleanOption(true);
|
||||
public BooleanOption show_fps = new BooleanOption(true);
|
||||
|
||||
|
||||
UIOptions() { }
|
||||
@ -98,11 +99,13 @@ public final class CmodsOptions {
|
||||
void load(@Nullable Properties properties) {
|
||||
enabled.value = getBooleanProperty(properties, PREFIX + "enabled", enabled.value);
|
||||
show_coordinates.value = getBooleanProperty(properties, PREFIX + "show_coordinates", show_coordinates.value);
|
||||
show_fps.value = getBooleanProperty(properties, PREFIX + "show_fps", show_coordinates.value);
|
||||
}
|
||||
|
||||
void save(Properties properties) {
|
||||
properties.setProperty(PREFIX + "enabled", enabled.value.toString());
|
||||
properties.setProperty(PREFIX + "show_coordinates", show_coordinates.value.toString());
|
||||
properties.setProperty(PREFIX + "show_fps", show_fps.value.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ public class CmodsOptionsScreen extends Screen {
|
||||
}
|
||||
|
||||
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
|
||||
renderBackground(context);
|
||||
renderBackground(context, mouseX, mouseY, delta);
|
||||
Text versionText = Text.literal("v" + CmodsClient.version);
|
||||
|
||||
|
||||
|
@ -36,8 +36,8 @@ public class ToggleButton extends ButtonWidget {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderButton(DrawContext context, int mouseX, int mouseY, float delta) {
|
||||
public void renderWidget(DrawContext context, int mouseX, int mouseY, float delta) {
|
||||
updateText();
|
||||
super.renderButton(context, mouseX, mouseY, delta);
|
||||
super.renderWidget(context, mouseX, mouseY, delta);
|
||||
}
|
||||
}
|
||||
|
@ -42,6 +42,9 @@ public class UIOptionsScreen extends Screen {
|
||||
adder.add(new ToggleButton(0, 0, buttonWidth, buttonHeight,
|
||||
Text.translatable("cmods.options.ui.show_coordinates"), options.uiOptions.show_coordinates));
|
||||
|
||||
adder.add(new ToggleButton(0, 0, buttonWidth, buttonHeight,
|
||||
Text.translatable("cmods.options.ui.show_fps"), options.uiOptions.show_fps));
|
||||
|
||||
for (Pair<ArrayList<ButtonBuilder>, Integer> buttonArray : extraButtons) {
|
||||
for (ButtonBuilder buttonBuilder : buttonArray.getLeft()) {
|
||||
adder.add(buttonBuilder.build(this, client));
|
||||
@ -70,7 +73,7 @@ public class UIOptionsScreen extends Screen {
|
||||
}
|
||||
|
||||
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
|
||||
this.renderBackground(context);
|
||||
this.renderBackground(context, mouseX, mouseY, delta);
|
||||
context.drawCenteredTextWithShadow(this.textRenderer, this.title, this.width / 2, 15, 0xffffff);
|
||||
super.render(context, mouseX, mouseY, delta);
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import cmods.cmods.client.ui.Line;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.hud.DebugHud;
|
||||
import net.minecraft.client.gui.hud.InGameHud;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Pair;
|
||||
@ -27,17 +28,20 @@ public abstract class HudMixin {
|
||||
@Shadow public abstract TextRenderer getTextRenderer();
|
||||
|
||||
|
||||
@Shadow @Final private DebugHud debugHud;
|
||||
|
||||
@Inject(at = @At("TAIL"), method = "render")
|
||||
private void render(DrawContext context, float tickDelta, CallbackInfo ci) {
|
||||
CmodsOptions options = CmodsOptions.getInstance();
|
||||
|
||||
if (this.client.options.debugEnabled || this.client.isPaused() || client.player == null ||
|
||||
if (this.debugHud.shouldShowDebugHud() || this.client.isPaused() || client.player == null ||
|
||||
!options.uiOptions.enabled.get()) {
|
||||
return;
|
||||
}
|
||||
|
||||
TextRenderer textRenderer = this.getTextRenderer();
|
||||
ArrayList<Line> lines = new ArrayList<>();
|
||||
this.client.getCurrentFps();
|
||||
|
||||
int x = 5;
|
||||
int y = 5;
|
||||
@ -51,6 +55,12 @@ public abstract class HudMixin {
|
||||
lines.add(new Line(Text.literal(coordinate_string), white, 0));
|
||||
}
|
||||
|
||||
if (options.uiOptions.show_fps.get()) {
|
||||
int fps = client.getCurrentFps();
|
||||
String fps_string = String.format("FPS: %d", fps);
|
||||
lines.add(new Line(Text.literal(fps_string), white, 0));
|
||||
}
|
||||
|
||||
for (Pair<Consumer<ArrayList<Line>>, Integer> callback: HudRenderCallback.callbacks) {
|
||||
callback.getLeft().accept(lines);
|
||||
}
|
||||
|
@ -10,5 +10,6 @@
|
||||
"cmods.options.ui": "UI",
|
||||
"cmods.options.ui.title": "UI Options",
|
||||
"cmods.options.ui.hud_enabled": "Show HUD",
|
||||
"cmods.options.ui.show_coordinates": "Show Coordinates"
|
||||
"cmods.options.ui.show_coordinates": "Show Coordinates",
|
||||
"cmods.options.ui.show_fps": "Show FPS"
|
||||
}
|
@ -23,6 +23,6 @@
|
||||
"depends": {
|
||||
"fabricloader": ">=0.14.10",
|
||||
"fabric": "*",
|
||||
"minecraft": "1.20.1"
|
||||
"minecraft": "1.20.4"
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user