use of net.glowstone.net.message.play.entity.DestroyEntitiesMessage in project Glowstone by GlowstoneMC.
the class EntityUtils method refresh.
/**
* Refreshes the entity for nearby clients.
*
* <p>This will first destroy, and then spawn the painting again using its current art and
* facing value.
*
* @param entity the entity to refresh.
*/
public static void refresh(@NotNull GlowEntity entity) {
final DestroyEntitiesMessage destroyMessage = new DestroyEntitiesMessage(Collections.singletonList(entity.getEntityId()));
final List<Message> spawnMessages = entity.createSpawnMessage();
final Message[] messages = new Message[] { destroyMessage, spawnMessages.get(0) };
entity.getWorld().getRawPlayers().stream().filter(p -> p.canSeeEntity(entity)).forEach(p -> p.getSession().sendAll(messages));
}
Aggregations