Call PlayerReadyArrowEvent for when items in the offhand are used (#8842)

This commit is contained in:
TM (Holly) 2023-02-13 09:36:25 +00:00
parent ffc1cf92a1
commit 205d1402f8

View File

@ -28,12 +28,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@Override
public ItemStack getProjectile(ItemStack stack) {
if (!(stack.getItem() instanceof ProjectileWeaponItem)) {
@@ -0,0 +0,0 @@ public abstract class Player extends LivingEntity {
return ItemStack.EMPTY;
} else {
- Predicate<ItemStack> predicate = ((ProjectileWeaponItem) stack.getItem()).getSupportedHeldProjectiles();
+ Predicate<ItemStack> predicate = ((ProjectileWeaponItem) stack.getItem()).getSupportedHeldProjectiles().and(item -> tryReadyArrow(stack, item)); // Paper
ItemStack itemstack1 = ProjectileWeaponItem.getHeldProjectile(this, predicate);
if (!itemstack1.isEmpty()) {
return itemstack1;
} else {
- predicate = ((ProjectileWeaponItem) stack.getItem()).getAllSupportedProjectiles();
+ predicate = ((ProjectileWeaponItem) stack.getItem()).getAllSupportedProjectiles().and(item -> tryReadyArrow(stack, item)); // Paper
for (int i = 0; i < this.inventory.getContainerSize(); ++i) {
ItemStack itemstack2 = this.inventory.getItem(i);
- if (predicate.test(itemstack2)) {
+ if (predicate.test(itemstack2) && tryReadyArrow(stack, itemstack2)) { // Paper
return itemstack2;
}
}