ArrowHitBlockEvent
I've discontinued development of this plugin due to the collapse of Bukkit and Mojang's handling of the whole situation. The source code is available and it's a fairly simple plugin. Feel free to do with it what you wish.
The Problem
Say you want to see what block an arrow hit. Sounds simple? Turns out it isn't. Finding what block the arrow hit is pretty much impossible using the BukkitAPI.
The Solution
This plugin fires an event when an arrow hits a block. It provides the arrow, and the block it hit. It's really simple to use. Just put the jar in your build path, and you'll have access to the following event
@EventHandler private void onArrowHitBlock(ArrowHitBlockEvent event) { Arrow arrow = event.getArrow(); Block block = event.getBlock(); // the block that was hit }
Other Things To Note
As this plugin uses reflection to access hidden methods within CraftBukkit, it will break on significant updates. Make sure to use a version that matches the version of CraftBukkit your server runs on.
PLEASE UPGRADE TO 1.7.9@ :D
@Valon750
I tested it with skulls and it works fine. You should check your code to make sure the event handler is working correctly.
@nullschritt
I'm not sure.Craftbukkit may have a method that detects when an arrow hits water. You could also try a repeating task that checks what kind of block the arrow is in. Probably a good idea to ask on the Bukkit forums and see if anyone has tried doing it before.
@Valon750
I'll have a look at skulls and see what's happening there.
@GoldenEagle1995
I don't think the technique used here would work for pearls as they despawn instantly. I may have a quick look at supporting other projectiles but no promises.
Could you also add enderpearl i know it's a lot of work but it would help me a lot thanks and pm me
Hi! Looks neat, but is there a way to detect when an arrow hits water?
The duplicate event bug has been fixed in the latest dev version of craftbukkit.
@minepipe
Updated to 1.7. There are some minor bugs though. Gotta wait on craftbukkit to fix them.
Could you upload this to 1.7.2? It would make me happy :D
@minepipe
No problem. Glad you found it useful :-)
Thanks, bro!