Search in sources :

Example 1 with StaticSpawnLocationComponent

use of org.terasology.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();
    clientInfo.addOrSaveComponent(staticSpawnLocationComponent);
    return "Set spawn location to- " + staticSpawnLocationComponent.position;
}
Also used : StaticSpawnLocationComponent(org.terasology.logic.players.StaticSpawnLocationComponent) EntityRef(org.terasology.entitySystem.entity.EntityRef) ClientComponent(org.terasology.network.ClientComponent) Command(org.terasology.logic.console.commandSystem.annotations.Command)

Aggregations

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