Skip to content

Instantly share code, notes, and snippets.

@sathonay
Last active January 9, 2024 15:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sathonay/fdc8249084f7185578e7e18f486952e6 to your computer and use it in GitHub Desktop.
Save sathonay/fdc8249084f7185578e7e18f486952e6 to your computer and use it in GitHub Desktop.
Fix NoCom exploit by reducing the unloaded chunk check to the playerview distance - NoCom Ref -> https://github.com/nerdsinspace/nocom-explanation/blob/main/README.md
From 6b0a93e2ddfdb13b7aff806e071e79173d20b13b Mon Sep 17 00:00:00 2001
From: Michael Himing <mhiming@gmail.com>
Date: Sun, 8 Jan 2017 18:50:35 +1100
Subject: [PATCH] Fix block break desync
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index 4f8865d61..802008b4e 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -868,6 +868,8 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
double d3 = d0 * d0 + d1 * d1 + d2 * d2;
if (d3 > 36.0D) {
+ int d4 = MathHelper.pow2(player.viewDistance * 16);
+ if (d3 < d4 && worldserver.isChunkLoaded(blockposition.getX() >> 4, blockposition.getZ() >> 4, true)) // Paper - Fix block break desync - Don't send for unloaded chunks
+ this.sendPacket(new PacketPlayOutBlockChange(worldserver, blockposition)); // Paper - Fix block break desync
return;
} else if (blockposition.getY() >= this.minecraftServer.getMaxBuildHeight()) {
return;
--
2.17.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment