SmallFireball not rendering?

Discussion in 'Spigot Plugin Development' started by KuramaStone, Mar 29, 2017.

  1. Hello, I am creating a plugin which will launch fireballs in the direction a player is facing. Multiple fireballs will be spawning, so I'd prefer not to use Player#launchProjectile(). Here is what I am currently using:
    Code (Text):
        private SmallFireball[] spawnFireballs(int amount) {
            SmallFireball[] fireballs = new SmallFireball[amount];
            for(int i = 0; i < amount; i++) {
                SmallFireball fireball = (SmallFireball) player.getWorld()
                        .spawnEntity(getLocation(), EntityType.SMALL_FIREBALL);
                fireballs[i] = fireball;
            return fireballs;
    The Fireball seems to work just fine except it doesn't appear on the screen except for a split second after it spawns. Several seconds after it vanishes fire will appear on the ground where it would have hit making me assume that it is not spawning.

    Why is it doing this? Also the fireballs are not changed once outside of this class.
  2. NathanWolf


    Projectiles are weird, which is why there's a special method for launching them. Why don't you want to use launchProjectile (the "spawning lots of them" reason doesn't make much sense to me)

    If you want to go this route I think you need to use some NMS to call the "shoot" method on the projectile after spawning, and maybe set its dirX, dirY and dirZ fields, maybe call setPositionRotation. I do all these things in my plugin and honestly not sure which one is what makes it work anymore :)
  3. I tried using the launchProjectile method and teleporting the object soon after which doesn't work well. It doesn't teleport until several seconds after they fire and are already 5 blocks out of the original position.

    I am unfamiliar with the NMS shoot method you are referring to. Is it part of the EntitySmallFireball class?
  4. NathanWolf


    Oh, I see- yeah you can't (sadly) launch projectiles from an arbitrary location, so I'm with you there- that's basically why I use all this hacky NMS stuff. Teleporting projectiles after they're spawned/launched doesn't really work either, they just glitch out.

    I think shoot() is a method of the base NMS EntityProject class. It basically initializes the projectile's trajectory, the signature is (dirX, dirY, dirZ, speed, spread) - where the dir's are a directional vector.

    I also set the dirX,dirY and dirZ fields to the direction I want, seems like shoot() doesn't do that.

    And finally I call setPositionRotation (x,y,z,yaw,pitch) though not 100% sure if that's necessary.

    These are all NMS methods and fields on Entity or EntityProjectile.

    EDIT: And you want to call them all before you add the projectile to the World!

    Kind of sounds like a PR for launching a projectile from an arbitrary location would be nice to have!
    • Informative Informative x 1
  5. Ah, thank you. Although EntitySmallFireball is not an instanceof EntityProjectile I was able to look at the source code and decipher how to create have it go in the direction I wanted.
    • Like Like x 1