Skip to content
This repository has been archived by the owner on Feb 27, 2023. It is now read-only.

Commit

Permalink
Update FPSLock and Fullbright with support for default value, FPSLock…
Browse files Browse the repository at this point in the history
… fix (fr1kin#73)
  • Loading branch information
VADemon authored and fr1kin committed Jun 6, 2019
1 parent d76ecf3 commit 2c706f3
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
21 changes: 16 additions & 5 deletions src/main/java/com/matt/forgehax/mods/FPSLock.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,18 @@

@RegisterMod
public class FPSLock extends ToggleMod {
private final Setting<Integer> fps =

private final Setting<Integer> defaultFps =
getCommandStub()
.builders()
.<Integer>newSettingBuilder()
.name("default-fps")
.description("default FPS to revert to")
.defaultTo(MC.gameSettings.limitFramerate)
.min(1)
.build();

private final Setting<Integer> fps =
getCommandStub()
.builders()
.<Integer>newSettingBuilder()
Expand All @@ -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() {
Expand All @@ -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
Expand Down
14 changes: 13 additions & 1 deletion src/main/java/com/matt/forgehax/mods/FullBrightMod.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -12,14 +13,25 @@ public FullBrightMod() {
super(Category.WORLD, "FullBright", false, "Makes everything render with maximum brightness");
}

private final Setting<Float> defaultGamma =
getCommandStub()
.builders()
.<Float>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;
}

@Override
public void onDisabled() {
MC.gameSettings.gammaSetting = 1F;
MC.gameSettings.gammaSetting = defaultGamma.get();
}

@SubscribeEvent
Expand Down

0 comments on commit 2c706f3

Please sign in to comment.