aboutsummaryrefslogtreecommitdiffhomepage
path: root/paper-server/patches/unapplied/net/minecraft/world/item/ProjectileWeaponItem.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'paper-server/patches/unapplied/net/minecraft/world/item/ProjectileWeaponItem.java.patch')
-rw-r--r--paper-server/patches/unapplied/net/minecraft/world/item/ProjectileWeaponItem.java.patch52
1 files changed, 52 insertions, 0 deletions
diff --git a/paper-server/patches/unapplied/net/minecraft/world/item/ProjectileWeaponItem.java.patch b/paper-server/patches/unapplied/net/minecraft/world/item/ProjectileWeaponItem.java.patch
new file mode 100644
index 0000000000..dfdb8d27c6
--- /dev/null
+++ b/paper-server/patches/unapplied/net/minecraft/world/item/ProjectileWeaponItem.java.patch
@@ -0,0 +1,52 @@
+--- a/net/minecraft/world/item/ProjectileWeaponItem.java
++++ b/net/minecraft/world/item/ProjectileWeaponItem.java
+@@ -54,9 +54,25 @@
+ float f6 = f4 + f5 * (float) ((i + 1) / 2) * f3;
+
+ f5 = -f5;
+- Projectile.spawnProjectile(this.createProjectile(world, shooter, stack, itemstack1, critical), world, itemstack1, (iprojectile) -> {
+- this.shootProjectile(shooter, iprojectile, i, speed, divergence, f6, target);
+- });
++ // CraftBukkit start
++ Projectile iprojectile = this.createProjectile(world, shooter, stack, itemstack1, critical);
++ this.shootProjectile(shooter, iprojectile, i, speed, divergence, f6, target);
++
++ org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(shooter, stack, itemstack1, iprojectile, hand, speed, true);
++ if (event.isCancelled()) {
++ event.getProjectile().remove();
++ return;
++ }
++
++ if (event.getProjectile() == iprojectile.getBukkitEntity()) {
++ if (Projectile.spawnProjectile(iprojectile, world, itemstack1).isRemoved()) {
++ if (shooter instanceof net.minecraft.server.level.ServerPlayer) {
++ ((net.minecraft.server.level.ServerPlayer) shooter).getBukkitEntity().updateInventory();
++ }
++ return;
++ }
++ }
++ // CraftBukkit end
+ stack.hurtAndBreak(this.getDurabilityUse(itemstack1), shooter, LivingEntity.getSlotForHand(hand));
+ if (stack.isEmpty()) {
+ break;
+@@ -93,6 +109,11 @@
+ }
+
+ protected static List<ItemStack> draw(ItemStack stack, ItemStack projectileStack, LivingEntity shooter) {
++ // Paper start
++ return draw(stack, projectileStack, shooter, true);
++ }
++ protected static List<ItemStack> draw(ItemStack stack, ItemStack projectileStack, LivingEntity shooter, boolean consume) {
++ // Paper end
+ if (projectileStack.isEmpty()) {
+ return List.of();
+ } else {
+@@ -112,7 +133,7 @@
+ ItemStack itemstack2 = projectileStack.copy();
+
+ for (int k = 0; k < j; ++k) {
+- ItemStack itemstack3 = ProjectileWeaponItem.useAmmo(stack, k == 0 ? projectileStack : itemstack2, shooter, k > 0);
++ ItemStack itemstack3 = ProjectileWeaponItem.useAmmo(stack, k == 0 ? projectileStack : itemstack2, shooter, k > 0 || !consume); // Paper
+
+ if (!itemstack3.isEmpty()) {
+ list.add(itemstack3);