Skip to content

Commit

Permalink
1.16.5
Browse files Browse the repository at this point in the history
NOTE: HUD overlay and debug overlay info doesn't render on Forge.
  • Loading branch information
LostLuma committed Feb 17, 2024
1 parent b6ca2e7 commit f1d4f03
Show file tree
Hide file tree
Showing 26 changed files with 253 additions and 177 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)
}
}
}
22 changes: 11 additions & 11 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.16.5"

# Platform libraries

fabric_loader = "0.15.6"
fabric_api = "0.96.1+1.20.4"
fabric_api = "0.29.4+1.16"

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.16.23"
cloth_config = "4.17.101"

mixinextras = "0.3.5"

Expand All @@ -30,10 +30,10 @@ 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" }
# 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

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 All @@ -34,40 +35,40 @@ public static Screen genConfigScreen(Screen parent) {

general.addEntry(
entryBuilder.startBooleanToggle(
localized("config", "enabled"),
DynamicFPSMod.modConfig.enabled()
)
.setDefaultValue(true)
.setSaveConsumer(DynamicFPSMod.modConfig::setEnabled)
.build()
localized("config", "enabled"),
DynamicFPSMod.modConfig.enabled()
)
.setDefaultValue(true)
.setSaveConsumer(DynamicFPSMod.modConfig::setEnabled)
.build()
);

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

general.addEntry(
entryBuilder.startIntSlider(
localized("config", "idle_time"),
DynamicFPSMod.modConfig.idleTime() / 60,
0, 30
)
.setDefaultValue(0)
.setSaveConsumer(value -> DynamicFPSMod.modConfig.setIdleTime(value * 60))
.setTextGetter(ClothConfig::idleTimeMessage)
.setTooltip(localized("config", "idle_time_tooltip"))
.build()
localized("config", "idle_time"),
DynamicFPSMod.modConfig.idleTime() / 60,
0, 30
)
.setDefaultValue(0)
.setSaveConsumer(value -> DynamicFPSMod.modConfig.setIdleTime(value * 60))
.setTextGetter(ClothConfig::idleTimeMessage)
.setTooltip(localized("config", "idle_time_tooltip"))
.build()
);

general.addEntry(
entryBuilder.startBooleanToggle(
localized("config", "uncap_menu_frame_rate"),
DynamicFPSMod.modConfig.uncapMenuFrameRate()
)
.setDefaultValue(false)
.setSaveConsumer(DynamicFPSMod.modConfig::setUncapMenuFrameRate)
.setTooltip(localized("config", "uncap_menu_frame_rate_tooltip"))
.build()
localized("config", "uncap_menu_frame_rate"),
DynamicFPSMod.modConfig.uncapMenuFrameRate()
)
.setDefaultValue(false)
.setSaveConsumer(DynamicFPSMod.modConfig::setUncapMenuFrameRate)
.setTooltip(localized("config", "uncap_menu_frame_rate_tooltip"))
.build()
);

for (PowerState state : PowerState.values()) {
Expand All @@ -84,14 +85,14 @@ public static Screen genConfigScreen(Screen parent) {

category.addEntry(
entryBuilder.startIntSlider(
localized("config", "frame_rate_target"),
fromConfigFpsTarget(config.frameRateTarget()),
0, 61
)
.setDefaultValue(fromConfigFpsTarget(standard.frameRateTarget()))
.setSaveConsumer(value -> config.setFrameRateTarget(toConfigFpsTarget(value)))
.setTextGetter(ClothConfig::fpsTargetMessage)
.build()
localized("config", "frame_rate_target"),
fromConfigFpsTarget(config.frameRateTarget()),
0, 61
)
.setDefaultValue(fromConfigFpsTarget(standard.frameRateTarget()))
.setSaveConsumer(value -> config.setFrameRateTarget(toConfigFpsTarget(value)))
.setTextGetter(ClothConfig::fpsTargetMessage)
.build()
);

SubCategoryBuilder volumes = entryBuilder.startSubCategory(localized("config", "volume_multiplier"));
Expand All @@ -101,52 +102,52 @@ public static Screen genConfigScreen(Screen parent) {

volumes.add(
entryBuilder.startIntSlider(
Component.translatable("soundCategory." + name),
(int) (config.volumeMultiplier(source) * 100),
0, 100
)
.setDefaultValue((int) (standard.volumeMultiplier(source) * 100))
.setSaveConsumer(value -> config.setVolumeMultiplier(source, value / 100f))
.setTextGetter(ClothConfig::volumeMultiplierMessage)
.build()
new TranslatableComponent("soundCategory." + name),
(int) (config.volumeMultiplier(source) * 100),
0, 100
)
.setDefaultValue((int) (standard.volumeMultiplier(source) * 100))
.setSaveConsumer(value -> config.setVolumeMultiplier(source, value / 100f))
.setTextGetter(ClothConfig::volumeMultiplierMessage)
.build()
);
}

category.addEntry(volumes.build());

category.addEntry(
entryBuilder.startEnumSelector(
localized("config", "graphics_state"),
GraphicsState.class,
config.graphicsState()
)
.setDefaultValue(standard.graphicsState())
.setSaveConsumer(config::setGraphicsState)
.setEnumNameProvider(ClothConfig::graphicsStateMessage)
.setTooltipSupplier(ClothConfig::graphicsStateTooltip)
.build()
localized("config", "graphics_state"),
GraphicsState.class,
config.graphicsState()
)
.setDefaultValue(standard.graphicsState())
.setSaveConsumer(config::setGraphicsState)
.setEnumNameProvider(ClothConfig::graphicsStateMessage)
.setTooltipSupplier((current) -> ClothConfig.graphicsStateTooltip((GraphicsState) current)) // wth
.build()
);

category.addEntry(
entryBuilder.startBooleanToggle(
localized("config", "show_toasts"),
config.showToasts()
)
.setDefaultValue(standard.showToasts())
.setSaveConsumer(config::setShowToasts)
.setTooltip(localized("config", "show_toasts_tooltip"))
.build()
localized("config", "show_toasts"),
config.showToasts()
)
.setDefaultValue(standard.showToasts())
.setSaveConsumer(config::setShowToasts)
.setTooltip(localized("config", "show_toasts_tooltip"))
.build()
);

category.addEntry(
entryBuilder.startBooleanToggle(
localized("config", "run_garbage_collector"),
config.runGarbageCollector()
)
.setDefaultValue(standard.runGarbageCollector())
.setSaveConsumer(config::setRunGarbageCollector)
.setTooltip(localized("config", "run_garbage_collector_tooltip"))
.build()
localized("config", "run_garbage_collector"),
config.runGarbageCollector()
)
.setDefaultValue(standard.runGarbageCollector())
.setSaveConsumer(config::setRunGarbageCollector)
.setTooltip(localized("config", "run_garbage_collector_tooltip"))
.build()
);
}

Expand All @@ -173,14 +174,14 @@ private static int fromConfigFpsTarget(int value) {

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

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

private static Component graphicsStateMessage(Enum<GraphicsState> graphicsState) {
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
Expand Up @@ -52,7 +52,7 @@ private void getFramerateLimit(CallbackInfoReturnable<Integer> callbackInfo) {
callbackInfo.setReturnValue(limit);
}
} else if (DynamicFPSMod.uncapMenuFrameRate()) {
if (self.options.enableVsync().get()) {
if (self.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
Loading

0 comments on commit f1d4f03

Please sign in to comment.