So I'm making a plugin where you throw a firework star and it creates a certain firework effect where it hits. I know how to make the firework and stuff, but I don't know how to create the throwing item code and detecting the location of the firework star thrown. Any help?
You may be able to have an egg/snowball be thrown when you right click when holding a firework star, and reduce the stack you are holding by one. you MAY be able to then change the egg/snowball to look like a firework star, but I am not sure. You should then be able to listen for the egg/snowball hitting something event. Failing that you could spawn an ItemStack for the firework star, and change its velocity perhaps?
MUG806 I give you props. I never thought of changing what the item looks like to the player to represent another item.
I can't remember from where, but I know that it is possible to launch a projectile using player.getEyeHeight()... I'll do some research, but make no promises.
player.launchProjectile(Snowball.class) you can change Snowball to any regular projectile like eggs and enderpearls i think. an i think you should be able todo player.getEyeHeight().launchProjectile(Snowball.class) aswell. If this is wronge sorry but i dont have the time to check at this moment!
Drkmaster83 callum2904 It doesn't look like you can do that. launchProjectile() is a LivingEntity method, while getEyeHeight() returns a double. I don't see why player.launchProjectile() wouldn't do the trick?
FunnyGopher i know that player.launchProjectile() works but from the message above it said something about player.getEyeHeight so i was suggesting it as an idea and when i was typing forgot that it wouldnt work as i was in a rush todo something!
Reptar_ The way I do this in my OtherWeapons plugin is this: PlayerInteractEvent > Get Right Click > Get Item In Hand > Snowball snow = player.launchProjectile(Snowball.class) > snow.setFireTicks(100); > snow.setMetadata("Light", new FixedMetadataValue(plugin, "Light")); ProjectileHitEvent > Get Entity Type > Get If It Has The Metadata Light > Apply Effect At Ending Location (event.getEntity().getLocation()