From f6227934a3462237f45b494b5d8a71795e998d0d Mon Sep 17 00:00:00 2001
From: Shane Bee <shanebolenback@me.com>
Date: Sun, 9 Aug 2020 18:42:07 +1000
Subject: [PATCH] SPIGOT-3020: Fix issue with BlockBreakEvent throwing
 AssertionError when setting a player's tool to AIR/NULL

---
 nms-patches/ItemBlock.patch | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/nms-patches/ItemBlock.patch b/nms-patches/ItemBlock.patch
index 05b6a17e24..6afa8d1870 100644
--- a/nms-patches/ItemBlock.patch
+++ b/nms-patches/ItemBlock.patch
@@ -41,15 +41,17 @@
                          if (entityhuman instanceof EntityPlayer) {
                              CriterionTriggers.y.a((EntityPlayer) entityhuman, blockposition, itemstack);
                          }
-@@ -55,7 +75,7 @@
+@@ -55,8 +75,8 @@
  
                      SoundEffectType soundeffecttype = iblockdata1.getStepSound();
  
 -                    world.playSound(entityhuman, blockposition, this.a(iblockdata1), SoundCategory.BLOCKS, (soundeffecttype.a() + 1.0F) / 2.0F, soundeffecttype.b() * 0.8F);
+-                    if (entityhuman == null || !entityhuman.abilities.canInstantlyBuild) {
 +                    // world.playSound(entityhuman, blockposition, this.a(iblockdata1), SoundCategory.BLOCKS, (soundeffecttype.a() + 1.0F) / 2.0F, soundeffecttype.b() * 0.8F);
-                     if (entityhuman == null || !entityhuman.abilities.canInstantlyBuild) {
++                    if ((entityhuman == null || !entityhuman.abilities.canInstantlyBuild) && itemstack != ItemStack.b) { // CraftBukkit
                          itemstack.subtract(1);
                      }
+ 
 @@ -92,6 +112,21 @@
  
          if (nbttagcompound != null) {