Backport quick mode to 1.9.4+ and disable below
This commit is contained in:
@@ -281,4 +281,17 @@ public class Utils {
|
|||||||
super.draw(renderer, size, renderInfo);
|
super.draw(renderer, size, renderInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static <T extends Throwable> void throwIfInstanceOf(Throwable t, Class<T> cls) throws T {
|
||||||
|
if (cls.isInstance(t)) {
|
||||||
|
throw cls.cast(t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static void throwIfUnchecked(Throwable t) {
|
||||||
|
if (t instanceof RuntimeException) {
|
||||||
|
throw (RuntimeException) t;
|
||||||
|
} else if (t instanceof Error) {
|
||||||
|
throw (Error) t;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -496,7 +496,7 @@ public class FullReplaySender extends ChannelDuplexHandler implements ReplaySend
|
|||||||
//#if MC>=10809
|
//#if MC>=10809
|
||||||
//$$ String url = packet.getURL();
|
//$$ String url = packet.getURL();
|
||||||
//#else
|
//#else
|
||||||
//$$ String url = packet.func_179783_a();
|
//$$ String url = packet.func_179783_a();
|
||||||
//#endif
|
//#endif
|
||||||
//#endif
|
//#endif
|
||||||
if (url.startsWith("replay://")) {
|
if (url.startsWith("replay://")) {
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
//#if MC>=10904
|
||||||
package com.replaymod.replay;
|
package com.replaymod.replay;
|
||||||
|
|
||||||
import com.github.steveice10.mc.protocol.data.game.PlayerListEntry;
|
import com.github.steveice10.mc.protocol.data.game.PlayerListEntry;
|
||||||
@@ -32,14 +33,13 @@ import com.github.steveice10.packetlib.io.NetOutput;
|
|||||||
import com.github.steveice10.packetlib.io.stream.StreamNetInput;
|
import com.github.steveice10.packetlib.io.stream.StreamNetInput;
|
||||||
import com.github.steveice10.packetlib.io.stream.StreamNetOutput;
|
import com.github.steveice10.packetlib.io.stream.StreamNetOutput;
|
||||||
import com.google.common.base.Optional;
|
import com.google.common.base.Optional;
|
||||||
import com.google.common.base.Throwables;
|
|
||||||
import com.google.common.collect.ListMultimap;
|
import com.google.common.collect.ListMultimap;
|
||||||
import com.google.common.collect.Multimaps;
|
import com.google.common.collect.Multimaps;
|
||||||
import com.google.common.util.concurrent.FutureCallback;
|
import com.google.common.util.concurrent.FutureCallback;
|
||||||
import com.google.common.util.concurrent.Futures;
|
import com.google.common.util.concurrent.Futures;
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
import com.google.common.util.concurrent.SettableFuture;
|
import com.google.common.util.concurrent.SettableFuture;
|
||||||
import com.replaymod.core.utils.WrappedTimer;
|
import com.replaymod.core.utils.Utils;
|
||||||
import com.replaymod.replaystudio.PacketData;
|
import com.replaymod.replaystudio.PacketData;
|
||||||
import com.replaymod.replaystudio.io.ReplayInputStream;
|
import com.replaymod.replaystudio.io.ReplayInputStream;
|
||||||
import com.replaymod.replaystudio.io.ReplayOutputStream;
|
import com.replaymod.replaystudio.io.ReplayOutputStream;
|
||||||
@@ -79,6 +79,10 @@ import java.util.TreeMap;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
//#if MC>=11200
|
||||||
|
import com.replaymod.core.utils.WrappedTimer;
|
||||||
|
//#endif
|
||||||
|
|
||||||
import static com.replaymod.core.versions.MCVer.FML_BUS;
|
import static com.replaymod.core.versions.MCVer.FML_BUS;
|
||||||
import static com.replaymod.replay.ReplayModReplay.LOGGER;
|
import static com.replaymod.replay.ReplayModReplay.LOGGER;
|
||||||
|
|
||||||
@@ -574,12 +578,17 @@ public class QuickReplaySender extends ChannelHandlerAdapter implements ReplaySe
|
|||||||
|
|
||||||
byteBuf.skipBytes(8); // Skip packet length & timestamp
|
byteBuf.skipBytes(8); // Skip packet length & timestamp
|
||||||
|
|
||||||
int packetId = packetBuf.readVarInt();
|
int packetId =
|
||||||
|
//#if MC>=11102
|
||||||
|
packetBuf.readVarInt();
|
||||||
|
//#else
|
||||||
|
//$$ packetBuf.readVarIntFromBuffer();
|
||||||
|
//#endif
|
||||||
Packet<?> mcPacket = EnumConnectionState.PLAY.getPacket(EnumPacketDirection.CLIENTBOUND, packetId);
|
Packet<?> mcPacket = EnumConnectionState.PLAY.getPacket(EnumPacketDirection.CLIENTBOUND, packetId);
|
||||||
mcPacket.readPacketData(packetBuf);
|
mcPacket.readPacketData(packetBuf);
|
||||||
return mcPacket;
|
return mcPacket;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Throwables.throwIfUnchecked(e);
|
Utils.throwIfUnchecked(e);
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
} finally {
|
} finally {
|
||||||
byteBuf.readerIndex(readerIndex); // Reset reader & writer index for next use
|
byteBuf.readerIndex(readerIndex); // Reset reader & writer index for next use
|
||||||
@@ -594,13 +603,18 @@ public class QuickReplaySender extends ChannelHandlerAdapter implements ReplaySe
|
|||||||
try {
|
try {
|
||||||
packetBuf.writeBytes(in.readBytes(in.readVarInt()));
|
packetBuf.writeBytes(in.readBytes(in.readVarInt()));
|
||||||
|
|
||||||
int packetId = packetBuf.readVarInt();
|
int packetId =
|
||||||
|
//#if MC>=11102
|
||||||
|
packetBuf.readVarInt();
|
||||||
|
//#else
|
||||||
|
//$$ packetBuf.readVarIntFromBuffer();
|
||||||
|
//#endif
|
||||||
Packet<?> mcPacket = EnumConnectionState.PLAY.getPacket(EnumPacketDirection.CLIENTBOUND, packetId);
|
Packet<?> mcPacket = EnumConnectionState.PLAY.getPacket(EnumPacketDirection.CLIENTBOUND, packetId);
|
||||||
mcPacket.readPacketData(packetBuf);
|
mcPacket.readPacketData(packetBuf);
|
||||||
return mcPacket;
|
return mcPacket;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Throwables.throwIfInstanceOf(e, IOException.class);
|
Utils.throwIfInstanceOf(e, IOException.class);
|
||||||
Throwables.throwIfUnchecked(e);
|
Utils.throwIfUnchecked(e);
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
} finally {
|
} finally {
|
||||||
byteBuf.readerIndex(readerIndex); // Reset reader & writer index for next use
|
byteBuf.readerIndex(readerIndex); // Reset reader & writer index for next use
|
||||||
@@ -640,8 +654,8 @@ public class QuickReplaySender extends ChannelHandlerAdapter implements ReplaySe
|
|||||||
out.writeByte(byteBuf.readByte());
|
out.writeByte(byteBuf.readByte());
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Throwables.throwIfInstanceOf(e, IOException.class);
|
Utils.throwIfInstanceOf(e, IOException.class);
|
||||||
Throwables.throwIfUnchecked(e);
|
Utils.throwIfUnchecked(e);
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
} finally {
|
} finally {
|
||||||
byteBuf.readerIndex(readerIndex); // Reset reader & writer index for next use
|
byteBuf.readerIndex(readerIndex); // Reset reader & writer index for next use
|
||||||
@@ -908,3 +922,4 @@ public class QuickReplaySender extends ChannelHandlerAdapter implements ReplaySe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//#endif
|
||||||
|
|||||||
@@ -34,6 +34,12 @@ import org.lwjgl.opengl.Display;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
//#if MC<10904
|
||||||
|
//$$ import de.johni0702.minecraft.gui.element.GuiLabel;
|
||||||
|
//$$ import de.johni0702.minecraft.gui.popup.GuiInfoPopup;
|
||||||
|
//$$ import de.johni0702.minecraft.gui.utils.Colors;
|
||||||
|
//#endif
|
||||||
|
|
||||||
//#if MC>=10800
|
//#if MC>=10800
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import net.minecraft.client.network.NetHandlerPlayClient;
|
import net.minecraft.client.network.NetHandlerPlayClient;
|
||||||
@@ -78,8 +84,12 @@ public class ReplayHandler {
|
|||||||
* Decodes and sends packets into channel.
|
* Decodes and sends packets into channel.
|
||||||
*/
|
*/
|
||||||
private final FullReplaySender fullReplaySender;
|
private final FullReplaySender fullReplaySender;
|
||||||
|
//#if MC>=10904
|
||||||
private final QuickReplaySender quickReplaySender;
|
private final QuickReplaySender quickReplaySender;
|
||||||
private boolean quickMode = false;
|
private boolean quickMode = false;
|
||||||
|
//#else
|
||||||
|
//$$ private static final String QUICK_MODE_MIN_MC = "1.9.4";
|
||||||
|
//#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Currently active replay restrictions.
|
* Currently active replay restrictions.
|
||||||
@@ -117,7 +127,9 @@ public class ReplayHandler {
|
|||||||
markers = new ArrayList<>(replayFile.getMarkers().or(Collections.emptySet()));
|
markers = new ArrayList<>(replayFile.getMarkers().or(Collections.emptySet()));
|
||||||
|
|
||||||
fullReplaySender = new FullReplaySender(this, replayFile, false);
|
fullReplaySender = new FullReplaySender(this, replayFile, false);
|
||||||
|
//#if MC>=10904
|
||||||
quickReplaySender = new QuickReplaySender(ReplayModReplay.instance, replayFile);
|
quickReplaySender = new QuickReplaySender(ReplayModReplay.instance, replayFile);
|
||||||
|
//#endif
|
||||||
|
|
||||||
setup();
|
setup();
|
||||||
|
|
||||||
@@ -149,7 +161,9 @@ public class ReplayHandler {
|
|||||||
FML_BUS.post(new ReplayCloseEvent.Pre(this));
|
FML_BUS.post(new ReplayCloseEvent.Pre(this));
|
||||||
|
|
||||||
fullReplaySender.terminateReplay();
|
fullReplaySender.terminateReplay();
|
||||||
|
//#if MC>=10904
|
||||||
quickReplaySender.unregister();
|
quickReplaySender.unregister();
|
||||||
|
//#endif
|
||||||
|
|
||||||
replayFile.save();
|
replayFile.save();
|
||||||
replayFile.close();
|
replayFile.close();
|
||||||
@@ -214,6 +228,9 @@ public class ReplayHandler {
|
|||||||
//$$ channel.attr(NetworkDispatcher.FML_DISPATCHER).set(networkDispatcher);
|
//$$ channel.attr(NetworkDispatcher.FML_DISPATCHER).set(networkDispatcher);
|
||||||
//$$
|
//$$
|
||||||
//$$ channel.pipeline().addFirst("ReplayModReplay_replaySender", fullReplaySender);
|
//$$ channel.pipeline().addFirst("ReplayModReplay_replaySender", fullReplaySender);
|
||||||
|
//#if MC>=10904
|
||||||
|
//$$ channel.pipeline().addFirst("ReplayModReplay_quickReplaySender", quickReplaySender);
|
||||||
|
//#endif
|
||||||
//$$ channel.pipeline().addAfter("ReplayModReplay_replaySender", "fml:packet_handler", networkDispatcher);
|
//$$ channel.pipeline().addAfter("ReplayModReplay_replaySender", "fml:packet_handler", networkDispatcher);
|
||||||
//$$ channel.pipeline().fireChannelActive();
|
//$$ channel.pipeline().fireChannelActive();
|
||||||
//#endif
|
//#endif
|
||||||
@@ -266,13 +283,18 @@ public class ReplayHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ReplaySender getReplaySender() {
|
public ReplaySender getReplaySender() {
|
||||||
|
//#if MC>=10904
|
||||||
return quickMode ? quickReplaySender : fullReplaySender;
|
return quickMode ? quickReplaySender : fullReplaySender;
|
||||||
|
//#else
|
||||||
|
//$$ return fullReplaySender;
|
||||||
|
//#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public GuiReplayOverlay getOverlay() {
|
public GuiReplayOverlay getOverlay() {
|
||||||
return overlay;
|
return overlay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//#if MC>=10904
|
||||||
public void ensureQuickModeInitialized(Runnable andThen) {
|
public void ensureQuickModeInitialized(Runnable andThen) {
|
||||||
ListenableFuture<Void> future = quickReplaySender.getInitializationPromise();
|
ListenableFuture<Void> future = quickReplaySender.getInitializationPromise();
|
||||||
if (future == null) {
|
if (future == null) {
|
||||||
@@ -346,6 +368,20 @@ public class ReplayHandler {
|
|||||||
public boolean isQuickMode() {
|
public boolean isQuickMode() {
|
||||||
return quickMode;
|
return quickMode;
|
||||||
}
|
}
|
||||||
|
//#else
|
||||||
|
//$$ public void ensureQuickModeInitialized(@SuppressWarnings("unused") Runnable andThen) {
|
||||||
|
//$$ GuiInfoPopup.open(overlay,
|
||||||
|
//$$ new GuiLabel().setI18nText("replaymod.gui.noquickmode", QUICK_MODE_MIN_MC).setColor(Colors.BLACK));
|
||||||
|
//$$ }
|
||||||
|
//$$
|
||||||
|
//$$ public void setQuickMode(@SuppressWarnings("unused") boolean quickMode) {
|
||||||
|
//$$ throw new UnsupportedOperationException("Quick Mode not supported on this version.");
|
||||||
|
//$$ }
|
||||||
|
//$$
|
||||||
|
//$$ public boolean isQuickMode() {
|
||||||
|
//$$ return false;
|
||||||
|
//$$ }
|
||||||
|
//#endif
|
||||||
|
|
||||||
public int getReplayDuration() {
|
public int getReplayDuration() {
|
||||||
return replayDuration;
|
return replayDuration;
|
||||||
@@ -460,10 +496,12 @@ public class ReplayHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void doJump(int targetTime, boolean retainCameraPosition) {
|
public void doJump(int targetTime, boolean retainCameraPosition) {
|
||||||
|
//#if MC>=10904
|
||||||
if (getReplaySender() == quickReplaySender) {
|
if (getReplaySender() == quickReplaySender) {
|
||||||
quickReplaySender.sendPacketsTill(targetTime);
|
quickReplaySender.sendPacketsTill(targetTime);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
//#endif
|
||||||
FullReplaySender replaySender = fullReplaySender;
|
FullReplaySender replaySender = fullReplaySender;
|
||||||
|
|
||||||
if (replaySender.isHurrying()) {
|
if (replaySender.isHurrying()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user