mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-06 00:07:56 +01:00
SPIGOT-3538: Add getHitBlockFace for ProjectileHitEvent
By: md_5 <git@md-5.net>
This commit is contained in:
parent
6a8b528359
commit
5e9fc1140e
@ -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.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user