Added Core Mod to redirect the Enchantment Rendering getSystemTime() calls to a the EnchantmentTimer (glow now slows down)
This commit is contained in:
@@ -1,174 +0,0 @@
|
||||
package eu.crushedpixel.replaymod.replay;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.Timer;
|
||||
import eu.crushedpixel.replaymod.reflection.MCPNames;
|
||||
import eu.crushedpixel.replaymod.video.ReplayTimer;
|
||||
|
||||
public class MCTimerHandler {
|
||||
|
||||
private static Field mcTimer;
|
||||
private static Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
private static ReplayTimer rpt = new ReplayTimer(20);
|
||||
private static Timer timerBefore;
|
||||
|
||||
static {
|
||||
try {
|
||||
mcTimer = Minecraft.class.getDeclaredField(MCPNames.field("field_71428_T"));
|
||||
mcTimer.setAccessible(true);
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void setActiveTimer() {
|
||||
try {
|
||||
if(timerBefore != null) {
|
||||
mcTimer.set(mc, timerBefore);
|
||||
}
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void setPassiveTimer() {
|
||||
try {
|
||||
if(!(getTimer() instanceof ReplayTimer)) {
|
||||
timerBefore = getTimer();
|
||||
mcTimer.set(mc, rpt);
|
||||
}
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static int getTicks() {
|
||||
try {
|
||||
Timer t = getTimer();
|
||||
return t.elapsedTicks;
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static float getPartialTicks() {
|
||||
try {
|
||||
Timer t = getTimer();
|
||||
return t.elapsedPartialTicks;
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static float getRenderTicks() {
|
||||
try {
|
||||
Timer t = getTimer();
|
||||
return t.renderPartialTicks;
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static Timer getTimer() throws IllegalArgumentException, IllegalAccessException {
|
||||
return (Timer)mcTimer.get(mc);
|
||||
}
|
||||
|
||||
public static void advanceTicks(int ticks) {
|
||||
try {
|
||||
Timer t = getTimer();
|
||||
t.elapsedTicks += ticks;
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void advancePartialTicks(float ticks) {
|
||||
try {
|
||||
Timer t = getTimer();
|
||||
t.elapsedPartialTicks += ticks;
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void advanceRenderPartialTicks(float ticks) {
|
||||
try {
|
||||
Timer t = getTimer();
|
||||
t.renderPartialTicks += ticks;
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void setTimerSpeed(float speed) {
|
||||
try {
|
||||
Timer t = getTimer();
|
||||
t.timerSpeed = speed;
|
||||
if(timerBefore != null) {
|
||||
timerBefore.timerSpeed = speed;
|
||||
}
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void setRenderPartialTicks(float ticks) {
|
||||
try {
|
||||
getTimer().renderPartialTicks = ticks;
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void setPartialTicks(float ticks) {
|
||||
try {
|
||||
getTimer().elapsedPartialTicks = ticks;
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void setTicks(int ticks) {
|
||||
try {
|
||||
getTimer().elapsedTicks = ticks;
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static float getTimerSpeed() {
|
||||
try {
|
||||
return getTimer().timerSpeed;
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
public static void updateTimer(double d) {
|
||||
try {
|
||||
Timer t = getTimer();
|
||||
double d2 = d;
|
||||
//d2 = MathHelper.clamp_double(d2, 0.0D, 1.0D);
|
||||
t.elapsedPartialTicks = (float)((double)t.elapsedPartialTicks + d2 * (double)t.timerSpeed * 20);
|
||||
t.elapsedTicks = (int)t.elapsedPartialTicks;
|
||||
t.elapsedPartialTicks -= (float)t.elapsedTicks;
|
||||
|
||||
if (t.elapsedTicks > 10)
|
||||
{
|
||||
t.elapsedTicks = 10;
|
||||
}
|
||||
|
||||
t.renderPartialTicks = t.elapsedPartialTicks;
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import java.io.File;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import eu.crushedpixel.replaymod.ReplayMod;
|
||||
import eu.crushedpixel.replaymod.chat.ChatMessageRequests;
|
||||
import eu.crushedpixel.replaymod.chat.ChatMessageRequests.ChatMessageType;
|
||||
@@ -14,6 +15,8 @@ import eu.crushedpixel.replaymod.holders.TimeKeyframe;
|
||||
import eu.crushedpixel.replaymod.interpolation.LinearPoint;
|
||||
import eu.crushedpixel.replaymod.interpolation.LinearTimestamp;
|
||||
import eu.crushedpixel.replaymod.interpolation.SplinePoint;
|
||||
import eu.crushedpixel.replaymod.timer.EnchantmentTimer;
|
||||
import eu.crushedpixel.replaymod.timer.MCTimerHandler;
|
||||
import eu.crushedpixel.replaymod.video.ScreenCapture;
|
||||
import eu.crushedpixel.replaymod.video.VideoWriter;
|
||||
|
||||
@@ -67,6 +70,8 @@ public class ReplayProcess {
|
||||
ReplayHandler.setInPath(true);
|
||||
previousReplaySpeed = ReplayHandler.getSpeed();
|
||||
|
||||
EnchantmentTimer.resetRecordingTime();
|
||||
|
||||
TimeKeyframe tf = ReplayHandler.getNextTimeKeyframe(-1);
|
||||
if(tf != null) {
|
||||
int ts = tf.getTimestamp();
|
||||
@@ -253,7 +258,6 @@ public class ReplayProcess {
|
||||
if(Float.isInfinite(currentTimeStepPerc)) currentTimeStepPerc = 0;
|
||||
|
||||
float splinePos = ((float)ReplayHandler.getKeyframeIndex(lastPos) + currentPosStepPerc)/(float)(ReplayHandler.getPosKeyframeCount()-1);
|
||||
|
||||
float timePos = ((float)ReplayHandler.getKeyframeIndex(lastTime) + currentTimeStepPerc)/(float)(ReplayHandler.getTimeKeyframeCount()-1);
|
||||
|
||||
Position pos = null;
|
||||
@@ -431,6 +435,7 @@ public class ReplayProcess {
|
||||
ReplayHandler.setSpeed((float)curSpeed);
|
||||
if(isVideoRecording()) {
|
||||
MCTimerHandler.updateTimer((1f/ReplayMod.replaySettings.getVideoFramerate()));
|
||||
EnchantmentTimer.increaseRecordingTime((1000/ReplayMod.replaySettings.getVideoFramerate()));
|
||||
}
|
||||
if(curPos != null) ReplayHandler.setReplayPos(curPos);
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package eu.crushedpixel.replaymod.replay;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.ChannelHandler.Sharable;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandlerAdapter;
|
||||
@@ -21,10 +19,8 @@ import net.minecraft.client.gui.GuiDownloadTerrain;
|
||||
import net.minecraft.client.particle.EffectRenderer;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.network.EnumConnectionState;
|
||||
import net.minecraft.network.EnumPacketDirection;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.server.S01PacketJoinGame;
|
||||
import net.minecraft.network.play.server.S02PacketChat;
|
||||
import net.minecraft.network.play.server.S03PacketTimeUpdate;
|
||||
@@ -70,6 +66,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.timer.MCTimerHandler;
|
||||
import eu.crushedpixel.replaymod.utils.ReplayFileIO;
|
||||
|
||||
@Sharable
|
||||
@@ -399,9 +396,12 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
||||
//If hurrying, ignore some packets, unless during Replay Path and *not* in initial hurry
|
||||
if(hurryToTimestamp && (!ReplayHandler.isInPath() || (desiredTimeStamp-currentTimeStamp > 1000))) {
|
||||
if(p instanceof S45PacketTitle ||
|
||||
p instanceof S29PacketSoundEffect ||
|
||||
p instanceof S2APacketParticles) return;
|
||||
}
|
||||
|
||||
if(p instanceof S29PacketSoundEffect && ReplayHandler.isInPath() && ReplayProcess.isVideoRecording()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(p instanceof S03PacketTimeUpdate) {
|
||||
p = TimeHandler.getTimePacket((S03PacketTimeUpdate)p);
|
||||
@@ -437,6 +437,13 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
||||
p = new S01PacketJoinGame(entId, GameType.SPECTATOR, false, dimension,
|
||||
difficulty, maxPlayers, worldType, false);
|
||||
}
|
||||
|
||||
if(p instanceof S07PacketRespawn) {
|
||||
S07PacketRespawn respawn = (S07PacketRespawn)p;
|
||||
p = new S07PacketRespawn(respawn.func_149082_c(),
|
||||
respawn.func_149081_d(), respawn.func_149080_f(), GameType.SPECTATOR);
|
||||
allowMovement = true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Proof of concept for some nasty player manipulation ;)
|
||||
@@ -475,12 +482,7 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
||||
System.out.println(((S0CPacketSpawnPlayer) p).func_148944_c());
|
||||
}
|
||||
*/
|
||||
|
||||
if(p instanceof S07PacketRespawn) {
|
||||
allowMovement = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(p instanceof S08PacketPlayerPosLook) {
|
||||
final S08PacketPlayerPosLook ppl = (S08PacketPlayerPosLook)p;
|
||||
|
||||
@@ -508,6 +510,7 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
||||
}
|
||||
|
||||
Entity ent = ReplayHandler.getCameraEntity();
|
||||
|
||||
if(ent == null || !(ent instanceof CameraEntity)) ent = new CameraEntity(mc.theWorld);
|
||||
CameraEntity cent = (CameraEntity)ent;
|
||||
cent.moveAbsolute(ppl.func_148932_c(), ppl.func_148928_d(), ppl.func_148933_e());
|
||||
|
||||
Reference in New Issue
Block a user