FPS Limiter

This commit is contained in:
kirillsaint 2023-07-03 20:06:42 +06:00
parent 49d36333dd
commit 35903e06ee

View File

@ -7,6 +7,7 @@ import net.minecraft.client.renderer.EntityRenderer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.resources.data.IMetadataSerializer;
import net.minecraft.client.settings.GameSettings;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.client.shader.Framebuffer;
import net.minecraft.client.stream.IStream;
@ -37,6 +38,7 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.io.File;
@ -111,6 +113,10 @@ public abstract class MinecraftMixin {
@Shadow private Framebuffer framebufferMc;
@Shadow public GuiScreen currentScreen;
@Shadow public GameSettings gameSettings;
@Inject(method = "displayGuiScreen", at = @At("RETURN"), cancellable = true)
public void displayGuiScreenInject(GuiScreen guiScreenIn, CallbackInfo ci) {
if(Client.backgroundPanorama == null) {
@ -270,4 +276,20 @@ public abstract class MinecraftMixin {
public void event(String folderName, String worldName, WorldSettings worldSettingsIn, CallbackInfo ci) {
new SingleplayerJoinEvent().call();
}
/**
* @author kirillsaint
* @reason FPS Limiter
*/
@Overwrite
public int getLimitFramerate()
{
if (this.theWorld == null && this.currentScreen != null) return this.theWorld == null && this.currentScreen != null ? 30 : this.gameSettings.limitFramerate;
if(!Display.isActive()) {
return 60;
}
return this.theWorld == null && this.currentScreen != null ? 30 : this.gameSettings.limitFramerate;
}
}