From 5e9fc1140e0e33c057a1788406b4d18b77886d5c Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Thu, 27 Dec 2018 12:17:32 +1100 Subject: [PATCH] SPIGOT-3538: Add getHitBlockFace for ProjectileHitEvent By: md_5 --- .../bukkit/event/entity/ProjectileHitEvent.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/paper-api/src/main/java/org/bukkit/event/entity/ProjectileHitEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/ProjectileHitEvent.java index 35f4148bb7..4b29753d75 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/ProjectileHitEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/ProjectileHitEvent.java @@ -1,6 +1,7 @@ package org.bukkit.event.entity; import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; import org.bukkit.entity.Entity; import org.bukkit.entity.Projectile; import org.bukkit.event.HandlerList; @@ -12,6 +13,7 @@ public class ProjectileHitEvent extends EntityEvent { private static final HandlerList handlers = new HandlerList(); private final Entity hitEntity; private final Block hitBlock; + private final BlockFace hitFace; public ProjectileHitEvent(final Projectile projectile) { this(projectile, null, null); @@ -26,9 +28,14 @@ public class ProjectileHitEvent extends EntityEvent { } public ProjectileHitEvent(final Projectile projectile, Entity hitEntity, Block hitBlock) { + this(projectile, hitEntity, hitBlock, null); + } + + public ProjectileHitEvent(final Projectile projectile, Entity hitEntity, Block hitBlock, BlockFace hitFace) { super(projectile); this.hitEntity = hitEntity; this.hitBlock = hitBlock; + this.hitFace = hitFace; } @Override @@ -45,6 +52,16 @@ public class ProjectileHitEvent extends EntityEvent { return hitBlock; } + /** + * Gets the block face that was hit, if it was a block that was hit and the + * face was provided in the vent. + * + * @return hit face or else null + */ + public BlockFace getHitBlockFace() { + return hitFace; + } + /** * Gets the entity that was hit, if it was an entity that was hit. *