Entity spawning?

Is entity spawning supported yet? If it is, how do you do it?

Afaik, it is not yet supported.

You can, by using createEntity on an EntityUniverse (e.g. World)
https://github.com/SpongePowered/SpongeAPI/blob/master/src/main/java/org/spongepowered/api/world/extent/EntityUniverse.java

But how do you get the EntityType or EntitySnapshot object from the entity interface?

Entity extends EntityState, so therefore, Entity#getType() and Entity#getSnapshot().

But how do you instantiate or otherwise get an object which you can use that on? It is an interface, remember.

You don’t instantiate it yourself, you’d use EntityUniverse#createEntity(EntityType,Vector3d)… If you haven’t learned about inheritance, please read up on it.

But I mean that all of the entity types in EntityTypes are null. I can’t really make an entity because I can’t instantiate an interface, but I need to instantiate an entity to get it’s type to make an entity. It looks like a chicken and egg situation to me.

@piepie62 I think that the general idea is that you compile against EntityType.WHATEVER and then it gets rewritten at runtime by the implementation (rather then using a sponge-only enum and having to monkey around with mapping it to whatever EntityType deal Forge uses)

Ah. Thank you for the insight!

Wouldn’t you add the entity to the world! There is net minecraft code you can use like on Bukkit!

Okay, new problem. The code in MixinWorld seems to do nothing but return an empty Optional object. Is this because Sponge is not finished yet?

Yes, there are lots of things still to implement, you can tell because it may return Optional.absent() or throw an UnsupportedOperationException or return an empty list or whatever. These things will be added in time.

Read here for what things that are yet to be implemented.

Okay, thank you!