Cannot Project a Projectile.

Discussion in 'Plugin Development' started by Darkllama23, Dec 28, 2013.

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

    Darkllama23

    Trying to make a rocket plugin, and this line of code keeps giving me error:

    Firework f = e.getPlayer().launchProjectile(Firework.class);

    Eclipse Tells Me: "Bound mismatch: The generic method launchProjectile(Class<? extends T>) of type LivingEntity is not applicable for the arguments (Class<Firework>). The inferred type Firework is not a valid substitute for the bounded parameter <T extends Projectile>"

    I see other people using this code without issues, what is wrong?
    Thanks.
     
  2. Offline

    NathanWolf

    I don't think a Firework is a projectile. You can't launch them like that- what code have you seen that does this? A firework just spawns as an entity and shoots up I the air, you can't launch it like an arrow or snowball.
     
  3. Offline

    GangstaCupcake1

    A firework is an entity. Do this:

    Firework f = (Firework)world.spawnEntity(loc, EntityType.FIREWORK);

    loc being a Location where the firework is being spawned and world being the world it is happening in.
     
  4. Offline

    Darkllama23

    Ok this works but how do i make it so it fires in the direction of the player.
     
  5. Offline

    GaaTavares

    Direction where the player is looking?
    Use p.getDirection() which returns a vector.
     
  6. Offline

    Darkllama23

    GaaTavares p.getDirection() is undefined for the type Player.
     
  7. Offline

    GaaTavares

    try p.getLocation().getDirection()
     
  8. Offline

    thepaperboy99

    In pretty sure it's player.getEyeLocation().getDirection().
     
  9. Offline

    Darkllama23

    GaaTavares thepaperboy99 Awesome! Even though it doesnt deal with the op, how do you make it explode on impact?
     
  10. Offline

    thepaperboy99

    I have no idea lol.
     
  11. Offline

    DeMaggo

    Get the projectiles speed, the distance to the player, calculate the time to fly and give it its countdown in some way.
     
Thread Status:
Not open for further replies.

Share This Page