Throw Any Item

Discussion in 'Plugin Development' started by Reptar_, Jun 6, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    Reptar_

    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?
     
  2. Offline

    MUG806

    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?
     
  3. Offline

    FunnyGopher

    MUG806
    I give you props. I never thought of changing what the item looks like to the player to represent another item. :)
     
    MUG806 likes this.
  4. Offline

    Drkmaster83

    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.
     
  5. Offline

    callum2904

    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!
     
  6. Offline

    FunnyGopher

    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?
     
  7. Offline

    callum2904

    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!
     
  8. Offline

    Rockon999

    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();)
     
Thread Status:
Not open for further replies.

Share This Page