From c1b4964978818ff3f7147d3b161f8c4328b65b52 Mon Sep 17 00:00:00 2001 From: Jonas Herzig Date: Tue, 18 Dec 2018 13:32:26 +0100 Subject: [PATCH] Handle entity position interpolation when jumping in quick mode --- .../com/replaymod/replay/ReplayHandler.java | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/src/main/java/com/replaymod/replay/ReplayHandler.java b/src/main/java/com/replaymod/replay/ReplayHandler.java index 59c06672..3317045b 100755 --- a/src/main/java/com/replaymod/replay/ReplayHandler.java +++ b/src/main/java/com/replaymod/replay/ReplayHandler.java @@ -510,7 +510,48 @@ public class ReplayHandler { public void doJump(int targetTime, boolean retainCameraPosition) { //#if MC>=10904 if (getReplaySender() == quickReplaySender) { + // Always round to full tick + targetTime = targetTime + targetTime % 50; + + if (targetTime >= 50) { + // Jump to time of previous tick first + quickReplaySender.sendPacketsTill(targetTime - 50); + } + + // Update all entity positions (especially prev/lastTick values) + for (Entity entity : loadedEntityList(world(mc))) { + if (entity instanceof EntityOtherPlayerMP) { + EntityOtherPlayerMP e = (EntityOtherPlayerMP) entity; + e.setPosition(e.otherPlayerMPX, e.otherPlayerMPY, e.otherPlayerMPZ); + e.rotationYaw = (float) e.otherPlayerMPYaw; + e.rotationPitch = (float) e.otherPlayerMPPitch; + } + entity.lastTickPosX = entity.prevPosX = entity.posX; + entity.lastTickPosY = entity.prevPosY = entity.posY; + entity.lastTickPosZ = entity.prevPosZ = entity.posZ; + entity.prevRotationYaw = entity.rotationYaw; + entity.prevRotationPitch = entity.rotationPitch; + } + + // Run previous tick + try { + mc.runTick(); + } catch (IOException e) { + throw new RuntimeException(e); + } + + // Jump to target tick quickReplaySender.sendPacketsTill(targetTime); + + // Immediately apply player teleport interpolation + for (Entity entity : loadedEntityList(world(mc))) { + if (entity instanceof EntityOtherPlayerMP) { + EntityOtherPlayerMP e = (EntityOtherPlayerMP) entity; + e.setPosition(e.otherPlayerMPX, e.otherPlayerMPY, e.otherPlayerMPZ); + e.rotationYaw = (float) e.otherPlayerMPYaw; + e.rotationPitch = (float) e.otherPlayerMPPitch; + } + } return; } //#endif