Skip to content

Commit

Permalink
1.19.3
Browse files Browse the repository at this point in the history
  • Loading branch information
LostLuma committed Jan 19, 2024
1 parent 88de99c commit 9be924c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 25 deletions.
8 changes: 4 additions & 4 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[versions]
minecraft = "1.20"
minecraft = "1.19.3"

mixinextras = "0.3.2"
fabric_loader = "0.15.3"

modmenu = "7.0.1"
fabric_api = "0.83.0+1.20"
modmenu = "5.0.0"
fabric_api = "0.68.1+1.19.3"

cloth_config = "11.0.99"
cloth_config = "9.0.94"

[libraries]
minecraft = { module = "com.mojang:minecraft", version.ref = "minecraft" }
Expand Down
14 changes: 9 additions & 5 deletions src/main/java/dynamic_fps/impl/mixin/ToastComponentMixin.java
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();
}
}
}
23 changes: 8 additions & 15 deletions src/main/java/dynamic_fps/impl/util/HudInfoRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,37 @@
import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback;
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 implements HudRenderCallback {
@Override
public void onHudRender(GuiGraphics drawContext, float tickDelta) {
public void onHudRender(PoseStack poseStack, float tickDelta) {
if (DynamicFPSMod.isDisabled()) {
drawCenteredText(drawContext, localized("gui", "hud.disabled"), 32);
drawCenteredText(poseStack, localized("gui", "hud.disabled"), 32);
} else if (DynamicFPSMod.isForcingLowFPS()) {
drawCenteredText(drawContext, localized("gui", "hud.reducing"), 32);
drawCenteredText(poseStack, localized("gui", "hud.reducing"), 32);
}
}

private void drawCenteredText(GuiGraphics drawContext, Component component, float y) {
private void drawCenteredText(PoseStack poseStack, Component component, float y) {
Minecraft client = Minecraft.getInstance();
Font fontRenderer = client.gui.getFont();

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

fontRenderer.drawInBatch(
fontRenderer.drawShadow(
poseStack,
component,
(windowWidth - stringWidth) / 2f,
y,
0xFFFFFFFF,
true,
new Matrix4f(),
drawContext.bufferSource(),
DisplayMode.NORMAL,
0,
255
0xFFFFFFFF
);
}
}
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"accessWidener": "dynamic_fps.accesswidener",

"depends": {
"minecraft": ">=1.20.0",
"minecraft": "=1.19.3",
"mixinextras": ">=0.3.2",
"fabricloader": ">=0.15.0",
"fabric-resource-loader-v0": "*",
Expand Down

0 comments on commit 9be924c

Please sign in to comment.