Skip to content

Commit 5cc35a8

Browse files
kerudionSpottedleaf
authored andcommitted
Fix flickering with teleportAsync
Fixes flickering of entities without passengers when teleporting them with teleportAsync. We do not need to untrack/track the entity when there are no passengers, so we should not.
1 parent 35d3107 commit 5cc35a8

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

folia-server/minecraft-patches/sources/net/minecraft/world/entity/Entity.java.patch

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@
200200
if (!this.level().paperConfig().scoreboards.allowNonPlayerEntitiesOnScoreboards && !(this instanceof Player)) { return null; } // Paper - Perf: Disable Scoreboards for non players by default
201201
return this.level().getScoreboard().getPlayersTeam(this.getScoreboardName());
202202
}
203-
@@ -3726,8 +_,782 @@
203+
@@ -3726,8 +_,789 @@
204204
this.portalProcess = entity.portalProcess;
205205
}
206206

@@ -589,25 +589,32 @@
589589
+ ca.spottedleaf.moonrise.common.util.CoordinateUtils.getChunkX(pos), ca.spottedleaf.moonrise.common.util.CoordinateUtils.getChunkZ(pos)
590590
+ )
591591
+ ) {
592+
+ boolean hasPassengers = !this.passengers.isEmpty();
592593
+ EntityTreeNode passengerTree = this.detachPassengers();
593-
+ // Note: The client does not accept position updates for controlled entities. So, we must
594-
+ // perform a lot of tracker updates here to make it all work out.
595594
+
596-
+ // first, clear the tracker
597-
+ passengerTree.clearTracker();
595+
+ if (hasPassengers) {
596+
+ // Note: The client does not accept position updates for controlled entities. So, we must
597+
+ // perform a lot of tracker updates here to make it all work out.
598+
+
599+
+ // first, clear the tracker
600+
+ passengerTree.clearTracker();
601+
+ }
602+
+
598603
+ for (EntityTreeNode entity : passengerTree.getFullTree()) {
599604
+ entity.root.teleportSyncSameRegion(pos, yaw, pitch, velocity);
600605
+ }
601606
+
602-
+ passengerTree.restore();
603-
+ // re-add to the tracker once the tree is restored
604-
+ passengerTree.addTracker();
607+
+ if (hasPassengers) {
608+
+ passengerTree.restore();
609+
+ // re-add to the tracker once the tree is restored
610+
+ passengerTree.addTracker();
605611
+
606-
+ // adjust entities to final position
607-
+ passengerTree.adjustRiders(true);
612+
+ // adjust entities to final position
613+
+ passengerTree.adjustRiders(true);
608614
+
609-
+ // the tracker clear/add logic is only used in the same region, as the other logic
610-
+ // performs add/remove from world logic which will also perform add/remove tracker logic
615+
+ // the tracker clear/add logic is only used in the same region, as the other logic
616+
+ // performs add/remove from world logic which will also perform add/remove tracker logic
617+
+ }
611618
+
612619
+ if (teleportComplete != null) {
613620
+ teleportComplete.accept(this);

0 commit comments

Comments
 (0)