Spaces:
Build error
Build error
File size: 1,955 Bytes
d46f4a3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
package com.mojang.blaze3d.platform;
import net.minecraft.Util;
import net.minecraft.client.InactivityFpsLimit;
import net.minecraft.client.Minecraft;
import net.minecraft.client.Options;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public class FramerateLimitTracker {
private static final int OUT_OF_LEVEL_MENU_LIMIT = 60;
private static final int ICONIFIED_WINDOW_LIMIT = 10;
private static final int AFK_LIMIT = 30;
private static final int LONG_AFK_LIMIT = 10;
private static final long AFK_THRESHOLD_MS = 60000L;
private static final long LONG_AFK_THRESHOLD_MS = 600000L;
private final Options options;
private final Minecraft minecraft;
private int framerateLimit;
private long latestInputTime;
public FramerateLimitTracker(Options p_364723_, Minecraft p_360737_) {
this.options = p_364723_;
this.minecraft = p_360737_;
this.framerateLimit = p_364723_.framerateLimit().get();
}
public int getFramerateLimit() {
InactivityFpsLimit inactivityfpslimit = this.options.inactivityFpsLimit().get();
if (this.minecraft.getWindow().isIconified()) {
return 10;
} else {
if (inactivityfpslimit == InactivityFpsLimit.AFK) {
long i = Util.getMillis() - this.latestInputTime;
if (i > 600000L) {
return 10;
}
if (i > 60000L) {
return Math.min(this.framerateLimit, 30);
}
}
return this.minecraft.level != null || this.minecraft.screen == null && this.minecraft.getOverlay() == null ? this.framerateLimit : 60;
}
}
public void setFramerateLimit(int p_364240_) {
this.framerateLimit = p_364240_;
}
public void onInputReceived() {
this.latestInputTime = Util.getMillis();
}
} |