Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Subject: [PATCH] Optimise collision checking in player move packet handling
Move collision logic to just the hasNewCollision call instead of getCubes + hasNewCollision

diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index f3e8bb3b44fa2fe792049b6150f47119341b87ef..7f6cc8f111f6f5df311397a7e31e25fa2c93c685 100644
index a35ab7757056423688b8ffa42f79828c43ab6138..9a8230f4e1cff368485ee998aee05c3f15c67104 100644
--- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -612,6 +612,7 @@ public class ServerGamePacketListenerImpl
Expand Down Expand Up @@ -78,7 +78,7 @@ index f3e8bb3b44fa2fe792049b6150f47119341b87ef..7f6cc8f111f6f5df311397a7e31e25fa
}

@Override
@@ -1484,7 +1517,7 @@ public class ServerGamePacketListenerImpl
@@ -1489,7 +1522,7 @@ public class ServerGamePacketListenerImpl
}
}

Expand All @@ -87,15 +87,15 @@ index f3e8bb3b44fa2fe792049b6150f47119341b87ef..7f6cc8f111f6f5df311397a7e31e25fa
d3 = d - this.lastGoodX; // Paper - diff on change, used for checking large move vectors above
d4 = d1 - this.lastGoodY; // Paper - diff on change, used for checking large move vectors above
d5 = d2 - this.lastGoodZ; // Paper - diff on change, used for checking large move vectors above
@@ -1523,6 +1556,7 @@ public class ServerGamePacketListenerImpl
@@ -1528,6 +1561,7 @@ public class ServerGamePacketListenerImpl
boolean flag1 = this.player.verticalCollisionBelow;
this.player.move(MoverType.PLAYER, new Vec3(d3, d4, d5));
this.player.onGround = packet.isOnGround(); // CraftBukkit - SPIGOT-5810, SPIGOT-5835, SPIGOT-6828: reset by this.player.move
+ final boolean didCollide = toX != this.player.getX() || toY != this.player.getY() || toZ != this.player.getZ(); // Paper - needed here as the difference in Y can be reset - also note: this is only a guess at whether collisions took place, floating point errors can make this true when it shouldn't be...
// Paper start - prevent position desync
if (this.awaitingPositionFromClient != null) {
return; // ... thanks Mojang for letting move calls teleport across dimensions.
@@ -1555,7 +1589,17 @@ public class ServerGamePacketListenerImpl
@@ -1560,7 +1594,17 @@ public class ServerGamePacketListenerImpl
}

// Paper start - Add fail move event
Expand All @@ -114,7 +114,7 @@ index f3e8bb3b44fa2fe792049b6150f47119341b87ef..7f6cc8f111f6f5df311397a7e31e25fa
if (!allowMovement) {
io.papermc.paper.event.player.PlayerFailMoveEvent event = fireFailMove(io.papermc.paper.event.player.PlayerFailMoveEvent.FailReason.CLIPPED_INTO_BLOCK,
toX, toY, toZ, toYaw, toPitch, false);
@@ -1691,7 +1735,7 @@ public class ServerGamePacketListenerImpl
@@ -1696,7 +1740,7 @@ public class ServerGamePacketListenerImpl

private boolean updateAwaitingTeleport() {
if (this.awaitingPositionFromClient != null) {
Expand All @@ -123,7 +123,7 @@ index f3e8bb3b44fa2fe792049b6150f47119341b87ef..7f6cc8f111f6f5df311397a7e31e25fa
this.awaitingTeleportTime = this.tickCount;
this.teleport(
this.awaitingPositionFromClient.x,
@@ -1710,6 +1754,34 @@ public class ServerGamePacketListenerImpl
@@ -1715,6 +1759,34 @@ public class ServerGamePacketListenerImpl
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@
return;
}

@@ -525,12 +_,20 @@
@@ -525,12 +_,25 @@
this.lastGoodZ = this.awaitingPositionFromClient.z;
this.player.hasChangedDimension();
this.awaitingPositionFromClient = null;
Expand All @@ -385,6 +385,11 @@
@Override
public void handleAcceptPlayerLoad(ServerboundPlayerLoadedPacket packet) {
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level());
+ // Paper start - Fix camera desync
+ if (this.player.getCamera() != this.player) {
+ this.connection.send(new net.minecraft.network.protocol.game.ClientboundSetCameraPacket(this.player.getCamera()));
+ }
+ // Paper end - Fix camera desync
+ // Paper start - PlayerLoadedWorldEvent
+ if (this.player.hasClientLoaded()) {
+ return;
Expand Down
Loading