Solved Get a spawned entity

Discussion in 'Plugin Development' started by TheDiamond06, Jun 11, 2015.

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

    TheDiamond06

    So I have an event where if a player right clicks an item it spawns a random entity.

    This works, however I want the entity to fly up into the air. I know how to do this this, but how would I get this entity. I used World#spawnCreature(); and there might be a way to get that entity at the location I spawned it at, but I do not know how.

    So how would I get that entity into a variable?
     
  2. Offline

    567legodude

    @TheDiamond06 World.spawnEntity returns an entity, so you already have it.
    Entity e = world.spawnEntity()....
    Something like that.
     
  3. Offline

    TheDiamond06

    @567legodude Seems a bit weird how that method returns an entity, but whatever.
     
  4. Offline

    567legodude

    @TheDiamond06 Its not really weird. There are plenty of methods that return something, it's just that you are not required to use it, so you don't always have to put it in a variable.
    Things like scheduleSyncDelayedTask returns an int for the task number, so if you wanted you could cancel the task before it happened.
     
  5. Offline

    TheDiamond06

    @567legodude If the method returns an Entity, then howcome no errors are thrown upon just doing World#spawnCreature without the declaration of an entity.
     
  6. Offline

    567legodude

    @TheDiamond06 Thats what I was saying, its not required that you use the output of a method. Thats just what it returns, java doesn't make you do anything with the return so it doesn't matter if you use what comes out.
     
Thread Status:
Not open for further replies.

Share This Page