Stop spectating when applying camera keyframe

This commit is contained in:
Moulberry committed 2025-02-11 18:31:09 +08:00
1 parent 7b9f11f60d
commit a6bb7bf506
4 files changed
+22

No files matched your search

@@ -9,9 +9,11 @@ import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.stats.Stat;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.RecipeHolder;
import net.minecraft.world.level.biome.BiomeManager;
import org.jetbrains.annotations.Nullable;
import java.util.Collection;
import java.util.UUID;
@@ -43,6 +45,15 @@ public class ReplayPlayer extends ServerPlayer {
serverLevel.isDebug(), serverLevel.isFlat(), this.getLastDeathLocation(), this.getPortalCooldown());
}
@Override
public void setCamera(@Nullable Entity entity) {
super.setCamera(entity);
if (entity == null) {
this.spectatingUuid = null;
}
}
@Override
public int awardRecipes(Collection<RecipeHolder<?>> collection) {
return 0;
@@ -885,6 +885,7 @@ public class ReplayServer extends IntegratedServer {
if (targetEntity != null && !targetEntity.isRemoved()) {
replayViewer.setCamera(null);
replayViewer.setCamera(targetEntity);
replayViewer.spectatingUuid = targetEntity.getUUID();
if (replayViewer.forceRespectateTickCount == 0) {
replayViewer.forceRespectateTickCount = 5;