diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityArrow.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityArrow.patch index 54ab623718..432cf51e84 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityArrow.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityArrow.patch @@ -13,6 +13,15 @@ public abstract class EntityArrow extends IProjectile { private static final DataWatcherObject f = DataWatcher.a(EntityArrow.class, DataWatcherRegistry.a); +@@ -181,7 +187,7 @@ + } + + if (object != null && !flag) { +- this.a((MovingObjectPosition) object); ++ this.preOnHit((MovingObjectPosition) object); // CraftBukkit - projectile hit event + this.impulse = true; + } + @@ -328,7 +334,13 @@ int k = entity.getFireTicks(); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityFireball.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityFireball.patch index 407ffbe6bb..a35f97523b 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityFireball.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityFireball.patch @@ -29,10 +29,12 @@ double d6 = (double) MathHelper.sqrt(d3 * d3 + d4 * d4 + d5 * d5); if (d6 != 0.0D) { -@@ -64,6 +74,12 @@ +@@ -63,7 +73,13 @@ + MovingObjectPosition movingobjectposition = ProjectileHelper.a((Entity) this, this::a); if (movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.MISS) { - this.a(movingobjectposition); +- this.a(movingobjectposition); ++ this.preOnHit(movingobjectposition); // CraftBukkit - projectile hit event + + // CraftBukkit start - Fire ProjectileHitEvent + if (this.dead) { diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityFireworks.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityFireworks.patch index 872f22c6fa..4d5a32a5a8 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityFireworks.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityFireworks.patch @@ -9,6 +9,15 @@ public class EntityFireworks extends IProjectile { public static final DataWatcherObject FIREWORK_ITEM = DataWatcher.a(EntityFireworks.class, DataWatcherRegistry.g); +@@ -130,7 +132,7 @@ + MovingObjectPosition movingobjectposition = ProjectileHelper.a((Entity) this, this::a); + + if (!this.noclip) { +- this.a(movingobjectposition); ++ this.preOnHit(movingobjectposition); // CraftBukkit - projectile hit event + this.impulse = true; + } + @@ -145,7 +147,11 @@ } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityFishingHook.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityFishingHook.patch index fa548f1180..76ecfffcc2 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityFishingHook.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityFishingHook.patch @@ -26,6 +26,15 @@ private EntityFishingHook(World world, EntityHuman entityhuman, int i, int j) { super(EntityTypes.FISHING_BOBBER, world); this.b = new Random(); +@@ -244,7 +256,7 @@ + private void m() { + MovingObjectPosition movingobjectposition = ProjectileHelper.a((Entity) this, this::a); + +- this.a(movingobjectposition); ++ this.preOnHit(movingobjectposition); // CraftBukkit - projectile hit event + } + + @Override @@ -291,6 +303,10 @@ this.waitTime = 0; this.ai = 0; diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityLlamaSpit.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityLlamaSpit.patch new file mode 100644 index 0000000000..562b8a14ee --- /dev/null +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityLlamaSpit.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/entity/projectile/EntityLlamaSpit.java ++++ b/net/minecraft/world/entity/projectile/EntityLlamaSpit.java +@@ -34,7 +34,7 @@ + MovingObjectPosition movingobjectposition = ProjectileHelper.a((Entity) this, this::a); + + if (movingobjectposition != null) { +- this.a(movingobjectposition); ++ this.preOnHit(movingobjectposition); // CraftBukkit - projectile hit event + } + + double d0 = this.locX() + vec3d.x; diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityProjectile.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityProjectile.patch new file mode 100644 index 0000000000..1b906a8ae7 --- /dev/null +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityProjectile.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/entity/projectile/EntityProjectile.java ++++ b/net/minecraft/world/entity/projectile/EntityProjectile.java +@@ -57,7 +57,7 @@ + } + + if (movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.MISS && !flag) { +- this.a(movingobjectposition); ++ this.preOnHit(movingobjectposition); // CraftBukkit - projectile hit event + } + + this.checkBlockCollisions(); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityShulkerBullet.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityShulkerBullet.patch index 618d82e939..7936a5259f 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityShulkerBullet.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityShulkerBullet.patch @@ -22,6 +22,15 @@ @Override public SoundCategory getSoundCategory() { return SoundCategory.HOSTILE; +@@ -218,7 +231,7 @@ + MovingObjectPosition movingobjectposition = ProjectileHelper.a((Entity) this, this::a); + + if (movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.MISS) { +- this.a(movingobjectposition); ++ this.preOnHit(movingobjectposition); // CraftBukkit - projectile hit event + } + } + @@ -280,7 +293,7 @@ if (flag) { this.a(entityliving, entity); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/projectile/IProjectile.patch b/paper-server/nms-patches/net/minecraft/world/entity/projectile/IProjectile.patch index 7e46f4c456..3fd477f568 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/projectile/IProjectile.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/projectile/IProjectile.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/IProjectile.java +++ b/net/minecraft/world/entity/projectile/IProjectile.java -@@ -15,6 +15,10 @@ +@@ -15,12 +15,20 @@ import net.minecraft.world.phys.MovingObjectPositionEntity; import net.minecraft.world.phys.Vec3D; @@ -11,7 +11,17 @@ public abstract class IProjectile extends Entity { private UUID shooter; -@@ -30,6 +34,7 @@ + private int c; + private boolean d; + ++ // CraftBukkit start ++ private boolean hitCancelled = false; ++ // CraftBukkit end ++ + IProjectile(EntityTypes entitytypes, World world) { + super(entitytypes, world); + } +@@ -30,6 +38,7 @@ this.shooter = entity.getUniqueID(); this.c = entity.getId(); } @@ -19,11 +29,32 @@ } -@@ -112,6 +117,7 @@ +@@ -111,6 +120,16 @@ + this.setMot(this.getMot().add(vec3d.x, entity.isOnGround() ? 0.0D : vec3d.y, vec3d.z)); } ++ // CraftBukkit start - call projectile hit event ++ protected void preOnHit(MovingObjectPosition movingobjectposition) { ++ org.bukkit.event.entity.ProjectileHitEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this, movingobjectposition); ++ this.hitCancelled = event != null && event.isCancelled(); ++ if (movingobjectposition.getType() == MovingObjectPosition.EnumMovingObjectType.BLOCK || !this.hitCancelled) { ++ this.a(movingobjectposition); // PAIL rename onHit ++ } ++ } ++ // CraftBukkit end ++ protected void a(MovingObjectPosition movingobjectposition) { -+ org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this, movingobjectposition); // CraftBukkit - Call event MovingObjectPosition.EnumMovingObjectType movingobjectposition_enummovingobjecttype = movingobjectposition.getType(); - if (movingobjectposition_enummovingobjecttype == MovingObjectPosition.EnumMovingObjectType.ENTITY) { +@@ -125,6 +144,11 @@ + protected void a(MovingObjectPositionEntity movingobjectpositionentity) {} + + protected void a(MovingObjectPositionBlock movingobjectpositionblock) { ++ // CraftBukkit start - cancellable hit event ++ if (hitCancelled) { ++ return; ++ } ++ // CraftBukkit end + IBlockData iblockdata = this.world.getType(movingobjectpositionblock.getBlockPosition()); + + iblockdata.a(this.world, iblockdata, movingobjectpositionblock, this); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index d0b6662366..43750df524 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -1167,9 +1167,9 @@ public class CraftEventFactory { return event; } - public static void callProjectileHitEvent(Entity entity, MovingObjectPosition position) { + public static ProjectileHitEvent callProjectileHitEvent(Entity entity, MovingObjectPosition position) { if (position.getType() == MovingObjectPosition.EnumMovingObjectType.MISS) { - return; + return null; } Block hitBlock = null; @@ -1187,6 +1187,7 @@ public class CraftEventFactory { ProjectileHitEvent event = new ProjectileHitEvent((Projectile) entity.getBukkitEntity(), hitEntity, hitBlock, hitFace); entity.world.getServer().getPluginManager().callEvent(event); + return event; } public static ExpBottleEvent callExpBottleEvent(Entity entity, int exp) {