Skip to content
Merged
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,18 +6,18 @@ 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 a778e994c6cdfedd0f3574b7a27f2387af11d5b2..1feb7e47b3aeb840676cf90ed3f62a42f4b03306 100644
index 214613e9422606b7b1f37716fc060db63c38849a..e158d614abed8d16e80192c0c9abd8537c92b9dc 100644
--- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -623,6 +623,7 @@ public class ServerGamePacketListenerImpl
@@ -624,6 +624,7 @@ public class ServerGamePacketListenerImpl
}

rootVehicle.move(MoverType.PLAYER, new Vec3(d3, d4, d5));
+ final boolean didCollide = toX != rootVehicle.getX() || toY != rootVehicle.getY() || toZ != rootVehicle.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...
double verticalDelta = d4;
d3 = d - rootVehicle.getX();
d4 = d1 - rootVehicle.getY();
@@ -634,12 +635,21 @@ public class ServerGamePacketListenerImpl
@@ -635,12 +636,21 @@ public class ServerGamePacketListenerImpl
d7 = d3 * d3 + d4 * d4 + d5 * d5;
boolean flag1 = false;
if (d7 > org.spigotmc.SpigotConfig.movedWronglyThreshold) { // Spigot
Expand All @@ -42,7 +42,7 @@ index a778e994c6cdfedd0f3574b7a27f2387af11d5b2..1feb7e47b3aeb840676cf90ed3f62a42
rootVehicle.absSnapTo(x, y, z, f, f1);
this.send(ClientboundMoveVehiclePacket.fromEntity(rootVehicle));
rootVehicle.removeLatestMovementRecording();
@@ -718,9 +728,32 @@ public class ServerGamePacketListenerImpl
@@ -719,9 +729,32 @@ public class ServerGamePacketListenerImpl
}

private boolean noBlocksAround(Entity entity) {
Expand Down Expand Up @@ -78,7 +78,7 @@ index a778e994c6cdfedd0f3574b7a27f2387af11d5b2..1feb7e47b3aeb840676cf90ed3f62a42
}

@Override
@@ -1502,7 +1535,7 @@ public class ServerGamePacketListenerImpl
@@ -1503,7 +1536,7 @@ public class ServerGamePacketListenerImpl
}
}

Expand All @@ -87,15 +87,15 @@ index a778e994c6cdfedd0f3574b7a27f2387af11d5b2..1feb7e47b3aeb840676cf90ed3f62a42
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
@@ -1541,6 +1574,7 @@ public class ServerGamePacketListenerImpl
@@ -1542,6 +1575,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.
@@ -1574,7 +1608,17 @@ public class ServerGamePacketListenerImpl
@@ -1575,7 +1609,17 @@ public class ServerGamePacketListenerImpl
}

// Paper start - Add fail move event
Expand All @@ -114,7 +114,7 @@ index a778e994c6cdfedd0f3574b7a27f2387af11d5b2..1feb7e47b3aeb840676cf90ed3f62a42
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);
@@ -1709,7 +1753,7 @@ public class ServerGamePacketListenerImpl
@@ -1710,7 +1754,7 @@ public class ServerGamePacketListenerImpl

private boolean updateAwaitingTeleport() {
if (this.awaitingPositionFromClient != null) {
Expand All @@ -123,7 +123,7 @@ index a778e994c6cdfedd0f3574b7a27f2387af11d5b2..1feb7e47b3aeb840676cf90ed3f62a42
this.awaitingTeleportTime = this.tickCount;
this.teleport(
this.awaitingPositionFromClient.x,
@@ -1728,6 +1772,34 @@ public class ServerGamePacketListenerImpl
@@ -1729,6 +1773,34 @@ public class ServerGamePacketListenerImpl
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@

public ServerGamePacketListenerImpl(MinecraftServer server, Connection connection, ServerPlayer player, CommonListenerCookie cookie) {
super(server, connection, cookie);
@@ -276,8 +_,22 @@
@@ -276,11 +_,26 @@
player.connection = this;
player.getTextFilter().join();
this.signedMessageDecoder = SignedMessageChain.Decoder.unsigned(player.getUUID(), server::enforceSecureProfile);
Expand All @@ -108,6 +108,10 @@

@Override
public void tick() {
+ if (this.isDisconnected()) return; // Paper
if (this.ackBlockChangesUpTo > -1) {
this.send(new ClientboundBlockChangedAckPacket(this.ackBlockChangesUpTo));
this.ackBlockChangesUpTo = -1;
@@ -290,11 +_,13 @@
this.keepConnectionAlive();
this.chatSpamThrottler.tick();
Expand Down
Loading