player
Contains functions to control the local player
place_block()
Places a block and returns if it was actually placed
place_block(slot: int, block_pos: vec3i, hit_vec: vec3d, facing: facing): boolean
Parameters
name | type | description |
---|---|---|
slot | int | The slot number you are holding (any others will not work properly) |
block_pos | vec3i | The position of the block to place on |
hit_vec | vec3d | The hit vector |
facing | facing | The facing placed on |
ray_cast()
Fires a ray-cast with the given parameters and returns the ray-cast result
ray_cast(yaw: float, pitch: float, reach: float): raycastresult
Parameters
name | type | description |
---|---|---|
yaw | float | The yaw used to fire the ray-cast |
pitch | float | The pitch used to fire the ray-cast |
reach | float | The reach used to fire the ray-cast |
set_yaw()
Sets the players client-side yaw
set_yaw(yaw: float): void
Parameters
name | type | description |
---|---|---|
yaw | float | The new yaw |
set_pitch()
Sets the players client-side pitch
set_pitch(pitch: float): void
Parameters
name | type | description |
---|---|---|
pitch | float | The new pitch |
set_held_item()
Sets the players hot-bar slot
set_held_item(slot: int): void
Parameters
name | type | description |
---|---|---|
slot | int | The new slot |
set_speed()
Sets the speed of the player using the move event
set_speed(event: luatable, speed: double): void
Parameters
name | type | description |
---|---|---|
event | luatable | The move event (if you want to set the speed outside of the move event, use set_motion_speed) |
speed | double | The speed to move with |
set_motion_speed()
Sets the speed of the player using motions
set_motion_speed(speed: double): void
Parameters
name | type | description |
---|---|---|
speed | double | The speed to move with |
set_sprinting()
Sets the players sprinting state
set_sprinting(sprinting: boolean): void
Parameters
name | type | description |
---|---|---|
sprinting | boolean | The new sprinting state |
set_motion_x()
Sets the players motion x
set_motion_x(x: double): void
Parameters
name | type | description |
---|---|---|
x | double | The new motion x |
set_motion_y()
Sets the players motion y
set_motion_y(y: double): void
Parameters
name | type | description |
---|---|---|
y | double | The new motion y |
set_motion_z()
Sets the players motion z
set_motion_z(z: double): void
Parameters
name | type | description |
---|---|---|
z | double | The new motion z |
set_motion()
Sets the players motion
set_motion(motion: vec3d): void
Parameters
name | type | description |
---|---|---|
motion | vec3d | The new motion as a vector |
set_position()
Sets the players position
set_position(position: vec3d): void
Parameters
name | type | description |
---|---|---|
position | vec3d | The new position as a vector |
set_position_and_update()
Sets the players position and updates the last positions
set_position_and_update(position: vec3d): void
Parameters
name | type | description |
---|---|---|
position | vec3d | The new position as a vector |
set_sneaking()
Sets the sneaking state, this utilizes key-presses, make sure to use revert states properly
set_sneaking(state: boolean): void
Parameters
name | type | description |
---|---|---|
state | boolean | The state of sneaking |
send_packet()
Sends a packet to the server
The packets currently supported: 0x00, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x0A, 0x0B, 0x0F
Always refer to https://wiki.vg/index.php?title=Protocol&oldid=7368#Serverbound_2 when working with packets!
send_packet(id: int, arguments: object[]): void
Parameters
name | type | description |
---|---|---|
id | int | The packet id |
arguments | object[] | The packet arguments |
send_packet_no_event()
Sends a packet to the server without causing any other modules to process them
send_packet_no_event(id: int, arguments: object[]): void
Parameters
name | type | description |
---|---|---|
id | int | The packet id |
arguments | object[] | The packet arguments |
distance_to()
Calculates the distance between the given coordinates and the player position
distance_to(x: float, y: float, z: float): double
Parameters
name | type | description |
---|---|---|
x | float | The x coordinate |
y | float | The y coordinate |
z | float | The z coordinate |
distance_to_vec()
Calculates the distance between the given vector and the player position
distance_to_vec(vec: vec3d): double
Parameters
name | type | description |
---|---|---|
vec | vec3d | The target vector |
distance_to_entity()
Calculates the distance between the given entity and the player
distance_to_entity(entity_id: int): double
Parameters
name | type | description |
---|---|---|
entity_id | int | The target entity's id |
rotations_to()
Calculates the yaw and pitch for looking at the given position
rotations_to(position: vec3d): vec2f
Parameters
name | type | description |
---|---|---|
position | vec3d | The position |
jump()
Makes the player jump
jump(): void
This method does not have any parameters
left_click()
Clicks the left mouse button
left_click(): void
This method does not have any parameters
right_click()
Clicks the right mouse button
right_click(): void
This method does not have any parameters
swing_item()
Swings the players item
swing_item(): void
This method does not have any parameters
use_item()
Uses the current held item
use_item(): void
This method does not have any parameters
is_on_edge()
Returns whether the player is on edge or not
is_on_edge(): boolean
This method does not have any parameters
get_input()
Returns the current forward and strafe the player is moving at
get_input(): vec2f
This method does not have any parameters
get_yaw()
Returns the current players yaw
get_yaw(): float
This method does not have any parameters
get_pitch()
Returns the current players pitch
get_pitch(): float
This method does not have any parameters
get_prev_yaw()
Returns the last players yaw
get_prev_yaw(): float
This method does not have any parameters
get_prev_pitch()
Returns the last players pitch
get_prev_pitch(): float
This method does not have any parameters
get_motion_x()
Returns the players current motion x
get_motion_x(): double
This method does not have any parameters
get_motion_y()
Returns the players current motion z
get_motion_y(): double
This method does not have any parameters
get_motion_z()
Returns the players current motion y
get_motion_z(): double
This method does not have any parameters
get_motion()
Returns the players current motion
get_motion(): vec3d
This method does not have any parameters
get_position_x()
Returns the players current position x
get_position_x(): double
This method does not have any parameters
get_position_y()
Returns the players current position z
get_position_y(): double
This method does not have any parameters
get_position_z()
Returns the players current position y
get_position_z(): double
This method does not have any parameters
get_position()
Returns the players current position
get_position(): vec3d
This method does not have any parameters
get_prev_position_x()
Returns the players previous position x
get_prev_position_x(): double
This method does not have any parameters
get_prev_position_y()
Returns the players previous position z
get_prev_position_y(): double
This method does not have any parameters
get_prev_position_z()
Returns the players previous position y
get_prev_position_z(): double
This method does not have any parameters
get_prev_position()
Returns the players previous position
get_prev_position(): vec3d
This method does not have any parameters
is_moving()
Returns if the player is moving
is_moving(): boolean
This method does not have any parameters
is_on_ground()
Returns if the player is on ground
is_on_ground(): boolean
This method does not have any parameters
is_sprinting()
Returns if the player is sprinting
is_sprinting(): boolean
This method does not have any parameters
is_using_item()
Returns if the player is using the item
is_using_item(): boolean
This method does not have any parameters
is_blocking()
Returns if the player is blocking
is_blocking(): boolean
This method does not have any parameters
is_in_water()
Returns if the player is in water
is_in_water(): boolean
This method does not have any parameters
is_in_lava()
Returns if the player is in lava
is_in_lava(): boolean
This method does not have any parameters
is_on_ladder()
Returns if the player is on a ladder
is_on_ladder(): boolean
This method does not have any parameters
is_burning()
Returns if the player is burning
is_burning(): boolean
This method does not have any parameters
is_sneaking()
Returns if the player is sneaking
is_sneaking(): boolean
This method does not have any parameters
is_in_cobweb()
Returns if the player is in a cobweb
is_in_cobweb(): boolean
This method does not have any parameters
is_dead()
Returns if the player is dead
is_dead(): boolean
This method does not have any parameters
is_riding()
Returns if the player is riding a vehicle
is_riding(): boolean
This method does not have any parameters
collided_vertically()
Returns if the player is currently colliding with anything vertically
collided_vertically(): boolean
This method does not have any parameters
collided_horizontally()
Returns if the player is currently colliding with anything horizontally
collided_horizontally(): boolean
This method does not have any parameters
get_ticks_existed()
Returns the players current ticks existed
get_ticks_existed(): int
This method does not have any parameters
get_speed()
Returns the players current speed
get_speed(): double
This method does not have any parameters
get_base_move_speed()
Returns the base move speed
get_base_move_speed(): double
This method does not have any parameters
get_fall_distance()
Returns the players current fall distance
get_fall_distance(): double
This method does not have any parameters
get_health()
Returns the players current health
get_health(): double
This method does not have any parameters
get_max_health()
Returns the players max health
get_max_health(): double
This method does not have any parameters
get_absorption()
Returns the players current absorption hearts
get_absorption(): double
This method does not have any parameters
get_food_amount()
Returns the players current food amount
get_food_amount(): double
This method does not have any parameters
get_hurt_time()
Returns the players current hurt-time
get_hurt_time(): int
This method does not have any parameters
get_held_item_slot()
Returns the players currently held item
get_held_item_slot(): int
This method does not have any parameters
get_name()
Returns the players current name
get_name(): string
This method does not have any parameters
get_id()
Returns the players entity id
get_id(): int
This method does not have any parameters
get_facing()
Returns the players facing
For reference please click here
get_facing(): facing
This method does not have any parameters
get_mouse_over()
Returns the current minecraft ray-cast result used for all in-game actions
get_mouse_over(): raycastresult
This method does not have any parameters
get_active_effects()
Returns all active potion effects
get_active_effects(): potion[]
This method does not have any parameters
has_effect()
Returns if the player has the given potion effect
has_effect(id: int): boolean
Parameters
name | type | description |
---|---|---|
id | int | The id of the potion |
get_effect()
Returns a specific potion effect if active otherwise returns nil
get_effect(id: int): potion
Parameters
name | type | description |
---|---|---|
id | int | The id of the potion |