Search in sources :

Example 1 with OnPlayerSpawnedEvent

use of org.terasology.logic.players.event.OnPlayerSpawnedEvent in project Terasology by MovingBlocks.

the class PlayerSystem method spawnPlayer.

private void spawnPlayer(EntityRef clientEntity) {
    ClientComponent client = clientEntity.getComponent(ClientComponent.class);
    PlayerFactory playerFactory = new PlayerFactory(entityManager, worldProvider);
    EntityRef playerCharacter = playerFactory.newInstance(clientEntity);
    Client clientListener = networkSystem.getOwner(clientEntity);
    Vector3i distance = clientListener.getViewDistance().getChunkDistance();
    updateRelevanceEntity(clientEntity, distance);
    client.character = playerCharacter;
    clientEntity.saveComponent(client);
    playerCharacter.send(new OnPlayerSpawnedEvent());
}
Also used : OnPlayerSpawnedEvent(org.terasology.logic.players.event.OnPlayerSpawnedEvent) Vector3i(org.terasology.math.geom.Vector3i) Client(org.terasology.network.Client) ClientComponent(org.terasology.network.ClientComponent) EntityRef(org.terasology.entitySystem.entity.EntityRef)

Aggregations

EntityRef (org.terasology.entitySystem.entity.EntityRef)1 OnPlayerSpawnedEvent (org.terasology.logic.players.event.OnPlayerSpawnedEvent)1 Vector3i (org.terasology.math.geom.Vector3i)1 Client (org.terasology.network.Client)1 ClientComponent (org.terasology.network.ClientComponent)1