13
0
geforkt von Mirrors/Paper
Paper/paper-server/nms-patches/net/minecraft/world/item/ItemProjectileWeapon.patch
CraftBukkit/Spigot d3a23f42c3 Update to Minecraft 1.21.2
By: md_5 <git@md-5.net>
2024-10-23 02:15:00 +11:00

32 Zeilen
1.8 KiB
Diff

--- a/net/minecraft/world/item/ItemProjectileWeapon.java
+++ b/net/minecraft/world/item/ItemProjectileWeapon.java
@@ -54,9 +54,25 @@
float f6 = f4 + f5 * (float) ((i + 1) / 2) * f3;
f5 = -f5;
- IProjectile.spawnProjectile(this.createProjectile(worldserver, entityliving, itemstack, itemstack1, flag), worldserver, itemstack1, (iprojectile) -> {
- this.shootProjectile(entityliving, iprojectile, i, f, f1, f6, entityliving1);
- });
+ // CraftBukkit start
+ IProjectile iprojectile = this.createProjectile(worldserver, entityliving, itemstack, itemstack1, flag);
+ this.shootProjectile(entityliving, iprojectile, i, f, f1, f6, entityliving1);
+
+ 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 (IProjectile.spawnProjectile(iprojectile, worldserver, itemstack1).isRemoved()) {
+ 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;