mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-30 16:19:03 +01:00
Fix distanceSq check on block breaking (#6195)
This commit is contained in:
parent
6602dc655e
commit
186cf8842e
2 changed files with 6 additions and 2 deletions
|
@ -210,7 +210,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
}
|
||||
}
|
||||
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
||||
double blockDistanceSquared = this.player.distanceToSqr(blockposition.getX() + 0.5D, blockposition.getY() + 0.5D + 1.5D, blockposition.getZ() + 0.5D); // Copied from ServerPlayerGameMode#handleBlockBreakAction
|
||||
double blockDistanceSquared = d0 * d0 + d1 * d1 + d2 * d2;
|
||||
if (blockDistanceSquared > 40 * 40) {
|
||||
LOGGER.warn("{} tried to break a block {} square blocks away from their position", this.player.getScoreboardName(), blockDistanceSquared);
|
||||
- this.disconnect("Invalid block break distance");
|
||||
|
|
|
@ -72,7 +72,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
case STOP_DESTROY_BLOCK:
|
||||
- this.player.gameMode.handleBlockBreakAction(blockposition, packetplayinblockdig_enumplayerdigtype, packet.getDirection(), this.player.level.getMaxBuildHeight());
|
||||
+ // Paper start - Don't allow digging in unloaded chunks
|
||||
+ double blockDistanceSquared = this.player.distanceToSqr(blockposition.getX() + 0.5D, blockposition.getY() + 0.5D + 1.5D, blockposition.getZ() + 0.5D); // Copied from ServerPlayerGameMode#handleBlockBreakAction
|
||||
+ // Copied from ServerPlayerGameMode#handleBlockBreakAction
|
||||
+ double d0 = this.player.getX() - ((double) blockposition.getX() + 0.5D);
|
||||
+ double d1 = this.player.getY() - ((double) blockposition.getY() + 0.5D) + 1.5D;
|
||||
+ double d2 = this.player.getZ() - ((double) blockposition.getZ() + 0.5D);
|
||||
+ double blockDistanceSquared = d0 * d0 + d1 * d1 + d2 * d2;
|
||||
+ if (blockDistanceSquared > 40 * 40) {
|
||||
+ LOGGER.warn("{} tried to break a block {} square blocks away from their position", this.player.getScoreboardName(), blockDistanceSquared);
|
||||
+ this.disconnect("Invalid block break distance");
|
||||
|
|
Loading…
Reference in a new issue