Add full brightness extra
This commit is contained in:
41
src/main/java/com/replaymod/extras/FullBrightness.java
Normal file
41
src/main/java/com/replaymod/extras/FullBrightness.java
Normal file
@@ -0,0 +1,41 @@
|
||||
package com.replaymod.extras;
|
||||
|
||||
import com.replaymod.core.ReplayMod;
|
||||
import net.minecraft.client.settings.GameSettings;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
public class FullBrightness implements Extra {
|
||||
private GameSettings gameSettings;
|
||||
private boolean active;
|
||||
private float originalGamma;
|
||||
|
||||
@Override
|
||||
public void register(final ReplayMod mod) throws Exception {
|
||||
this.gameSettings = mod.getMinecraft().gameSettings;
|
||||
|
||||
mod.getKeyBindingRegistry().registerKeyBinding("replaymod.input.lighting", Keyboard.KEY_Z, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
active = !active;
|
||||
mod.getMinecraft().entityRenderer.lightmapUpdateNeeded = true;
|
||||
}
|
||||
});
|
||||
|
||||
FMLCommonHandler.instance().bus().register(this);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void preRender(TickEvent.RenderTickEvent event) {
|
||||
if (active) {
|
||||
if (event.phase == TickEvent.Phase.START) {
|
||||
originalGamma = gameSettings.gammaSetting;
|
||||
gameSettings.gammaSetting = 1000;
|
||||
} else if (event.phase == TickEvent.Phase.END) {
|
||||
gameSettings.gammaSetting = originalGamma;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,8 @@ public class ReplayModExtras {
|
||||
@Mod.Instance(ReplayMod.MOD_ID)
|
||||
private static ReplayMod core;
|
||||
|
||||
private static final List<Class<? extends Extra>> builtin = Arrays.<Class<? extends Extra>>asList(
|
||||
private static final List<Class<? extends Extra>> builtin = Arrays.asList(
|
||||
FullBrightness.class,
|
||||
HotkeyButtons.class
|
||||
);
|
||||
|
||||
|
||||
@@ -47,8 +47,6 @@ public class KeybindRegistry {
|
||||
|
||||
replayModKeyBindings.add(new KeyBinding(KEY_PLAYER_OVERVIEW, Keyboard.KEY_B, "replaymod.title"));
|
||||
|
||||
replayModKeyBindings.add(new KeyBinding(KEY_LIGHTING, Keyboard.KEY_Z, "replaymod.title"));
|
||||
|
||||
replayModKeyBindings.add(new KeyBinding(KEY_ASSET_MANAGER, Keyboard.KEY_G, "replaymod.title"));
|
||||
replayModKeyBindings.add(new KeyBinding(KEY_OBJECT_MANAGER, Keyboard.KEY_F, "replaymod.title"));
|
||||
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
package eu.crushedpixel.replaymod.registry;
|
||||
|
||||
import com.replaymod.core.ReplayMod;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.settings.GameSettings.Options;
|
||||
|
||||
public class LightingHandler {
|
||||
|
||||
//I've picked this value because it's very unlikely someone is going to set it manually
|
||||
private static final float AMBIENT_GAMMA = 1000;
|
||||
|
||||
private static final Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
private static float initialGamma = 0;
|
||||
|
||||
public static void setLighting(boolean lighting) {
|
||||
|
||||
float gamma = mc.gameSettings.getOptionFloatValue(Options.GAMMA);
|
||||
if(gamma != AMBIENT_GAMMA) {
|
||||
initialGamma = gamma;
|
||||
}
|
||||
|
||||
if(lighting) mc.gameSettings.setOptionFloatValue(Options.GAMMA, AMBIENT_GAMMA);
|
||||
else mc.gameSettings.setOptionFloatValue(Options.GAMMA, initialGamma);
|
||||
|
||||
if(ReplayMod.replaySender.paused()) {
|
||||
mc.entityRenderer.lightmapUpdateNeeded = true;
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mc.gameSettings.gammaSetting = initialGamma;
|
||||
mc.gameSettings.saveOptions();
|
||||
}
|
||||
}, "lighting-handler-shutdown-hook"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package eu.crushedpixel.replaymod.settings;
|
||||
|
||||
import eu.crushedpixel.replaymod.registry.LightingHandler;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import net.minecraftforge.common.config.Property;
|
||||
@@ -51,15 +50,6 @@ public class ReplaySettings {
|
||||
return (Boolean) ReplayOptions.linear.getValue();
|
||||
}
|
||||
|
||||
public boolean isLightingEnabled() {
|
||||
return (Boolean) ReplayOptions.lighting.getValue();
|
||||
}
|
||||
|
||||
public void setLightingEnabled(boolean enabled) {
|
||||
ReplayOptions.lighting.setValue(enabled);
|
||||
LightingHandler.setLighting(enabled);
|
||||
}
|
||||
|
||||
public boolean showPathPreview() { return (Boolean) ReplayOptions.previewPath.getValue(); }
|
||||
|
||||
public void setShowPathPreview(boolean show) {
|
||||
@@ -142,7 +132,6 @@ public class ReplaySettings {
|
||||
|
||||
public enum ReplayOptions implements ValueEnum {
|
||||
linear(false, "replaymod.gui.settings.interpolation"),
|
||||
lighting(false, "replaymod.gui.settings.lighting"),
|
||||
previewPath(false, "replaymod.gui.settings.pathpreview"),
|
||||
keyframeCleanCallback(true, "replaymod.gui.settings.keyframecleancallback"),
|
||||
showChat(false, "options.chat.visibility"),
|
||||
|
||||
Reference in New Issue
Block a user