Started implementing authentication system

Added information (MC Version and online Users) to Replay Metadata
This commit is contained in:
Marius Metzger
2015-01-22 22:21:25 +01:00
parent ebe6334232
commit 9ae8f9fc5e
17 changed files with 329 additions and 182 deletions

View File

@@ -26,22 +26,22 @@ public class LesserDataWatcher extends DataWatcher {
@Override
public byte getWatchableObjectByte(int id) {
return 0;
return 10;
}
@Override
public short getWatchableObjectShort(int id) {
return 0;
return 10;
}
@Override
public int getWatchableObjectInt(int id) {
return 0;
return 10;
}
@Override
public float getWatchableObjectFloat(int id) {
return 0;
return 10f;
}
@Override

View File

@@ -23,6 +23,7 @@ import eu.crushedpixel.replaymod.chat.ChatMessageRequests;
import eu.crushedpixel.replaymod.entities.CameraEntity;
import eu.crushedpixel.replaymod.holders.Keyframe;
import eu.crushedpixel.replaymod.holders.KeyframeComparator;
import eu.crushedpixel.replaymod.holders.Position;
import eu.crushedpixel.replaymod.holders.PositionKeyframe;
import eu.crushedpixel.replaymod.holders.TimeKeyframe;
@@ -47,6 +48,16 @@ public class ReplayHandler {
public static long lastExit = 0;
private static float gamma = 0f;
public static void setInitialGamma(float initial) {
gamma = initial;
}
public static float getInitialGamma() {
return gamma;
}
public static void setReplaying(boolean replaying) {
isReplaying = replaying;
}
@@ -369,4 +380,13 @@ public class ReplayHandler {
public static void setRealTimelineCursor(int pos) {
realTimelinePosition = pos;
}
private static Position lastPosition = null;
public static void setLastPosition(Position position) {
lastPosition = position;
}
public static Position getLastPosition() {
return lastPosition;
}
}

View File

@@ -31,20 +31,24 @@ public class ReplayProcess {
private static LinearTimestamp timeLinear = null;
private static double previousReplaySpeed = 0;
private static boolean calculated = false;
public static void startReplayProcess() {
lastPosition = null;
motionSpline = null;
timeLinear = null;
calculated = false;
ChatMessageRequests.initialize();
if(ReplayHandler.getKeyframes().isEmpty()) {
ChatMessageRequests.addChatMessage("No keyframes set!", ChatMessageType.WARNING);
if(ReplayHandler.getPosKeyframeCount() < 2) {
ChatMessageRequests.addChatMessage("At least 2 position keyframes required!", ChatMessageType.WARNING);
return;
}
startRealTime = System.currentTimeMillis();
lastRealTime = startRealTime;
lastRealReplayTime = 0;
lastTimestamp = -1;
lastPosition = null;
motionSpline = null;
timeLinear = null;
linear = ReplayMod.replaySettings.isLinearMovement();
ReplayHandler.sortKeyframes();
ReplayHandler.setReplaying(true);
@@ -86,10 +90,8 @@ public class ReplayProcess {
motionSpline.addPoint(pos);
}
}
if(motionSpline.getPoints().size() < 3) linear = true;
else motionSpline.calcSpline();
}
if(linear && motionLinear == null) {
//set up linear path
motionLinear = new LinearPoint();
@@ -109,16 +111,13 @@ public class ReplayProcess {
}
}
/*
for(float x = 0; x <= 1f; x+=0.1) {
//timeLinear.getPoint(x);
System.out.println(x+" | "+timeLinear.getPoint(x));
}
*/
//System.out.println(timeLinear.getPoint(0));
}
if(!calculated) {
calculated = true;
motionSpline.calcSpline();
}
long curTime = System.currentTimeMillis();
long timeStep = curTime - lastRealTime;
@@ -170,6 +169,10 @@ public class ReplayProcess {
if(!(nextTime == null || lastTime == null)) {
curSpeed = ((double)((nextTime.getTimestamp()-lastTime.getTimestamp())))/((double)((nextTimeStamp-lastTimeStamp)));
}
if(lastTimeStamp == nextTimeStamp) {
curSpeed = 0f;
}
}
int currentDiff = nextPosStamp - lastPosStamp;

View File

@@ -14,13 +14,11 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiDownloadTerrain;
import net.minecraft.client.particle.EffectRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.network.EnumConnectionState;
import net.minecraft.network.EnumPacketDirection;
import net.minecraft.network.NetworkManager;
@@ -32,7 +30,6 @@ import net.minecraft.network.play.server.S06PacketUpdateHealth;
import net.minecraft.network.play.server.S07PacketRespawn;
import net.minecraft.network.play.server.S08PacketPlayerPosLook;
import net.minecraft.network.play.server.S0BPacketAnimation;
import net.minecraft.network.play.server.S18PacketEntityTeleport;
import net.minecraft.network.play.server.S1CPacketEntityMetadata;
import net.minecraft.network.play.server.S1DPacketEntityEffect;
import net.minecraft.network.play.server.S1FPacketSetExperience;
@@ -61,8 +58,10 @@ import org.apache.commons.io.FilenameUtils;
import com.google.gson.Gson;
import eu.crushedpixel.replaymod.ReplayMod;
import eu.crushedpixel.replaymod.entities.CameraEntity;
import eu.crushedpixel.replaymod.events.RecordingHandler;
import eu.crushedpixel.replaymod.holders.Position;
import eu.crushedpixel.replaymod.recording.ConnectionEventHandler;
import eu.crushedpixel.replaymod.recording.ReplayMetaData;
import eu.crushedpixel.replaymod.reflection.MCPNames;
@@ -112,7 +111,7 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
private int replayLength = 0;
private int actualID = -1;
private EffectRenderer old = mc.effectRenderer;
private ZipArchiveEntry replayEntry;
@@ -209,6 +208,8 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
} catch (Exception e) {
e.printStackTrace();
}
ReplayHandler.setInitialGamma(mc.gameSettings.gammaSetting);
this.replayFile = replayFile;
this.networkManager = nm;
@@ -312,6 +313,18 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
((Timer)mcTimer.get(mc)).elapsedTicks += 5;
((Timer)mcTimer.get(mc)).renderPartialTicks += 5;
}
if(!ReplayHandler.isReplaying()) {
Position pos = ReplayHandler.getLastPosition();
CameraEntity cam = ReplayHandler.getCameraEntity();
if(cam != null) {
if(Math.abs(pos.getX() - cam.posX) < ReplayMod.TP_DISTANCE_LIMIT && Math.abs(pos.getZ() - cam.posZ) < ReplayMod.TP_DISTANCE_LIMIT)
if(pos != null) {
cam.moveAbsolute(pos.getX(), pos.getY(), pos.getZ());
cam.rotationPitch = pos.getPitch();
cam.rotationYaw = pos.getYaw();
}
}
}
if(!ReplayHandler.isReplaying()) {
setReplaySpeed(0);
}
@@ -348,7 +361,7 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
};
private boolean allowMovement = false;
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg)
throws Exception {
@@ -422,26 +435,27 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
p = new S01PacketJoinGame(entId, GameType.SPECTATOR, false, dimension,
difficulty, maxPlayers, worldType, false);
}
if(p instanceof S07PacketRespawn) {
allowMovement = true;
}
if(p instanceof S08PacketPlayerPosLook) {
final S08PacketPlayerPosLook ppl = (S08PacketPlayerPosLook)p;
if(ReplayHandler.isReplaying() && !hurryToTimestamp) return;
CameraEntity cent = ReplayHandler.getCameraEntity();
if(!allowMovement && !((Math.abs(cent.posX - ppl.func_148932_c()) > 100) || (Math.abs(cent.posZ - ppl.func_148933_e()) > 100))) {
if(!allowMovement && !((Math.abs(cent.posX - ppl.func_148932_c()) > ReplayMod.TP_DISTANCE_LIMIT) ||
(Math.abs(cent.posZ - ppl.func_148933_e()) > ReplayMod.TP_DISTANCE_LIMIT))) {
return;
} else {
allowMovement = false;
}
Thread t = new Thread(new Runnable() {
@Override