Revert "Fix cancelling PlayerInteractEvent at (0, 0, 0) (#12215)"

This reverts commit a2b0ff0644e76fb4a644d870bc335bf81bc6a109.
This commit is contained in:
Bjarne Koll 2025-03-09 18:38:42 +01:00
parent 7afae7f465
commit e5d988df85
No known key found for this signature in database
GPG Key ID: 9576DAF3FDDB088F
3 changed files with 13 additions and 22 deletions

View File

@ -6,10 +6,10 @@ Subject: [PATCH] Optimise collision checking in player move packet handling
Move collision logic to just the hasNewCollision call instead of getCubes + hasNewCollision 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 diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 3aad9ee86d6af392f4a98022cbc88bb53000e7be..27ef385a85b13ceb58e8d149849983107c539b31 100644 index addeb449904ec9a2ef59b99022787bee689b83cf..27718a20666a3edc0b036e4cdeda5d7901f814ce 100644
--- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java --- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -561,7 +561,7 @@ public class ServerGamePacketListenerImpl @@ -563,7 +563,7 @@ public class ServerGamePacketListenerImpl
return; return;
} }
@ -18,7 +18,7 @@ index 3aad9ee86d6af392f4a98022cbc88bb53000e7be..27ef385a85b13ceb58e8d14984998310
d3 = d - this.vehicleLastGoodX; // Paper - diff on change, used for checking large move vectors above d3 = d - this.vehicleLastGoodX; // Paper - diff on change, used for checking large move vectors above
d4 = d1 - this.vehicleLastGoodY; // Paper - diff on change, used for checking large move vectors above d4 = d1 - this.vehicleLastGoodY; // Paper - diff on change, used for checking large move vectors above
d5 = d2 - this.vehicleLastGoodZ; // Paper - diff on change, used for checking large move vectors above d5 = d2 - this.vehicleLastGoodZ; // Paper - diff on change, used for checking large move vectors above
@@ -571,6 +571,7 @@ public class ServerGamePacketListenerImpl @@ -573,6 +573,7 @@ public class ServerGamePacketListenerImpl
} }
rootVehicle.move(MoverType.PLAYER, new Vec3(d3, d4, d5)); rootVehicle.move(MoverType.PLAYER, new Vec3(d3, d4, d5));
@ -26,7 +26,7 @@ index 3aad9ee86d6af392f4a98022cbc88bb53000e7be..27ef385a85b13ceb58e8d14984998310
double verticalDelta = d4; // Paper - Decompile fix, was named d11 previously, is now gone in the source double verticalDelta = d4; // Paper - Decompile fix, was named d11 previously, is now gone in the source
d3 = d - rootVehicle.getX(); d3 = d - rootVehicle.getX();
d4 = d1 - rootVehicle.getY(); d4 = d1 - rootVehicle.getY();
@@ -582,14 +583,22 @@ public class ServerGamePacketListenerImpl @@ -584,14 +585,22 @@ public class ServerGamePacketListenerImpl
d7 = d3 * d3 + d4 * d4 + d5 * d5; d7 = d3 * d3 + d4 * d4 + d5 * d5;
boolean flag2 = false; boolean flag2 = false;
if (d7 > org.spigotmc.SpigotConfig.movedWronglyThreshold) { // Spigot if (d7 > org.spigotmc.SpigotConfig.movedWronglyThreshold) { // Spigot
@ -52,7 +52,7 @@ index 3aad9ee86d6af392f4a98022cbc88bb53000e7be..27ef385a85b13ceb58e8d14984998310
rootVehicle.absMoveTo(x, y, z, f, f1); rootVehicle.absMoveTo(x, y, z, f, f1);
this.player.absMoveTo(x, y, z, this.player.getYRot(), this.player.getXRot()); // CraftBukkit this.player.absMoveTo(x, y, z, this.player.getYRot(), this.player.getXRot()); // CraftBukkit
this.send(ClientboundMoveVehiclePacket.fromEntity(rootVehicle)); this.send(ClientboundMoveVehiclePacket.fromEntity(rootVehicle));
@@ -667,9 +676,32 @@ public class ServerGamePacketListenerImpl @@ -669,9 +678,32 @@ public class ServerGamePacketListenerImpl
} }
private boolean noBlocksAround(Entity entity) { private boolean noBlocksAround(Entity entity) {
@ -88,7 +88,7 @@ index 3aad9ee86d6af392f4a98022cbc88bb53000e7be..27ef385a85b13ceb58e8d14984998310
} }
@Override @Override
@@ -1368,7 +1400,7 @@ public class ServerGamePacketListenerImpl @@ -1370,7 +1402,7 @@ public class ServerGamePacketListenerImpl
} }
} }
@ -97,7 +97,7 @@ index 3aad9ee86d6af392f4a98022cbc88bb53000e7be..27ef385a85b13ceb58e8d14984998310
d3 = d - this.lastGoodX; // Paper - diff on change, used for checking large move vectors above 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 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 d5 = d2 - this.lastGoodZ; // Paper - diff on change, used for checking large move vectors above
@@ -1407,6 +1439,7 @@ public class ServerGamePacketListenerImpl @@ -1409,6 +1441,7 @@ public class ServerGamePacketListenerImpl
boolean flag1 = this.player.verticalCollisionBelow; boolean flag1 = this.player.verticalCollisionBelow;
this.player.move(MoverType.PLAYER, new Vec3(d3, d4, d5)); 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 this.player.onGround = packet.isOnGround(); // CraftBukkit - SPIGOT-5810, SPIGOT-5835, SPIGOT-6828: reset by this.player.move
@ -105,7 +105,7 @@ index 3aad9ee86d6af392f4a98022cbc88bb53000e7be..27ef385a85b13ceb58e8d14984998310
// Paper start - prevent position desync // Paper start - prevent position desync
if (this.awaitingPositionFromClient != null) { if (this.awaitingPositionFromClient != null) {
return; // ... thanks Mojang for letting move calls teleport across dimensions. return; // ... thanks Mojang for letting move calls teleport across dimensions.
@@ -1439,7 +1472,17 @@ public class ServerGamePacketListenerImpl @@ -1441,7 +1474,17 @@ public class ServerGamePacketListenerImpl
} }
// Paper start - Add fail move event // Paper start - Add fail move event
@ -124,7 +124,7 @@ index 3aad9ee86d6af392f4a98022cbc88bb53000e7be..27ef385a85b13ceb58e8d14984998310
if (teleportBack) { if (teleportBack) {
io.papermc.paper.event.player.PlayerFailMoveEvent event = fireFailMove(io.papermc.paper.event.player.PlayerFailMoveEvent.FailReason.CLIPPED_INTO_BLOCK, io.papermc.paper.event.player.PlayerFailMoveEvent event = fireFailMove(io.papermc.paper.event.player.PlayerFailMoveEvent.FailReason.CLIPPED_INTO_BLOCK,
toX, toY, toZ, toYaw, toPitch, false); toX, toY, toZ, toYaw, toPitch, false);
@@ -1575,7 +1618,7 @@ public class ServerGamePacketListenerImpl @@ -1577,7 +1620,7 @@ public class ServerGamePacketListenerImpl
private boolean updateAwaitingTeleport() { private boolean updateAwaitingTeleport() {
if (this.awaitingPositionFromClient != null) { if (this.awaitingPositionFromClient != null) {
@ -133,7 +133,7 @@ index 3aad9ee86d6af392f4a98022cbc88bb53000e7be..27ef385a85b13ceb58e8d14984998310
this.awaitingTeleportTime = this.tickCount; this.awaitingTeleportTime = this.tickCount;
this.teleport( this.teleport(
this.awaitingPositionFromClient.x, this.awaitingPositionFromClient.x,
@@ -1594,6 +1637,33 @@ public class ServerGamePacketListenerImpl @@ -1596,6 +1639,33 @@ public class ServerGamePacketListenerImpl
} }
} }

View File

@ -11,10 +11,10 @@ a portal in spectator mode and then later switching to creative mode
would portal the player. would portal the player.
diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 366c26b2ca539be189b67d75ae73a587c4102c14..4068132a33f87dd07d6df1033ed11ba16a57313b 100644 index 27718a20666a3edc0b036e4cdeda5d7901f814ce..727792ca1a2c9044abb1d404fbf8420652e1507c 100644
--- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java --- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -657,7 +657,7 @@ public class ServerGamePacketListenerImpl @@ -659,7 +659,7 @@ public class ServerGamePacketListenerImpl
// CraftBukkit end // CraftBukkit end
this.player.serverLevel().getChunkSource().move(this.player); this.player.serverLevel().getChunkSource().move(this.player);
@ -23,7 +23,7 @@ index 366c26b2ca539be189b67d75ae73a587c4102c14..4068132a33f87dd07d6df1033ed11ba1
Vec3 vec3 = new Vec3(rootVehicle.getX() - x, rootVehicle.getY() - y, rootVehicle.getZ() - z); Vec3 vec3 = new Vec3(rootVehicle.getX() - x, rootVehicle.getY() - y, rootVehicle.getZ() - z);
this.handlePlayerKnownMovement(vec3); this.handlePlayerKnownMovement(vec3);
rootVehicle.setOnGroundWithMovement(packet.onGround(), vec3); rootVehicle.setOnGroundWithMovement(packet.onGround(), vec3);
@@ -1574,7 +1574,7 @@ public class ServerGamePacketListenerImpl @@ -1576,7 +1576,7 @@ public class ServerGamePacketListenerImpl
Vec3 vec3 = new Vec3(this.player.getX() - x, this.player.getY() - y, this.player.getZ() - z); Vec3 vec3 = new Vec3(this.player.getX() - x, this.player.getY() - y, this.player.getZ() - z);
this.player.setOnGroundWithMovement(packet.isOnGround(), packet.horizontalCollision(), vec3); this.player.setOnGroundWithMovement(packet.isOnGround(), packet.horizontalCollision(), vec3);
this.player.doCheckFallDamage(vec3.x, vec3.y, vec3.z, packet.isOnGround()); this.player.doCheckFallDamage(vec3.x, vec3.y, vec3.z, packet.isOnGround());

View File

@ -167,15 +167,6 @@
if (!blockState.isAir() && f >= 1.0F) { if (!blockState.isAir() && f >= 1.0F) {
this.destroyAndAck(pos, sequence, "insta mine"); this.destroyAndAck(pos, sequence, "insta mine");
} else { } else {
@@ -188,7 +_,7 @@
this.lastSentState = i;
}
} else if (action == ServerboundPlayerActionPacket.Action.STOP_DESTROY_BLOCK) {
- if (pos.equals(this.destroyPos)) {
+ if (this.isDestroyingBlock && pos.equals(this.destroyPos)) { // Paper - require isDestroyingBlock to be true (special condition for when destroy pos is 0,0,0 and the event is cancelled)
int i1 = this.gameTicks - this.destroyProgressStart;
BlockState blockStatex = this.level.getBlockState(pos);
if (!blockStatex.isAir()) {
@@ -212,14 +_,22 @@ @@ -212,14 +_,22 @@
this.debugLogging(pos, true, sequence, "stopped destroying"); this.debugLogging(pos, true, sequence, "stopped destroying");
} else if (action == ServerboundPlayerActionPacket.Action.ABORT_DESTROY_BLOCK) { } else if (action == ServerboundPlayerActionPacket.Action.ABORT_DESTROY_BLOCK) {