WIP 1.15 and ReplayStudio v2 update
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package com.replaymod.replay;
|
||||
|
||||
import com.github.steveice10.packetlib.io.NetOutput;
|
||||
import com.github.steveice10.packetlib.tcp.io.ByteBufNetOutput;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.io.Files;
|
||||
import com.replaymod.core.ReplayMod;
|
||||
@@ -9,9 +11,6 @@ import com.replaymod.core.utils.Restrictions;
|
||||
import com.replaymod.replay.camera.CameraEntity;
|
||||
import com.replaymod.replaystudio.io.ReplayInputStream;
|
||||
import com.replaymod.replaystudio.replay.ReplayFile;
|
||||
import com.replaymod.replaystudio.studio.ReplayStudio;
|
||||
import com.replaymod.replaystudio.studio.protocol.StudioCodec;
|
||||
import com.replaymod.replaystudio.studio.protocol.StudioSession;
|
||||
import de.johni0702.minecraft.gui.utils.EventRegistrations;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
@@ -26,7 +25,6 @@ import net.minecraft.client.gui.screen.NoticeScreen;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.NetworkState;
|
||||
import net.minecraft.network.ClientConnection;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.util.PacketByteBuf;
|
||||
import net.minecraft.client.network.packet.ChatMessageS2CPacket;
|
||||
@@ -586,12 +584,18 @@ public class FullReplaySender extends ChannelDuplexHandler implements ReplaySend
|
||||
p = new GameJoinS2CPacket(
|
||||
entId,
|
||||
GameMode.SPECTATOR,
|
||||
//#if MC>=11500
|
||||
//$$ packet.getSeed(),
|
||||
//#endif
|
||||
false,
|
||||
packet.getDimension(),
|
||||
0, // max players (has no getter -> never actually used)
|
||||
packet.getGeneratorType(),
|
||||
packet.getChunkLoadDistance(),
|
||||
packet.hasReducedDebugInfo()
|
||||
//#if MC>=11500
|
||||
//$$ , packet.showsDeathScreen()
|
||||
//#endif
|
||||
);
|
||||
//#else
|
||||
//#if MC>=10800
|
||||
@@ -630,7 +634,14 @@ public class FullReplaySender extends ChannelDuplexHandler implements ReplaySend
|
||||
if(p instanceof PlayerRespawnS2CPacket) {
|
||||
PlayerRespawnS2CPacket respawn = (PlayerRespawnS2CPacket) p;
|
||||
//#if MC>=11400
|
||||
p = new PlayerRespawnS2CPacket(respawn.getDimension(), respawn.getGeneratorType(), GameMode.SPECTATOR);
|
||||
p = new PlayerRespawnS2CPacket(
|
||||
respawn.getDimension(),
|
||||
//#if MC>=11500
|
||||
//$$ respawn.method_22425(),
|
||||
//#endif
|
||||
respawn.getGeneratorType(),
|
||||
GameMode.SPECTATOR
|
||||
);
|
||||
//#else
|
||||
//#if MC>=10809
|
||||
//$$ p = new SPacketRespawn(respawn.getDimensionID(),
|
||||
@@ -684,8 +695,8 @@ public class FullReplaySender extends ChannelDuplexHandler implements ReplaySend
|
||||
//#endif
|
||||
|
||||
if(cent != null) {
|
||||
if(!allowMovement && !((Math.abs(cent.x - ppl.getX()) > TP_DISTANCE_LIMIT) ||
|
||||
(Math.abs(cent.z - ppl.getZ()) > TP_DISTANCE_LIMIT))) {
|
||||
if(!allowMovement && !((Math.abs(Entity_getX(cent) - ppl.getX()) > TP_DISTANCE_LIMIT) ||
|
||||
(Math.abs(Entity_getZ(cent) - ppl.getZ()) > TP_DISTANCE_LIMIT))) {
|
||||
return null;
|
||||
} else {
|
||||
allowMovement = false;
|
||||
@@ -813,7 +824,7 @@ public class FullReplaySender extends ChannelDuplexHandler implements ReplaySend
|
||||
while (!terminate) {
|
||||
synchronized (FullReplaySender.this) {
|
||||
if (replayIn == null) {
|
||||
replayIn = replayFile.getPacketData(new ReplayStudio(), true);
|
||||
replayIn = replayFile.getPacketData(getPacketTypeRegistry(true));
|
||||
}
|
||||
// Packet loop
|
||||
while (true) {
|
||||
@@ -1010,7 +1021,7 @@ public class FullReplaySender extends ChannelDuplexHandler implements ReplaySend
|
||||
}
|
||||
|
||||
if (replayIn == null) {
|
||||
replayIn = replayFile.getPacketData(new ReplayStudio(), true);
|
||||
replayIn = replayFile.getPacketData(getPacketTypeRegistry(true));
|
||||
}
|
||||
|
||||
while (true) { // Send packets
|
||||
@@ -1153,8 +1164,7 @@ public class FullReplaySender extends ChannelDuplexHandler implements ReplaySend
|
||||
|
||||
private static final class PacketData {
|
||||
private static final com.github.steveice10.netty.buffer.ByteBuf byteBuf = com.github.steveice10.netty.buffer.Unpooled.buffer();
|
||||
private static final StudioCodec codecLoginPhase = new StudioCodec(new StudioSession(new ReplayStudio(), false, true));
|
||||
private static final StudioCodec codecPlayPhase = new StudioCodec(new StudioSession(new ReplayStudio(), false, false));
|
||||
private static final NetOutput netOutput = new ByteBufNetOutput(byteBuf);
|
||||
|
||||
private final int timestamp;
|
||||
private final byte[] bytes;
|
||||
@@ -1175,25 +1185,25 @@ public class FullReplaySender extends ChannelDuplexHandler implements ReplaySend
|
||||
throw new EOFException();
|
||||
}
|
||||
timestamp = (int) data.getTime();
|
||||
// We need to re-encode MCProtocolLib packets, so we can later decode them as NMS packets
|
||||
com.replaymod.replaystudio.protocol.Packet packet = data.getPacket();
|
||||
// We need to re-encode ReplayStudio 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 (byteBuf) {
|
||||
byteBuf.markReaderIndex(); // Mark the current reader and writer index (should be at start)
|
||||
byteBuf.markWriterIndex();
|
||||
|
||||
try {
|
||||
(loginPhase ? codecLoginPhase : codecPlayPhase).encode(null, data.getPacket(), byteBuf);
|
||||
} catch (Exception e) {
|
||||
throw new IOException(e);
|
||||
}
|
||||
|
||||
bytes = new byte[byteBuf.readableBytes()]; // Create bytes array of sufficient size
|
||||
byteBuf.readBytes(bytes); // Read all data into bytes
|
||||
netOutput.writeVarInt(packet.getId());
|
||||
int idSize = byteBuf.readableBytes();
|
||||
int contentSize = packet.getBuf().readableBytes();
|
||||
bytes = new byte[idSize + contentSize]; // Create bytes array of sufficient size
|
||||
byteBuf.readBytes(bytes, 0, idSize);
|
||||
packet.getBuf().readBytes(bytes, idSize, contentSize);
|
||||
|
||||
byteBuf.resetReaderIndex(); // Reset reader & writer index for next use
|
||||
byteBuf.resetWriterIndex();
|
||||
}
|
||||
packet.getBuf().release();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,14 @@ import net.minecraft.client.MinecraftClient;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import net.minecraft.client.util.ScreenshotUtils;
|
||||
|
||||
//#if MC>=11500
|
||||
//$$ import net.minecraft.client.util.math.MatrixStack;
|
||||
//#endif
|
||||
|
||||
//#if MC>=11300
|
||||
import static com.replaymod.core.versions.MCVer.getWindow;
|
||||
//#endif
|
||||
|
||||
//#if MC<11300
|
||||
//$$ import com.google.common.io.Files;
|
||||
//$$ import org.apache.commons.io.FileUtils;
|
||||
@@ -35,7 +43,7 @@ public class NoGuiScreenshot {
|
||||
}
|
||||
|
||||
//#if MC>=11300
|
||||
int frameWidth = mc.window.getFramebufferWidth(), frameHeight = mc.window.getFramebufferHeight();
|
||||
int frameWidth = getWindow(mc).getFramebufferWidth(), frameHeight = getWindow(mc).getFramebufferHeight();
|
||||
//#else
|
||||
//$$ int frameWidth = mc.displayWidth, frameHeight = mc.displayHeight;
|
||||
//#endif
|
||||
@@ -56,7 +64,13 @@ public class NoGuiScreenshot {
|
||||
GlStateManager.enableTexture();
|
||||
|
||||
//#if MC>=11300
|
||||
mc.gameRenderer.renderWorld(MCVer.getRenderPartialTicks(), System.nanoTime());
|
||||
mc.gameRenderer.renderWorld(
|
||||
MCVer.getRenderPartialTicks(),
|
||||
System.nanoTime()
|
||||
//#if MC>=11500
|
||||
//$$ , new MatrixStack()
|
||||
//#endif
|
||||
);
|
||||
//#else
|
||||
//#if MC>=10809
|
||||
//$$ mc.entityRenderer.updateCameraAndRender(MCVer.getRenderPartialTicks(), System.nanoTime());
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -35,8 +35,11 @@ import net.minecraft.network.ClientConnection;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
//#if MC>=11500
|
||||
//$$ import com.mojang.blaze3d.systems.RenderSystem;
|
||||
//$$ import org.lwjgl.opengl.GL11;
|
||||
//#endif
|
||||
|
||||
//#if MC>=11300
|
||||
import com.replaymod.replay.mixin.EntityLivingBaseAccessor;
|
||||
@@ -393,7 +396,7 @@ public class ReplayHandler {
|
||||
|
||||
CameraEntity cam = getCameraEntity();
|
||||
if (cam != null) {
|
||||
targetCameraPosition = new Location(cam.x, cam.y, cam.z, cam.yaw, cam.pitch);
|
||||
targetCameraPosition = new Location(Entity_getX(cam), Entity_getY(cam), Entity_getZ(cam), cam.yaw, cam.pitch);
|
||||
} else {
|
||||
targetCameraPosition = null;
|
||||
}
|
||||
@@ -535,9 +538,9 @@ public class ReplayHandler {
|
||||
// Update all entity positions (especially prev/lastTick values)
|
||||
for (Entity entity : loadedEntityList(mc.world)) {
|
||||
skipTeleportInterpolation(entity);
|
||||
entity.prevRenderX = entity.prevX = entity.x;
|
||||
entity.prevRenderY = entity.prevY = entity.y;
|
||||
entity.prevRenderZ = entity.prevZ = entity.z;
|
||||
entity.prevRenderX = entity.prevX = Entity_getX(entity);
|
||||
entity.prevRenderY = entity.prevY = Entity_getY(entity);
|
||||
entity.prevRenderZ = entity.prevZ = Entity_getZ(entity);
|
||||
entity.prevYaw = entity.yaw;
|
||||
entity.prevPitch = entity.pitch;
|
||||
}
|
||||
@@ -576,7 +579,7 @@ public class ReplayHandler {
|
||||
if (retainCameraPosition) {
|
||||
CameraEntity cam = getCameraEntity();
|
||||
if (cam != null) {
|
||||
targetCameraPosition = new Location(cam.x, cam.y, cam.z,
|
||||
targetCameraPosition = new Location(Entity_getX(cam), Entity_getY(cam), Entity_getZ(cam),
|
||||
cam.yaw, cam.pitch);
|
||||
} else {
|
||||
targetCameraPosition = null;
|
||||
@@ -618,8 +621,18 @@ public class ReplayHandler {
|
||||
);
|
||||
enableTexture();
|
||||
mc.getFramebuffer().beginWrite(true);
|
||||
//#if MC>=11500
|
||||
//$$ Window window = getWindow(mc);
|
||||
//$$ RenderSystem.clear(256, MinecraftClient.IS_SYSTEM_MAC);
|
||||
//$$ RenderSystem.matrixMode(GL11.GL_PROJECTION);
|
||||
//$$ RenderSystem.loadIdentity();
|
||||
//$$ RenderSystem.ortho(0, window.getFramebufferWidth() / window.getScaleFactor(), window.getFramebufferHeight() / window.getScaleFactor(), 0, 1000, 3000);
|
||||
//$$ RenderSystem.matrixMode(GL11.GL_MODELVIEW);
|
||||
//$$ RenderSystem.loadIdentity();
|
||||
//$$ RenderSystem.translatef(0, 0, -2000);
|
||||
//#else
|
||||
//#if MC>=11400
|
||||
mc.window.method_4493(true);
|
||||
getWindow(mc).method_4493(true);
|
||||
//#else
|
||||
//#if MC>=11300
|
||||
//$$ mc.mainWindow.setupOverlayRendering();
|
||||
@@ -627,6 +640,7 @@ public class ReplayHandler {
|
||||
//$$ mc.entityRenderer.setupOverlayRendering();
|
||||
//#endif
|
||||
//#endif
|
||||
//#endif
|
||||
|
||||
//#if MC>=11300
|
||||
Window
|
||||
@@ -645,17 +659,21 @@ public class ReplayHandler {
|
||||
popMatrix();
|
||||
pushMatrix();
|
||||
//#if MC>=11300
|
||||
mc.getFramebuffer().draw(mc.window.getFramebufferWidth(), mc.window.getFramebufferHeight());
|
||||
mc.getFramebuffer().draw(getWindow(mc).getFramebufferWidth(), getWindow(mc).getFramebufferHeight());
|
||||
//#else
|
||||
//$$ mc.getFramebuffer().framebufferRender(mc.displayWidth, mc.displayHeight);
|
||||
//#endif
|
||||
popMatrix();
|
||||
|
||||
//#if MC>=11500
|
||||
//$$ getWindow(mc).swapBuffers();
|
||||
//#else
|
||||
//#if MC>=11300
|
||||
mc.window.setFullscreen(true);
|
||||
getWindow(mc).setFullscreen(true);
|
||||
//#else
|
||||
//$$ Display.update();
|
||||
//#endif
|
||||
//#endif
|
||||
|
||||
// Send the packets
|
||||
replaySender.sendPacketsTill(targetTime);
|
||||
@@ -676,9 +694,9 @@ public class ReplayHandler {
|
||||
//#endif
|
||||
for (Entity entity : loadedEntityList(mc.world)) {
|
||||
skipTeleportInterpolation(entity);
|
||||
entity.prevRenderX = entity.prevX = entity.x;
|
||||
entity.prevRenderY = entity.prevY = entity.y;
|
||||
entity.prevRenderZ = entity.prevZ = entity.z;
|
||||
entity.prevRenderX = entity.prevX = Entity_getX(entity);
|
||||
entity.prevRenderY = entity.prevY = Entity_getY(entity);
|
||||
entity.prevRenderZ = entity.prevZ = Entity_getZ(entity);
|
||||
entity.prevYaw = entity.yaw;
|
||||
entity.prevPitch = entity.pitch;
|
||||
}
|
||||
|
||||
@@ -33,6 +33,8 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Optional;
|
||||
|
||||
import static com.replaymod.core.versions.MCVer.*;
|
||||
|
||||
public class ReplayModReplay implements Module {
|
||||
|
||||
{ instance = this; }
|
||||
@@ -66,9 +68,9 @@ public class ReplayModReplay implements Module {
|
||||
if (camera != null) {
|
||||
Marker marker = new Marker();
|
||||
marker.setTime(replayHandler.getReplaySender().currentTimeStamp());
|
||||
marker.setX(camera.x);
|
||||
marker.setY(camera.y);
|
||||
marker.setZ(camera.z);
|
||||
marker.setX(Entity_getX(camera));
|
||||
marker.setY(Entity_getY(camera));
|
||||
marker.setZ(Entity_getZ(camera));
|
||||
marker.setYaw(camera.yaw);
|
||||
marker.setPitch(camera.pitch);
|
||||
marker.setRoll(camera.roll);
|
||||
|
||||
@@ -169,7 +169,7 @@ public class CameraEntity
|
||||
* @param z Delta in Z direction
|
||||
*/
|
||||
public void moveCamera(double x, double y, double z) {
|
||||
setCameraPosition(this.x + x, this.y + y, this.z + z);
|
||||
setCameraPosition(Entity_getX(this) + x, Entity_getY(this) + y, Entity_getZ(this) + z);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -179,9 +179,10 @@ public class CameraEntity
|
||||
* @param z Z coordinate
|
||||
*/
|
||||
public void setCameraPosition(double x, double y, double z) {
|
||||
this.prevRenderX = this.prevX = this.x = x;
|
||||
this.prevRenderY = this.prevY = this.y = y;
|
||||
this.prevRenderZ = this.prevZ = this.z = z;
|
||||
this.prevRenderX = this.prevX = x;
|
||||
this.prevRenderY = this.prevY = y;
|
||||
this.prevRenderZ = this.prevZ = z;
|
||||
Entity_setPos(this, x, y, z);
|
||||
updateBoundingBox();
|
||||
}
|
||||
|
||||
@@ -222,9 +223,7 @@ public class CameraEntity
|
||||
this.prevZ = to.prevZ;
|
||||
this.prevYaw = to.prevYaw;
|
||||
this.prevPitch = to.prevPitch;
|
||||
this.x = to.x;
|
||||
this.y = to.y + yOffset;
|
||||
this.z = to.z;
|
||||
Entity_setPos(this, Entity_getX(to), Entity_getY(to), Entity_getZ(to));
|
||||
this.yaw = to.yaw;
|
||||
this.pitch = to.pitch;
|
||||
this.prevRenderX = to.prevRenderX;
|
||||
@@ -243,8 +242,8 @@ public class CameraEntity
|
||||
//#else
|
||||
//$$ this.boundingBox.setBB(AxisAlignedBB.getBoundingBox(
|
||||
//#endif
|
||||
this.x - width / 2, this.y, this.z - width / 2,
|
||||
this.x + width / 2, this.y + height, this.z + width / 2));
|
||||
Entity_getX(this) - width / 2, Entity_getY(this), Entity_getZ(this) - width / 2,
|
||||
Entity_getX(this) + width / 2, Entity_getY(this) + height, Entity_getZ(this) + width / 2));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user