use of org.terasology.network.ClientComponent in project Terasology by MovingBlocks.
the class PermissionCommands method listPermissions.
@Command(shortDescription = "Lists all permission the specified player has", helpText = "Lists all permission the specified player has", runOnServer = true, requiredPermission = PermissionManager.USER_MANAGEMENT_PERMISSION)
public String listPermissions(@CommandParam(value = "player", suggester = UsernameSuggester.class) String player) {
for (EntityRef client : entityManager.getEntitiesWith(ClientComponent.class)) {
ClientComponent clientComponent = client.getComponent(ClientComponent.class);
if (clientHasName(clientComponent, player)) {
EntityRef clientInfo = clientComponent.clientInfo;
PermissionSetComponent permissionSetComp = clientInfo.getComponent(PermissionSetComponent.class);
return Objects.toString(permissionSetComp.permissions);
}
}
return "Player not found";
}
use of org.terasology.network.ClientComponent in project Terasology by MovingBlocks.
the class LocalPlayer method getViewRotation.
public Quat4f getViewRotation() {
ClientComponent clientComponent = getClientEntity().getComponent(ClientComponent.class);
if (clientComponent == null) {
return new Quat4f(Quat4f.IDENTITY);
}
LocationComponent location = clientComponent.camera.getComponent(LocationComponent.class);
if (location == null) {
return getRotation();
}
return location.getWorldRotation();
}
use of org.terasology.network.ClientComponent in project Terasology by MovingBlocks.
the class PlayerSystem method spawnPlayer.
private void spawnPlayer(EntityRef clientEntity) {
ClientComponent client = clientEntity.getComponent(ClientComponent.class);
PlayerFactory playerFactory = new PlayerFactory(entityManager, worldProvider);
EntityRef playerCharacter = playerFactory.newInstance(clientEntity);
Client clientListener = networkSystem.getOwner(clientEntity);
Vector3i distance = clientListener.getViewDistance().getChunkDistance();
updateRelevanceEntity(clientEntity, distance);
client.character = playerCharacter;
clientEntity.saveComponent(client);
playerCharacter.send(new OnPlayerSpawnedEvent());
}
use of org.terasology.network.ClientComponent in project Terasology by MovingBlocks.
the class HealthCommands method restoreCollisionDamage.
@Command(shortDescription = "Restore default collision damage values", runOnServer = true, requiredPermission = PermissionManager.CHEAT_PERMISSION)
public String restoreCollisionDamage(@Sender EntityRef client) {
ClientComponent clientComp = client.getComponent(ClientComponent.class);
Optional<Prefab> prefab = Assets.get(new ResourceUrn("engine:player"), Prefab.class);
HealthComponent healthDefault = prefab.get().getComponent(HealthComponent.class);
HealthComponent health = clientComp.character.getComponent(HealthComponent.class);
if (health != null && healthDefault != null) {
health.fallingDamageSpeedThreshold = healthDefault.fallingDamageSpeedThreshold;
health.horizontalDamageSpeedThreshold = healthDefault.horizontalDamageSpeedThreshold;
health.excessSpeedDamageMultiplier = healthDefault.excessSpeedDamageMultiplier;
clientComp.character.saveComponent(health);
}
return "Normal collision damage values restored";
}
use of org.terasology.network.ClientComponent in project Terasology by MovingBlocks.
the class HealthCommands method softLanding.
@Command(shortDescription = "Land without breaking a leg", runOnServer = true, requiredPermission = PermissionManager.CHEAT_PERMISSION)
public String softLanding(@Sender EntityRef client) {
ClientComponent clientComp = client.getComponent(ClientComponent.class);
HealthComponent health = clientComp.character.getComponent(HealthComponent.class);
if (health != null) {
health.fallingDamageSpeedThreshold = 85f;
health.excessSpeedDamageMultiplier = 2f;
clientComp.character.saveComponent(health);
return "Soft landing mode activated";
}
return "";
}
Aggregations