> For the complete documentation index, see [llms.txt](https://daikirai.gitbook.io/scripting/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://daikirai.gitbook.io/scripting/documentation/client.md).

# client

{% hint style="info" %}
see also: [`entity`](/scripting/documentation/entity.md) for entity-specific methods and [`world`](/scripting/documentation/world.md) for world data.
{% endhint %}

### addEnemy

adds the specified player to the enemy list.

```java
client.addEnemy(String username);
```

***

### addFriend

adds the specified player to the friend list.

```java
client.addFriend(String username);
```

***

### allowEditing

returns `true` if the player may edit blocks.

```java
boolean allowEditing = client.allowEditing();
```

***

### allowFlying

returns `true` if the player has the ability to fly.

```java
boolean allowFlying = client.allowFlying();
```

***

### attack

performs an attack on the specified [`Entity`](/scripting/documentation/entity.md).

```java
client.attack(Entity entity);
```

***

### async

runs the provided task on a cached background thread.

```java
client.async(() -> {
    // background work
});
```

***

### canSeeEntity

returns `true` if the player has line of sight to the entity.

```java
boolean visible = client.canSeeEntity(Entity entity);
```

***

### chat

sends a chat message as the local player.

```java
client.chat(String message);
```

***

### closeScreen

closes the currently open gui.

```java
client.closeScreen();
```

***

### dropItem

drops the currently held item. set `stack` to `true` to drop the entire stack.

```java
client.dropItem(boolean stack);
```

***

### getDisplaySize

returns `[width, height, scaleFactor]` for the scaled window.

```java
int[] display = client.getDisplaySize();
```

***

### getDirection

returns the movement direction string calculated by the client.

```java
String direction = client.getDirection();
```

***

### getForward

returns the forward movement input value.

```java
float forward = client.getForward();
```

***

### getFPS

returns the current frames per second.

```java
int fps = client.getFPS();
```

***

### getFreeMemory

returns the amount of free jvm memory in bytes.

```java
long freeMemory = client.getFreeMemory();
```

***

### getMaxMemory

returns the maximum jvm memory allocation in bytes.

```java
long maxMemory = client.getMaxMemory();
```

***

### getMotion

returns the local player's motion vector as a [`Vec3`](/scripting/documentation/vec3.md).

```java
Vec3 motion = client.getMotion();
```

***

### getPlayer

returns the local player as an [`Entity`](/scripting/documentation/entity.md).

```java
Entity player = client.getPlayer();
```

***

### getRenderArmPitch

returns the render arm pitch angle.

```java
float pitch = client.getRenderArmPitch();
```

***

### getRotations

returns `[yaw, pitch]` required to aim at a position.

```java
float[] rotations = client.getRotations(Vec3 position);
```

***

### getRotationsToBlock

returns `[yaw, pitch]` needed to aim at a block. provide a face or omit to use the default face.

```java
float[] rotations = client.getRotationsToBlock(Vec3 position, String face);
float[] rotationsDefault = client.getRotationsToBlock(Vec3 position);
```

***

### getRotationsToEntity

returns `[yaw, pitch]` needed to aim at an entity.

```java
float[] rotations = client.getRotationsToEntity(Entity entity);
```

***

### getScreen

returns the simple class name of the currently open gui, or an empty string when no gui is open.

```java
String screen = client.getScreen();
```

***

### getServerDirection

returns the server-reported movement direction using a [`PlayerState`](/scripting/documentation/playerstate.md).

```java
String direction = client.getServerDirection(PlayerState state);
```

***

### getServerIP

returns the connected server ip, or an empty string in singleplayer.

```java
String serverIP = client.getServerIP();
```

***

### getStrafe

returns the strafe movement input value.

```java
float strafe = client.getStrafe();
```

***

### getTotalMemory

returns the total jvm memory in bytes currently allocated.

```java
long totalMemory = client.getTotalMemory();
```

***

### getUID

returns the raven user id.

```java
int uid = client.getUID();
```

***

### getUser

returns the raven username.

```java
String user = client.getUser();
```

***

### getVersion

returns the current raven version.

```java
String user = client.getVersion();
```

***

### isDiagonal

returns `true` if the player is moving diagonally.

```java
boolean diagonal = client.isDiagonal();
```

***

### isEnemy

returns `true` if the specified name is on the enemy list.

```java
boolean enemy = client.isEnemy(String username);
```

***

### isFacingDiagonal

returns `true` if the player is facing diagonally.

```java
boolean facing = client.isFacingDiagonal();
```

***

### isFlying

returns `true` if the player is currently flying.

```java
boolean flying = client.isFlying();
```

***

### isFriend

returns `true` if the specified name is on the friend list.

```java
boolean friend = client.isFriend(String username);
```

***

### isJump

returns `true` if the jump input is active.

```java
boolean jumping = client.isJump();
```

***

### isMoving

returns `true` if either forward or strafe input is active.

```java
boolean moving = client.isMoving();
```

***

### isSingleplayer

returns `true` when running in a singleplayer world.

```java
boolean singleplayer = client.isSingleplayer();
```

***

### isSneak

returns `true` if the sneak input is active.

```java
boolean sneaking = client.isSneak();
```

***

### isCreative

returns `true` if the player is in creative mode.

```java
boolean creative = client.isCreative();
```

***

### jump

makes the player jump.

```java
client.jump();
```

***

### log

logs a value to `latest.log`.

```java
client.log(Object value);
```

***

### multiplyMotion

multiplies horizontal motion by the supplied factor.

```java
client.multiplyMotion(double factor);
```

***

### nanoTime

returns the current system time in nanoseconds. use in place of `System.nanoTime()`.

```java
long nanoTime = client.nanoTime();
```

***

### pling

plays the `note.pling` sound with volume 1 and pitch 1.

```java
client.pling();
client.playSound("note.pling", 1, 1); // identical
```

***

### placeBlock

attempts to place a block using the specified hit data. returns `true` on success.

```java
boolean placed = client.placeBlock(Vec3 blockPos, String side, Vec3 hitOffset);
```

***

### playSound

plays a sound at the player position.

```java
client.playSound(String name, float volume, float pitch);
```

***

### print

prints a chat message without the raven prefix.

```java
client.print(Object value);
```

***

### processPacket

processes an incoming server packet immediately.

```java
client.processPacket(SPacket packet);
```

***

### raycastBlock

performs a block raycast and returns `[Vec3 blockPos, Vec3 hitOffset, String side]`, or `null` if nothing is hit.

```java
Object[] hit = client.raycastBlock(double distance);
Object[] hitCustom = client.raycastBlock(double distance, float yaw, float pitch);
```

***

### raycastEntity

performs an entity raycast and returns `[Entity target, Vec3 hitOffset, double distanceSq]`, or `null` if nothing is hit.

```java
Object[] result = client.raycastEntity(double distance);
Object[] resultCustom = client.raycastEntity(double distance, float yaw, float pitch);
```

***

### removeEnemy

removes the specified name from the enemy list.

```java
client.removeEnemy(String username);
```

***

### removeFriend

removes the specified name from the friend list.

```java
client.removeFriend(String username);
```

***

### removePotionEffect

removes the specified potion effect from the player.

```java
client.removePotionEffect(int potionId);
```

***

### runForgeCommand

run a forge chat command registered through `ClientCommandHandler`. automatically appends command prefix.

```java
boolean success = client.runForgeCommand(String commandNoPrefix);
```

***

### runRavenCommand

run a raven chat command, works while `Chat Commands` module is disabled. automatically appends command prefix.

```java
boolean success = client.runRavenCommand(String commandNoPrefix);
```

***

### sendPacket

sends a client packet and posts events.

```java
client.sendPacket(CPacket packet);
```

***

### sendPacketNoEvent

sends a client packet without triggering events.

```java
client.sendPacketNoEvent(CPacket packet);
```

***

### setFlying

enables or disables flying for the player.

```java
client.setFlying(boolean flying);
```

***

### setForward

sets the forward movement input value, only works [`onPostPlayerInput`](/scripting/documentation/events.md#onpostplayerinput).

```java
client.setForward(float value);
```

***

### setJump

sets the jump input state, only works [`onPostPlayerInput`](/scripting/documentation/events.md#onpostplayerinput).

```java
client.setJump(boolean jumping);
```

***

### setMotion

sets the player motion using a vector or explicit components.

```java
client.setMotion(Vec3 motion);
client.setMotion(double x, double y, double z);
```

***

### setRenderArmPitch

sets the render arm pitch.

```java
client.setRenderArmPitch(float pitch);
```

***

### setSneak

sets the sneak input state, only works [`onPostPlayerInput`](/scripting/documentation/events.md#onpostplayerinput).

```java
client.setSneak(boolean sneaking);
```

***

### setSpeed

sets the horizontal speed value used by movement utilities.

```java
client.setSpeed(double speed);
```

***

### setSpeedForward

sets the forward speed value used by movement utilities.

```java
client.setSpeedForward(double speed);
```

***

### setSprinting

sets the sprinting state.

```java
client.setSprinting(boolean sprinting);
```

***

### setStrafe

sets the strafe movement input value, only works [`onPostPlayerInput`](/scripting/documentation/events.md#onpostplayerinput).

```java
client.setStrafe(float value);
```

***

### setTabName

sets a player's tab list display name. pass `null` as displayName to restore default.

```java
client.setTabName(String name, String displayName);
```

***

### setTimer

adjusts the client timer speed.

```java
client.setTimer(double timer);
```

***

### sleep

sleeps the current thread for the specified milliseconds. returns `true` if uninterrupted.

```java
boolean ok = client.sleep(long milliseconds);
```

***

### swing

swings the held item.

```java
client.swing();
```

***

### swingReset

swings the held item and resets the equipped animation.

```java
client.swingReset();
```

***

### time

returns the current system time in milliseconds. use in place of `System.currentTimeMillis()`.

```java
long ms = client.time();
```

***

### timeTag

returns truncated millisecond timestamp for lightweight debugging.

```java
int tag = client.timeTag();
```
