From 05a5f029d576346004b67a93abcd7d7f58924f25 Mon Sep 17 00:00:00 2001 From: SoSeDiK Date: Thu, 2 Dec 2021 03:48:15 +0200 Subject: [PATCH] Fix NPE when getting destroy speed of air (#6989) --- patches/server/Add-Destroy-Speed-API.patch | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/patches/server/Add-Destroy-Speed-API.patch b/patches/server/Add-Destroy-Speed-API.patch index 113b765096..4c604c09f5 100644 --- a/patches/server/Add-Destroy-Speed-API.patch +++ b/patches/server/Add-Destroy-Speed-API.patch @@ -19,10 +19,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + net.minecraft.world.item.ItemStack nmsItemStack; + if (itemStack instanceof CraftItemStack) { + nmsItemStack = ((CraftItemStack) itemStack).handle; ++ if (nmsItemStack == null) { ++ nmsItemStack = net.minecraft.world.item.ItemStack.EMPTY; ++ } + } else { + nmsItemStack = CraftItemStack.asNMSCopy(itemStack); + } -+ float speed = nmsItemStack.getItem().getDestroySpeed(nmsItemStack, this.getNMS().getBlock().defaultBlockState()); ++ float speed = nmsItemStack.getDestroySpeed(this.getNMS().getBlock().defaultBlockState()); + if (speed > 1.0F && considerEnchants) { + int enchantLevel = net.minecraft.world.item.enchantment.EnchantmentHelper.getItemEnchantmentLevel(net.minecraft.world.item.enchantment.Enchantments.BLOCK_EFFICIENCY, nmsItemStack); + if (enchantLevel > 0) {