Setting Entity Stats (How do you instantiate an Entity?)

Discussion in 'Plugin Development' started by Thumbz, Apr 27, 2012.

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


    Here's basically what I'm trying to do is spawn a fireball with a set direction.

    //Location loc
    //Vector vec
    //World w
    //Player p
    Fireball fire = new Fireball();
    w.spawn(loc, fire)

    the issue is that Fireball seems to be an abstract class, along with every other Entity, so I can't instantiate it.

    if I do:
    p.getWorld().spawn(p.getLocation(), Fireball.class);

    I can get a fireball to spawn, but I can't for the life of me find any way of setting a fireballs direction before spawning it.

    Basically I want a want to know how you set an entities data (is on fire, poisoned, direction, whatever) before you spawn it.

    Thanks very much, I'll make sure to cross post this to the bukkit plugin tutorial wiki as soon as I get a solution,
  2. Offline


    Thumbz Moved to the plugin development forum.
  3. Offline


    Try this, let me know if it works

    Fireball fire = null;
    w.spawn(loc, fire);

    Basically made a new fireball that's null then set direction.
    I haven't tested it but I believe it should work
  4. Offline


    CraigCraig: that would throw a NPE.

    Thumbz: I don't think you can change it before you spawn it, but you can change stuff right after. (world.spawn() returns the spawned entity)
  5. Offline


    Thank you. I managed to get the answer from another thread already, but thanks still.
Thread Status:
Not open for further replies.

Share This Page