Search in sources :

Example 46 with ClientComponent

use of org.terasology.engine.network.ClientComponent in project Terasology by MovingBlocks.

the class MovementDebugCommands method flight.

@Command(shortDescription = "Grants flight", runOnServer = true, requiredPermission = PermissionManager.CHEAT_PERMISSION)
public String flight(@Sender EntityRef client) {
    ClientComponent clientComp = client.getComponent(ClientComponent.class);
    clientComp.character.send(new SetMovementModeEvent(MovementMode.FLYING));
    return "Flight mode toggled";
}
Also used : SetMovementModeEvent(org.terasology.engine.logic.characters.events.SetMovementModeEvent) ClientComponent(org.terasology.engine.network.ClientComponent) Command(org.terasology.engine.logic.console.commandSystem.annotations.Command)

Example 47 with ClientComponent

use of org.terasology.engine.network.ClientComponent in project Terasology by MovingBlocks.

the class MovementDebugCommands method teleportPlayerToMe.

@Command(shortDescription = "Teleport player to you", runOnServer = true, requiredPermission = PermissionManager.USER_MANAGEMENT_PERMISSION)
public String teleportPlayerToMe(@Sender EntityRef sender, @CommandParam("username") String username) {
    for (EntityRef clientEntity : entityManager.getEntitiesWith(ClientComponent.class)) {
        EntityRef clientInfo = clientEntity.getComponent(ClientComponent.class).clientInfo;
        DisplayNameComponent name = clientInfo.getComponent(DisplayNameComponent.class);
        if (username.equalsIgnoreCase(name.name)) {
            LocationComponent locationComponent = sender.getComponent(LocationComponent.class);
            if (locationComponent != null) {
                Vector3f vLocation = locationComponent.getWorldPosition(new Vector3f());
                ClientComponent clientComp = clientEntity.getComponent(ClientComponent.class);
                if (clientComp != null) {
                    clientComp.character.send(new CharacterTeleportEvent(vLocation));
                    return "Teleporting " + username + " to you at " + vLocation.x + " " + vLocation.y + " " + vLocation.z;
                }
            }
        }
    }
    throw new IllegalArgumentException("No such user '" + username + "'");
}
Also used : DisplayNameComponent(org.terasology.engine.logic.common.DisplayNameComponent) CharacterTeleportEvent(org.terasology.engine.logic.characters.CharacterTeleportEvent) Vector3f(org.joml.Vector3f) EntityRef(org.terasology.engine.entitySystem.entity.EntityRef) ClientComponent(org.terasology.engine.network.ClientComponent) LocationComponent(org.terasology.engine.logic.location.LocationComponent) Command(org.terasology.engine.logic.console.commandSystem.annotations.Command)

Example 48 with ClientComponent

use of org.terasology.engine.network.ClientComponent in project Terasology by MovingBlocks.

the class MovementDebugCommands method sleigh.

@Command(shortDescription = "Toggles the maximum slope the player can walk up", runOnServer = true, requiredPermission = PermissionManager.CHEAT_PERMISSION)
public String sleigh(@Sender EntityRef client) {
    ClientComponent clientComp = client.getComponent(ClientComponent.class);
    CharacterMovementComponent move = clientComp.character.getComponent(CharacterMovementComponent.class);
    if (move != null) {
        float oldFactor = move.slopeFactor;
        if (move.slopeFactor > 0.7f) {
            move.slopeFactor = 0.6f;
        } else {
            move.slopeFactor = 0.9f;
        }
        clientComp.character.saveComponent(move);
        return "Slope factor is now " + move.slopeFactor + " (was " + oldFactor + ")";
    }
    return "";
}
Also used : CharacterMovementComponent(org.terasology.engine.logic.characters.CharacterMovementComponent) ClientComponent(org.terasology.engine.network.ClientComponent) Command(org.terasology.engine.logic.console.commandSystem.annotations.Command)

Example 49 with ClientComponent

use of org.terasology.engine.network.ClientComponent in project Terasology by MovingBlocks.

