use of org.terasology.engine.network.ClientComponent 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.network.ClientComponent in project Terasology by MovingBlocks.
the class MovementDebugCommands method hjump.
@Command(shortDescription = "Jump really high", runOnServer = true, requiredPermission = PermissionManager.CHEAT_PERMISSION)
public String hjump(@Sender EntityRef client) {
ClientComponent clientComp = client.getComponent(ClientComponent.class);
CharacterMovementComponent move = clientComp.character.getComponent(CharacterMovementComponent.class);
if (move != null) {
move.jumpSpeed = 75f;
clientComp.character.saveComponent(move);
return "High-jump mode activated";
}
return "";
}
use of org.terasology.engine.network.ClientComponent in project Terasology by MovingBlocks.
the class MovementDebugCommands method teleportAllPlayersToPlayer.
@Command(shortDescription = "Teleport all users to specified user", runOnServer = true, requiredPermission = PermissionManager.USER_MANAGEMENT_PERMISSION)
public String teleportAllPlayersToPlayer(@CommandParam("username") String username) {
Vector3f vPlayerLocation = new Vector3f();
boolean bPlayerLocationWasFound = false;
EntityRef playerEntity = null;
for (EntityRef clientEntity : entityManager.getEntitiesWith(ClientComponent.class)) {
EntityRef clientInfo = clientEntity.getComponent(ClientComponent.class).clientInfo;
DisplayNameComponent name = clientInfo.getComponent(DisplayNameComponent.class);
if (username.equalsIgnoreCase(name.name)) {
LocationComponent locationComponent = clientEntity.getComponent(LocationComponent.class);
if (locationComponent != null) {
vPlayerLocation = locationComponent.getWorldPosition(new Vector3f());
bPlayerLocationWasFound = true;
playerEntity = clientEntity;
}
break;
}
}
if (!bPlayerLocationWasFound) {
throw new IllegalArgumentException("No such user '" + username + "'");
}
MovementMode playerMovementMode = MovementMode.NONE;
ClientComponent clientInfo = playerEntity.getComponent(ClientComponent.class);
if (clientInfo != null) {
CharacterMovementComponent playerMovementComponent = clientInfo.character.getComponent(CharacterMovementComponent.class);
if (playerMovementComponent != null) {
playerMovementMode = playerMovementComponent.mode;
}
}
for (EntityRef clientEntity : entityManager.getEntitiesWith(ClientComponent.class)) {
ClientComponent clientComp = clientEntity.getComponent(ClientComponent.class);
if (clientComp != null) {
clientComp.character.send(new CharacterTeleportEvent(vPlayerLocation));
CharacterMovementComponent characterMovementComponent = clientComp.character.getComponent(CharacterMovementComponent.class);
if (characterMovementComponent != null && playerMovementMode != MovementMode.NONE && playerMovementMode != characterMovementComponent.mode) {
clientComp.character.send(new SetMovementModeEvent(playerMovementMode));
}
}
}
return "All possible players teleported to " + username + " and set to " + playerMovementMode;
}
use of org.terasology.engine.network.ClientComponent in project Terasology by MovingBlocks.
the class MovementDebugCommands method setJumpSpeed.
@Command(shortDescription = "Set jump speed", runOnServer = true, requiredPermission = PermissionManager.CHEAT_PERMISSION)
public String setJumpSpeed(@Sender EntityRef client, @CommandParam("amount") float amount) {
ClientComponent clientComp = client.getComponent(ClientComponent.class);
CharacterMovementComponent move = clientComp.character.getComponent(CharacterMovementComponent.class);
if (move != null) {
float oldSpeed = move.jumpSpeed;
move.jumpSpeed = amount;
clientComp.character.saveComponent(move);
return "Jump speed set to " + amount + " (was " + oldSpeed + ")";
}
return "";
}
use of org.terasology.engine.network.ClientComponent in project Terasology by MovingBlocks.
the class MovementDebugCommands method pushCharacterCommand.
@Command(value = "pushCharacter", shortDescription = "Pushes you in the direction (x, y, z)", runOnServer = true)
public String pushCharacterCommand(@Sender EntityRef sender, @CommandParam("x") float x, @CommandParam("y") float y, @CommandParam("z") float z) {
ClientComponent clientComponent = sender.getComponent(ClientComponent.class);
clientComponent.character.send(new CharacterImpulseEvent(new Vector3f(x, y, z)));
return "Pushing character with " + x + " " + y + " " + z;
}
Aggregations