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