mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-23 17:37:45 +01:00
SPIGOT-3538: Add getHitBlockFace for ProjectileHitEvent
This commit is contained in:
parent
b54b9409e0
commit
a408f3751e
@ -940,12 +940,13 @@ public class CraftEventFactory {
|
|||||||
|
|
||||||
public static ProjectileHitEvent callProjectileHitEvent(Entity entity, MovingObjectPosition position) {
|
public static ProjectileHitEvent callProjectileHitEvent(Entity entity, MovingObjectPosition position) {
|
||||||
Block hitBlock = null;
|
Block hitBlock = null;
|
||||||
|
BlockFace hitFace = null;
|
||||||
if (position.type == MovingObjectPosition.EnumMovingObjectType.BLOCK) {
|
if (position.type == MovingObjectPosition.EnumMovingObjectType.BLOCK) {
|
||||||
BlockPosition blockposition = position.getBlockPosition();
|
hitBlock = CraftBlock.at(entity.world, position.getBlockPosition());
|
||||||
hitBlock = entity.getBukkitEntity().getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
|
hitFace = CraftBlock.notchToBlockFace(position.direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
ProjectileHitEvent event = new ProjectileHitEvent((Projectile) entity.getBukkitEntity(), position.entity == null ? null : position.entity.getBukkitEntity(), hitBlock);
|
ProjectileHitEvent event = new ProjectileHitEvent((Projectile) entity.getBukkitEntity(), position.entity == null ? null : position.entity.getBukkitEntity(), hitBlock, hitFace);
|
||||||
entity.world.getServer().getPluginManager().callEvent(event);
|
entity.world.getServer().getPluginManager().callEvent(event);
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user