Search in sources :

Example 1 with GazeMountPointComponent

use of org.terasology.engine.logic.characters.GazeMountPointComponent in project Terasology by MovingBlocks.

the class MovementDebugCommands method showHeight.

@Command(shortDescription = "Show your Height", requiredPermission = PermissionManager.CHEAT_PERMISSION)
public String showHeight(@Sender EntityRef client) {
    ClientComponent clientComp = client.getComponent(ClientComponent.class);
    CharacterMovementComponent move = clientComp.character.getComponent(CharacterMovementComponent.class);
    float height = move.height;
    GazeMountPointComponent gazeMountPointComponent = clientComp.character.getComponent(GazeMountPointComponent.class);
    float eyeHeight = gazeMountPointComponent.translate.y;
    return "Your height: " + height + " Eye-height: " + eyeHeight;
}
Also used : GazeMountPointComponent(org.terasology.engine.logic.characters.GazeMountPointComponent) CharacterMovementComponent(org.terasology.engine.logic.characters.CharacterMovementComponent) ClientComponent(org.terasology.engine.network.ClientComponent) Command(org.terasology.engine.logic.console.commandSystem.annotations.Command)

Example 2 with GazeMountPointComponent

use of org.terasology.engine.logic.characters.GazeMountPointComponent in project Terasology by MovingBlocks.

the class MovementDebugCommands method playerEyeHeight.

@Command(shortDescription = "Sets the eye-height of the player", runOnServer = true, requiredPermission = PermissionManager.CHEAT_PERMISSION)
public String playerEyeHeight(@Sender EntityRef client, @CommandParam("eye-height") float amount) {
    EntityRef player = client.getComponent(ClientComponent.class).character;
    try {
        GazeMountPointComponent gazeMountPointComponent = player.getComponent(GazeMountPointComponent.class);
        if (gazeMountPointComponent != null) {
            float prevHeight = gazeMountPointComponent.translate.y;
            gazeMountPointComponent.translate.y = amount;
            Location.removeChild(player, gazeMountPointComponent.gazeEntity);
            Location.attachChild(player, gazeMountPointComponent.gazeEntity, gazeMountPointComponent.translate, new Quaternionf());
            player.saveComponent(gazeMountPointComponent);
            return "Eye-height of player set to " + amount + " (was " + prevHeight + ")";
        }
        return "";
    } catch (NullPointerException e) {
        e.printStackTrace();
        return "";
    }
}
Also used : GazeMountPointComponent(org.terasology.engine.logic.characters.GazeMountPointComponent) Quaternionf(org.joml.Quaternionf) EntityRef(org.terasology.engine.entitySystem.entity.EntityRef) ClientComponent(org.terasology.engine.network.ClientComponent) Command(org.terasology.engine.logic.console.commandSystem.annotations.Command)

Aggregations

GazeMountPointComponent (org.terasology.engine.logic.characters.GazeMountPointComponent)2 Command (org.terasology.engine.logic.console.commandSystem.annotations.Command)2 ClientComponent (org.terasology.engine.network.ClientComponent)2 Quaternionf (org.joml.Quaternionf)1 EntityRef (org.terasology.engine.entitySystem.entity.EntityRef)1 CharacterMovementComponent (org.terasology.engine.logic.characters.CharacterMovementComponent)1