diff options
Diffstat (limited to 'src/main/java/com/arslaancodes/arslaansmagichax/modules/impl/Fullbright.java')
| -rw-r--r-- | src/main/java/com/arslaancodes/arslaansmagichax/modules/impl/Fullbright.java | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/src/main/java/com/arslaancodes/arslaansmagichax/modules/impl/Fullbright.java b/src/main/java/com/arslaancodes/arslaansmagichax/modules/impl/Fullbright.java new file mode 100644 index 0000000..56b0800 --- /dev/null +++ b/src/main/java/com/arslaancodes/arslaansmagichax/modules/impl/Fullbright.java @@ -0,0 +1,85 @@ +package com.arslaancodes.arslaansmagichax.modules.impl; + +import com.arslaancodes.arslaansmagichax.modules.Category; +import com.arslaancodes.arslaansmagichax.modules.Module; +import com.arslaancodes.arslaansmagichax.modules.settings.ModeSetting; +import java.util.Objects; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.world.effect.MobEffectInstance; +import net.minecraft.world.effect.MobEffects; + +public class Fullbright extends Module { + public ModeSetting mode = new ModeSetting("Mode", "Gamma", "Effect", "Gamma", "Effect + Gamma", "Break AO Renderer"); + private double previousGamma = 1.0; + private boolean setPreviousGamma = false; + private String lastMode = ""; // track previous mode + + public Fullbright() { + super("Fullbright", "Brightens up your world!", -1, Category.RENDER); + addSetting(mode); + lastMode = mode.getMode(); // initialize + } + + @Override + protected void onEnable() { + if (mc.options == null) return; + applyMode(mode.getMode()); + + if (mc.levelRenderer != null) { + mc.levelRenderer.allChanged(); + } + } + + @Override + public void tick() { + if (!this.isEnabled() || mc.player == null) return; + + String currentMode = mode.getMode(); + if (!Objects.equals(currentMode, lastMode)) { + applyMode(currentMode); + + if (mc.levelRenderer != null) { + mc.levelRenderer.allChanged(); + } + + lastMode = currentMode; + } + + if (Objects.equals(currentMode, "Effect")) { + mc.player.addEffect(new MobEffectInstance(BuiltInRegistries.MOB_EFFECT.wrapAsHolder(MobEffects.NIGHT_VISION.value()), 1, 255)); + } else if (Objects.equals(currentMode, "Effect + Gamma")) { + mc.player.addEffect(new MobEffectInstance(BuiltInRegistries.MOB_EFFECT.wrapAsHolder(MobEffects.NIGHT_VISION.value()), 1, 255)); + } + } + + private void applyMode(String modeName) { + if (Objects.equals(modeName, "Gamma")) { + if (!setPreviousGamma) previousGamma = mc.options.gamma().get(); + setPreviousGamma = true; + mc.options.gamma().set(1000.0); + } else if (Objects.equals(modeName, "Effect + Gamma")) { + if (!setPreviousGamma) previousGamma = mc.options.gamma().get(); + setPreviousGamma = true; + mc.options.gamma().set(1000.0); + } else if (Objects.equals(modeName, "Effect")) { + mc.options.gamma().set(previousGamma); + setPreviousGamma = false; + } + } + + @Override + protected void onDisable() { + if (mc.player == null) return; + + if (mc.player.hasEffect(BuiltInRegistries.MOB_EFFECT.wrapAsHolder(MobEffects.NIGHT_VISION.value()))) { + mc.player.removeEffect(BuiltInRegistries.MOB_EFFECT.wrapAsHolder(MobEffects.NIGHT_VISION.value())); + } + + mc.options.gamma().set(previousGamma); + + if (mc.levelRenderer != null) { + mc.levelRenderer.allChanged(); + } + } +} + |
