Skip to content

Commit

Permalink
Merge pull request #148 from LostLuma/fix-lost-focus-pause-no-rendering
Browse files Browse the repository at this point in the history
Fix pausing on lost focus not working when rendering is disabled
  • Loading branch information
LostLuma authored Dec 28, 2023
2 parents 6dd3ad9 + ad05b5c commit e88f761
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/main/java/dynamic_fps/impl/mixin/GameRendererMixin.java
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
package dynamic_fps.impl.mixin;

import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;

import dynamic_fps.impl.DynamicFPSMod;
import net.minecraft.client.renderer.GameRenderer;

@Mixin(GameRenderer.class)
public class GameRendererMixin {
/**
* Implements the mod's big feature.
*
* Note: Inject after the pause on lost focus check,
* This allows the feature to work even at zero FPS.
*/
@Inject(at = @At("HEAD"), method = "render", cancellable = true)
private void onRender(CallbackInfo callbackInfo) {
if (!DynamicFPSMod.checkForRender()) {
callbackInfo.cancel();
}
@ModifyExpressionValue(method = "render", at = @At(value = "FIELD", target = "Lnet/minecraft/client/Minecraft;noRender:Z", opcode = Opcodes.GETFIELD))
private boolean skipRendering(boolean original) {
return original || !DynamicFPSMod.checkForRender();
}

/**
Expand Down

0 comments on commit e88f761

Please sign in to comment.