diff --git a/src/main/java/com/replaymod/extras/FullBrightness.java b/src/main/java/com/replaymod/extras/FullBrightness.java index 4f1fa7c5..63fe5c16 100644 --- a/src/main/java/com/replaymod/extras/FullBrightness.java +++ b/src/main/java/com/replaymod/extras/FullBrightness.java @@ -11,6 +11,8 @@ import de.johni0702.minecraft.gui.element.IGuiImage; import de.johni0702.minecraft.gui.layout.HorizontalLayout; import de.johni0702.minecraft.gui.utils.EventRegistrations; import net.minecraft.client.MinecraftClient; +import net.minecraft.entity.effect.StatusEffectInstance; +import net.minecraft.entity.effect.StatusEffects; //#if FABRIC>=1 import com.replaymod.core.events.PreRenderCallback; @@ -21,6 +23,7 @@ import com.replaymod.core.events.PostRenderCallback; //#endif public class FullBrightness extends EventRegistrations implements Extra { + private ReplayMod core; private ReplayModReplay module; private final IGuiImage indicator = new GuiImage().setTexture(ReplayMod.TEXTURE, 90, 20, 19, 16).setSize(19, 16); @@ -35,6 +38,7 @@ public class FullBrightness extends EventRegistrations implements Extra { @Override public void register(final ReplayMod mod) throws Exception { + this.core = mod; this.module = ReplayModReplay.instance; this.mc = mod.getMinecraft(); @@ -58,6 +62,16 @@ public class FullBrightness extends EventRegistrations implements Extra { register(); } + public Type getType() { + String str = core.getSettingsRegistry().get(Setting.FULL_BRIGHTNESS); + for (Type type : Type.values()) { + if (type.toString().equals(str)) { + return type; + } + } + return Type.Gamma; + } + //#if FABRIC>=1 { on(PreRenderCallback.EVENT, this::preRender); } private void preRender() { @@ -67,8 +81,20 @@ public class FullBrightness extends EventRegistrations implements Extra { //$$ if (event.phase != TickEvent.Phase.START) return; //#endif if (active && module.getReplayHandler() != null) { - originalGamma = mc.options.gamma; - mc.options.gamma = 1000; + Type type = getType(); + if (type == Type.Gamma || type == Type.Both) { + originalGamma = mc.options.gamma; + mc.options.gamma = 1000; + } + if (type == Type.NightVision || type == Type.Both) { + if (mc.player != null) { + mc.player.addStatusEffect(new StatusEffectInstance(StatusEffects.NIGHT_VISION + //#if MC<=10809 + //$$ .id + //#endif + , Integer.MAX_VALUE)); + } + } } } @@ -81,7 +107,19 @@ public class FullBrightness extends EventRegistrations implements Extra { //$$ if (event.phase != TickEvent.Phase.END) return; //#endif if (active && module.getReplayHandler() != null) { - mc.options.gamma = originalGamma; + Type type = getType(); + if (type == Type.Gamma || type == Type.Both) { + mc.options.gamma = originalGamma; + } + if (type == Type.NightVision || type == Type.Both) { + if (mc.player != null) { + mc.player.removeStatusEffect(StatusEffects.NIGHT_VISION + //#if MC<=10809 + //$$ .id + //#endif + ); + } + } } } @@ -93,4 +131,16 @@ public class FullBrightness extends EventRegistrations implements Extra { overlay.statusIndicatorPanel.removeElement(indicator); } } + + enum Type { + Gamma, + NightVision, + Both, + ; + + @Override + public String toString() { + return "replaymod.gui.settings.fullbrightness." + name().toLowerCase(); + } + } } diff --git a/src/main/java/com/replaymod/extras/Setting.java b/src/main/java/com/replaymod/extras/Setting.java index ae6a359c..278ff94f 100644 --- a/src/main/java/com/replaymod/extras/Setting.java +++ b/src/main/java/com/replaymod/extras/Setting.java @@ -2,9 +2,18 @@ package com.replaymod.extras; import com.replaymod.core.SettingsRegistry; +import java.util.Arrays; +import java.util.stream.Collectors; + public final class Setting { public static final SettingsRegistry.SettingKey ASK_FOR_OPEN_EYE = new SettingsRegistry.SettingKeys<>("advanced", "askForOpenEye", null, true); public static final SettingsRegistry.SettingKey SKIP_POST_SCREENSHOT_GUI = new SettingsRegistry.SettingKeys<>("advanced", "skipPostScreenshotGui", null, false); + public static final SettingsRegistry.MultipleChoiceSettingKeys FULL_BRIGHTNESS = new SettingsRegistry.MultipleChoiceSettingKeys<>( + "advanced", "fullBrightness", "replaymod.gui.settings.fullbrightness", + FullBrightness.Type.Gamma.toString()); + static { + FULL_BRIGHTNESS.setChoices(Arrays.stream(FullBrightness.Type.values()).map(Object::toString).collect(Collectors.toList())); + } } diff --git a/src/main/resources/assets/replaymod/lang b/src/main/resources/assets/replaymod/lang index f1663f04..6449e661 160000 --- a/src/main/resources/assets/replaymod/lang +++ b/src/main/resources/assets/replaymod/lang @@ -1 +1 @@ -Subproject commit f1663f04f97bde22f3a9d53ddb28485836ac91c6 +Subproject commit 6449e661be12b5bfd32a5aec868804bebad150fb diff --git a/versions/1.14.4-forge/mapping.txt b/versions/1.14.4-forge/mapping.txt index d2db8300..029bf807 100644 --- a/versions/1.14.4-forge/mapping.txt +++ b/versions/1.14.4-forge/mapping.txt @@ -1,3 +1,4 @@ +net.minecraft.potion.EffectInstance net.minecraft.potion.PotionEffect net.minecraft.client.gui.screen.AddServerScreen net.minecraft.client.gui.GuiScreenAddServer net.minecraft.resources.AbstractResourcePack net.minecraft.client.resources.AbstractResourcePack net.minecraft.resources.FolderPack net.minecraft.client.resources.FolderResourcePack