SpongeAPI icon indicating copy to clipboard operation
SpongeAPI copied to clipboard

API for sending entity spawn packet to client

Open NeumimTo opened this issue 6 years ago • 6 comments

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

NeumimTo avatar Mar 21 '19 19:03 NeumimTo

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.

gabizou avatar Mar 21 '19 19:03 gabizou

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.

Cybermaxke avatar Apr 12 '19 10:04 Cybermaxke

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.

simon816 avatar Apr 12 '19 17:04 simon816

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 avatar Apr 12 '19 18:04 Cybermaxke

@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?

pie-flavor avatar Jun 14 '19 17:06 pie-flavor

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)

mosemister avatar Sep 30 '20 20:09 mosemister