9
0
mirror of https://github.com/LeavesMC/Leaves.git synced 2025-12-30 04:19:30 +00:00

Fix replay api crash with return-nether-portal-fix (#716)

Thank you mojang for set "lastPos" to null instead of the spawning pos.
This commit is contained in:
Lumine1909
2025-08-23 02:53:05 -07:00
committed by GitHub
parent 3feea8e40a
commit 2915edc2a0

View File

@@ -32,7 +32,7 @@ public class ServerPhotographer extends ServerPlayer {
private ServerPlayer followPlayer;
private Recorder recorder;
private File saveFile;
private Vec3 lastPos;
private Vec3 lastPosVec3;
private final ServerStatsCounter stats;
@@ -41,7 +41,7 @@ public class ServerPhotographer extends ServerPlayer {
this.gameMode = new ServerPhotographerGameMode(this);
this.followPlayer = null;
this.stats = new BotStatsCounter(server);
this.lastPos = this.position();
this.lastPosVec3 = this.position();
}
public static ServerPhotographer createPhotographer(@NotNull PhotographerCreateState state) throws IOException {
@@ -76,6 +76,7 @@ public class ServerPhotographer extends ServerPlayer {
@Override
public void tick() {
this.lastPos = this.blockPosition();
super.tick();
if (this.getServer().getTickCount() % 10 == 0) {
@@ -88,12 +89,12 @@ public class ServerPhotographer extends ServerPlayer {
this.getBukkitPlayer().teleport(this.getCamera().getBukkitEntity().getLocation());
this.setCamera(followPlayer);
}
if (lastPos.distanceToSqr(this.position()) > 1024D) {
if (lastPosVec3.distanceToSqr(this.position()) > 1024D) {
this.getBukkitPlayer().teleport(this.getCamera().getBukkitEntity().getLocation());
}
}
lastPos = this.position();
lastPosVec3 = this.position();
}
@Override