Skip to content

Commit

Permalink
1.14.4
Browse files Browse the repository at this point in the history
  • Loading branch information
LostLuma committed Feb 23, 2024
1 parent f5881d7 commit c9483ef
Show file tree
Hide file tree
Showing 32 changed files with 183 additions and 145 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ allprojects {
withSourcesJar()

toolchain {
languageVersion = JavaLanguageVersion.of(17)
languageVersion = JavaLanguageVersion.of(8)
}
}

tasks.withType(JavaCompile).configureEach {
it.options.encoding = "UTF-8"

javaCompiler = javaToolchains.compilerFor {
languageVersion = JavaLanguageVersion.of(17)
languageVersion = JavaLanguageVersion.of(8)
}
}
}
30 changes: 15 additions & 15 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.14.4"

# Platform libraries

fabric_loader = "0.15.6"
fabric_api = "0.96.1+1.20.4"
fabric_api = "0.28.5+1.14"

forge = "1.20.4-49.0.30"
# forge = "1.16.5-36.2.41"

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_loader = "0.23.1"
# quilt_standard_libraries = "1.1.0-beta.26+1.18.2"

# Third-party libraries

modmenu = "9.0.0"
cloth_config = "13.0.121"
modmenu = "1.7.17"
cloth_config = "1.8+fabric"

mixinextras = "0.3.5"

Expand All @@ -28,20 +28,20 @@ minecraft = { module = "com.mojang:minecraft", version.ref = "minecraft" }
fabric_loader = { module = "net.fabricmc:fabric-loader", version.ref = "fabric_loader" }
# fabric_api = { module = "net.fabricmc.fabric-api:fabric-api", version.ref = "fabric_api" }

forge = { module = "net.minecraftforge:forge", version.ref = "forge" }
# 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" }
# 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" }

# Third-party libraries

modmenu = { module = "com.terraformersmc:modmenu", version.ref = "modmenu" }
cloth_config = { module = "me.shedaniel.cloth:cloth-config", version.ref = "cloth_config" }
modmenu = { module = "maven.modrinth:modmenu", version.ref = "modmenu" }
cloth_config = { module = "maven.modrinth:cloth-config", version.ref = "cloth_config" }

mixinextras_common = { module = "io.github.llamalad7:mixinextras-common", version.ref = "mixinextras" }
mixinextras_forge = { module = "io.github.llamalad7:mixinextras-forge", version.ref = "mixinextras" }
# mixinextras_forge = { module = "io.github.llamalad7:mixinextras-forge", version.ref = "mixinextras" }

[bundles]

Expand Down
4 changes: 4 additions & 0 deletions platforms/common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ loom {
accessWidenerPath = file("src/main/resources/dynamic_fps.accesswidener")
}

repositories {
maven { url = "https://api.modrinth.com/maven" } // cloth-config
}

