Search in sources :

Example 61 with ClientComponent

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

the class HealthCommands method heal.

@Command(shortDescription = "Restores your health by an amount", runOnServer = true, requiredPermission = PermissionManager.CHEAT_PERMISSION)
public String heal(@Sender EntityRef client, @CommandParam("amount") int amount) {
    ClientComponent clientComp = client.getComponent(ClientComponent.class);
    clientComp.character.send(new DoHealEvent(amount, clientComp.character));
    return "Health restored for " + amount;
}
Also used : ClientComponent(org.terasology.network.ClientComponent) Command(org.terasology.logic.console.commandSystem.annotations.Command)

Example 62 with ClientComponent

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

the class HealthCommands method killCommand.

@Command(value = "kill", shortDescription = "Reduce the player's health to zero", runOnServer = true, requiredPermission = PermissionManager.NO_PERMISSION)
public void killCommand(@Sender EntityRef client) {
    ClientComponent clientComp = client.getComponent(ClientComponent.class);
    HealthComponent health = clientComp.character.getComponent(HealthComponent.class);
    if (health != null) {
        clientComp.character.send(new DestroyEvent(clientComp.character, EntityRef.NULL, EngineDamageTypes.DIRECT.get()));
    }
}
Also used : ClientComponent(org.terasology.network.ClientComponent) Command(org.terasology.logic.console.commandSystem.annotations.Command)

Example 63 with ClientComponent

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

the class HealthCommands method setMaxHealth.

@Command(shortDescription = "Set max health", runOnServer = true, requiredPermission = PermissionManager.CHEAT_PERMISSION)
public String setMaxHealth(@Sender EntityRef client, @CommandParam("max") int max) {
    ClientComponent clientComp = client.getComponent(ClientComponent.class);
    HealthComponent health = clientComp.character.getComponent(HealthComponent.class);
    float oldMaxHealth = health.maxHealth;
    if (health != null) {
        health.maxHealth = max;
        clientComp.character.saveComponent(health);
    }
    return "Max health changed from " + oldMaxHealth + " to " + max;
}
Also used : ClientComponent(org.terasology.network.ClientComponent) Command(org.terasology.logic.console.commandSystem.annotations.Command)

Example 64 with ClientComponent

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

the class HealthCommands method setRegenRate.

@Command(shortDescription = "Set health regen rate", runOnServer = true, requiredPermission = PermissionManager.CHEAT_PERMISSION)
public String setRegenRate(@Sender EntityRef client, @CommandParam("rate") float rate) {
    ClientComponent clientComp = client.getComponent(ClientComponent.class);
    HealthComponent health = clientComp.character.getComponent(HealthComponent.class);
    float oldRegenRate = health.regenRate;
    if (health != null) {
        health.regenRate = rate;
        clientComp.character.saveComponent(health);
    }
    return "Health regeneration changed from " + oldRegenRate + " to " + rate;
}
Also used : ClientComponent(org.terasology.network.ClientComponent) Command(org.terasology.logic.console.commandSystem.annotations.Command)

Aggregations

ClientComponent (org.terasology.network.ClientComponent)64 Command (org.terasology.logic.console.commandSystem.annotations.Command)37 EntityRef (org.terasology.entitySystem.entity.EntityRef)28 LocationComponent (org.terasology.logic.location.LocationComponent)13 Vector3f (org.terasology.math.geom.Vector3f)13 CharacterMovementComponent (org.terasology.logic.characters.CharacterMovementComponent)11 DisplayNameComponent (org.terasology.logic.common.DisplayNameComponent)10 ConsoleCommand (org.terasology.logic.console.commandSystem.ConsoleCommand)8 CharacterTeleportEvent (org.terasology.logic.characters.CharacterTeleportEvent)7 ReceiveEvent (org.terasology.entitySystem.event.ReceiveEvent)5 Prefab (org.terasology.entitySystem.prefab.Prefab)5 LocalPlayer (org.terasology.logic.players.LocalPlayer)4 Quat4f (org.terasology.math.geom.Quat4f)4 ComponentSystemManager (org.terasology.engine.ComponentSystemManager)3 SetMovementModeEvent (org.terasology.logic.characters.events.SetMovementModeEvent)3 DropItemEvent (org.terasology.logic.inventory.events.DropItemEvent)3 Client (org.terasology.network.Client)3 ResourceUrn (org.terasology.assets.ResourceUrn)2 EngineEntityManager (org.terasology.entitySystem.entity.internal.EngineEntityManager)2 EventSystem (org.terasology.entitySystem.event.internal.EventSystem)2