From b9fc8a3b18200bf321481b2049df24adf52f177f Mon Sep 17 00:00:00 2001 From: VADemon Date: Sun, 24 Feb 2019 17:15:11 +0100 Subject: [PATCH] Update FPSLock and Fullbright with support for default value, FPSLock fix --- .../java/com/matt/forgehax/mods/FPSLock.java | 21 ++++++++++++++----- .../com/matt/forgehax/mods/FullBrightMod.java | 14 ++++++++++++- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/matt/forgehax/mods/FPSLock.java b/src/main/java/com/matt/forgehax/mods/FPSLock.java index 605c1c667..c7c5394ea 100644 --- a/src/main/java/com/matt/forgehax/mods/FPSLock.java +++ b/src/main/java/com/matt/forgehax/mods/FPSLock.java @@ -12,7 +12,18 @@ @RegisterMod public class FPSLock extends ToggleMod { - private final Setting fps = + + private final Setting defaultFps = + getCommandStub() + .builders() + .newSettingBuilder() + .name("default-fps") + .description("default FPS to revert to") + .defaultTo(MC.gameSettings.limitFramerate) + .min(1) + .build(); + + private final Setting fps = getCommandStub() .builders() .newSettingBuilder() @@ -38,7 +49,7 @@ public class FPSLock extends ToggleMod { .name("no-focus-fps") .description("FPS when the game window doesn't have focus. Set to 0 to disable.") .min(0) - .defaultTo(1) + .defaultTo(3) .build(); public FPSLock() { @@ -51,13 +62,13 @@ public FPSLock() { private int getFps() { if (no_focus_fps.get() > 0 && !Display.isActive()) return no_focus_fps.get(); - else if (getWorld() != null) return fps.get() > 0 ? fps.get() : MC.gameSettings.limitFramerate; - else return menu_fps.get() > 0 ? menu_fps.get() : MC.gameSettings.limitFramerate; + else if (MC.currentScreen != null) return menu_fps.get() > 0 ? menu_fps.get() : defaultFps.get(); + else return fps.get() > 0 ? fps.get() : defaultFps.get(); } @Override protected void onDisabled() { - MC.gameSettings.limitFramerate = 60; + MC.gameSettings.limitFramerate = defaultFps.get(); } @SubscribeEvent diff --git a/src/main/java/com/matt/forgehax/mods/FullBrightMod.java b/src/main/java/com/matt/forgehax/mods/FullBrightMod.java index ebd9a3d9d..facd27387 100644 --- a/src/main/java/com/matt/forgehax/mods/FullBrightMod.java +++ b/src/main/java/com/matt/forgehax/mods/FullBrightMod.java @@ -1,5 +1,6 @@ package com.matt.forgehax.mods; +import com.matt.forgehax.util.command.Setting; import com.matt.forgehax.util.mod.Category; import com.matt.forgehax.util.mod.ToggleMod; import com.matt.forgehax.util.mod.loader.RegisterMod; @@ -12,6 +13,17 @@ public FullBrightMod() { super(Category.WORLD, "FullBright", false, "Makes everything render with maximum brightness"); } + private final Setting defaultGamma = + getCommandStub() + .builders() + .newSettingBuilder() + .name("gamma") + .description("default gamma to revert to") + .defaultTo(MC.gameSettings.gammaSetting) + .min(0.1F) + .max(16F) + .build(); + @Override public void onEnabled() { MC.gameSettings.gammaSetting = 16F; @@ -19,7 +31,7 @@ public void onEnabled() { @Override public void onDisabled() { - MC.gameSettings.gammaSetting = 1F; + MC.gameSettings.gammaSetting = defaultGamma.get(); } @SubscribeEvent