Bulk bugfixes for itemstack damage API (#11063)

A general set of bugfixes for itemstack damage related logic.

1. Prevent NPE when calling deprecated ItemStack#getMaxItemUseDuration()
2. Do not apply enchantments when damaging items via API
3. Do not error when passing a null equipment slot to hurtAndBreak
4. Correctly call PlayerItemBreakEvent
This commit is contained in:
Bjarne Koll
2024-07-12 20:47:08 +02:00
parent 32d0bfcdea
commit 1b20e12355
3 changed files with 43 additions and 3 deletions

View File

@@ -42,7 +42,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ if (entity == null && handle.is(Items.CROSSBOW)) {
+ throw new UnsupportedOperationException("This item requires an entity to determine the max use duration");
+ }
+ return handle.getUseDuration(((CraftLivingEntity) entity).getHandle());
+ return handle.getUseDuration(entity != null ? ((CraftLivingEntity) entity).getHandle() : null);
+ }
+ // Paper end
+