From 1d54397474b270227e82aabf15ef5444ecfe839c Mon Sep 17 00:00:00 2001 From: md_5 Date: Fri, 2 Dec 2016 09:38:50 +1100 Subject: [PATCH] SPIGOT-911: Add hitBlock to PorjectileHitEvent --- .../org/bukkit/craftbukkit/event/CraftEventFactory.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index 2621b777db..0508413044 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -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; }