Skip to content

Commit

Permalink
1.19.3
Browse files Browse the repository at this point in the history
  • Loading branch information
LostLuma committed Feb 17, 2024
1 parent b6ca2e7 commit f4a1f4d
Show file tree
Hide file tree
Showing 14 changed files with 92 additions and 50 deletions.
16 changes: 8 additions & 8 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
[versions]
minecraft = "1.20.4"
minecraft = "1.19.3"

# Platform libraries

fabric_loader = "0.15.6"
fabric_api = "0.96.1+1.20.4"
fabric_api = "0.76.1+1.19.3"

forge = "1.20.4-49.0.30"
forge = "1.19.3-44.1.23"

neoforge = "20.4.160-beta"
# neoforge = "20.4.160-beta"

quilt_loader = "0.23.1"
quilt_standard_libraries = "7.0.0-alpha.10+1.20.2"
quilt_standard_libraries = "4.0.0-beta.13+1.19.3"

# Third-party libraries

modmenu = "9.0.0"
cloth_config = "13.0.121"
modmenu = "5.1.0"
cloth_config = "9.1.104"

mixinextras = "0.3.5"

Expand All @@ -30,7 +30,7 @@ fabric_loader = { module = "net.fabricmc:fabric-loader", version.ref = "fabric_l

forge = { module = "net.minecraftforge:forge", version.ref = "forge" }

neoforge = { module = "net.neoforged:neoforge", version.ref = "neoforge" }
# neoforge = { module = "net.neoforged:neoforge", version.ref = "neoforge" }

quilt_loader = { module = "org.quiltmc:quilt-loader", version.ref = "quilt_loader" }
qsl_lifecycle_events = { module = "org.quiltmc.qsl.core:lifecycle_events", version.ref = "quilt_standard_libraries" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import me.shedaniel.clothconfig2.impl.builders.SubCategoryBuilder;
import net.minecraft.ChatFormatting;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.CommonComponents;
import net.minecraft.network.chat.Component;
import net.minecraft.sounds.SoundSource;

Expand Down Expand Up @@ -43,7 +42,7 @@ public static Screen genConfigScreen(Screen parent) {
);

general.addEntry(
entryBuilder.startTextDescription(CommonComponents.SPACE).build()
entryBuilder.startTextDescription(Component.literal(" ")).build()
);

general.addEntry(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package dynamic_fps.impl.mixin;

import dynamic_fps.impl.util.HudInfoRenderer;
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 dynamic_fps.impl.DynamicFPSMod;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiGraphics;

@Mixin(Gui.class)
public class GuiMixin {
Expand All @@ -21,18 +19,4 @@ private void shouldRender(CallbackInfo callbackInfo) {
callbackInfo.cancel();
}
}

/**
* Render info on whether Dynamic FPS is disabled or always reducing the user's FPS.
*/
@Inject(
method = "render",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/gui/Gui;renderSavingIndicator(Lnet/minecraft/client/gui/GuiGraphics;)V"
)
)
private void render(GuiGraphics guiGraphics, float f, CallbackInfo callbackInfo) {
HudInfoRenderer.renderInfo(guiGraphics);
}
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
package dynamic_fps.impl.mixin;

import java.util.Deque;

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 org.spongepowered.asm.mixin.injection.Redirect;

import dynamic_fps.impl.DynamicFPSMod;
import net.minecraft.client.gui.components.toasts.Toast;
import net.minecraft.client.gui.components.toasts.ToastComponent;

@Mixin(ToastComponent.class)
public class ToastComponentMixin {
@Inject(method = "freeSlots", at = @At("HEAD"), cancellable = true)
private void hasFreeSlots(CallbackInfoReturnable<Integer> callbackInfo) {
@Redirect(method = "render", at = @At(value = "INVOKE", target = "Ljava/util/Deque;isEmpty()Z"))
private boolean onQueueIsEmpty(Deque<Toast> queued) {
if (!DynamicFPSMod.shouldShowToasts()) {
callbackInfo.setReturnValue(0);
return true;
} else {
return queued.isEmpty();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,37 @@

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.Font.DisplayMode;
import net.minecraft.network.chat.Component;

import static dynamic_fps.impl.util.Localization.localized;

import org.joml.Matrix4f;
import com.mojang.blaze3d.vertex.PoseStack;

import dynamic_fps.impl.DynamicFPSMod;

public final class HudInfoRenderer {
private static final Minecraft minecraft = Minecraft.getInstance();

public static void renderInfo(GuiGraphics guiGraphics) {
public static void renderInfo(PoseStack poseStack) {
if (DynamicFPSMod.disabledByUser()) {
drawCenteredText(guiGraphics, localized("gui", "hud.disabled"), 32);
drawCenteredText(poseStack, localized("gui", "hud.disabled"), 32);
} else if (DynamicFPSMod.isForcingLowFPS()) {
drawCenteredText(guiGraphics, localized("gui", "hud.reducing"), 32);
drawCenteredText(poseStack, localized("gui", "hud.reducing"), 32);
}
}

private static void drawCenteredText(GuiGraphics guiGraphics, Component component, float y) {
private static void drawCenteredText(PoseStack poseStack, Component component, float y) {
Font fontRenderer = minecraft.gui.getFont();

int stringWidth = fontRenderer.width(component);
int windowWidth = minecraft.getWindow().getGuiScaledWidth();

fontRenderer.drawInBatch(
fontRenderer.drawShadow(
poseStack,
component,
(windowWidth - stringWidth) / 2f,
y,
0xFFFFFFFF,
true,
new Matrix4f(),
guiGraphics.bufferSource(),
DisplayMode.NORMAL,
0,
255
0xFFFFFFFF
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package net.lostluma.dynamic_fps.impl.fabric.mixin;

import com.llamalad7.mixinextras.sugar.Local;
import com.mojang.blaze3d.vertex.PoseStack;
import dynamic_fps.impl.util.HudInfoRenderer;
import net.minecraft.client.gui.Gui;
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;

@Mixin(Gui.class)
public class GuiMixin {
/**
* Render info on whether Dynamic FPS is disabled or always reducing the user's FPS.
*/
@Inject(
method = "render",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/gui/Gui;renderSavingIndicator(Lcom/mojang/blaze3d/vertex/PoseStack;)V"
)
)
private void render(CallbackInfo callbackInfo, @Local PoseStack poseStack) {
HudInfoRenderer.renderInfo(poseStack);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"compatibilityLevel": "JAVA_17",
"minVersion": "0.8",
"client": [
"GuiMixin",
"OptionsMixin"
],
"mixins": [],
Expand Down
2 changes: 1 addition & 1 deletion platforms/fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
},
"depends": {
"fabricloader": ">=0.15.0",
"minecraft": ">=1.20.0",
"minecraft": "=1.19.3",
"mixinextras": ">=0.3.2",
"fabric-resource-loader-v0": "*",
"fabric-lifecycle-events-v1": "*"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,15 @@ public DynamicFPSForgeMod() {
);

MinecraftForge.EVENT_BUS.addListener(this::onClientTick);
MinecraftForge.EVENT_BUS.addListener(this::renderGuiOverlay);

FMLJavaModLoadingContext.get().getModEventBus().addListener(this::registerKeyMappings);
}

public void renderGuiOverlay(RenderGuiOverlayEvent event) {
HudInfoRenderer.renderInfo(event.getPoseStack());
}

public void registerKeyMappings(RegisterKeyMappingsEvent event) {
for (KeyMappingHandler handler : KeyMappingHandler.getHandlers()) {
event.register(handler.keyMapping());
Expand Down
2 changes: 1 addition & 1 deletion platforms/forge/src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ file="META-INF/accesstransformer.cfg"
[[dependencies.dynamic_fps]]
modId = "minecraft"
mandatory = true
versionRange = "[1.20.0,)"
versionRange = "[1.19.3]"
ordering = "NONE"
side = "CLIENT"

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package net.lostluma.dynamic_fps.impl.quilt.mixin;

import com.llamalad7.mixinextras.sugar.Local;
import com.mojang.blaze3d.vertex.PoseStack;
import dynamic_fps.impl.util.HudInfoRenderer;
import net.minecraft.client.gui.Gui;
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;

@Mixin(Gui.class)
public class GuiMixin {
/**
* Render info on whether Dynamic FPS is disabled or always reducing the user's FPS.
*/
@Inject(
method = "render",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/gui/Gui;renderSavingIndicator(Lcom/mojang/blaze3d/vertex/PoseStack;)V"
)
)
private void render(CallbackInfo callbackInfo, @Local PoseStack poseStack) {
HudInfoRenderer.renderInfo(poseStack);
}
}
1 change: 1 addition & 0 deletions platforms/quilt/src/main/resources/dynamic_fps.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"compatibilityLevel": "JAVA_17",
"minVersion": "0.8",
"client": [
"GuiMixin",
"OptionsMixin"
],
"mixins": [],
Expand Down
2 changes: 1 addition & 1 deletion platforms/quilt/src/main/resources/quilt.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
},
{
"id": "minecraft",
"versions": ">=1.20.0"
"versions": "=1.19.3"
},
{
"id": "mixinextras",
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ rootProject.name = "dynamic-fps"
include(":platforms:common")
include(":platforms:fabric")
include(":platforms:forge")
include(":platforms:neoforge")
// include(":platforms:neoforge")
include(":platforms:quilt")

0 comments on commit f4a1f4d

Please sign in to comment.