use of org.terasology.network.ClientComponent in project Terasology by MovingBlocks.
the class CoreCommands method spawnBlock.
/**
* Spawns a block in front of the player
* @param sender Sender of command
* @param blockName String containing name of block to spawn
* @return String containg final message
*/
@Command(shortDescription = "Spawns a block in front of the player", helpText = "Spawns the specified block as a " + "item in front of the player. You can simply pick it up.", runOnServer = true, requiredPermission = PermissionManager.CHEAT_PERMISSION)
public String spawnBlock(@Sender EntityRef sender, @CommandParam("blockName") String blockName) {
ClientComponent clientComponent = sender.getComponent(ClientComponent.class);
LocationComponent characterLocation = clientComponent.character.getComponent(LocationComponent.class);
Vector3f spawnPos = characterLocation.getWorldPosition();
Vector3f offset = characterLocation.getWorldDirection();
offset.scale(3);
spawnPos.add(offset);
BlockFamily block = blockManager.getBlockFamily(blockName);
if (block == null) {
return "";
}
BlockItemFactory blockItemFactory = new BlockItemFactory(entityManager);
EntityRef blockItem = blockItemFactory.newInstance(block);
blockItem.send(new DropItemEvent(spawnPos));
return "Spawned block.";
}
use of org.terasology.network.ClientComponent in project Terasology by MovingBlocks.
the class NetClient method setColor.
public void setColor(Color color) {
this.color = color;
ClientComponent client = getEntity().getComponent(ClientComponent.class);
if (client != null) {
ColorComponent colorInfo = client.clientInfo.getComponent(ColorComponent.class);
if (colorInfo != null) {
colorInfo.color = color;
client.clientInfo.saveComponent(colorInfo);
}
}
}
use of org.terasology.network.ClientComponent in project Terasology by MovingBlocks.
the class HealthCommands method healthMax.
@Command(shortDescription = "Restores your health to max", runOnServer = true, requiredPermission = PermissionManager.CHEAT_PERMISSION)
public String healthMax(@Sender EntityRef clientEntity) {
ClientComponent clientComp = clientEntity.getComponent(ClientComponent.class);
clientComp.character.send(new DoHealEvent(100000, clientComp.character));
return "Health fully restored";
}
use of org.terasology.network.ClientComponent in project Terasology by MovingBlocks.
the class HealthCommands method showHealth.
@Command(shortDescription = "Show your health", requiredPermission = PermissionManager.NO_PERMISSION)
public String showHealth(@Sender EntityRef client) {
ClientComponent clientComp = client.getComponent(ClientComponent.class);
HealthComponent health = clientComp.character.getComponent(HealthComponent.class);
if (health != null) {
return "Your health:" + health.currentHealth + " max:" + health.maxHealth + " regen:" + health.regenRate;
}
return "I guess you're dead?";
}
use of org.terasology.network.ClientComponent in project Terasology by MovingBlocks.
the class HealthCommands method damageWithType.
@Command(shortDescription = "Reduce the player's health by an amount by a specific type of damage", runOnServer = true, requiredPermission = PermissionManager.CHEAT_PERMISSION)
public String damageWithType(@Sender EntityRef client, @CommandParam("damageType") String damageType, @CommandParam("amount") int amount) {
ClientComponent clientComp = client.getComponent(ClientComponent.class);
Prefab damageTypePrefab = prefabManager.getPrefab(damageType);
if (damageTypePrefab != null) {
clientComp.character.send(new DoDamageEvent(amount, damageTypePrefab, clientComp.character));
return "Inflicted " + amount + " damage of type " + damageType;
} else {
return "Specified damage type does not exist.";
}
}
Aggregations