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.
-
View User Profile
-
Send Message
Posted May 3, 2014PLEASE UPGRADE TO 1.7.9@ :D
-
View User Profile
-
Send Message
Posted Apr 17, 2014@Valon750
I tested it with skulls and it works fine. You should check your code to make sure the event handler is working correctly.
-
View User Profile
-
Send Message
Posted Apr 15, 2014@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.
-
View User Profile
-
Send Message
Posted Apr 13, 2014Could you also add enderpearl i know it's a lot of work but it would help me a lot thanks and pm me
-
View User Profile
-
Send Message
Posted Mar 30, 2014Hi! Looks neat, but is there a way to detect when an arrow hits water?
-
View User Profile
-
Send Message
Posted Jan 31, 2014The duplicate event bug has been fixed in the latest dev version of craftbukkit.
-
View User Profile
-
Send Message
Posted Dec 19, 2013@minepipe
Updated to 1.7. There are some minor bugs though. Gotta wait on craftbukkit to fix them.
-
View User Profile
-
Send Message
Posted Dec 7, 2013Could you upload this to 1.7.2? It would make me happy :D
-
View User Profile
-
Send Message
Posted Nov 28, 2013@minepipe
No problem. Glad you found it useful :-)
-
View User Profile
-
Send Message
Posted Nov 28, 2013Thanks, bro!