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;
}
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()));
}
}
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;
}
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;
}
Aggregations