mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-16 05:11:27 +01:00
Fix NPE when getting destroy speed of air (#6989)
This commit is contained in:
parent
d1eed05360
commit
05a5f029d5
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user