diff options
Diffstat (limited to 'patch-remap/mache-spigotflower-stripped/net/minecraft/world/entity/projectile/Projectile.java.patch')
-rw-r--r-- | patch-remap/mache-spigotflower-stripped/net/minecraft/world/entity/projectile/Projectile.java.patch | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower-stripped/net/minecraft/world/entity/projectile/Projectile.java.patch b/patch-remap/mache-spigotflower-stripped/net/minecraft/world/entity/projectile/Projectile.java.patch new file mode 100644 index 0000000000..7389e32773 --- /dev/null +++ b/patch-remap/mache-spigotflower-stripped/net/minecraft/world/entity/projectile/Projectile.java.patch @@ -0,0 +1,69 @@ +--- a/net/minecraft/world/entity/projectile/Projectile.java ++++ b/net/minecraft/world/entity/projectile/Projectile.java +@@ -24,6 +24,9 @@ + import net.minecraft.world.phys.EntityHitResult; + import net.minecraft.world.phys.HitResult; + import net.minecraft.world.phys.Vec3; ++// CraftBukkit start ++import org.bukkit.projectiles.ProjectileSource; ++// CraftBukkit end + + public abstract class Projectile extends Entity implements TraceableEntity { + +@@ -34,8 +37,12 @@ + private boolean leftOwner; + private boolean hasBeenShot; + +- Projectile(EntityType<? extends Projectile> entitytype, Level level) { +- super(entitytype, level); ++ // CraftBukkit start ++ private boolean hitCancelled = false; ++ // CraftBukkit end ++ ++ Projectile(EntityType<? extends Projectile> entityType, Level level) { ++ super(entityType, level); + } + + public void setOwner(@Nullable Entity entity) { +@@ -43,6 +50,7 @@ + this.ownerUUID = entity.getUUID(); + this.cachedOwner = entity; + } ++ this.projectileSource = (owner != null && owner.getBukkitEntity() instanceof ProjectileSource) ? (ProjectileSource) owner.getBukkitEntity() : null; // CraftBukkit + + } + +@@ -172,8 +175,15 @@ + this.setDeltaMovement(this.getDeltaMovement().add(vec3.x, entity.onGround() ? 0.0D : vec3.y, vec3.z)); + } + +- protected void onHit(HitResult hitresult) { +- HitResult.Type hitresult_type = hitresult.getType(); ++ // CraftBukkit start - call projectile hit event ++ protected void preOnHit(HitResult movingobjectposition) { ++ org.bukkit.event.entity.ProjectileHitEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this, movingobjectposition); ++ this.hitCancelled = event != null && event.isCancelled(); ++ if (movingobjectposition.getType() == HitResult.EnumMovingObjectType.BLOCK || !this.hitCancelled) { ++ this.onHit(movingobjectposition); ++ } ++ } ++ // CraftBukkit end + + if (hitresult_type == HitResult.Type.ENTITY) { + this.onHitEntity((EntityHitResult) hitresult); +@@ -191,8 +204,13 @@ + + protected void onHitEntity(EntityHitResult entityhitresult) {} + +- protected void onHitBlock(BlockHitResult blockhitresult) { +- BlockState blockstate = this.level().getBlockState(blockhitresult.getBlockPos()); ++ protected void onHitBlock(BlockHitResult result) { ++ // CraftBukkit start - cancellable hit event ++ if (hitCancelled) { ++ return; ++ } ++ // CraftBukkit end ++ IBlockData iblockdata = this.level().getBlockState(result.getBlockPos()); + + blockstate.onProjectileHit(this.level(), blockstate, blockhitresult, this); + } |