From a62100071f525f57a00ebfe72cf0f9649bad6ec0 Mon Sep 17 00:00:00 2001 From: Jonas Herzig Date: Sun, 27 Sep 2020 14:34:48 +0200 Subject: [PATCH] Fix camera getting stuck spectating itself (fixes #300) This bug was introduced when we started to record the login phase because it contains the UUID of the local player. In the replay case this will be the UUID of the camera entity but also the one of the recording player, so if the recording player despawns while it is being spectated (e.g. because of a backwards jump), then the camera snaps onto itself and gets stuck in place until one presses Shift. --- .../java/com/replaymod/replay/camera/CameraEntity.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/com/replaymod/replay/camera/CameraEntity.java b/src/main/java/com/replaymod/replay/camera/CameraEntity.java index 8e0cb2bb..b9f0f16d 100644 --- a/src/main/java/com/replaymod/replay/camera/CameraEntity.java +++ b/src/main/java/com/replaymod/replay/camera/CameraEntity.java @@ -80,6 +80,7 @@ import net.minecraft.client.render.entity.PlayerModelPart; //$$ import net.minecraft.util.Session; //#endif +import java.nio.charset.StandardCharsets; import java.util.Map; import java.util.UUID; import java.util.function.Function; @@ -99,6 +100,8 @@ public class CameraEntity //$$ extends EntityClientPlayerMP //#endif { + private static final UUID CAMERA_UUID = UUID.nameUUIDFromBytes("ReplayModCamera".getBytes(StandardCharsets.UTF_8)); + /** * Roll of this camera in degrees. */ @@ -155,6 +158,11 @@ public class CameraEntity , false //#endif ); + //#if MC>=10900 + setUuid(CAMERA_UUID); + //#else + //$$ entityUniqueID = CAMERA_UUID; + //#endif eventHandler.register(); if (ReplayModReplay.instance.getReplayHandler().getSpectatedUUID() == null) { cameraController = ReplayModReplay.instance.createCameraController(this);