diff options
Diffstat (limited to 'patch-remap/og/net/minecraft/world/entity/projectile/IProjectile.patch')
-rw-r--r-- | patch-remap/og/net/minecraft/world/entity/projectile/IProjectile.patch | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/patch-remap/og/net/minecraft/world/entity/projectile/IProjectile.patch b/patch-remap/og/net/minecraft/world/entity/projectile/IProjectile.patch new file mode 100644 index 0000000000..3f2ade60da --- /dev/null +++ b/patch-remap/og/net/minecraft/world/entity/projectile/IProjectile.patch @@ -0,0 +1,61 @@ +--- a/net/minecraft/world/entity/projectile/IProjectile.java ++++ b/net/minecraft/world/entity/projectile/IProjectile.java +@@ -25,6 +25,10 @@ + import net.minecraft.world.phys.MovingObjectPositionEntity; + import net.minecraft.world.phys.Vec3D; + ++// CraftBukkit start ++import org.bukkit.projectiles.ProjectileSource; ++// CraftBukkit end ++ + public abstract class IProjectile extends Entity implements TraceableEntity { + + @Nullable +@@ -34,6 +38,10 @@ + private boolean leftOwner; + private boolean hasBeenShot; + ++ // CraftBukkit start ++ private boolean hitCancelled = false; ++ // CraftBukkit end ++ + IProjectile(EntityTypes<? extends IProjectile> entitytypes, World world) { + super(entitytypes, world); + } +@@ -43,6 +51,7 @@ + this.ownerUUID = entity.getUUID(); + this.cachedOwner = entity; + } ++ this.projectileSource = (entity != null && entity.getBukkitEntity() instanceof ProjectileSource) ? (ProjectileSource) entity.getBukkitEntity() : null; // CraftBukkit + + } + +@@ -167,6 +176,16 @@ + this.setDeltaMovement(this.getDeltaMovement().add(vec3d.x, entity.onGround() ? 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.onHit(movingobjectposition); ++ } ++ } ++ // CraftBukkit end ++ + protected void onHit(MovingObjectPosition movingobjectposition) { + MovingObjectPosition.EnumMovingObjectType movingobjectposition_enummovingobjecttype = movingobjectposition.getType(); + +@@ -187,6 +206,11 @@ + protected void onHitEntity(MovingObjectPositionEntity movingobjectpositionentity) {} + + protected void onHitBlock(MovingObjectPositionBlock movingobjectpositionblock) { ++ // CraftBukkit start - cancellable hit event ++ if (hitCancelled) { ++ return; ++ } ++ // CraftBukkit end + IBlockData iblockdata = this.level().getBlockState(movingobjectpositionblock.getBlockPos()); + + iblockdata.onProjectileHit(this.level(), iblockdata, movingobjectpositionblock, this); |