API for sending entity spawn packet to client
Viewer#spawnFakeEntity(EntityArchetype, Location)
- sends an enttiy spawn packet to a single player,without actually spawning the entity it on server side
World#spawnFakeEntity(EntityArchetype, Position)
- sends an enttiy spawn packet to a nearby players, without actually spawning the entity it on server side
Viewer#spawnFakeEntity(EntityArchetype, Vector3d)
Viewer already can only exist on a particular World iirc, so it doesn't make sense to be passing a Location object.
How will this entity removed from the client? Destroy packets are expected for this, this should also happen when the entity is outside of the view distance of the player. What happens if the player gets back in the view distance of the entity, should it reappear or a new fake entity needs to be spawned.
There will need to be tracking for what player sees what entity. Minecraft already does this (net.minecraft.entity.EntityTracker), it might be possible to use that.
This fake entity proposal sounds like a specific case of the more general "contexual" API's that I think were drafted at some point.
Maybe it's better to use a custom entity that can be "disguised" as a specific entity. So we don't have add custom tracking, but it will still be a entity. So it's not really "fake". This in combination with a contextual API would be great.
@Cybermaxke Would this API support the use-case of showing an item entity in a shop only to a player who's viewing that shop?
In the idea of spawning a entity on the server and just showing the "fake" entity on the client. Would it make more sense for a function more like the following
entity.setSkin(EntityArchetype, Viewer...)
Whereby the entity is the server entity, the entity archetype is the "fake" entity to display with the viewers being those who see the "fake" entity?
Or some other combo of that such as
viewer.setSkinOf(Entity, EntityArchetype)