diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..015dae8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,17 @@ +# Gradle +.gradle/ +build/ +out/ + +# Fabric Loom +run/ +remappedSrc/ +*.log + +# IDE +.idea/ +*.iml +.vscode/ + +# OS +.DS_Store diff --git a/gradlew b/gradlew old mode 100644 new mode 100755 diff --git a/src/main/java/cc/fros/features/modules/render/FullbrightModule.java b/src/main/java/cc/fros/features/modules/render/FullbrightModule.java new file mode 100644 index 0000000..63dbbc7 --- /dev/null +++ b/src/main/java/cc/fros/features/modules/render/FullbrightModule.java @@ -0,0 +1,80 @@ +package cc.fros.features.modules.render; + +import cc.fros.features.modules.Module; +import cc.fros.features.settings.Setting; +import net.minecraft.world.effect.MobEffectInstance; +import net.minecraft.world.effect.MobEffects; + +public class FullbrightModule extends Module { + private static final int POTION_DURATION = 400; + + public final Setting mode = mode("Mode", Mode.GAMMA); + public final Setting gamma = num("Gamma", 5.0, 0.1, 100.0); + public final Setting particles = bool("Particles", false); + + private Mode activeMode = Mode.GAMMA; + private double previousGamma; + private boolean hadNightVision; + + public FullbrightModule() { + super("Fullbright", "Makes everything bright", Category.RENDER); + } + + @Override + public void onEnable() { + activeMode = mode.getValue(); + prepare(activeMode); + } + + @Override + public void onTick() { + if (mode.getValue() != activeMode) { + restore(activeMode); + activeMode = mode.getValue(); + prepare(activeMode); + } + + if (activeMode == Mode.GAMMA) { + applyGamma(); + return; + } + + if (nullCheck()) return; + // reapply every tick so it never expires + mc.player.addEffect(new MobEffectInstance(MobEffects.NIGHT_VISION, + POTION_DURATION, 0, true, particles.getValue())); + } + + @Override + public void onDisable() { + restore(activeMode); + } + + private void prepare(Mode newMode) { + if (newMode == Mode.GAMMA) { + previousGamma = mc.options.gamma().get(); + return; + } + hadNightVision = !nullCheck() && mc.player.hasEffect(MobEffects.NIGHT_VISION); + } + + private void restore(Mode oldMode) { + if (oldMode == Mode.GAMMA) { + // bypass OptionInstance#set, which rejects values outside [0.0, 1.0] + mc.options.gamma().value = previousGamma; + return; + } + if (!nullCheck() && !hadNightVision) { + mc.player.removeEffect(MobEffects.NIGHT_VISION); + } + } + + private void applyGamma() { + mc.options.gamma().value = gamma.getValue(); + } + + public enum Mode { + GAMMA, + POTION + } +} diff --git a/src/main/java/cc/fros/manager/ModuleManager.java b/src/main/java/cc/fros/manager/ModuleManager.java index 887a581..f6c778e 100644 --- a/src/main/java/cc/fros/manager/ModuleManager.java +++ b/src/main/java/cc/fros/manager/ModuleManager.java @@ -31,6 +31,7 @@ import cc.fros.features.modules.player.FastPlaceModule; import cc.fros.features.modules.player.NoFallModule; import cc.fros.features.modules.player.VelocityModule; import cc.fros.features.modules.render.BlockHighlightModule; +import cc.fros.features.modules.render.FullbrightModule; import cc.fros.util.traits.Jsonable; import cc.fros.util.traits.Util; import org.slf4j.Logger; @@ -62,6 +63,7 @@ public class ModuleManager implements Jsonable, Util { register(new FastPlaceModule()); register(new VelocityModule()); register(new BlockHighlightModule()); + register(new FullbrightModule()); register(new NoFallModule()); register(new KeyPearlModule()); register(new KillAuraModule()); diff --git a/src/main/resources/fros.accesswidener b/src/main/resources/fros.accesswidener index 32453a4..2eb6bc5 100644 --- a/src/main/resources/fros.accesswidener +++ b/src/main/resources/fros.accesswidener @@ -10,4 +10,5 @@ accessible field com/mojang/blaze3d/platform/InputConstants$Type map Lit/unimi/d accessible field net/minecraft/client/player/LocalPlayer positionReminder I accessible field net/minecraft/client/player/LocalPlayer yRotLast F -accessible field net/minecraft/client/player/LocalPlayer xRotLast F \ No newline at end of file +accessible field net/minecraft/client/player/LocalPlayer xRotLast F +accessible field net/minecraft/client/OptionInstance value Ljava/lang/Object; \ No newline at end of file