dependencies {
// We depend on fabric loader here to use the fabric @Environment annotations and get the mixin dependencies
// Do NOT use other classes from fabric loader
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static void init() {
ModCompatHelper.init();

Platform platform = Platform.getInstance();
String version = platform.getModVersion(Constants.MOD_ID).orElseThrow();
String version = platform.getModVersion(Constants.MOD_ID).orElseThrow(RuntimeException::new);

Logging.getLogger().info("Dynamic FPS {} active on {}!", version, platform.getName());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
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.network.chat.TextComponent;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.sounds.SoundSource;

import java.util.Locale;
Expand Down Expand Up @@ -43,7 +44,7 @@ public static Screen genConfigScreen(Screen parent) {
);

general.addEntry(
entryBuilder.startTextDescription(CommonComponents.SPACE).build()
entryBuilder.startTextDescription(new TextComponent(" ").getContents()).build()
);

general.addEntry(
Expand Down Expand Up @@ -101,7 +102,7 @@ public static Screen genConfigScreen(Screen parent) {

volumes.add(
entryBuilder.startIntSlider(
Component.translatable("soundCategory." + name),
new TranslatableComponent("soundCategory." + name).getContents(),
(int) (config.rawVolumeMultiplier(source) * 100),
0, 100
)
Expand All @@ -121,9 +122,9 @@ public static Screen genConfigScreen(Screen parent) {
config.graphicsState()
)
.setDefaultValue(standard.graphicsState())
.setSaveConsumer(config::setGraphicsState)
.setEnumNameProvider(ClothConfig::graphicsStateMessage)
.setTooltipSupplier(ClothConfig::graphicsStateTooltip)
.setSaveConsumer((selected) -> config.setGraphicsState((GraphicsState) selected))
.setEnumNameProvider((selected) -> ClothConfig.graphicsStateMessage((GraphicsState) selected))
.setTooltipSupplier((selected) -> ClothConfig.graphicsStateTooltip((GraphicsState) selected)) // what
.build()
);

Expand Down Expand Up @@ -153,7 +154,7 @@ public static Screen genConfigScreen(Screen parent) {
return builder.build();
}

private static Component idleTimeMessage(int value) {
private static String idleTimeMessage(int value) {
if (value == 0) {
return localized("config", "disabled");
} else {
Expand All @@ -171,27 +172,27 @@ private static int fromConfigFpsTarget(int value) {
return value == -1 ? 61 : value;
}

private static Component fpsTargetMessage(int value) {
private static String fpsTargetMessage(int value) {
if (toConfigFpsTarget(value) != -1) {
return Component.translatable("options.framerate", value);
return new TranslatableComponent("options.framerate", value).getContents();
} else {
return Component.translatable("options.framerateLimit.max");
return new TranslatableComponent("options.framerateLimit.max").getContents();
}
}

private static Component volumeMultiplierMessage(int value) {
return Component.literal(Integer.toString(value) + "%");
private static String volumeMultiplierMessage(int value) {
return new TextComponent(Integer.toString(value) + "%").getContents();
}

private static Component graphicsStateMessage(Enum<GraphicsState> graphicsState) {
private static String graphicsStateMessage(Enum<GraphicsState> graphicsState) {
return localized("config", "graphics_state_" + graphicsState.toString().toLowerCase(Locale.ROOT));
}

private static Optional<Component[]> graphicsStateTooltip(GraphicsState graphicsState) {
private static Optional<String[]> graphicsStateTooltip(GraphicsState graphicsState) {
if (!graphicsState.equals(GraphicsState.MINIMAL)) {
return Optional.empty();
}

return Optional.of(new Component[]{ localized("config", "graphics_state_minimal_tooltip").withStyle(ChatFormatting.RED) });
return Optional.of(new String[]{ localized("config", "graphics_state_minimal_tooltip") });
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.mojang.blaze3d.platform.Window;
import dynamic_fps.impl.DynamicFPSMod;
import dynamic_fps.impl.PowerState;
import dynamic_fps.impl.util.Logging;
import net.minecraft.client.Minecraft;
import net.minecraft.client.Options;
import org.spongepowered.asm.mixin.Final;
Expand All @@ -26,7 +27,7 @@ public class MinecraftMixin {
// Minecraft considers limits >=260 as infinite
private static final int NO_FRAME_RATE_LIMIT = 260;

@Inject(method = "<init>", at = @At("TAIL"))
@Inject(method = "init", at = @At("RETURN"))
private void onInit(CallbackInfo callbackInfo) {
DynamicFPSMod.setWindow(this.window.window);
}
Expand All @@ -48,7 +49,7 @@ private void getFramerateLimit(CallbackInfoReturnable<Integer> callbackInfo) {
callbackInfo.setReturnValue(limit);
}
} else if (DynamicFPSMod.uncapMenuFrameRate()) {
if (this.options.enableVsync().get()) {
if (this.options.enableVsync) {
// VSync will regulate to a non-infinite value
callbackInfo.setReturnValue(NO_FRAME_RATE_LIMIT);
} else {
Expand Down
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
@@ -1,5 +1,6 @@
package dynamic_fps.impl.service;

import java.util.NoSuchElementException;
import java.util.Optional;
import java.util.ServiceLoader;

Expand All @@ -8,11 +9,9 @@ class Services {
static ModCompat MOD_COMPAT = loadService(ModCompat.class);

static <T> T loadService(Class<T> type) {
Optional<T> optional = ServiceLoader.load(type).findFirst();

if (optional.isPresent()) {
return optional.get();
} else {
try {
return ServiceLoader.load(type).iterator().next();
} catch (NoSuchElementException e) {
throw new RuntimeException("Failed to load Dynamic FPS " + type.getSimpleName() + " service!");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,34 @@

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 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() {
if (DynamicFPSMod.disabledByUser()) {
drawCenteredText(guiGraphics, localized("gui", "hud.disabled"), 32);
drawCenteredText(localized("gui", "hud.disabled"), 32);
} else if (DynamicFPSMod.isForcingLowFPS()) {
drawCenteredText(guiGraphics, localized("gui", "hud.reducing"), 32);
drawCenteredText(localized("gui", "hud.reducing"), 32);
}
}

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

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

fontRenderer.drawInBatch(
fontRenderer.drawShadow(
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
Expand Up @@ -2,16 +2,16 @@

import dynamic_fps.impl.Constants;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.TranslatableComponent;

public final class Localization {
/** e.g. keyString("title", "config") -> "title.dynamic_fps.config") */
public static String translationKey(String domain, String path) {
return domain + "." + Constants.MOD_ID + "." + path;
}

public static MutableComponent localized(String domain, String path, Object... args) {
return Component.translatable(translationKey(domain, path), args);
public static String localized(String domain, String path, Object... args) {
return new TranslatableComponent(translationKey(domain, path), args).getContents();
}

private Localization() {}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package dynamic_fps.impl.util;

import dynamic_fps.impl.Constants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

public class Logging {
private static final Logger logger = LoggerFactory.getLogger(Constants.MOD_ID);
private static final Logger logger = LogManager.getLogger(Constants.MOD_ID);

public static Logger getLogger() {
return logger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static void init() {
private static void fixFastloadSoftLock() {
Optional<String> optional = Platform.getInstance().getModVersion("fastload");

if (optional.isEmpty()) {
if (!optional.isPresent()) {
return;
}

Expand Down
Loading

0 comments on commit c9483ef

Please sign in to comment.