Skip to content

Commit b6dad9c

Browse files
authored
Fix desync on teleporting entity on first tick (#7183)
1 parent 04a337a commit b6dad9c

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
3+
Date: Thu, 23 Dec 2021 23:59:12 -0500
4+
Subject: [PATCH] Fix Entity Position Desync
5+
6+
If entities were teleported in the first tick it would not be send to the client.
7+
8+
This also fixes desync caused be relatively teleporting paintings.
9+
This is caused by the fact that setPacketCoordinates isn't called on paintings when they are spawned (unlike every other entity, like XP orbs)
10+
on the client for some reason. This causes it to be relatively teleported to the world origin (0,0,0).
11+
12+
diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java
13+
index 9a6c67b614944f841813ec2892381c3342bc365c..b0a79e335ac9dc24fc6f18010bf40716ecc724bf 100644
14+
--- a/src/main/java/net/minecraft/server/level/ServerEntity.java
15+
+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java
16+
@@ -164,13 +164,14 @@ public class ServerEntity {
17+
}
18+
// CraftBukkit end
19+
20+
- if (this.tickCount > 0 || this.entity instanceof AbstractArrow) {
21+
+ if (true || this.tickCount > 0 || this.entity instanceof AbstractArrow) { // Paper - Always update position
22+
// Paper start - remove allocation of Vec3D here
23+
long k = ClientboundMoveEntityPacket.entityToPacket(vec3d_dx);
24+
long l = ClientboundMoveEntityPacket.entityToPacket(vec3d_dy);
25+
long i1 = ClientboundMoveEntityPacket.entityToPacket(vec3d_dz);
26+
// Paper end - remove allocation of Vec3D here
27+
boolean flag4 = k < -32768L || k > 32767L || l < -32768L || l > 32767L || i1 < -32768L || i1 > 32767L;
28+
+ if (this.entity instanceof net.minecraft.world.entity.decoration.Painting) {flag4 = true;} // Paper - Always send exact position for paintings
29+
30+
if (!flag4 && this.teleportDelay <= 400 && !this.wasRiding && this.wasOnGround == this.entity.isOnGround() && !(com.destroystokyo.paper.PaperConfig.sendFullPosForHardCollidingEntities && this.entity.hardCollides())) { // Paper - send full pos for hard colliding entities to prevent collision problems due to desync
31+
if ((!flag2 || !flag3) && !(this.entity instanceof AbstractArrow)) {

0 commit comments

Comments
 (0)