From a2b0ff0644e76fb4a644d870bc335bf81bc6a109 Mon Sep 17 00:00:00 2001
From: Noah van der Aa <ndvdaa@gmail.com>
Date: Sat, 8 Mar 2025 22:52:10 +0100
Subject: [PATCH] Fix cancelling PlayerInteractEvent at (0, 0, 0) (#12215)

---------

Co-authored-by: Warrior <50800980+warriorrrr@users.noreply.github.com>
---
 .../server/level/ServerPlayerGameMode.java.patch         | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/paper-server/patches/sources/net/minecraft/server/level/ServerPlayerGameMode.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ServerPlayerGameMode.java.patch
index df18866114..23cb422715 100644
--- a/paper-server/patches/sources/net/minecraft/server/level/ServerPlayerGameMode.java.patch
+++ b/paper-server/patches/sources/net/minecraft/server/level/ServerPlayerGameMode.java.patch
@@ -167,6 +167,15 @@
                  if (!blockState.isAir() && f >= 1.0F) {
                      this.destroyAndAck(pos, sequence, "insta mine");
                  } 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 @@
                  this.debugLogging(pos, true, sequence, "stopped destroying");
              } else if (action == ServerboundPlayerActionPacket.Action.ABORT_DESTROY_BLOCK) {