Made chunk loading block independent from computer's performance
Fixed UI glitch in Survival caused by incorrect usage of the GL Manager
This commit is contained in:
@@ -132,7 +132,7 @@ public class ReplayMod
|
|||||||
JOptionPane.showMessageDialog(null, "It seems like you didn't donate, so you can't use the Replay Mod yet.");
|
JOptionPane.showMessageDialog(null, "It seems like you didn't donate, so you can't use the Replay Mod yet.");
|
||||||
FMLCommonHandler.instance().exitJava(0, false);
|
FMLCommonHandler.instance().exitJava(0, false);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeTmcprFiles() {
|
private void removeTmcprFiles() {
|
||||||
|
|||||||
@@ -84,18 +84,18 @@ public class GuiReplayOverlay extends Gui {
|
|||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onRenderGui(RenderGameOverlayEvent event) {
|
public void onRenderGui(RenderGameOverlayEvent event) {
|
||||||
if(ReplayProcess.isVideoRecording() && ReplayHandler.isInPath() && !(mc.currentScreen instanceof GuiCancelRender)) {
|
if(ReplayProcess.isVideoRecording() && ReplayHandler.isInPath() && !(mc.currentScreen instanceof GuiCancelRender)) {
|
||||||
event.setCanceled(true);
|
if(event.isCancelable()) event.setCanceled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void renderRecordingIndicator(RenderGameOverlayEvent.Text event) {
|
public void renderRecordingIndicator(RenderGameOverlayEvent.Text event) {
|
||||||
if(!ReplayHandler.isInReplay() && ReplayMod.replaySettings.showRecordingIndicator() && ConnectionEventHandler.isRecording()) {
|
if(!ReplayHandler.isInReplay() && ReplayMod.replaySettings.showRecordingIndicator() && ConnectionEventHandler.isRecording()) {
|
||||||
|
this.drawString(mc.fontRendererObj, "RECORDING", 30, 18-(mc.fontRendererObj.FONT_HEIGHT/2), Color.WHITE.getRGB());
|
||||||
|
mc.renderEngine.bindTexture(replay_gui);
|
||||||
GlStateManager.resetColor();
|
GlStateManager.resetColor();
|
||||||
GlStateManager.enableAlpha();
|
GlStateManager.enableAlpha();
|
||||||
mc.renderEngine.bindTexture(replay_gui);
|
|
||||||
this.drawModalRectWithCustomSizedTexture(10, 10, 40, 21, 16, 16, 64, 64);
|
this.drawModalRectWithCustomSizedTexture(10, 10, 40, 21, 16, 16, 64, 64);
|
||||||
this.drawString(mc.fontRendererObj, "RECORDING", 30, 18-(mc.fontRendererObj.FONT_HEIGHT/2), Color.WHITE.getRGB());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -87,6 +87,10 @@ public class ReplayHandler {
|
|||||||
inPath = replaying;
|
inPath = replaying;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void resetToleratedTimestamp() {
|
||||||
|
if(replaySender != null) replaySender.resetToleratedTimeStamp();
|
||||||
|
}
|
||||||
|
|
||||||
public static void stopHurrying() {
|
public static void stopHurrying() {
|
||||||
if(replaySender != null) replaySender.stopHurrying();
|
if(replaySender != null) replaySender.stopHurrying();
|
||||||
}
|
}
|
||||||
@@ -380,9 +384,16 @@ public class ReplayHandler {
|
|||||||
|
|
||||||
ChannelPipeline pipeline = networkManager.channel().pipeline();
|
ChannelPipeline pipeline = networkManager.channel().pipeline();
|
||||||
|
|
||||||
try {
|
mc.addScheduledTask(new Runnable() {
|
||||||
ReplayMod.overlay.resetUI();
|
@Override
|
||||||
} catch(Exception e) {}
|
public void run() {
|
||||||
|
try {
|
||||||
|
ReplayMod.overlay.resetUI();
|
||||||
|
} catch(Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
inReplay = true;
|
inReplay = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,10 +4,12 @@ import java.awt.image.BufferedImage;
|
|||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.gui.GuiDownloadTerrain;
|
||||||
import net.minecraft.client.gui.GuiScreen;
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
import net.minecraft.client.renderer.ChunkRenderContainer;
|
import net.minecraft.client.renderer.ChunkRenderContainer;
|
||||||
import net.minecraft.client.renderer.RenderGlobal;
|
import net.minecraft.client.renderer.RenderGlobal;
|
||||||
import net.minecraft.client.renderer.chunk.RenderChunk;
|
import net.minecraft.client.renderer.chunk.RenderChunk;
|
||||||
|
import net.minecraft.client.renderer.entity.RenderEntity;
|
||||||
import eu.crushedpixel.replaymod.ReplayMod;
|
import eu.crushedpixel.replaymod.ReplayMod;
|
||||||
import eu.crushedpixel.replaymod.chat.ChatMessageRequests;
|
import eu.crushedpixel.replaymod.chat.ChatMessageRequests;
|
||||||
import eu.crushedpixel.replaymod.chat.ChatMessageRequests.ChatMessageType;
|
import eu.crushedpixel.replaymod.chat.ChatMessageRequests.ChatMessageType;
|
||||||
@@ -57,6 +59,8 @@ public class ReplayProcess {
|
|||||||
public static void startReplayProcess(boolean record) {
|
public static void startReplayProcess(boolean record) {
|
||||||
ReplayHandler.selectKeyframe(null);
|
ReplayHandler.selectKeyframe(null);
|
||||||
|
|
||||||
|
firstTime = true;
|
||||||
|
|
||||||
isVideoRecording = record;
|
isVideoRecording = record;
|
||||||
lastPosition = null;
|
lastPosition = null;
|
||||||
motionSpline = null;
|
motionSpline = null;
|
||||||
@@ -64,6 +68,8 @@ public class ReplayProcess {
|
|||||||
timeLinear = null;
|
timeLinear = null;
|
||||||
calculated = false;
|
calculated = false;
|
||||||
requestFinish = false;
|
requestFinish = false;
|
||||||
|
|
||||||
|
ReplayHandler.resetToleratedTimestamp();
|
||||||
|
|
||||||
ChatMessageRequests.initialize();
|
ChatMessageRequests.initialize();
|
||||||
if(ReplayHandler.getPosKeyframeCount() < 2 && ReplayHandler.getTimeKeyframeCount() < 2) {
|
if(ReplayHandler.getPosKeyframeCount() < 2 && ReplayHandler.getTimeKeyframeCount() < 2) {
|
||||||
@@ -96,8 +102,6 @@ public class ReplayProcess {
|
|||||||
|
|
||||||
ChatMessageRequests.addChatMessage("Replay started!", ChatMessageType.INFORMATION);
|
ChatMessageRequests.addChatMessage("Replay started!", ChatMessageType.INFORMATION);
|
||||||
|
|
||||||
mc.renderGlobal.loadRenderers();
|
|
||||||
|
|
||||||
if(isVideoRecording()) {
|
if(isVideoRecording()) {
|
||||||
MCTimerHandler.setTimerSpeed(1f);
|
MCTimerHandler.setTimerSpeed(1f);
|
||||||
MCTimerHandler.setPassiveTimer();
|
MCTimerHandler.setPassiveTimer();
|
||||||
@@ -135,23 +139,50 @@ public class ReplayProcess {
|
|||||||
pathTick(isVideoRecording(), justCheck);
|
pathTick(isVideoRecording(), justCheck);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static float lastPartialTicks, lastRenderPartialTicks;
|
||||||
|
private static int lastTicks;
|
||||||
|
|
||||||
|
private static boolean resetTimer = false;
|
||||||
|
|
||||||
|
private static boolean firstTime = false;
|
||||||
|
|
||||||
private static void pathTick(boolean recording, boolean justCheck) {
|
private static void pathTick(boolean recording, boolean justCheck) {
|
||||||
if(ReplayHandler.isHurrying()) {
|
if(ReplayHandler.isHurrying()) {
|
||||||
lastRealTime = System.currentTimeMillis();
|
lastRealTime = System.currentTimeMillis();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(firstTime) {
|
||||||
|
firstTime = false;
|
||||||
|
lastPartialTicks = 100;
|
||||||
|
lastRenderPartialTicks = 100;
|
||||||
|
lastTicks = 100;
|
||||||
|
MCTimerHandler.setRenderPartialTicks(100);
|
||||||
|
MCTimerHandler.setPartialTicks(100);
|
||||||
|
MCTimerHandler.setTicks(100);
|
||||||
|
System.out.println(ReplayHandler.getReplayTime());
|
||||||
|
}
|
||||||
|
|
||||||
if(recording && ((ReplayMod.replaySettings.getWaitForChunks() && RenderChunk.renderChunksUpdated != 0) || mc.currentScreen instanceof GuiCancelRender)) {
|
if(recording && ((ReplayMod.replaySettings.getWaitForChunks() && RenderChunk.renderChunksUpdated != 0) || mc.currentScreen instanceof GuiCancelRender)) {
|
||||||
MCTimerHandler.setTimerSpeed(0f);
|
if(!firstTime) {
|
||||||
MCTimerHandler.setPartialTicks(0f);
|
MCTimerHandler.setTimerSpeed(0f);
|
||||||
MCTimerHandler.setRenderPartialTicks(0f);
|
MCTimerHandler.setPartialTicks(0f);
|
||||||
MCTimerHandler.setTicks(0);
|
MCTimerHandler.setRenderPartialTicks(0f);
|
||||||
|
MCTimerHandler.setTicks(0);
|
||||||
|
resetTimer = true;
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
} else if (recording && ReplayMod.replaySettings.getWaitForChunks()) {
|
} else if (recording && ReplayMod.replaySettings.getWaitForChunks()) {
|
||||||
MCTimerHandler.setTimerSpeed((float)lastSpeed);
|
MCTimerHandler.setTimerSpeed((float)lastSpeed);
|
||||||
|
//MCTimerHandler.setRenderPartialTicks(lastRenderPartialTicks);
|
||||||
|
if(resetTimer) {
|
||||||
|
MCTimerHandler.setPartialTicks(lastPartialTicks);
|
||||||
|
MCTimerHandler.setRenderPartialTicks(lastRenderPartialTicks);
|
||||||
|
MCTimerHandler.setTicks(lastTicks);
|
||||||
|
resetTimer = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(justCheck) return;
|
if(justCheck) return;
|
||||||
|
|
||||||
if(recording) {
|
if(recording) {
|
||||||
@@ -317,6 +348,10 @@ public class ReplayProcess {
|
|||||||
EnchantmentTimer.increaseRecordingTime((1000/ReplayMod.replaySettings.getVideoFramerate()));
|
EnchantmentTimer.increaseRecordingTime((1000/ReplayMod.replaySettings.getVideoFramerate()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lastPartialTicks = MCTimerHandler.getPartialTicks();
|
||||||
|
lastRenderPartialTicks = MCTimerHandler.getRenderTicks();
|
||||||
|
lastTicks = MCTimerHandler.getTicks();
|
||||||
|
|
||||||
if(curTimestamp != null && curTimestamp != ReplayHandler.getDesiredTimestamp()) ReplayHandler.setReplayTime(curTimestamp);
|
if(curTimestamp != null && curTimestamp != ReplayHandler.getDesiredTimestamp()) ReplayHandler.setReplayTime(curTimestamp);
|
||||||
|
|
||||||
//splinePos = (index of last entry + add) / total entries
|
//splinePos = (index of last entry + add) / total entries
|
||||||
|
|||||||
@@ -78,11 +78,12 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
|||||||
|
|
||||||
private long currentTimeStamp;
|
private long currentTimeStamp;
|
||||||
private boolean hurryToTimestamp;
|
private boolean hurryToTimestamp;
|
||||||
private long desiredTimeStamp;
|
private long desiredTimeStamp = -1;
|
||||||
|
private long toleratedTimeStamp = -1;
|
||||||
private long lastTimeStamp, lastPacketSent;
|
private long lastTimeStamp, lastPacketSent;
|
||||||
|
|
||||||
private boolean hasRestarted = false;
|
private boolean hasRestarted = false;
|
||||||
|
|
||||||
private File replayFile;
|
private File replayFile;
|
||||||
private boolean active = true;
|
private boolean active = true;
|
||||||
private ZipFile archive;
|
private ZipFile archive;
|
||||||
@@ -95,6 +96,8 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
|||||||
private boolean terminate = false;
|
private boolean terminate = false;
|
||||||
|
|
||||||
private double replaySpeed = 1f;
|
private double replaySpeed = 1f;
|
||||||
|
|
||||||
|
private boolean hasWorldLoaded = false;
|
||||||
|
|
||||||
private Field joinPacketEntityId, joinPacketWorldType,
|
private Field joinPacketEntityId, joinPacketWorldType,
|
||||||
joinPacketDimension, joinPacketDifficulty, joinPacketMaxPlayers;
|
joinPacketDimension, joinPacketDifficulty, joinPacketMaxPlayers;
|
||||||
@@ -130,7 +133,7 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
|||||||
public int replayLength() {
|
public int replayLength() {
|
||||||
return replayLength;
|
return replayLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopHurrying() {
|
public void stopHurrying() {
|
||||||
hurryToTimestamp = false;
|
hurryToTimestamp = false;
|
||||||
}
|
}
|
||||||
@@ -148,15 +151,27 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
|||||||
public long getDesiredTimestamp() {
|
public long getDesiredTimestamp() {
|
||||||
return desiredTimeStamp;
|
return desiredTimeStamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void resetToleratedTimeStamp() {
|
||||||
|
toleratedTimeStamp = -1;
|
||||||
|
}
|
||||||
|
|
||||||
public void jumpToTime(int millis) {
|
public void jumpToTime(int millis) {
|
||||||
if(!(ReplayHandler.isInPath() && ReplayProcess.isVideoRecording())) setReplaySpeed(replaySpeed);
|
if(!(ReplayHandler.isInPath() && ReplayProcess.isVideoRecording())) setReplaySpeed(replaySpeed);
|
||||||
|
|
||||||
if((millis < currentTimeStamp && !isHurrying())) {
|
if((millis < currentTimeStamp && !isHurrying())) {
|
||||||
|
if(ReplayHandler.isInPath()) {
|
||||||
|
if(millis >= toleratedTimeStamp && toleratedTimeStamp >= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
startFromBeginning = true;
|
startFromBeginning = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
desiredTimeStamp = millis;
|
desiredTimeStamp = millis;
|
||||||
|
if(ReplayHandler.isInPath()) {
|
||||||
|
toleratedTimeStamp = millis;
|
||||||
|
}
|
||||||
hurryToTimestamp = true;
|
hurryToTimestamp = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -246,15 +261,16 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
|||||||
while(!terminate) {
|
while(!terminate) {
|
||||||
if(startFromBeginning) {
|
if(startFromBeginning) {
|
||||||
hasRestarted = true;
|
hasRestarted = true;
|
||||||
|
hasWorldLoaded = false;
|
||||||
currentTimeStamp = 0;
|
currentTimeStamp = 0;
|
||||||
dis.close();
|
dis.close();
|
||||||
dis = new DataInputStream(archive.getInputStream(replayEntry));
|
dis = new DataInputStream(archive.getInputStream(replayEntry));
|
||||||
startFromBeginning = false;
|
startFromBeginning = false;
|
||||||
lastPacketSent = System.currentTimeMillis();
|
lastPacketSent = System.currentTimeMillis();
|
||||||
ReplayHandler.restartReplay();
|
ReplayHandler.restartReplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
while(!terminate && !startFromBeginning && (!paused() || FMLClientHandler.instance().isGUIOpen(GuiDownloadTerrain.class))) {
|
while(!terminate && !startFromBeginning && (!paused() || !hasWorldLoaded)) {
|
||||||
try {
|
try {
|
||||||
/*
|
/*
|
||||||
* LOGIC:
|
* LOGIC:
|
||||||
@@ -277,8 +293,7 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
|||||||
currentTimeStamp = pd.getTimestamp();
|
currentTimeStamp = pd.getTimestamp();
|
||||||
//System.out.println(currentTimeStamp);
|
//System.out.println(currentTimeStamp);
|
||||||
|
|
||||||
if(!ReplayHandler.isInPath() && !hurryToTimestamp && (mc.theWorld != null && mc.theWorld.getChunkProvider().getLoadedChunkCount() > 0)) {
|
if(!ReplayHandler.isInPath() && !hurryToTimestamp && hasWorldLoaded) {
|
||||||
//if(!hurryToTimestamp && !FMLClientHandler.instance().isGUIOpen(GuiDownloadTerrain.class)) {
|
|
||||||
int timeWait = (int)Math.round((currentTimeStamp - lastTimeStamp)/replaySpeed);
|
int timeWait = (int)Math.round((currentTimeStamp - lastTimeStamp)/replaySpeed);
|
||||||
long timeDiff = System.currentTimeMillis() - lastPacketSent;
|
long timeDiff = System.currentTimeMillis() - lastPacketSent;
|
||||||
lastPacketSent = System.currentTimeMillis();
|
lastPacketSent = System.currentTimeMillis();
|
||||||
@@ -599,6 +614,7 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
if(p instanceof S08PacketPlayerPosLook) {
|
if(p instanceof S08PacketPlayerPosLook) {
|
||||||
|
if(!hasWorldLoaded) hasWorldLoaded = true;
|
||||||
final S08PacketPlayerPosLook ppl = (S08PacketPlayerPosLook)p;
|
final S08PacketPlayerPosLook ppl = (S08PacketPlayerPosLook)p;
|
||||||
|
|
||||||
if(ReplayHandler.isInPath() && !hurryToTimestamp) return;
|
if(ReplayHandler.isInPath() && !hurryToTimestamp) return;
|
||||||
|
|||||||
Reference in New Issue
Block a user