Cleaned up Packet checking in ReplaySender
Removed broken Time Keyframe functionality to create a stable build
This commit is contained in:
@@ -186,7 +186,7 @@ public class GuiReplayOverlay extends Gui {
|
|||||||
mc.displayGuiScreen((GuiScreen)null);
|
mc.displayGuiScreen((GuiScreen)null);
|
||||||
}
|
}
|
||||||
|
|
||||||
ReplayHandler.setReplayPos((int)time, false);
|
ReplayHandler.setReplayPos((int)time);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -230,9 +230,9 @@ public class ReplayHandler {
|
|||||||
selectKeyframe(null);
|
selectKeyframe(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setReplayPos(int pos, boolean force) {
|
public static void setReplayPos(int pos) {
|
||||||
if(replaySender != null) {
|
if(replaySender != null) {
|
||||||
replaySender.jumpToTime(pos, force);
|
replaySender.jumpToTime(pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,11 +48,13 @@ public class ReplayProcess {
|
|||||||
ReplayHandler.sortKeyframes();
|
ReplayHandler.sortKeyframes();
|
||||||
ReplayHandler.setReplaying(true);
|
ReplayHandler.setReplaying(true);
|
||||||
previousReplaySpeed = ReplayHandler.getSpeed();
|
previousReplaySpeed = ReplayHandler.getSpeed();
|
||||||
|
/*
|
||||||
TimeKeyframe tf = ReplayHandler.getNextTimeKeyframe(-1);
|
TimeKeyframe tf = ReplayHandler.getNextTimeKeyframe(-1);
|
||||||
if(tf != null) {
|
if(tf != null) {
|
||||||
int ts = tf.getTimestamp();
|
int ts = tf.getTimestamp();
|
||||||
ReplayHandler.setReplayPos(ts, true);
|
ReplayHandler.setReplayPos(ts);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
ChatMessageRequests.addChatMessage("Replay started!", ChatMessageType.INFORMATION);
|
ChatMessageRequests.addChatMessage("Replay started!", ChatMessageType.INFORMATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,6 +68,7 @@ public class ReplayProcess {
|
|||||||
|
|
||||||
public static void tickReplay() {
|
public static void tickReplay() {
|
||||||
if(!ReplayHandler.isReplaying()) return;
|
if(!ReplayHandler.isReplaying()) return;
|
||||||
|
|
||||||
if(ReplayHandler.isHurrying()) {
|
if(ReplayHandler.isHurrying()) {
|
||||||
lastRealTime = System.currentTimeMillis();
|
lastRealTime = System.currentTimeMillis();
|
||||||
System.out.println("rethurrn");
|
System.out.println("rethurrn");
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ import net.minecraft.network.play.server.S37PacketStatistics;
|
|||||||
import net.minecraft.network.play.server.S39PacketPlayerAbilities;
|
import net.minecraft.network.play.server.S39PacketPlayerAbilities;
|
||||||
import net.minecraft.network.play.server.S43PacketCamera;
|
import net.minecraft.network.play.server.S43PacketCamera;
|
||||||
import net.minecraft.network.play.server.S45PacketTitle;
|
import net.minecraft.network.play.server.S45PacketTitle;
|
||||||
|
import net.minecraft.network.play.server.S48PacketResourcePackSend;
|
||||||
import net.minecraft.network.play.server.S14PacketEntity.S17PacketEntityLookMove;
|
import net.minecraft.network.play.server.S14PacketEntity.S17PacketEntityLookMove;
|
||||||
import net.minecraft.util.Timer;
|
import net.minecraft.util.Timer;
|
||||||
import net.minecraft.world.EnumDifficulty;
|
import net.minecraft.world.EnumDifficulty;
|
||||||
@@ -74,8 +75,6 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
|||||||
private long desiredTimeStamp;
|
private long desiredTimeStamp;
|
||||||
private long lastTimeStamp, lastPacketSent;
|
private long lastTimeStamp, lastPacketSent;
|
||||||
|
|
||||||
private long toleratedTimeStamp;
|
|
||||||
|
|
||||||
private File replayFile;
|
private File replayFile;
|
||||||
private PacketDeserializer ds = new PacketDeserializer(EnumPacketDirection.SERVERBOUND);
|
private PacketDeserializer ds = new PacketDeserializer(EnumPacketDirection.SERVERBOUND);
|
||||||
private boolean active = true;
|
private boolean active = true;
|
||||||
@@ -138,24 +137,11 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void jumpToTime(int millis, boolean forceReload) {
|
public void jumpToTime(int millis) {
|
||||||
setReplaySpeed(replaySpeed);
|
setReplaySpeed(replaySpeed);
|
||||||
|
|
||||||
if((millis < currentTimeStamp && !isHurrying()) || forceReload) {
|
if((millis < currentTimeStamp && !isHurrying())) {
|
||||||
if(forceReload) System.out.println("forced");
|
startFromBeginning = true;
|
||||||
if(ReplayHandler.isReplaying()) {
|
|
||||||
if(forceReload) {
|
|
||||||
startFromBeginning = true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
startFromBeginning = false;
|
|
||||||
desiredTimeStamp = millis;
|
|
||||||
hurryToTimestamp = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
startFromBeginning = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
desiredTimeStamp = millis;
|
desiredTimeStamp = millis;
|
||||||
@@ -276,17 +262,20 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
|||||||
* If hurrying, don't wait for correct timing.
|
* If hurrying, don't wait for correct timing.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
if(!hurryToTimestamp && ReplayHandler.isReplaying()) {
|
if(!hurryToTimestamp && ReplayHandler.isReplaying()) {
|
||||||
continue;
|
continue;
|
||||||
} else if(ReplayHandler.isReplaying()) {
|
} else if(ReplayHandler.isReplaying()) {
|
||||||
System.out.println("nocont "+currentTimeStamp+" | "+((Timer)mcTimer.get(mc)).timerSpeed);
|
System.out.println("nocont "+currentTimeStamp+" | "+((Timer)mcTimer.get(mc)).timerSpeed);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
int timestamp = dis.readInt();
|
int timestamp = dis.readInt();
|
||||||
|
|
||||||
currentTimeStamp = timestamp;
|
currentTimeStamp = timestamp;
|
||||||
|
|
||||||
if(!ReplayHandler.isReplaying() && !hurryToTimestamp && !FMLClientHandler.instance().isGUIOpen(GuiDownloadTerrain.class)) {
|
//if(!ReplayHandler.isReplaying() && !hurryToTimestamp && !FMLClientHandler.instance().isGUIOpen(GuiDownloadTerrain.class)) {
|
||||||
|
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();
|
||||||
@@ -302,7 +291,6 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
|||||||
lastTimeStamp = currentTimeStamp;
|
lastTimeStamp = currentTimeStamp;
|
||||||
|
|
||||||
if(hurryToTimestamp && currentTimeStamp >= desiredTimeStamp && !startFromBeginning) {
|
if(hurryToTimestamp && currentTimeStamp >= desiredTimeStamp && !startFromBeginning) {
|
||||||
toleratedTimeStamp = currentTimeStamp;
|
|
||||||
hurryToTimestamp = false;
|
hurryToTimestamp = false;
|
||||||
System.out.println("stop hurrying");
|
System.out.println("stop hurrying");
|
||||||
}
|
}
|
||||||
@@ -318,17 +306,20 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
private List<Class> packetClasses = new ArrayList<Class>();
|
private ArrayList<Class> badPackets = new ArrayList<Class>() {
|
||||||
|
{
|
||||||
private static Field field_149074_a; //TODO: REMOVE
|
add(S28PacketEffect.class);
|
||||||
static {
|
add(S48PacketResourcePackSend.class);
|
||||||
try {
|
add(S2BPacketChangeGameState.class);
|
||||||
field_149074_a = S14PacketEntity.class.getDeclaredField(MCPNames.field("field_149074_a"));
|
add(S06PacketUpdateHealth.class);
|
||||||
field_149074_a.setAccessible(true);
|
add(S2DPacketOpenWindow.class);
|
||||||
} catch(Exception e) {
|
add(S2EPacketCloseWindow.class);
|
||||||
e.printStackTrace();
|
add(S2FPacketSetSlot.class);
|
||||||
|
add(S30PacketWindowItems.class);
|
||||||
|
add(S36PacketSignEditorOpen.class);
|
||||||
|
add(S37PacketStatistics.class);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void channelRead(ChannelHandlerContext ctx, Object msg)
|
public void channelRead(ChannelHandlerContext ctx, Object msg)
|
||||||
@@ -356,38 +347,6 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
|||||||
p instanceof S29PacketSoundEffect) return;
|
p instanceof S29PacketSoundEffect) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(p instanceof S28PacketEffect) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(p instanceof S2BPacketChangeGameState) { //TODO: Test with rain
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(p instanceof S06PacketUpdateHealth) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(p instanceof S2DPacketOpenWindow) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(p instanceof S2EPacketCloseWindow) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(p instanceof S2FPacketSetSlot) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(p instanceof S30PacketWindowItems) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(p instanceof S36PacketSignEditorOpen) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(p instanceof S02PacketChat) {
|
if(p instanceof S02PacketChat) {
|
||||||
byte pos = (Byte)chatPacketPosition.get(p);
|
byte pos = (Byte)chatPacketPosition.get(p);
|
||||||
if(pos == 1) { //Ignores command block output sent
|
if(pos == 1) { //Ignores command block output sent
|
||||||
@@ -395,13 +354,12 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(p instanceof S37PacketStatistics) {
|
if(badPackets.contains(p.getClass())) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
p.readPacketData(pb);
|
p.readPacketData(pb);
|
||||||
|
|
||||||
|
/*
|
||||||
if(p instanceof S0CPacketSpawnPlayer) {
|
if(p instanceof S0CPacketSpawnPlayer) {
|
||||||
S0CPacketSpawnPlayer sp = (S0CPacketSpawnPlayer)p;
|
S0CPacketSpawnPlayer sp = (S0CPacketSpawnPlayer)p;
|
||||||
System.out.println("PACKET SPAWN PLAYER ----------");
|
System.out.println("PACKET SPAWN PLAYER ----------");
|
||||||
@@ -415,6 +373,7 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
|||||||
System.out.println("ITEM: "+sp.func_148947_k());
|
System.out.println("ITEM: "+sp.func_148947_k());
|
||||||
System.out.println("PACKET END -------------------");
|
System.out.println("PACKET END -------------------");
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
if(p instanceof S01PacketJoinGame) {
|
if(p instanceof S01PacketJoinGame) {
|
||||||
|
|
||||||
@@ -464,8 +423,8 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
|||||||
if(p instanceof S43PacketCamera) {
|
if(p instanceof S43PacketCamera) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(ReplayHandler.isReplaying())
|
//if(ReplayHandler.isReplaying())
|
||||||
System.out.println("packet arrived");
|
// System.out.println("packet arrived");
|
||||||
super.channelRead(ctx, p);
|
super.channelRead(ctx, p);
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
System.out.println(p.getClass());
|
System.out.println(p.getClass());
|
||||||
|
|||||||
Reference in New Issue
Block a user