use of org.terasology.logic.characters.GazeMountPointComponent in project Terasology by MovingBlocks.
the class MovementDebugCommands method showHeight.
@Command(shortDescription = "Show your Height", requiredPermission = PermissionManager.CHEAT_PERMISSION)
public String showHeight(@Sender EntityRef client) {
ClientComponent clientComp = client.getComponent(ClientComponent.class);
CharacterMovementComponent move = clientComp.character.getComponent(CharacterMovementComponent.class);
float height = move.height;
GazeMountPointComponent gazeMountPointComponent = clientComp.character.getComponent(GazeMountPointComponent.class);
float eyeHeight = gazeMountPointComponent.translate.y;
return "Your height: " + height + " Eye-height: " + eyeHeight;
}
use of org.terasology.logic.characters.GazeMountPointComponent in project Terasology by MovingBlocks.
the class MovementDebugCommands method playerEyeHeight.
@Command(shortDescription = "Sets the eye-height of the player", runOnServer = true, requiredPermission = PermissionManager.CHEAT_PERMISSION)
public String playerEyeHeight(@Sender EntityRef client, @CommandParam("eye-height") float amount) {
EntityRef player = client.getComponent(ClientComponent.class).character;
try {
GazeMountPointComponent gazeMountPointComponent = player.getComponent(GazeMountPointComponent.class);
if (gazeMountPointComponent != null) {
float prevHeight = gazeMountPointComponent.translate.y;
gazeMountPointComponent.translate.y = amount;
Location.removeChild(player, gazeMountPointComponent.gazeEntity);
Location.attachChild(player, gazeMountPointComponent.gazeEntity, gazeMountPointComponent.translate, new Quat4f(Quat4f.IDENTITY));
player.saveComponent(gazeMountPointComponent);
return "Eye-height of player set to " + amount + " (was " + prevHeight + ")";
}
return "";
} catch (NullPointerException e) {
e.printStackTrace();
return "";
}
}
use of org.terasology.logic.characters.GazeMountPointComponent in project Terasology by MovingBlocks.
the class LocalPlayerSystem method onPlayerSpawn.
@ReceiveEvent
public void onPlayerSpawn(OnPlayerSpawnedEvent event, EntityRef character) {
if (character.equals(localPlayer.getCharacterEntity())) {
// Change height as per PlayerSettings
Float height = config.getPlayer().getHeight();
movementDebugCommands.playerHeight(localPlayer.getClientEntity(), height);
// Change eyeHeight as per PlayerSettings
Float eyeHeight = config.getPlayer().getEyeHeight();
GazeMountPointComponent gazeMountPointComponent = character.getComponent(GazeMountPointComponent.class);
gazeMountPointComponent.translate = new Vector3f(0, eyeHeight, 0);
// 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