the class MovementDebugCommands method ghost.

@Command(shortDescription = "Grants flight and movement through walls", runOnServer = true, requiredPermission = PermissionManager.CHEAT_PERMISSION)
public String ghost(@Sender EntityRef client) {
    ClientComponent clientComp = client.getComponent(ClientComponent.class);
    clientComp.character.send(new SetMovementModeEvent(MovementMode.GHOSTING));
    return "Ghost mode toggled";
}
Also used : SetMovementModeEvent(org.terasology.engine.logic.characters.events.SetMovementModeEvent) ClientComponent(org.terasology.engine.network.ClientComponent) Command(org.terasology.engine.logic.console.commandSystem.annotations.Command)

Example 50 with ClientComponent

use of org.terasology.engine.network.ClientComponent in project Terasology by MovingBlocks.

the class MovementDebugCommands method restoreSpeed.

@Command(shortDescription = "Restore normal speed values", runOnServer = true, requiredPermission = PermissionManager.CHEAT_PERMISSION)
public String restoreSpeed(@Sender EntityRef client) {
    ClientComponent clientComp = client.getComponent(ClientComponent.class);
    Optional<Prefab> prefab = Assets.get(new ResourceUrn("engine:player"), Prefab.class);
    CharacterMovementComponent moveDefault = prefab.get().getComponent(CharacterMovementComponent.class);
    CharacterMovementComponent move = clientComp.character.getComponent(CharacterMovementComponent.class);
    if (move != null && moveDefault != null) {
        move.jumpSpeed = moveDefault.jumpSpeed;
        move.speedMultiplier = moveDefault.speedMultiplier;
        move.runFactor = moveDefault.runFactor;
        move.stepHeight = moveDefault.stepHeight;
        move.slopeFactor = moveDefault.slopeFactor;
        move.distanceBetweenFootsteps = moveDefault.distanceBetweenFootsteps;
        clientComp.character.saveComponent(move);
    }
    return "Normal speed values restored";
}
Also used : CharacterMovementComponent(org.terasology.engine.logic.characters.CharacterMovementComponent) ResourceUrn(org.terasology.gestalt.assets.ResourceUrn) ClientComponent(org.terasology.engine.network.ClientComponent) Prefab(org.terasology.engine.entitySystem.prefab.Prefab) Command(org.terasology.engine.logic.console.commandSystem.annotations.Command)

Aggregations

ClientComponent (org.terasology.engine.network.ClientComponent)54 EntityRef (org.terasology.engine.entitySystem.entity.EntityRef)30 Command (org.terasology.engine.logic.console.commandSystem.annotations.Command)27 Vector3f (org.joml.Vector3f)13 LocationComponent (org.terasology.engine.logic.location.LocationComponent)13 CharacterMovementComponent (org.terasology.engine.logic.characters.CharacterMovementComponent)11 DisplayNameComponent (org.terasology.engine.logic.common.DisplayNameComponent)10 ConsoleCommand (org.terasology.engine.logic.console.commandSystem.ConsoleCommand)8 ReceiveEvent (org.terasology.engine.entitySystem.event.ReceiveEvent)6 CharacterTeleportEvent (org.terasology.engine.logic.characters.CharacterTeleportEvent)6 DropItemEvent (org.terasology.engine.logic.inventory.events.DropItemEvent)4 BlockFamily (org.terasology.engine.world.block.family.BlockFamily)4 BlockItemFactory (org.terasology.engine.world.block.items.BlockItemFactory)4 Quaternionf (org.joml.Quaternionf)3 Prefab (org.terasology.engine.entitySystem.prefab.Prefab)3 LocalPlayer (org.terasology.engine.logic.players.LocalPlayer)3 Client (org.terasology.engine.network.Client)3 Vector3ic (org.joml.Vector3ic)2 EngineEntityManager (org.terasology.engine.entitySystem.entity.internal.EngineEntityManager)2 AliveCharacterComponent (org.terasology.engine.logic.characters.AliveCharacterComponent)2