mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-27 23:10:16 +01:00
fix flying too long check
This commit is contained in:
parent
286e3468d7
commit
3bfdf6a07a
2 changed files with 34 additions and 13 deletions
|
@ -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
|
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 96d36b2e285ec0a518b15ccdff4d7d1850b0a7e2..9a0a2a628d76a4e0410839d919a8bf38ff73a650 100644
|
index 650126e6445c0458c6a6649c235908bfeea428cd..d248671b2e1c6256fc4d74320bdb29ca078bad0b 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
|
@@ -561,7 +561,7 @@ public class ServerGamePacketListenerImpl
|
||||||
|
@ -23,10 +23,10 @@ index 96d36b2e285ec0a518b15ccdff4d7d1850b0a7e2..9a0a2a628d76a4e0410839d919a8bf38
|
||||||
|
|
||||||
rootVehicle.move(MoverType.PLAYER, new Vec3(d3, d4, d5));
|
rootVehicle.move(MoverType.PLAYER, new Vec3(d3, d4, d5));
|
||||||
+ 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...
|
+ 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; // 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();
|
||||||
if (d4 > -0.5 || d4 < 0.5) {
|
@@ -582,14 +583,22 @@ public class ServerGamePacketListenerImpl
|
||||||
@@ -581,14 +582,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 96d36b2e285ec0a518b15ccdff4d7d1850b0a7e2..9a0a2a628d76a4e0410839d919a8bf38
|
||||||
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));
|
||||||
@@ -666,9 +675,32 @@ public class ServerGamePacketListenerImpl
|
@@ -667,9 +676,32 @@ public class ServerGamePacketListenerImpl
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean noBlocksAround(Entity entity) {
|
private boolean noBlocksAround(Entity entity) {
|
||||||
|
@ -88,7 +88,7 @@ index 96d36b2e285ec0a518b15ccdff4d7d1850b0a7e2..9a0a2a628d76a4e0410839d919a8bf38
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1360,7 +1392,7 @@ public class ServerGamePacketListenerImpl
|
@@ -1361,7 +1393,7 @@ public class ServerGamePacketListenerImpl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ index 96d36b2e285ec0a518b15ccdff4d7d1850b0a7e2..9a0a2a628d76a4e0410839d919a8bf38
|
||||||
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
|
||||||
@@ -1399,6 +1431,7 @@ public class ServerGamePacketListenerImpl
|
@@ -1400,6 +1432,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 96d36b2e285ec0a518b15ccdff4d7d1850b0a7e2..9a0a2a628d76a4e0410839d919a8bf38
|
||||||
// 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.
|
||||||
@@ -1430,7 +1463,17 @@ public class ServerGamePacketListenerImpl
|
@@ -1432,7 +1465,17 @@ public class ServerGamePacketListenerImpl
|
||||||
}
|
}
|
||||||
|
|
||||||
// Paper start - Add fail move event
|
// Paper start - Add fail move event
|
||||||
|
@ -124,7 +124,7 @@ index 96d36b2e285ec0a518b15ccdff4d7d1850b0a7e2..9a0a2a628d76a4e0410839d919a8bf38
|
||||||
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);
|
||||||
@@ -1566,7 +1609,7 @@ public class ServerGamePacketListenerImpl
|
@@ -1568,7 +1611,7 @@ public class ServerGamePacketListenerImpl
|
||||||
|
|
||||||
private boolean updateAwaitingTeleport() {
|
private boolean updateAwaitingTeleport() {
|
||||||
if (this.awaitingPositionFromClient != null) {
|
if (this.awaitingPositionFromClient != null) {
|
||||||
|
@ -133,7 +133,7 @@ index 96d36b2e285ec0a518b15ccdff4d7d1850b0a7e2..9a0a2a628d76a4e0410839d919a8bf38
|
||||||
this.awaitingTeleportTime = this.tickCount;
|
this.awaitingTeleportTime = this.tickCount;
|
||||||
this.teleport(
|
this.teleport(
|
||||||
this.awaitingPositionFromClient.x,
|
this.awaitingPositionFromClient.x,
|
||||||
@@ -1585,6 +1628,33 @@ public class ServerGamePacketListenerImpl
|
@@ -1587,6 +1630,33 @@ public class ServerGamePacketListenerImpl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -256,7 +256,7 @@
|
||||||
LOGGER.warn(
|
LOGGER.warn(
|
||||||
"{} (vehicle of {}) moved too quickly! {},{},{}", rootVehicle.getName().getString(), this.player.getName().getString(), d3, d4, d5
|
"{} (vehicle of {}) moved too quickly! {},{},{}", rootVehicle.getName().getString(), this.player.getName().getString(), d3, d4, d5
|
||||||
);
|
);
|
||||||
@@ -417,9 +_,9 @@
|
@@ -417,15 +_,16 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean flag = serverLevel.noCollision(rootVehicle, rootVehicle.getBoundingBox().deflate(0.0625));
|
boolean flag = serverLevel.noCollision(rootVehicle, rootVehicle.getBoundingBox().deflate(0.0625));
|
||||||
|
@ -269,6 +269,13 @@
|
||||||
boolean flag1 = rootVehicle.verticalCollisionBelow;
|
boolean flag1 = rootVehicle.verticalCollisionBelow;
|
||||||
if (rootVehicle instanceof LivingEntity livingEntity && livingEntity.onClimbable()) {
|
if (rootVehicle instanceof LivingEntity livingEntity && livingEntity.onClimbable()) {
|
||||||
livingEntity.resetFallDistance();
|
livingEntity.resetFallDistance();
|
||||||
|
}
|
||||||
|
|
||||||
|
rootVehicle.move(MoverType.PLAYER, new Vec3(d3, d4, d5));
|
||||||
|
+ double verticalDelta = d4; // Paper - Decompile fix, was named d11 previously, is now gone in the source
|
||||||
|
d3 = d - rootVehicle.getX();
|
||||||
|
d4 = d1 - rootVehicle.getY();
|
||||||
|
if (d4 > -0.5 || d4 < 0.5) {
|
||||||
@@ -435,18 +_,71 @@
|
@@ -435,18 +_,71 @@
|
||||||
d5 = d2 - rootVehicle.getZ();
|
d5 = d2 - rootVehicle.getZ();
|
||||||
d7 = d3 * d3 + d4 * d4 + d5 * d5;
|
d7 = d3 * d3 + d4 * d4 + d5 * d5;
|
||||||
|
@ -342,6 +349,15 @@
|
||||||
|
|
||||||
this.player.serverLevel().getChunkSource().move(this.player);
|
this.player.serverLevel().getChunkSource().move(this.player);
|
||||||
rootVehicle.recordMovementThroughBlocks(new Vec3(x, y, z), rootVehicle.position());
|
rootVehicle.recordMovementThroughBlocks(new Vec3(x, y, z), rootVehicle.position());
|
||||||
|
@@ -455,7 +_,7 @@
|
||||||
|
rootVehicle.setOnGroundWithMovement(packet.onGround(), vec3);
|
||||||
|
rootVehicle.doCheckFallDamage(vec3.x, vec3.y, vec3.z, packet.onGround());
|
||||||
|
this.player.checkMovementStatistics(vec3.x, vec3.y, vec3.z);
|
||||||
|
- this.clientVehicleIsFloating = d4 >= -0.03125
|
||||||
|
+ this.clientVehicleIsFloating = verticalDelta >= -0.03125 // Paper - Decompile fix
|
||||||
|
&& !flag1
|
||||||
|
&& !this.server.isFlightAllowed()
|
||||||
|
&& !rootVehicle.isNoGravity()
|
||||||
@@ -478,12 +_,12 @@
|
@@ -478,12 +_,12 @@
|
||||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||||
if (packet.getId() == this.awaitingTeleport) {
|
if (packet.getId() == this.awaitingTeleport) {
|
||||||
|
@ -694,7 +710,7 @@
|
||||||
if (this.player.isSleeping()) {
|
if (this.player.isSleeping()) {
|
||||||
if (d7 > 1.0) {
|
if (d7 > 1.0) {
|
||||||
this.teleport(this.player.getX(), this.player.getY(), this.player.getZ(), f, f1);
|
this.teleport(this.player.getX(), this.player.getY(), this.player.getZ(), f, f1);
|
||||||
@@ -936,32 +_,104 @@
|
@@ -936,32 +_,105 @@
|
||||||
if (serverLevel.tickRateManager().runsNormally()) {
|
if (serverLevel.tickRateManager().runsNormally()) {
|
||||||
this.receivedMovePacketCount++;
|
this.receivedMovePacketCount++;
|
||||||
int i = this.receivedMovePacketCount - this.knownMovePacketCount;
|
int i = this.receivedMovePacketCount - this.knownMovePacketCount;
|
||||||
|
@ -805,10 +821,11 @@
|
||||||
+ return; // ... thanks Mojang for letting move calls teleport across dimensions.
|
+ return; // ... thanks Mojang for letting move calls teleport across dimensions.
|
||||||
+ }
|
+ }
|
||||||
+ // Paper end - prevent position desync
|
+ // Paper end - prevent position desync
|
||||||
|
+ double verticalDelta = d4; // Paper - Decompile fix, was named d11 previously, is now gone in the source
|
||||||
d3 = d - this.player.getX();
|
d3 = d - this.player.getX();
|
||||||
d4 = d1 - this.player.getY();
|
d4 = d1 - this.player.getY();
|
||||||
if (d4 > -0.5 || d4 < 0.5) {
|
if (d4 > -0.5 || d4 < 0.5) {
|
||||||
@@ -970,20 +_,101 @@
|
@@ -970,23 +_,104 @@
|
||||||
|
|
||||||
d5 = d2 - this.player.getZ();
|
d5 = d2 - this.player.getZ();
|
||||||
d7 = d3 * d3 + d4 * d4 + d5 * d5;
|
d7 = d3 * d3 + d4 * d4 + d5 * d5;
|
||||||
|
@ -918,7 +935,11 @@
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
this.player.absMoveTo(d, d1, d2, f, f1);
|
this.player.absMoveTo(d, d1, d2, f, f1);
|
||||||
boolean isAutoSpinAttack = this.player.isAutoSpinAttack();
|
boolean isAutoSpinAttack = this.player.isAutoSpinAttack();
|
||||||
this.clientIsFloating = d4 >= -0.03125
|
- this.clientIsFloating = d4 >= -0.03125
|
||||||
|
+ this.clientIsFloating = verticalDelta >= -0.03125 // Paper - Decompile fix
|
||||||
|
&& !flag1
|
||||||
|
&& this.player.gameMode.getGameModeForPlayer() != GameType.SPECTATOR
|
||||||
|
&& !this.server.isFlightAllowed()
|
||||||
@@ -1019,7 +_,7 @@
|
@@ -1019,7 +_,7 @@
|
||||||
this.lastGoodY = this.player.getY();
|
this.lastGoodY = this.player.getY();
|
||||||
this.lastGoodZ = this.player.getZ();
|
this.lastGoodZ = this.player.getZ();
|
||||||
|
|
Loading…
Reference in a new issue