@EventHandler public void onEntityHitEvent(ProjectileHitEvent e) { Projectile p = e.getEntity(); if(!(p instanceof Arrow)) return; Arrow a = (Arrow) p; a.getWorld().createExplosion(a.getLocation(), 1.0F); How would I get this so that the arrow only explodes when it has a certain item meta?
The game can't distinguish between an arrow who's item had custom meta, and just a regular arrow afaik. When it's shot, the item is consumed and an entity is spawned
Use the .getShooter() method for projectiles/arrows. This will return the entity/player that shot the arrow.
Not really after the player that shot the arrow, i was just looking for if theres a way to check the item meta of the arrow or the bow that shot it
when shot, apply a fixed metadata value to it using Entity#setMetaData or whatever the method is called. when it lands, check for the metadata value. if it's null, return, else, explode.
What you can do is to create a hashmap where you put the arrow in as a key and have and itemmeta or a list of strings as an object, and you can use that as an arrow identification system. When you fire the arrow, put it in, and when it lands, you can get the data feom the hashmap and compare it to see if it has the right meta or something.
There's an event for that. Something like ProjectileShootEvent or ProjectileLaunchEvent or something similar Sent from my Nexus 5 using Tapatalk