SPIGOT-911: Add hitBlock to PorjectileHitEvent

This commit is contained in:
md_5 2016-12-02 09:38:50 +11:00
parent b6ad714e85
commit 1d54397474

View File

@ -779,7 +779,13 @@ public class CraftEventFactory {
}
public static ProjectileHitEvent callProjectileHitEvent(Entity entity, MovingObjectPosition position) {
ProjectileHitEvent event = new ProjectileHitEvent((Projectile) entity.getBukkitEntity(), position.entity == null ? null : position.entity.getBukkitEntity());
Block hitBlock = null;
if (position.type == MovingObjectPosition.EnumMovingObjectType.BLOCK) {
BlockPosition blockposition = position.a();
hitBlock = entity.getBukkitEntity().getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
}
ProjectileHitEvent event = new ProjectileHitEvent((Projectile) entity.getBukkitEntity(), position.entity == null ? null : position.entity.getBukkitEntity(), hitBlock);
entity.world.getServer().getPluginManager().callEvent(event);
return event;
}