Skip to content

Commit

Permalink
Merge branch 'main' into 1.19.0
Browse files Browse the repository at this point in the history
  • Loading branch information
LostLuma committed Dec 28, 2023
2 parents f321ae1 + b75e6a4 commit e555e27
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 26 deletions.
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ dependencies {
modImplementation libs.fabric.api
modImplementation libs.fabric.loader

// Why do I need this on 0.15.x ..?
modImplementation libs.mixinextras
annotationProcessor libs.mixinextras

modApi libs.modmenu
modApi libs.cloth.config
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ org.gradle.parallel = true
org.gradle.jvmargs = -Xmx1G

# Mod Properties
mod_version = 3.3.1
mod_version = 3.3.2
maven_group = juliand665
archives_base_name = dynamic-fps
6 changes: 5 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
[versions]
minecraft = "1.19"
fabric_loader = "0.14.22"

mixinextras = "0.3.2"
fabric_loader = "0.15.3"

modmenu = "4.0.0"
fabric_api = "0.55.3+1.19"
Expand All @@ -9,6 +11,8 @@ cloth_config = "7.0.72"

[libraries]
minecraft = { module = "com.mojang:minecraft", version.ref = "minecraft" }

mixinextras = { module = "io.github.llamalad7:mixinextras-fabric", version.ref = "mixinextras" }
fabric_loader = { module = "net.fabricmc:fabric-loader", version.ref = "fabric_loader" }

modmenu = { module = "com.terraformersmc:modmenu", version.ref = "modmenu" }
Expand Down
18 changes: 10 additions & 8 deletions src/main/java/dynamic_fps/impl/mixin/DebugScreenOverlayMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,29 @@

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.CallbackInfoReturnable;

import com.llamalad7.mixinextras.injector.ModifyReturnValue;

import dynamic_fps.impl.DynamicFPSMod;
import dynamic_fps.impl.PowerState;
import net.minecraft.client.gui.components.DebugScreenOverlay;

@Mixin(DebugScreenOverlay.class)
public class DebugScreenOverlayMixin {
/*
* Insert information about effective frame rate below misleading FPS counter.
/**
* Show the current power state and effective frame rate below the FPS counter, unless focused.
*
* As we only slow the client loop to a minimum of 15 TPS the vanilla frame rate counter is inaccurate and confusing.
*/
@Inject(method = "getGameInformation", at = @At("RETURN"))
private void onGetGameInformation(CallbackInfoReturnable<List<String>> callbackInfo) {
@ModifyReturnValue(method = "getGameInformation", at = @At("RETURN"))
private List<String> getGameInformation(List<String> result) {
var status = DynamicFPSMod.powerState();

if (status != PowerState.FOCUSED) {
var result = callbackInfo.getReturnValue();
int target = DynamicFPSMod.targetFrameRate();

result.add(2, String.format(Locale.ROOT, "§c[Dynamic FPS] FPS: %s P: %s§r", target, status.toString().toLowerCase()));
}

return result;
}
}
16 changes: 10 additions & 6 deletions src/main/java/dynamic_fps/impl/mixin/GameRendererMixin.java
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
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();
}

/*
/**
* Cancels rendering the world if a it is determined to currently not be visible.
*/
@Inject(at = @At("HEAD"), method = { "renderLevel", "renderItemActivationAnimation" }, cancellable = true)
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/dynamic_fps/impl/mixin/GuiMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

@Mixin(Gui.class)
public class GuiMixin {
/*
/**
* Cancels rendering the GUI if a it is determined to currently not be visible.
*/
@Inject(at = @At("HEAD"), method = "render", cancellable = true)
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/dynamic_fps/impl/mixin/MinecraftMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ private void onInit(CallbackInfo callbackInfo) {
DynamicFPSMod.setWindow(this.window.window);
}

/*
@Inject(method = "setScreen", at = @At("TAIL"))
private void onSetScreen(CallbackInfo callbackInfo) {
DynamicFPSMod.onStatusChanged();
}
*/
}
15 changes: 7 additions & 8 deletions src/main/java/dynamic_fps/impl/mixin/SoundEngineMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import com.llamalad7.mixinextras.injector.ModifyReturnValue;
import com.llamalad7.mixinextras.sugar.Local;
import com.mojang.blaze3d.audio.Listener;

import dynamic_fps.impl.DynamicFPSMod;
Expand Down Expand Up @@ -102,16 +103,14 @@ private void play(SoundInstance instance, CallbackInfo callbackInfo) {
/**
* Applies the user's requested volume multiplier to any newly played sounds.
*/
@Inject(method = "getVolume", at = @At("HEAD"), cancellable = true)
private void getVolume(@Nullable SoundSource source, CallbackInfoReturnable<Float> callbackInfo) {
float base = 1.0f;

@ModifyReturnValue(method = "getVolume", at = @At("RETURN"))
private float getVolume(float original, @Local @Nullable SoundSource source) {
// Note: The original doesn't consider the user's setting when the source is MASTER
// In vanilla this doesn't matter because it's never called, but we use it when setting the gain
if (source != null) {
base = this.options.getSoundSourceVolume(source);
if (SoundSource.MASTER.equals(source)) {
original = this.options.getSoundSourceVolume(source);
}

callbackInfo.setReturnValue(base * DynamicFPSMod.volumeMultiplier(source));
return original * DynamicFPSMod.volumeMultiplier(source);
}
}
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

"depends": {
"minecraft": ["=1.19.0", "=1.19.1", "=1.19.2"],
"fabricloader": ">=0.14.22",
"fabricloader": ">=0.15.0",
"fabric-resource-loader-v0": "*",
"fabric-rendering-v1": "*",
"fabric-lifecycle-events-v1": "*",
Expand Down

0 comments on commit e555e27

Please sign in to comment.