File tree Expand file tree Collapse file tree
src/main/java/io/github/ultimateboomer/resolutioncontrol Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -105,6 +105,11 @@ public void onInitialize() {
105105 });
106106
107107 ClientTickEvents .END_CLIENT_TICK .register (client -> {
108+ // long frametime = client.metricsData.getSamples()[0];
109+ // if (frametime > 0) {
110+ // System.out.println(1_000_000_000 / frametime);
111+ // }
112+
108113 if (ConfigHandler .instance .getConfig ().enableDynamicResolution && client .world != null
109114 && getWindow ().getX () != -32000 ) {
110115 DynamicResolutionHandler .INSTANCE .tick ();
Original file line number Diff line number Diff line change 88import net .minecraft .client .gl .Framebuffer ;
99import net .minecraft .text .LiteralText ;
1010
11- import java .util .Collection ;
12- import java .util .HashMap ;
13- import java .util .List ;
14- import java .util .Map ;
11+ import java .util .*;
1512
1613public class DynamicResolutionHandler {
1714 public static final DynamicResolutionHandler INSTANCE = new DynamicResolutionHandler ();
@@ -40,7 +37,7 @@ private DynamicResolutionHandler() {
4037 public void tick () {
4138 timer ++;
4239
43- if (timer > 20 ) {
40+ if (timer > 5 ) {
4441 timer = 0 ;
4542 update ();
4643 }
@@ -49,7 +46,12 @@ public void tick() {
4946 private void update () {
5047 MinecraftClient client = MinecraftClient .getInstance ();
5148
52- int fps = MinecraftClient .currentFps ;
49+ final int smoothAmount = 10 ;
50+ long accumulatedFrameTime =
51+ Arrays .stream (client .metricsData .getSamples ()).limit (smoothAmount ).sum ();
52+
53+ double fps = 1_000_000_000.0 / accumulatedFrameTime * smoothAmount ;
54+ System .out .println (fps );
5355
5456 if (fps > 80 ) {
5557 setCurrentScale (Math .min (currentScale + 1 , scales .size () - 1 ));
You can’t perform that action at this time.
0 commit comments