use of org.terasology.engine.logic.characters.events.ScaleToRequest in project Terasology by MovingBlocks.
the class MovementDebugCommands method playerHeight.
@Command(shortDescription = "Sets the height of the player", runOnServer = true, requiredPermission = PermissionManager.CHEAT_PERMISSION)
public String playerHeight(@Sender EntityRef entity, @CommandParam("height") float newHeight) {
if (newHeight > 0.5 && newHeight <= 20) {
ClientComponent client = entity.getComponent(ClientComponent.class);
if (client != null) {
EntityRef character = client.character;
CharacterMovementComponent movement = client.character.getComponent(CharacterMovementComponent.class);
if (movement != null) {
float currentHeight = movement.height;
ScaleToRequest scaleRequest = new ScaleToRequest(newHeight);
character.send(scaleRequest);
return "Height of player set to " + newHeight + " (was " + currentHeight + ")";
}
}
} else {
return "Invalid input. Accepted values: [1 to 25]";
}
return "";
}
use of org.terasology.engine.logic.characters.events.ScaleToRequest in project Terasology by MovingBlocks.
the class LocalPlayerSystem method onPlayerSpawn.
@ReceiveEvent
public void onPlayerSpawn(OnPlayerSpawnedEvent event, EntityRef character) {
if (character.equals(localPlayer.getCharacterEntity())) {
// update character height as given in player settings
ScaleToRequest scaleRequest = new ScaleToRequest(playerConfig.height.get());
localPlayer.getCharacterEntity().send(scaleRequest);
// Trigger updating the player camera position as soon as the local player is spawned.
// This is not done while the game is still loading, since systems are not updated.
// RenderableWorldImpl pre-generates chunks around the player camera and therefore needs
// the correct location.
lookYaw = 0f;
lookPitch = 0f;
update(0);
}
}
Aggregations