Get recording and replay working
This commit is contained in:
@@ -48,8 +48,10 @@ import net.minecraft.world.GameType;
|
||||
//$$ import net.minecraft.world.WorldSettings.GameType;
|
||||
//#endif
|
||||
//#if MC>=10904
|
||||
import net.minecraft.network.login.server.SPacketLoginSuccess;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
//#else
|
||||
//$$ import net.minecraft.network.login.server.S02PacketLoginSuccess;
|
||||
//$$ import net.minecraft.util.IChatComponent;
|
||||
//#endif
|
||||
|
||||
@@ -123,6 +125,9 @@ public class FullReplaySender extends ChannelDuplexHandler implements ReplaySend
|
||||
|
||||
private static int TP_DISTANCE_LIMIT = 128;
|
||||
|
||||
private static final ByteBuf byteBuf = Unpooled.buffer();
|
||||
private static final ByteBufOutputStream byteBufOut = new ByteBufOutputStream(byteBuf);
|
||||
|
||||
/**
|
||||
* The replay handler responsible for the current replay.
|
||||
*/
|
||||
@@ -165,12 +170,22 @@ public class FullReplaySender extends ChannelDuplexHandler implements ReplaySend
|
||||
*/
|
||||
protected ReplayInputStream replayIn;
|
||||
|
||||
/**
|
||||
* @see PacketData#PacketData(ReplayInputStream, ReplayOutputStream)
|
||||
*/
|
||||
private ReplayOutputStream encoder;
|
||||
|
||||
/**
|
||||
* The next packet that should be sent.
|
||||
* This is required as some actions such as jumping to a specified timestamp have to peek at the next packet.
|
||||
*/
|
||||
protected PacketData nextPacket;
|
||||
|
||||
/**
|
||||
* Whether we're currently reading packets from the login phase.
|
||||
*/
|
||||
private boolean loginPhase;
|
||||
|
||||
/**
|
||||
* Whether we need to restart the current replay. E.g. when jumping backwards in time
|
||||
*/
|
||||
@@ -317,7 +332,11 @@ public class FullReplaySender extends ChannelDuplexHandler implements ReplaySend
|
||||
if (world(mc) != null) {
|
||||
for (EntityPlayer playerEntity : playerEntities(world(mc))) {
|
||||
if (!playerEntity.addedToChunk && playerEntity instanceof EntityOtherPlayerMP) {
|
||||
// FIXME playerEntity.onLivingUpdate();
|
||||
//#if MC>=11300
|
||||
playerEntity.livingTick();
|
||||
//#else
|
||||
//$$ playerEntity.onLivingUpdate();
|
||||
//#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -416,10 +435,11 @@ public class FullReplaySender extends ChannelDuplexHandler implements ReplaySend
|
||||
|
||||
int i = readVarInt(pb);
|
||||
|
||||
EnumConnectionState state = loginPhase ? EnumConnectionState.LOGIN : EnumConnectionState.PLAY;
|
||||
//#if MC>=10800
|
||||
Packet p = EnumConnectionState.PLAY.getPacket(EnumPacketDirection.CLIENTBOUND, i);
|
||||
Packet p = state.getPacket(EnumPacketDirection.CLIENTBOUND, i);
|
||||
//#else
|
||||
//$$ Packet p = Packet.generatePacket(EnumConnectionState.PLAY.func_150755_b(), i);
|
||||
//$$ Packet p = Packet.generatePacket(state.func_150755_b(), i);
|
||||
//#endif
|
||||
p.readPacketData(pb);
|
||||
|
||||
@@ -432,6 +452,15 @@ public class FullReplaySender extends ChannelDuplexHandler implements ReplaySend
|
||||
* @return The processed packet or {@code null} if no packet shall be sent
|
||||
*/
|
||||
protected Packet processPacket(Packet p) throws Exception {
|
||||
//#if MC>=10904
|
||||
if (p instanceof SPacketLoginSuccess) {
|
||||
//#else
|
||||
//$$ if (p instanceof S02PacketLoginSuccess) {
|
||||
//#endif
|
||||
loginPhase = false;
|
||||
return p;
|
||||
}
|
||||
|
||||
//#if MC>=10904
|
||||
if (p instanceof SPacketCustomPayload) {
|
||||
SPacketCustomPayload packet = (SPacketCustomPayload) p;
|
||||
@@ -584,7 +613,7 @@ public class FullReplaySender extends ChannelDuplexHandler implements ReplaySend
|
||||
//#endif
|
||||
EnumDifficulty difficulty = packet.getDifficulty();
|
||||
//#if MC>=11300
|
||||
int maxPlayers = 0;// FIXME needs AT packet.maxPlayers;
|
||||
int maxPlayers = packet.maxPlayers;
|
||||
//#else
|
||||
//$$ int maxPlayers = packet.getMaxPlayers();
|
||||
//#endif
|
||||
@@ -832,7 +861,8 @@ public class FullReplaySender extends ChannelDuplexHandler implements ReplaySend
|
||||
while (!terminate) {
|
||||
synchronized (FullReplaySender.this) {
|
||||
if (replayIn == null) {
|
||||
replayIn = replayFile.getPacketData();
|
||||
replayIn = replayFile.getPacketData(new ReplayStudio(), true);
|
||||
encoder = new ReplayOutputStream(new ReplayStudio(), byteBufOut, true);
|
||||
}
|
||||
// Packet loop
|
||||
while (true) {
|
||||
@@ -859,7 +889,7 @@ public class FullReplaySender extends ChannelDuplexHandler implements ReplaySend
|
||||
|
||||
// Read the next packet if we don't already have one
|
||||
if (nextPacket == null) {
|
||||
nextPacket = new PacketData(replayIn);
|
||||
nextPacket = new PacketData(replayIn, encoder);
|
||||
}
|
||||
|
||||
int nextTimeStamp = nextPacket.timestamp;
|
||||
@@ -912,6 +942,7 @@ public class FullReplaySender extends ChannelDuplexHandler implements ReplaySend
|
||||
// Restart the replay.
|
||||
hasWorldLoaded = false;
|
||||
lastTimeStamp = 0;
|
||||
loginPhase = true;
|
||||
startFromBeginning = false;
|
||||
nextPacket = null;
|
||||
lastPacketSent = System.currentTimeMillis();
|
||||
@@ -1025,13 +1056,15 @@ public class FullReplaySender extends ChannelDuplexHandler implements ReplaySend
|
||||
replayIn.close();
|
||||
replayIn = null;
|
||||
}
|
||||
loginPhase = true;
|
||||
startFromBeginning = false;
|
||||
nextPacket = null;
|
||||
replayHandler.restartedReplay();
|
||||
}
|
||||
|
||||
if (replayIn == null) {
|
||||
replayIn = replayFile.getPacketData();
|
||||
replayIn = replayFile.getPacketData(new ReplayStudio(), true);
|
||||
encoder = new ReplayOutputStream(new ReplayStudio(), byteBufOut, true);
|
||||
}
|
||||
|
||||
while (true) { // Send packets
|
||||
@@ -1043,7 +1076,7 @@ public class FullReplaySender extends ChannelDuplexHandler implements ReplaySend
|
||||
nextPacket = null;
|
||||
} else {
|
||||
// Otherwise read one from the input stream
|
||||
pd = new PacketData(replayIn);
|
||||
pd = new PacketData(replayIn, encoder);
|
||||
}
|
||||
|
||||
int nextTimeStamp = pd.timestamp;
|
||||
@@ -1176,19 +1209,16 @@ public class FullReplaySender extends ChannelDuplexHandler implements ReplaySend
|
||||
}
|
||||
|
||||
private static final class PacketData {
|
||||
private static final ByteBuf byteBuf = Unpooled.buffer();
|
||||
private static final ByteBufOutputStream byteBufOut = new ByteBufOutputStream(byteBuf);
|
||||
private static final ReplayOutputStream encoder = new ReplayOutputStream(new ReplayStudio(), byteBufOut);
|
||||
private final int timestamp;
|
||||
private final byte[] bytes;
|
||||
|
||||
public PacketData(ReplayInputStream in) throws IOException {
|
||||
PacketData(ReplayInputStream in, ReplayOutputStream encoder) throws IOException {
|
||||
com.replaymod.replaystudio.PacketData data = in.readPacket();
|
||||
timestamp = (int) data.getTime();
|
||||
// We need to re-encode MCProtocolLib packets, so we can later decode them as NMS packets
|
||||
// The main reason we aren't reading them as NMS packets is that we want ReplayStudio to be able
|
||||
// to apply ViaVersion (and potentially other magic) to it.
|
||||
synchronized (encoder) {
|
||||
synchronized (byteBuf) {
|
||||
byteBuf.markReaderIndex(); // Mark the current reader and writer index (should be at start)
|
||||
byteBuf.markWriterIndex();
|
||||
|
||||
|
||||
@@ -3,18 +3,19 @@ package com.replaymod.replay;
|
||||
import com.replaymod.core.utils.WrappedTimer;
|
||||
import com.replaymod.replay.camera.CameraController;
|
||||
import com.replaymod.replay.camera.CameraEntity;
|
||||
import com.replaymod.replay.events.ReplayDispatchKeypressesEvent;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.crash.CrashReport;
|
||||
import net.minecraft.util.Timer;
|
||||
import net.minecraftforge.client.ForgeHooksClient;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
//#if MC>=11300
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
//#else
|
||||
//$$ import com.replaymod.replay.events.ReplayDispatchKeypressesEvent;
|
||||
//$$ import net.minecraft.client.gui.GuiScreen;
|
||||
//$$ import net.minecraft.client.settings.GameSettings;
|
||||
//$$ import net.minecraft.client.settings.KeyBinding;
|
||||
//$$ import net.minecraft.crash.CrashReport;
|
||||
//$$ import net.minecraftforge.client.ForgeHooksClient;
|
||||
//$$ import net.minecraftforge.common.MinecraftForge;
|
||||
//$$ import org.lwjgl.input.Keyboard;
|
||||
//$$ import org.lwjgl.input.Mouse;
|
||||
//#if MC>=10800
|
||||
@@ -28,6 +29,7 @@ import net.minecraftforge.common.MinecraftForge;
|
||||
//$$
|
||||
//$$ import static com.replaymod.core.versions.MCVer.FML_BUS;
|
||||
//#endif
|
||||
//$$ import static com.replaymod.core.versions.MCVer.newReportedException;
|
||||
//#endif
|
||||
|
||||
public class InputReplayTimer extends WrappedTimer {
|
||||
@@ -40,10 +42,14 @@ public class InputReplayTimer extends WrappedTimer {
|
||||
this.mc = mod.getCore().getMinecraft();
|
||||
}
|
||||
|
||||
/* FIXME
|
||||
@Override
|
||||
public void updateTimer() {
|
||||
super.updateTimer();
|
||||
//#if MC>=11300
|
||||
public void updateTimer(long sysClock) {
|
||||
super.updateTimer(sysClock);
|
||||
//#else
|
||||
//$$ public void updateTimer() {
|
||||
//$$ super.updateTimer();
|
||||
//#endif
|
||||
|
||||
// 1.7.10: We have to run the scheduled executables (ours only) because MC would only run them every tick
|
||||
//#if MC<=10710
|
||||
@@ -53,43 +59,41 @@ public class InputReplayTimer extends WrappedTimer {
|
||||
// If we are in a replay, we have to manually process key and mouse events as the
|
||||
// tick speed may vary or there may not be any ticks at all (when the replay is paused)
|
||||
if (mod.getReplayHandler() != null) {
|
||||
//#if MC>=11300
|
||||
if (mc.currentScreen == null || mc.currentScreen.allowUserInput) {
|
||||
while (Mouse.next()) {
|
||||
handleMouseEvent();
|
||||
}
|
||||
|
||||
while (Keyboard.next()) {
|
||||
handleKeyEvent();
|
||||
}
|
||||
} else {
|
||||
GLFW.glfwPollEvents();
|
||||
mc.processKeyBinds();
|
||||
}
|
||||
mc.keyboardListener.tick();
|
||||
//#else
|
||||
//$$ if (mc.currentScreen == null || mc.currentScreen.allowUserInput) {
|
||||
//$$ while (Mouse.next()) {
|
||||
//$$ handleMouseEvent();
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ while (Keyboard.next()) {
|
||||
//$$ handleKeyEvent();
|
||||
//$$ }
|
||||
//$$ } else {
|
||||
//#if MC<11300
|
||||
//#if MC>=10800
|
||||
try {
|
||||
mc.currentScreen.handleInput();
|
||||
} catch (IOException e) { // *SIGH*
|
||||
e.printStackTrace();
|
||||
}
|
||||
//$$ try {
|
||||
//$$ mc.currentScreen.handleInput();
|
||||
//$$ } catch (IOException e) { // *SIGH*
|
||||
//$$ e.printStackTrace();
|
||||
//$$ }
|
||||
//#else
|
||||
//$$ mc.currentScreen.handleInput();
|
||||
//#endif
|
||||
}
|
||||
//#endif
|
||||
//$$ }
|
||||
//#endif
|
||||
}
|
||||
}
|
||||
|
||||
protected void handleMouseEvent() {
|
||||
if (ForgeHooksClient.postMouseEvent()) return;
|
||||
|
||||
int button = Mouse.getEventButton() - 100;
|
||||
boolean pressed = Mouse.getEventButtonState();
|
||||
|
||||
// Update key binding states
|
||||
KeyBinding.setKeyBindState(button, pressed);
|
||||
if (pressed) {
|
||||
KeyBinding.onTick(button);
|
||||
}
|
||||
|
||||
int wheel = Mouse.getEventDWheel();
|
||||
public static void handleScroll(int wheel) {
|
||||
if (wheel != 0) {
|
||||
ReplayHandler replayHandler = mod.getReplayHandler();
|
||||
ReplayHandler replayHandler = ReplayModReplay.instance.getReplayHandler();
|
||||
if (replayHandler != null) {
|
||||
CameraEntity cameraEntity = replayHandler.getCameraEntity();
|
||||
if (cameraEntity != null) {
|
||||
@@ -105,164 +109,181 @@ public class InputReplayTimer extends WrappedTimer {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mc.currentScreen == null) {
|
||||
if (!mc.inGameHasFocus && Mouse.getEventButtonState()) {
|
||||
// Regrab mouse if the user clicks into the window
|
||||
mc.setIngameFocus();
|
||||
}
|
||||
} else {
|
||||
//#if MC<11300
|
||||
//$$ protected void handleMouseEvent() {
|
||||
//$$ if (ForgeHooksClient.postMouseEvent()) return;
|
||||
//$$
|
||||
//$$ int button = Mouse.getEventButton() - 100;
|
||||
//$$ boolean pressed = Mouse.getEventButtonState();
|
||||
//$$
|
||||
//$$ // Update key binding states
|
||||
//$$ KeyBinding.setKeyBindState(button, pressed);
|
||||
//$$ if (pressed) {
|
||||
//$$ KeyBinding.onTick(button);
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ int wheel = Mouse.getEventDWheel();
|
||||
//$$ handleScroll(wheel);
|
||||
//$$
|
||||
//$$ if (mc.currentScreen == null) {
|
||||
//$$ if (!mc.inGameHasFocus && Mouse.getEventButtonState()) {
|
||||
//$$ // Regrab mouse if the user clicks into the window
|
||||
//$$ mc.setIngameFocus();
|
||||
//$$ }
|
||||
//$$ } else {
|
||||
//#if MC>=10800
|
||||
try {
|
||||
mc.currentScreen.handleMouseInput();
|
||||
} catch (IOException e) { // WHO IS RESPONSIBLE FOR THIS MESS?!?
|
||||
e.printStackTrace();
|
||||
}
|
||||
//$$ try {
|
||||
//$$ mc.currentScreen.handleMouseInput();
|
||||
//$$ } catch (IOException e) { // WHO IS RESPONSIBLE FOR THIS MESS?!?
|
||||
//$$ e.printStackTrace();
|
||||
//$$ }
|
||||
//#else
|
||||
//$$ mc.currentScreen.handleMouseInput();
|
||||
//#endif
|
||||
}
|
||||
|
||||
FMLCommonHandler.instance().fireMouseInput();
|
||||
}
|
||||
|
||||
protected void handleKeyEvent() {
|
||||
// TODO 1.7.10: This might be missing some 1.7.10-only key bindings or implement some of them incorrectly
|
||||
int key = Keyboard.getEventKey() == 0 ? Keyboard.getEventCharacter() + 256 : Keyboard.getEventKey();
|
||||
boolean pressed = Keyboard.getEventKeyState();
|
||||
|
||||
KeyBinding.setKeyBindState(key, pressed);
|
||||
if (pressed) {
|
||||
KeyBinding.onTick(key);
|
||||
}
|
||||
|
||||
// Still want to be able to create debug crashes ]:D
|
||||
if (mc.debugCrashKeyPressTime > 0) {
|
||||
if (Minecraft.getSystemTime() - mc.debugCrashKeyPressTime >= 6000L) {
|
||||
throw new ReportedException(new CrashReport("Manually triggered debug crash", new Throwable()));
|
||||
}
|
||||
|
||||
if (!Keyboard.isKeyDown(Keyboard.KEY_F3) || !Keyboard.isKeyDown(Keyboard.KEY_C)) {
|
||||
mc.debugCrashKeyPressTime = -1;
|
||||
}
|
||||
} else if (Keyboard.isKeyDown(Keyboard.KEY_F3) && Keyboard.isKeyDown(Keyboard.KEY_C)) {
|
||||
mc.debugCrashKeyPressTime = Minecraft.getSystemTime();
|
||||
}
|
||||
|
||||
// Twitch, screenshot, fullscreen, etc. (stuff that works everywhere)
|
||||
if (!MinecraftForge.EVENT_BUS.post(new ReplayDispatchKeypressesEvent.Pre())) {
|
||||
mc.dispatchKeypresses();
|
||||
}
|
||||
|
||||
if (pressed) {
|
||||
// This might be subject to change as vanilla shaders are still kinda unused in 1.8
|
||||
if (key == Keyboard.KEY_F4 && mc.entityRenderer != null) {
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ FMLCommonHandler.instance().fireMouseInput();
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ protected void handleKeyEvent() {
|
||||
//$$ // TODO 1.7.10: This might be missing some 1.7.10-only key bindings or implement some of them incorrectly
|
||||
//$$ int key = Keyboard.getEventKey() == 0 ? Keyboard.getEventCharacter() + 256 : Keyboard.getEventKey();
|
||||
//$$ boolean pressed = Keyboard.getEventKeyState();
|
||||
//$$
|
||||
//$$ KeyBinding.setKeyBindState(key, pressed);
|
||||
//$$ if (pressed) {
|
||||
//$$ KeyBinding.onTick(key);
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ // Still want to be able to create debug crashes ]:D
|
||||
//$$ if (mc.debugCrashKeyPressTime > 0) {
|
||||
//$$ if (Minecraft.getSystemTime() - mc.debugCrashKeyPressTime >= 6000L) {
|
||||
//$$ throw newReportedException(new CrashReport("Manually triggered debug crash", new Throwable()));
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ if (!Keyboard.isKeyDown(Keyboard.KEY_F3) || !Keyboard.isKeyDown(Keyboard.KEY_C)) {
|
||||
//$$ mc.debugCrashKeyPressTime = -1;
|
||||
//$$ }
|
||||
//$$ } else if (Keyboard.isKeyDown(Keyboard.KEY_F3) && Keyboard.isKeyDown(Keyboard.KEY_C)) {
|
||||
//$$ mc.debugCrashKeyPressTime = Minecraft.getSystemTime();
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ // Twitch, screenshot, fullscreen, etc. (stuff that works everywhere)
|
||||
//$$ if (!MinecraftForge.EVENT_BUS.post(new ReplayDispatchKeypressesEvent.Pre())) {
|
||||
//$$ mc.dispatchKeypresses();
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ if (pressed) {
|
||||
//$$ // This might be subject to change as vanilla shaders are still kinda unused in 1.8
|
||||
//$$ if (key == Keyboard.KEY_F4 && mc.entityRenderer != null) {
|
||||
//#if MC>=10800
|
||||
mc.entityRenderer.switchUseShader();
|
||||
//$$ mc.entityRenderer.switchUseShader();
|
||||
//#else
|
||||
//$$ mc.entityRenderer.activateNextShader();
|
||||
//#endif
|
||||
}
|
||||
|
||||
if (mc.currentScreen != null) {
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ if (mc.currentScreen != null) {
|
||||
//#if MC>=10800
|
||||
try {
|
||||
mc.currentScreen.handleKeyboardInput();
|
||||
} catch (IOException e) { // AND WHO THOUGHT THIS WAS A GREAT IDEA?
|
||||
e.printStackTrace();
|
||||
}
|
||||
//$$ try {
|
||||
//$$ mc.currentScreen.handleKeyboardInput();
|
||||
//$$ } catch (IOException e) { // AND WHO THOUGHT THIS WAS A GREAT IDEA?
|
||||
//$$ e.printStackTrace();
|
||||
//$$ }
|
||||
//#else
|
||||
//$$ mc.currentScreen.handleKeyboardInput();
|
||||
//#endif
|
||||
} else {
|
||||
if (key == Keyboard.KEY_ESCAPE) {
|
||||
mc.displayInGameMenu();
|
||||
}
|
||||
|
||||
// Following are a ton of vanilla keyboard shortcuts, some are removed as they're useless in the
|
||||
// replay viewer as of now
|
||||
// TODO Update maybe add new key bindings
|
||||
// TODO: Translate magic values to Keyboard.KEY_ constants
|
||||
|
||||
if (key == 32 && Keyboard.isKeyDown(61) && mc.ingameGUI != null) {
|
||||
//$$ } else {
|
||||
//$$ if (key == Keyboard.KEY_ESCAPE) {
|
||||
//$$ mc.displayInGameMenu();
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ // Following are a ton of vanilla keyboard shortcuts, some are removed as they're useless in the
|
||||
//$$ // replay viewer as of now
|
||||
//$$ // TODO Update maybe add new key bindings
|
||||
//$$ // TODO: Translate magic values to Keyboard.KEY_ constants
|
||||
//$$
|
||||
//$$ if (key == 32 && Keyboard.isKeyDown(61) && mc.ingameGUI != null) {
|
||||
//#if MC>=11100
|
||||
mc.ingameGUI.getChatGUI().clearChatMessages(false);
|
||||
//$$ mc.ingameGUI.getChatGUI().clearChatMessages(false);
|
||||
//#else
|
||||
//$$ mc.ingameGUI.getChatGUI().clearChatMessages();
|
||||
//#endif
|
||||
}
|
||||
|
||||
if (key == 31 && Keyboard.isKeyDown(61)) {
|
||||
mc.refreshResources();
|
||||
}
|
||||
|
||||
if (key == 20 && Keyboard.isKeyDown(61)) {
|
||||
mc.refreshResources();
|
||||
}
|
||||
|
||||
if (key == 33 && Keyboard.isKeyDown(61)) {
|
||||
boolean flag1 = Keyboard.isKeyDown(42) | Keyboard.isKeyDown(54);
|
||||
mc.gameSettings.setOptionValue(GameSettings.Options.RENDER_DISTANCE, flag1 ? -1 : 1);
|
||||
}
|
||||
|
||||
if (key == 30 && Keyboard.isKeyDown(61)) {
|
||||
mc.renderGlobal.loadRenderers();
|
||||
}
|
||||
|
||||
if (key == 48 && Keyboard.isKeyDown(61)) {
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ if (key == 31 && Keyboard.isKeyDown(61)) {
|
||||
//$$ mc.refreshResources();
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ if (key == 20 && Keyboard.isKeyDown(61)) {
|
||||
//$$ mc.refreshResources();
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ if (key == 33 && Keyboard.isKeyDown(61)) {
|
||||
//$$ boolean flag1 = Keyboard.isKeyDown(42) | Keyboard.isKeyDown(54);
|
||||
//$$ mc.gameSettings.setOptionValue(GameSettings.Options.RENDER_DISTANCE, flag1 ? -1 : 1);
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ if (key == 30 && Keyboard.isKeyDown(61)) {
|
||||
//$$ mc.renderGlobal.loadRenderers();
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ if (key == 48 && Keyboard.isKeyDown(61)) {
|
||||
//#if MC>=10800
|
||||
mc.getRenderManager().setDebugBoundingBox(!mc.getRenderManager().isDebugBoundingBox());
|
||||
//$$ mc.getRenderManager().setDebugBoundingBox(!mc.getRenderManager().isDebugBoundingBox());
|
||||
//#else
|
||||
//$$ RenderManager.debugBoundingBox = !RenderManager.debugBoundingBox;
|
||||
//#endif
|
||||
}
|
||||
|
||||
if (key == 25 && Keyboard.isKeyDown(61)) {
|
||||
mc.gameSettings.pauseOnLostFocus = !mc.gameSettings.pauseOnLostFocus;
|
||||
mc.gameSettings.saveOptions();
|
||||
}
|
||||
|
||||
if (key == 59) {
|
||||
mc.gameSettings.hideGUI = !mc.gameSettings.hideGUI;
|
||||
}
|
||||
|
||||
if (key == 61) {
|
||||
mc.gameSettings.showDebugInfo = !mc.gameSettings.showDebugInfo;
|
||||
mc.gameSettings.showDebugProfilerChart = GuiScreen.isShiftKeyDown();
|
||||
}
|
||||
|
||||
if (mc.gameSettings.keyBindTogglePerspective.isPressed()) {
|
||||
mc.gameSettings.thirdPersonView = (mc.gameSettings.thirdPersonView + 1) % 3;
|
||||
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ if (key == 25 && Keyboard.isKeyDown(61)) {
|
||||
//$$ mc.gameSettings.pauseOnLostFocus = !mc.gameSettings.pauseOnLostFocus;
|
||||
//$$ mc.gameSettings.saveOptions();
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ if (key == 59) {
|
||||
//$$ mc.gameSettings.hideGUI = !mc.gameSettings.hideGUI;
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ if (key == 61) {
|
||||
//$$ mc.gameSettings.showDebugInfo = !mc.gameSettings.showDebugInfo;
|
||||
//$$ mc.gameSettings.showDebugProfilerChart = GuiScreen.isShiftKeyDown();
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ if (mc.gameSettings.keyBindTogglePerspective.isPressed()) {
|
||||
//$$ mc.gameSettings.thirdPersonView = (mc.gameSettings.thirdPersonView + 1) % 3;
|
||||
//$$
|
||||
//#if MC>=10800
|
||||
if (mc.entityRenderer != null) { // Extra check, not in vanilla code
|
||||
if (mc.gameSettings.thirdPersonView == 0) {
|
||||
mc.entityRenderer.loadEntityShader(mc.getRenderViewEntity());
|
||||
} else if (mc.gameSettings.thirdPersonView == 1) {
|
||||
mc.entityRenderer.loadEntityShader(null);
|
||||
}
|
||||
}
|
||||
//$$ if (mc.entityRenderer != null) { // Extra check, not in vanilla code
|
||||
//$$ if (mc.gameSettings.thirdPersonView == 0) {
|
||||
//$$ mc.entityRenderer.loadEntityShader(mc.getRenderViewEntity());
|
||||
//$$ } else if (mc.gameSettings.thirdPersonView == 1) {
|
||||
//$$ mc.entityRenderer.loadEntityShader(null);
|
||||
//$$ }
|
||||
//$$ }
|
||||
//#endif
|
||||
}
|
||||
}
|
||||
|
||||
// Navigation in the debug chart
|
||||
if (mc.gameSettings.showDebugInfo && mc.gameSettings.showDebugProfilerChart) {
|
||||
if (key == Keyboard.KEY_0) {
|
||||
mc.updateDebugProfilerName(0);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
if (key == 2 + i) {
|
||||
mc.updateDebugProfilerName(i + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FMLCommonHandler.instance().fireKeyInput();
|
||||
}
|
||||
*/
|
||||
//$$ }
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ // Navigation in the debug chart
|
||||
//$$ if (mc.gameSettings.showDebugInfo && mc.gameSettings.showDebugProfilerChart) {
|
||||
//$$ if (key == Keyboard.KEY_0) {
|
||||
//$$ mc.updateDebugProfilerName(0);
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ for (int i = 0; i < 9; ++i) {
|
||||
//$$ if (key == 2 + i) {
|
||||
//$$ mc.updateDebugProfilerName(i + 1);
|
||||
//$$ }
|
||||
//$$ }
|
||||
//$$ }
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ FMLCommonHandler.instance().fireKeyInput();
|
||||
//$$ }
|
||||
//#endif
|
||||
|
||||
//#if MC<=10710
|
||||
//$$ public static class RunScheduledTasks extends Event {}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
//#if MC>=10904
|
||||
package com.replaymod.replay;
|
||||
|
||||
import com.github.steveice10.mc.auth.data.GameProfile;
|
||||
import com.github.steveice10.mc.protocol.data.game.PlayerListEntry;
|
||||
import com.github.steveice10.mc.protocol.data.game.PlayerListEntryAction;
|
||||
import com.github.steveice10.mc.protocol.data.game.chunk.BlockStorage;
|
||||
@@ -28,6 +29,7 @@ import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerMultiB
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerNotifyClientPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerUnloadChunkPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerUpdateTimePacket;
|
||||
import com.github.steveice10.mc.protocol.packet.login.server.LoginSuccessPacket;
|
||||
import com.github.steveice10.mc.protocol.util.NetUtil;
|
||||
import com.github.steveice10.packetlib.io.NetInput;
|
||||
import com.github.steveice10.packetlib.io.NetOutput;
|
||||
@@ -209,6 +211,7 @@ public class QuickReplaySender extends ChannelHandlerAdapter implements ReplaySe
|
||||
public void restart() {
|
||||
activeThings.clear();
|
||||
currentTimeStamp = 0;
|
||||
ctx.fireChannelRead(toMC(new LoginSuccessPacket(new GameProfile(UUID.nameUUIDFromBytes(new byte[0]), "Player")), EnumConnectionState.LOGIN));
|
||||
ctx.fireChannelRead(toMC(new ServerRespawnPacket(0, Difficulty.NORMAL, GameMode.SPECTATOR, WorldType.DEFAULT)));
|
||||
ctx.fireChannelRead(toMC(new ServerPlayerPositionRotationPacket(0, 0, 0, 0, 0, 0)));
|
||||
}
|
||||
@@ -624,6 +627,10 @@ public class QuickReplaySender extends ChannelHandlerAdapter implements ReplaySe
|
||||
private static final Deflater deflater = new Deflater();
|
||||
|
||||
private static Packet<?> toMC(com.github.steveice10.packetlib.packet.Packet packet) {
|
||||
return toMC(packet, EnumConnectionState.PLAY);
|
||||
}
|
||||
|
||||
private static Packet<?> toMC(com.github.steveice10.packetlib.packet.Packet packet, EnumConnectionState state) {
|
||||
// We need to re-encode MCProtocolLib packets, so we can then decode them as NMS packets
|
||||
// The main reason we aren't reading them as NMS packets is that we want ReplayStudio to be able
|
||||
// to apply ViaVersion (and potentially other magic) to it.
|
||||
@@ -642,7 +649,7 @@ public class QuickReplaySender extends ChannelHandlerAdapter implements ReplaySe
|
||||
//#else
|
||||
//$$ packetBuf.readVarIntFromBuffer();
|
||||
//#endif
|
||||
Packet<?> mcPacket = EnumConnectionState.PLAY.getPacket(EnumPacketDirection.CLIENTBOUND, packetId);
|
||||
Packet<?> mcPacket = state.getPacket(EnumPacketDirection.CLIENTBOUND, packetId);
|
||||
mcPacket.readPacketData(packetBuf);
|
||||
return mcPacket;
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -49,7 +49,6 @@ import net.minecraft.entity.EntityLivingBase;
|
||||
//#if MC>=10800
|
||||
import net.minecraft.network.EnumPacketDirection;
|
||||
//#if MC>=11300
|
||||
import net.minecraft.client.network.NetHandlerLoginClient;
|
||||
import net.minecraftforge.fml.network.NetworkHooks;
|
||||
//#else
|
||||
//$$ import com.mojang.authlib.GameProfile;
|
||||
@@ -57,6 +56,7 @@ import net.minecraftforge.fml.network.NetworkHooks;
|
||||
//$$ import net.minecraftforge.fml.client.FMLClientHandler;
|
||||
//$$ import net.minecraftforge.fml.common.network.handshake.NetworkDispatcher;
|
||||
//#endif
|
||||
import net.minecraft.client.network.NetHandlerLoginClient;
|
||||
|
||||
import static net.minecraft.client.renderer.GlStateManager.*;
|
||||
//#else
|
||||
@@ -236,32 +236,25 @@ public class ReplayHandler {
|
||||
|
||||
networkManager.setNetHandler(new NetHandlerLoginClient(networkManager, mc, null, it -> {}));
|
||||
NetworkHooks.registerClientLoginChannel(networkManager);
|
||||
// FIXME make this work (with vanilla and mods) on all other versions again, now that login phase is included
|
||||
// probably have to change some of the forge handshake calls
|
||||
//#else
|
||||
//$$ NetHandlerPlayClient netHandlerPlayClient =
|
||||
//$$ new NetHandlerPlayClient(mc, null, networkManager, new GameProfile(UUID.randomUUID(), "Player"));
|
||||
//$$ networkManager.setNetHandler(netHandlerPlayClient);
|
||||
//$$ FMLClientHandler.instance().setPlayClient(netHandlerPlayClient);
|
||||
//$$ NetHandlerLoginClient netHandlerLoginClient =
|
||||
//$$ new NetHandlerLoginClient(networkManager, mc, null);
|
||||
//$$ networkManager.setNetHandler(netHandlerLoginClient);
|
||||
//$$
|
||||
//#if MC>=11200
|
||||
//$$ channel = new EmbeddedChannel();
|
||||
//$$ NetworkDispatcher networkDispatcher = new NetworkDispatcher(networkManager);
|
||||
//$$ channel.attr(NetworkDispatcher.FML_DISPATCHER).set(networkDispatcher);
|
||||
//$$
|
||||
//$$ channel.pipeline().addFirst("ReplayModReplay_replaySender", fullReplaySender);
|
||||
//$$ channel.pipeline().addFirst("ReplayModReplay_quickReplaySender", quickReplaySender);
|
||||
//$$ channel.pipeline().addLast("packet_handler", networkManager);
|
||||
//$$ channel.pipeline().fireChannelActive();
|
||||
//$$ networkDispatcher.clientToServerHandshake();
|
||||
//#else
|
||||
//$$ channel = new EmbeddedChannel(networkManager);
|
||||
//$$ NetworkDispatcher networkDispatcher = new NetworkDispatcher(networkManager);
|
||||
//$$ channel.attr(NetworkDispatcher.FML_DISPATCHER).set(networkDispatcher);
|
||||
//$$
|
||||
//$$ 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().fireChannelActive();
|
||||
//#endif
|
||||
//#endif
|
||||
@@ -295,13 +288,6 @@ public class ReplayHandler {
|
||||
//$$ channel.pipeline().addFirst("ReplayModReplay_replaySender", fullReplaySender);
|
||||
//$$ channel.pipeline().addAfter("ReplayModReplay_replaySender", "packet_handler", networkManager);
|
||||
//$$ channel.pipeline().fireChannelActive();
|
||||
//$$
|
||||
//$$ // Call twice to force-overwrite the NetworkManager's internal state
|
||||
//$$ networkManager.setConnectionState(EnumConnectionState.PLAY);
|
||||
//$$ networkManager.getNetHandler().onConnectionStateTransition(EnumConnectionState.LOGIN, EnumConnectionState.PLAY);
|
||||
//$$ networkManager.setConnectionState(EnumConnectionState.PLAY);
|
||||
//$$
|
||||
//$$ FMLNetworkHandler.fmlClientHandshake(networkManager);
|
||||
//#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -172,7 +172,7 @@ public class ReplayModReplay implements Module {
|
||||
});
|
||||
|
||||
Minecraft mc = core.getMinecraft();
|
||||
// FIXME mc.timer = new InputReplayTimer(mc.timer, this);
|
||||
mc.timer = new InputReplayTimer(mc.timer, this);
|
||||
|
||||
new GuiHandler(this).register();
|
||||
}
|
||||
|
||||
@@ -399,7 +399,7 @@ public class GuiReplayViewer extends GuiScreen {
|
||||
} else {
|
||||
server.setText(metaData.getServerName());
|
||||
}
|
||||
incompatible = !new ReplayStudio().isCompatible(metaData.getFileFormatVersion());
|
||||
incompatible = !new ReplayStudio().isCompatible(metaData.getFileFormatVersion(), metaData.getProtocolVersion());
|
||||
if (incompatible) {
|
||||
version.setText("Minecraft " + metaData.getMcVersion());
|
||||
}
|
||||
|
||||
@@ -29,6 +29,9 @@ import static com.replaymod.core.versions.MCVer.*;
|
||||
import static com.replaymod.replay.ReplayModReplay.LOGGER;
|
||||
|
||||
public class GuiHandler {
|
||||
//#if MC>=11300
|
||||
private static final int BUTTON_OPTIONS = 0;
|
||||
//#endif
|
||||
private static final int BUTTON_EXIT_SERVER = 1;
|
||||
private static final int BUTTON_ADVANCEMENTS = 5;
|
||||
private static final int BUTTON_STATS = 6;
|
||||
@@ -86,16 +89,24 @@ public class GuiHandler {
|
||||
case BUTTON_OPEN_TO_LAN:
|
||||
removeButton(event, openToLan = b);
|
||||
break;
|
||||
//#if MC>=11300
|
||||
case BUTTON_OPTIONS:
|
||||
b.width = 200;
|
||||
break;
|
||||
//#endif
|
||||
}
|
||||
}
|
||||
if (achievements != null && stats != null) {
|
||||
moveAllButtonsDirectlyBelowUpwards(buttonList, y(achievements),
|
||||
x(achievements), x(stats) + stats.width);
|
||||
}
|
||||
if (openToLan != null) {
|
||||
moveAllButtonsDirectlyBelowUpwards(buttonList, y(openToLan),
|
||||
x(openToLan), x(openToLan) + openToLan.width);
|
||||
}
|
||||
// In 1.13+ Forge, the Options button shares one row with the Open to LAN button
|
||||
//#if MC<11300
|
||||
//$$ if (openToLan != null) {
|
||||
//$$ moveAllButtonsDirectlyBelowUpwards(buttonList, y(openToLan),
|
||||
//$$ x(openToLan), x(openToLan) + openToLan.width);
|
||||
//$$ }
|
||||
//#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ public class MixinTileEntityEndPortalRenderer {
|
||||
//#endif
|
||||
//#endif
|
||||
//#endif
|
||||
private static long replayModReplay_getEnchantmentTime() {
|
||||
private long replayModReplay_getEnchantmentTime() {
|
||||
ReplayHandler replayHandler = ReplayModReplay.instance.getReplayHandler();
|
||||
if (replayHandler != null) {
|
||||
return replayHandler.getReplaySender().currentTimeStamp();
|
||||
|
||||
Reference in New Issue
Block a user