PaperMC/paper-server/nms-patches/net/minecraft/world/item/ItemProjectileWeapon.patch

27 lines
1.5 KiB
Diff
Raw Normal View History

--- a/net/minecraft/world/item/ItemProjectileWeapon.java
+++ b/net/minecraft/world/item/ItemProjectileWeapon.java
@@ -62,7 +62,22 @@
IProjectile iprojectile = this.createProjectile(worldserver, entityliving, itemstack, itemstack1, flag);
this.shootProjectile(entityliving, iprojectile, i, f, f1, f6, entityliving1);
- worldserver.addFreshEntity(iprojectile);
+ // CraftBukkit start
+ org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(entityliving, itemstack, itemstack1, iprojectile, enumhand, f, true);
+ if (event.isCancelled()) {
+ event.getProjectile().remove();
+ return;
+ }
+
+ if (event.getProjectile() == iprojectile.getBukkitEntity()) {
+ if (!worldserver.addFreshEntity(iprojectile)) {
+ if (entityliving instanceof net.minecraft.server.level.EntityPlayer) {
+ ((net.minecraft.server.level.EntityPlayer) entityliving).getBukkitEntity().updateInventory();
+ }
+ return;
+ }
+ }
+ // CraftBukkit end
itemstack.hurtAndBreak(this.getDurabilityUse(itemstack1), entityliving, EntityLiving.getSlotForHand(enumhand));
if (itemstack.isEmpty()) {
break;