Add option to use night vision for full brightness (closes #315)
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<T> {
|
||||
public static final SettingsRegistry.SettingKey<Boolean> ASK_FOR_OPEN_EYE =
|
||||
new SettingsRegistry.SettingKeys<>("advanced", "askForOpenEye", null, true);
|
||||
public static final SettingsRegistry.SettingKey<Boolean> SKIP_POST_SCREENSHOT_GUI =
|
||||
new SettingsRegistry.SettingKeys<>("advanced", "skipPostScreenshotGui", null, false);
|
||||
public static final SettingsRegistry.MultipleChoiceSettingKeys<String> 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()));
|
||||
}
|
||||
}
|
||||
|
||||
Submodule src/main/resources/assets/replaymod/lang updated: f1663f04f9...6449e661be
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user