Search in sources :

Example 1 with StaticSpawnLocationComponent

use of org.terasology.engine.logic.players.StaticSpawnLocationComponent in project Terasology by MovingBlocks.

the class ClientCommands method setSpawnLocation.

/**
 * Sets the spawn location for the client to the current location
 * @return String containing debug information on the entity
 */
@Command(shortDescription = "Sets the spawn location for the client to the current location", runOnServer = true, requiredPermission = PermissionManager.CHEAT_PERMISSION)
public String setSpawnLocation(@Sender EntityRef sender) {
    EntityRef clientInfo = sender.getComponent(ClientComponent.class).clientInfo;
    StaticSpawnLocationComponent staticSpawnLocationComponent = new StaticSpawnLocationComponent();
    if (clientInfo.hasComponent(StaticSpawnLocationComponent.class)) {
        staticSpawnLocationComponent = clientInfo.getComponent(StaticSpawnLocationComponent.class);
    }
    staticSpawnLocationComponent.position = sender.getComponent(ClientComponent.class).character.getComponent(LocationComponent.class).getWorldPosition(new Vector3f());
    clientInfo.addOrSaveComponent(staticSpawnLocationComponent);
    return "Set spawn location to- " + staticSpawnLocationComponent.position;
}
Also used : StaticSpawnLocationComponent(org.terasology.engine.logic.players.StaticSpawnLocationComponent) Vector3f(org.joml.Vector3f) EntityRef(org.terasology.engine.entitySystem.entity.EntityRef) ClientComponent(org.terasology.engine.network.ClientComponent) Command(org.terasology.engine.logic.console.commandSystem.annotations.Command)

Aggregations

Vector3f (org.joml.Vector3f)1 EntityRef (org.terasology.engine.entitySystem.entity.EntityRef)1 Command (org.terasology.engine.logic.console.commandSystem.annotations.Command)1 StaticSpawnLocationComponent (org.terasology.engine.logic.players.StaticSpawnLocationComponent)1 ClientComponent (org.terasology.engine.network.ClientComponent)1