.tmcpr files are now being deleted upon starting the game
Finally fixed Replay code Finally fixed Lighting code
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
package eu.crushedpixel.replaymod;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
@@ -25,6 +28,7 @@ import eu.crushedpixel.replaymod.events.TickAndRenderListener;
|
||||
import eu.crushedpixel.replaymod.online.authentication.AuthenticationHandler;
|
||||
import eu.crushedpixel.replaymod.recording.ConnectionEventHandler;
|
||||
import eu.crushedpixel.replaymod.registry.KeybindRegistry;
|
||||
import eu.crushedpixel.replaymod.registry.LightingHandler;
|
||||
import eu.crushedpixel.replaymod.renderer.SafeEntityRenderer;
|
||||
import eu.crushedpixel.replaymod.settings.ReplaySettings;
|
||||
|
||||
@@ -110,6 +114,9 @@ public class ReplayMod
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
//clean up replay_recordings folder
|
||||
removeTmcprFiles();
|
||||
|
||||
/*
|
||||
boolean auth = false;
|
||||
try {
|
||||
@@ -124,5 +131,24 @@ public class ReplayMod
|
||||
FMLCommonHandler.instance().exitJava(0, false);
|
||||
}
|
||||
*/
|
||||
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
LightingHandler.setLighting(false);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
private void removeTmcprFiles() {
|
||||
File folder = new File("./replay_recordings/");
|
||||
folder.mkdirs();
|
||||
|
||||
for(File f : folder.listFiles()) {
|
||||
if("."+FilenameUtils.getExtension(f.getAbsolutePath()) == ConnectionEventHandler.TEMP_FILE_EXTENSION) {
|
||||
f.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ import eu.crushedpixel.replaymod.gui.online.GuiUploadFile;
|
||||
import eu.crushedpixel.replaymod.gui.replaystudio.GuiReplayStudio;
|
||||
import eu.crushedpixel.replaymod.gui.replayviewer.GuiReplayViewer;
|
||||
import eu.crushedpixel.replaymod.online.authentication.AuthenticationHandler;
|
||||
import eu.crushedpixel.replaymod.registry.LightingHandler;
|
||||
import eu.crushedpixel.replaymod.registry.ReplayGuiRegistry;
|
||||
import eu.crushedpixel.replaymod.replay.ReplayHandler;
|
||||
import eu.crushedpixel.replaymod.replay.ReplayProcess;
|
||||
@@ -200,7 +201,7 @@ public class GuiEventHandler {
|
||||
|
||||
event.button.enabled = false;
|
||||
|
||||
mc.gameSettings.setOptionFloatValue(Options.GAMMA, ReplayHandler.getInitialGamma());
|
||||
LightingHandler.setLighting(false);
|
||||
|
||||
ReplayHandler.lastExit = System.currentTimeMillis();
|
||||
|
||||
|
||||
@@ -155,8 +155,6 @@ public class GuiReplayOverlay extends Gui {
|
||||
GlStateManager.resetColor();
|
||||
this.drawModalRectWithCustomSizedTexture(ppButtonX, ppButtonY, x, y, 20, 20, 64, 64);
|
||||
|
||||
//GlStateManager.resetColor();
|
||||
|
||||
//When hurrying, no Timeline jumping etc. is possible
|
||||
if(Mouse.isButtonDown(0) && FMLClientHandler.instance().isGUIOpen(GuiMouseInput.class) && !ReplayHandler.isHurrying()) { //clicking the Button
|
||||
speedSlider.mousePressed(mc, mouseX, mouseY);
|
||||
@@ -196,6 +194,11 @@ public class GuiReplayOverlay extends Gui {
|
||||
}
|
||||
|
||||
} else {
|
||||
/*
|
||||
if(Mouse.isButtonDown(0) && FMLClientHandler.instance().isGUIOpen(GuiMouseInput.class) && ReplayHandler.isHurrying()) {
|
||||
System.out.println("HURRYIN'");
|
||||
}
|
||||
*/
|
||||
try {
|
||||
speedSlider.mouseReleased(mouseX, mouseY);
|
||||
mouseDown = false;
|
||||
|
||||
@@ -23,7 +23,9 @@ import eu.crushedpixel.replaymod.video.ReplayScreenshot;
|
||||
public class KeyInputHandler {
|
||||
|
||||
private Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
|
||||
private boolean escDown = false;
|
||||
|
||||
@SubscribeEvent
|
||||
public void onKeyInput(KeyInputEvent event) {
|
||||
|
||||
@@ -34,10 +36,12 @@ public class KeyInputHandler {
|
||||
|
||||
if(Keyboard.getEventKeyState() && !Keyboard.isRepeatEvent() && Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)
|
||||
&& ReplayHandler.isInPath() && ReplayProcess.isVideoRecording()
|
||||
&& mc.currentScreen == null) {
|
||||
&& mc.currentScreen == null && !escDown) {
|
||||
mc.displayGuiScreen(new GuiCancelRender());
|
||||
}
|
||||
|
||||
escDown = Keyboard.isKeyDown(Keyboard.KEY_ESCAPE) && Keyboard.getEventKeyState();
|
||||
|
||||
boolean found = false;
|
||||
|
||||
KeyBinding[] keyBindings = Minecraft.getMinecraft().gameSettings.keyBindings;
|
||||
@@ -103,7 +107,7 @@ public class KeyInputHandler {
|
||||
SpectateHandler.openSpectateSelection();
|
||||
}
|
||||
|
||||
if(kb.getKeyDescription().equals(KeybindRegistry.KEY_LIGHTING) && kb.isPressed() && !found) {
|
||||
if(kb.getKeyDescription().equals(KeybindRegistry.KEY_LIGHTING) && kb.isPressed()) {
|
||||
ReplayMod.replaySettings.setLightingEnabled(!ReplayMod.replaySettings.isLightingEnabled());
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.opengl.Display;
|
||||
|
||||
@@ -14,6 +15,7 @@ import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.InputEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||
import eu.crushedpixel.replaymod.gui.GuiCancelRender;
|
||||
import eu.crushedpixel.replaymod.reflection.MCPNames;
|
||||
import eu.crushedpixel.replaymod.replay.ReplayHandler;
|
||||
import eu.crushedpixel.replaymod.replay.ReplayProcess;
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package eu.crushedpixel.replaymod.registry;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.settings.GameSettings.Options;
|
||||
import net.minecraft.util.Timer;
|
||||
import eu.crushedpixel.replaymod.replay.ReplayHandler;
|
||||
import eu.crushedpixel.replaymod.timer.MCTimerHandler;
|
||||
|
||||
public class LightingHandler {
|
||||
|
||||
private static float initialGamma = 0;
|
||||
|
||||
private static boolean enabled = false;
|
||||
|
||||
public static void setInitialGamma(float gamma) {
|
||||
initialGamma = gamma;
|
||||
}
|
||||
|
||||
public static void setLighting(boolean lighting) {
|
||||
if(lighting) {
|
||||
if(!enabled) {
|
||||
initialGamma = Minecraft.getMinecraft().gameSettings.getOptionFloatValue(Options.GAMMA);
|
||||
}
|
||||
Minecraft.getMinecraft().gameSettings.setOptionFloatValue(Options.GAMMA, 1000);
|
||||
}
|
||||
else Minecraft.getMinecraft().gameSettings.setOptionFloatValue(Options.GAMMA, initialGamma);
|
||||
|
||||
enabled = lighting;
|
||||
|
||||
try {
|
||||
if(ReplayHandler.isPaused()) {
|
||||
MCTimerHandler.advancePartialTicks(1);
|
||||
MCTimerHandler.advanceRenderPartialTicks(1);
|
||||
} else {
|
||||
Minecraft.getMinecraft().entityRenderer.updateCameraAndRender(0);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -50,8 +50,6 @@ public class ReplayHandler {
|
||||
|
||||
public static long lastExit = 0;
|
||||
|
||||
private static float gamma = 0f;
|
||||
|
||||
private static Entity currentEntity = null;
|
||||
|
||||
public static void insertPacketInstantly(Packet p) {
|
||||
@@ -85,17 +83,13 @@ public class ReplayHandler {
|
||||
return currentEntity == cameraEntity;
|
||||
}
|
||||
|
||||
public static void setInitialGamma(float initial) {
|
||||
gamma = initial;
|
||||
}
|
||||
|
||||
public static float getInitialGamma() {
|
||||
return gamma;
|
||||
}
|
||||
|
||||
public static void setInPath(boolean replaying) {
|
||||
inPath = replaying;
|
||||
}
|
||||
|
||||
public static void stopHurrying() {
|
||||
if(replaySender != null) replaySender.stopHurrying();
|
||||
}
|
||||
|
||||
public static void startPath(boolean save) {
|
||||
if(!ReplayHandler.isInPath()) ReplayProcess.startReplayProcess(save);
|
||||
|
||||
@@ -114,9 +114,10 @@ public class ReplayProcess {
|
||||
}
|
||||
}
|
||||
ReplayHandler.setInPath(false);
|
||||
ReplayHandler.stopHurrying();
|
||||
MCTimerHandler.setActiveTimer();
|
||||
ReplayHandler.setSpeed(previousReplaySpeed);
|
||||
//ReplayHandler.setSpeed(0);
|
||||
ReplayHandler.setSpeed(0);
|
||||
}
|
||||
|
||||
private static boolean blocked = false;
|
||||
@@ -297,9 +298,9 @@ public class ReplayProcess {
|
||||
}
|
||||
}
|
||||
|
||||
Integer curPos = null;
|
||||
Integer curTimestamp = null;
|
||||
if(timeLinear != null && timeCount > 1) {
|
||||
curPos = timeLinear.getPoint(Math.max(0, Math.min(1, timePos)));
|
||||
curTimestamp = timeLinear.getPoint(Math.max(0, Math.min(1, timePos)));
|
||||
}
|
||||
|
||||
if(pos != null) {
|
||||
@@ -316,7 +317,7 @@ public class ReplayProcess {
|
||||
EnchantmentTimer.increaseRecordingTime((1000/ReplayMod.replaySettings.getVideoFramerate()));
|
||||
}
|
||||
|
||||
if(curPos != null && curPos != ReplayHandler.getDesiredTimestamp()) ReplayHandler.setReplayTime(curPos);
|
||||
if(curTimestamp != null && curTimestamp != ReplayHandler.getDesiredTimestamp()) ReplayHandler.setReplayTime(curTimestamp);
|
||||
|
||||
//splinePos = (index of last entry + add) / total entries
|
||||
|
||||
|
||||
@@ -69,6 +69,7 @@ import eu.crushedpixel.replaymod.holders.Position;
|
||||
import eu.crushedpixel.replaymod.recording.ConnectionEventHandler;
|
||||
import eu.crushedpixel.replaymod.recording.ReplayMetaData;
|
||||
import eu.crushedpixel.replaymod.reflection.MCPNames;
|
||||
import eu.crushedpixel.replaymod.registry.LightingHandler;
|
||||
import eu.crushedpixel.replaymod.timer.MCTimerHandler;
|
||||
import eu.crushedpixel.replaymod.utils.ReplayFileIO;
|
||||
|
||||
@@ -81,9 +82,7 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
||||
private long lastTimeStamp, lastPacketSent;
|
||||
|
||||
private boolean hasRestarted = false;
|
||||
|
||||
private long toleratedTimeStamp = Long.MAX_VALUE;
|
||||
|
||||
|
||||
private File replayFile;
|
||||
private boolean active = true;
|
||||
private ZipFile archive;
|
||||
@@ -131,6 +130,10 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
||||
public int replayLength() {
|
||||
return replayLength;
|
||||
}
|
||||
|
||||
public void stopHurrying() {
|
||||
hurryToTimestamp = false;
|
||||
}
|
||||
|
||||
public void terminateReplay() {
|
||||
terminate = true;
|
||||
@@ -150,11 +153,6 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
||||
if(!(ReplayHandler.isInPath() && ReplayProcess.isVideoRecording())) setReplaySpeed(replaySpeed);
|
||||
|
||||
if((millis < currentTimeStamp && !isHurrying())) {
|
||||
if(ReplayHandler.isInPath()) {
|
||||
if(millis < toleratedTimeStamp) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
startFromBeginning = true;
|
||||
}
|
||||
|
||||
@@ -207,8 +205,6 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
ReplayHandler.setInitialGamma(mc.gameSettings.gammaSetting);
|
||||
|
||||
this.replayFile = replayFile;
|
||||
this.networkManager = nm;
|
||||
if(("."+FilenameUtils.getExtension(replayFile.getAbsolutePath())).equals(ConnectionEventHandler.ZIP_FILE_EXTENSION)) {
|
||||
@@ -294,12 +290,6 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
||||
|
||||
lastTimeStamp = currentTimeStamp;
|
||||
|
||||
if(ReplayHandler.isInPath()) {
|
||||
toleratedTimeStamp = lastTimeStamp;
|
||||
} else {
|
||||
toleratedTimeStamp = -1;
|
||||
}
|
||||
|
||||
if(hurryToTimestamp && currentTimeStamp >= desiredTimeStamp && !startFromBeginning) {
|
||||
hurryToTimestamp = false;
|
||||
if(!ReplayHandler.isInPath() || hasRestarted) {
|
||||
|
||||
@@ -12,6 +12,7 @@ import net.minecraftforge.common.config.Configuration;
|
||||
import net.minecraftforge.common.config.Property;
|
||||
import eu.crushedpixel.replaymod.ReplayMod;
|
||||
import eu.crushedpixel.replaymod.reflection.MCPNames;
|
||||
import eu.crushedpixel.replaymod.registry.LightingHandler;
|
||||
import eu.crushedpixel.replaymod.replay.ReplayHandler;
|
||||
|
||||
public class ReplaySettings {
|
||||
@@ -74,19 +75,7 @@ public class ReplaySettings {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
|
||||
private static Field mcTimer;
|
||||
|
||||
static {
|
||||
try {
|
||||
mcTimer = Minecraft.class.getDeclaredField(MCPNames.field("field_71428_T"));
|
||||
mcTimer.setAccessible(true);
|
||||
} catch(Exception e) {
|
||||
mcTimer = null;
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public List<ValueEnum> getValueEnums() {
|
||||
List<ValueEnum> enums = new ArrayList<ReplaySettings.ValueEnum>();
|
||||
enums.addAll(Arrays.asList(ReplayOptions.values()));
|
||||
@@ -181,27 +170,10 @@ public class ReplaySettings {
|
||||
public boolean getWaitForChunks() {
|
||||
return (Boolean)RenderOptions.waitForChunks.getValue();
|
||||
}
|
||||
|
||||
//TODO: FIX
|
||||
|
||||
public void setLightingEnabled(boolean enabled) {
|
||||
ReplayOptions.lighting.setValue(enabled);
|
||||
if(enabled) {
|
||||
Minecraft.getMinecraft().gameSettings.setOptionFloatValue(Options.GAMMA, 1000);
|
||||
} else {
|
||||
Minecraft.getMinecraft().gameSettings.setOptionFloatValue(Options.GAMMA, ReplayHandler.getInitialGamma());
|
||||
}
|
||||
try {
|
||||
if(ReplayHandler.isPaused()) {
|
||||
Timer timer = (Timer)mcTimer.get(Minecraft.getMinecraft());
|
||||
timer.elapsedPartialTicks++;
|
||||
timer.renderPartialTicks++;
|
||||
} else {
|
||||
Minecraft.getMinecraft().entityRenderer.updateCameraAndRender(0);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
LightingHandler.setLighting(enabled);
|
||||
rewriteSettings();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user