Skip to content

Commit

Permalink
1.19.0
Browse files Browse the repository at this point in the history
  • Loading branch information
LostLuma committed Sep 29, 2023
1 parent 7707890 commit 205dbc2
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 31 deletions.
8 changes: 4 additions & 4 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[versions]
minecraft = "1.20"
minecraft = "1.19"
fabric_loader = "0.14.22"

modmenu = "7.0.1"
fabric_api = "0.83.0+1.20"
modmenu = "4.0.0"
fabric_api = "0.55.3+1.19"

cloth_config = "11.0.99"
cloth_config = "7.0.72"

[libraries]
minecraft = { module = "com.mojang:minecraft", version.ref = "minecraft" }
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/dynamic_fps/impl/GraphicsState.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public <T> DataResult<GraphicsState> read(DynamicOps<T> ops, T input) {
var value = ops.getStringValue(input).get().left();

if (value.isEmpty()) {
return DataResult.error(() -> "Graphics state must not be empty!");
return DataResult.error("Graphics state must not be empty!");
} else {
return DataResult.success(GraphicsState.valueOf(value.get().toUpperCase(Locale.ROOT)));
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/dynamic_fps/impl/PowerState.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public <T> DataResult<PowerState> read(DynamicOps<T> ops, T input) {
var value = ops.getStringValue(input).get().left();

if (value.isEmpty()) {
return DataResult.error(() -> "Power state must not be empty!");
return DataResult.error("Power state must not be empty!");
} else {
return DataResult.success(PowerState.valueOf(value.get().toUpperCase(Locale.ROOT)));
}
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
);
}
}
5 changes: 3 additions & 2 deletions src/main/java/dynamic_fps/impl/util/OptionsHolder.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package dynamic_fps.impl.util;

import dynamic_fps.impl.GraphicsState;
import net.minecraft.client.AmbientOcclusionStatus;
import net.minecraft.client.CloudStatus;
import net.minecraft.client.GraphicsStatus;
import net.minecraft.client.Options;
Expand All @@ -14,7 +15,7 @@
public class OptionsHolder {
private static CloudStatus cloudStatus;
private static GraphicsStatus graphicsStatus;
private static boolean ambientOcclusion;
private static AmbientOcclusionStatus ambientOcclusion;
private static ParticleStatus particlesStatus;
private static boolean entityShadows;
private static double entityDistance;
Expand Down Expand Up @@ -52,7 +53,7 @@ public static void applyOptions(Options options, GraphicsState state) {

if (state == GraphicsState.MINIMAL) {
options.graphicsMode().set(GraphicsStatus.FAST);
options.ambientOcclusion().set(false);
options.ambientOcclusion().set(AmbientOcclusionStatus.OFF);
}
}
}
Expand Down
4 changes: 1 addition & 3 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
],

"depends": {
"minecraft": ">=1.20.0",
"minecraft": ["=1.19.0", "=1.19.1", "=1.19.2"],
"fabricloader": ">=0.14.22",
"fabric-resource-loader-v0": "*",
"fabric-rendering-v1": "*",
Expand All @@ -54,7 +54,6 @@
"net.minecraft.class_426",
"net.minecraft.class_4288",
"net.minecraft.class_6777",
"net.minecraft.class_443",
"net.minecraft.class_446",
"net.minecraft.class_445",
"net.minecraft.class_6599"
Expand All @@ -71,7 +70,6 @@
"net.minecraft.class_426": "net.minecraft.client.gui.screens.LanguageSelectScreen",
"net.minecraft.class_4288": "net.minecraft.client.gui.screens.MouseSettingsScreen",
"net.minecraft.class_6777": "net.minecraft.client.gui.screens.OnlineOptionsScreen",
"net.minecraft.class_443": "net.minecraft.client.gui.screens.SoundOptionsScreen",
"net.minecraft.class_446": "net.minecraft.client.gui.screens.VideoSettingsScreen",
"net.minecraft.class_445": "net.minecraft.client.gui.screens.WinScreen",
"net.minecraft.class_6599": "net.minecraft.client.gui.screens.controls.KeyBindsScreen"
Expand Down

0 comments on commit 205dbc2

Please sign in to comment.