Search in sources :

Example 1 with OnPlayerSpawnedEvent

use of org.terasology.engine.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);
    Vector3ic distance = clientListener.getViewDistance().getChunkDistance();
    updateRelevanceEntity(clientEntity, distance);
    client.character = playerCharacter;
    clientEntity.saveComponent(client);
    playerCharacter.send(new OnPlayerSpawnedEvent());
}
Also used : OnPlayerSpawnedEvent(org.terasology.engine.logic.players.event.OnPlayerSpawnedEvent) Vector3ic(org.joml.Vector3ic) Client(org.terasology.engine.network.Client) ClientComponent(org.terasology.engine.network.ClientComponent) EntityRef(org.terasology.engine.entitySystem.entity.EntityRef)

Aggregations

Vector3ic (org.joml.Vector3ic)1 EntityRef (org.terasology.engine.entitySystem.entity.EntityRef)1 OnPlayerSpawnedEvent (org.terasology.engine.logic.players.event.OnPlayerSpawnedEvent)1 Client (org.terasology.engine.network.Client)1 ClientComponent (org.terasology.engine.network.ClientComponent)1