Welcome to Moon Scripting
This documentation page contains all information you need to write Moon Scripts.
BEWARE This documentation always represents the latest changes made on the Nightly
channel!
enums
template_type
The different batched rendering types
name | description |
---|---|
RECT | Applies the rectangle rendering type |
GRADIENT | Applies the gradient rendering type |
ROUNDED_RECT | Applies the rounded rectangle rendering type |
OUTLINED_ROUNDED_RECT | Applies the outlined rounded rectangle rendering type |
TEXT | Applies the text rendering type |
TRIANGLE | Applies the triangle rendering type |
entity_action
The different entity actions which can be sent in a 0x0B packet
name | description |
---|---|
START_SNEAKING | Starts sneaking on the server |
STOP_SNEAKING | Stops sneaking on the server |
STOP_SLEEPING | Stops sleeping on the server |
START_SPRINTING | Starts sprinting on the server |
STOP_SPRINTING | Stops sprinting on the server |
RIDING_JUMP | Executes a riding jump on the server |
OPEN_INVENTORY | Executed an open inventory request on the server |
interact_actions
The different entity interact actions which can be sent in a 0x02 packet
name | description |
---|---|
INTERACT | Interacts with the target entity |
ATTACK | Attacks the target entity |
INTERACT_AT | Interacts with the entity at the given hit vector |
digging_action
The different digging actions which can be sent in a 0x07 packet
name | description |
---|---|
START_DESTROY_BLOCK | Starts destroying a block |
ABORT_DESTROY_BLOCK | Aborts destroying a block |
STOP_DESTROY_BLOCK | Stops destroying a block, indicating its broken |
DROP_ALL_ITEMS | Drops all items |
DROP_ITEM | Drops one item |
RELEASE_USE_ITEM | Releases the current item |
client_status_actions
The different types of status actions which can be sent in a client status packet
name | description |
---|---|
PERFORM_RESPAWN | No description |
REQUEST_STATS | No description |
OPEN_INVENTORY_ACHIEVEMENT | No description |
hittype
The different hit types a ray-cast can have
name | description |
---|---|
MISS | Not hitting anything |
BLOCK | Hitting block |
ENITTY | Hitting entity |
facing
The different face values used in several functions
name | description |
---|---|
DOWN | No description |
UP | No description |
NORTH | No description |
SOUTH | No description |
WEST | No description |
EAST | No description |
custom_font_type
The different custom font types which can be used to render text
name | description |
---|---|
ROBOTO_MEDIUM | Roboto Medium |
INTER_MEDIUM | Inter Medium |
TAHOMA | Tahoma |
VERDANA | Verdana |
SF | San Francisco |
PRODUCT_SANS | Product Sans |
MATERIAL_ICONS | Material Icons (https://fonts.google.com/icons for more information) |
MATERIAL_SYMBOLS_OUTLINED_REGULAR | Material Symbols Outlined Regular (https://fonts.google.com/icons for more information) |
VOLTE_SEMI_BOLD | Volte Semi Bold |
tables
events
Contains all events you can hook while creating a module table.
BEWARE: If an event has any parameters, you need to add a generalized event argument to your function, NOT THE PARAMETERS THEMSELVES. You can access all the event parameters from the argument!
on_enable()
Called once the module is enabled
on_disable()
Called once the module is disabled
on_tick()
Called on client tick (every 0.05s)
Parameters
name | type | description |
---|---|---|
pre | boolean | Defines if the event was called pre or post tick |
on_update()
Called before and after client position update, this is done once every tick.
Parameters
name | type | description |
---|---|---|
pre | boolean | Whether the event was invoked before or after sending the position updates to the server. Keep in mind position, rotation and ground attributes can only be modified when this is true, otherwise changes will be ignored |
x | double | The x position sent to the server |
y | double | The y position sent to the server |
z | double | The z position sent to the server |
yaw | float | The yaw rotation sent to the server (Will update the third-person rotations once modified) |
pitch | float | The pitch rotation sent to the server (Will update the third-person rotations once modified) |
ground | boolean | The ground state sent to the server |
on_move()
Called before the movement of the player gets applied
Mainly used to make the player strafe or move faster
Parameters
name | type | description |
---|---|---|
x | double | The x motion used to apply the move |
y | double | The y motion used to apply the move |
z | double | The z motion used to apply the move |
on_packet_send()
Called once the client sends a packet to the server.
Additional parameters are available for specific packets.
Editing is currently supported for the following packets: 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x11, 0x13, 0x14, 0x18, 0x19, 0x0B, 0x0C, 0x0E, 0x0F
Parameters
name | type | description |
---|---|---|
packet_id | int | The packet id |
cancel | boolean | Whether the packet sending should be canceled or not |
on_packet_receive()
Called once the client receives a packet from the server.
Additional parameters are available for specific packets.
Editing is currently supported for the following packets: 0x00, 0x08, 0x14, 0x27, 0x32, 0x48
Only reading additionally is supported for the following packets: 0x02
Parameters
name | type | description |
---|---|---|
packet_id | int | The packet id |
cancel | boolean | Whether the packet processing should be canceled or not |
on_overlay_render()
Called once the overlay of the client is being rendered
Parameters
name | type | description |
---|---|---|
partial_ticks | float | The partial ticks |
pre | boolean | Whether its pre or post overlay render |
on_world_render()
Called once the world is rendered
Parameters
name | type | description |
---|---|---|
partial_ticks | float | The partial ticks |
on_effect_render()
Called once any blur effects are rendered (shadow, blur)
Parameters
name | type | description |
---|---|---|
blur | boolean | Whether the blur or shadow is called |
partial_ticks | float | The partial ticks |
types
template
template/outlined_rounded_rect
Contains information about an outlined rounded rect to be drawn
Fields
All fields contained in this type
field | description |
---|---|
x | No description |
y | No description |
width | No description |
height | No description |
radius | No description |
thickness | No description |
color | No description |
Methods
All methods contained in this type
toString()
This method does not have any parameters
template/gradient
Contains information about a gradient to be drawn
Fields
All fields contained in this type
field | description |
---|---|
x | No description |
y | No description |
width | No description |
height | No description |
from | No description |
to | No description |
vertical | No description |
Methods
All methods contained in this type
toString()
This method does not have any parameters
template/rect
Contains information about a rect to be drawn
Fields
All fields contained in this type
field | description |
---|---|
x | No description |
y | No description |
width | No description |
height | No description |
color | No description |
Methods
All methods contained in this type
toString()
This method does not have any parameters
template/rounded_rect
Contains information about a rounded_rect to be drawn
Fields
All fields contained in this type
field | description |
---|---|
x | No description |
y | No description |
width | No description |
height | No description |
radius | No description |
color | No description |
Methods
All methods contained in this type
toString()
This method does not have any parameters
template/text
Contains information about a text to be drawn
Fields
All fields contained in this type
field | description |
---|---|
font_type | No description |
text | No description |
size | No description |
x | No description |
y | No description |
color | No description |
shadow | No description |
Methods
All methods contained in this type
toString()
This method does not have any parameters
template/triangle
Contains information about a triangle to be drawn
Fields
All fields contained in this type
field | description |
---|---|
top_x | No description |
top_y | No description |
left_x | No description |
left_y | No description |
right_x | No description |
right_y | No description |
color | No description |
Methods
All methods contained in this type
toString()
This method does not have any parameters
render
render/render_batch
Contains information about a current render batch which is soon to be drawn
Methods
All methods contained in this type
add()
Puts the given render_template into the batch, make sure it matches the type you defined on creation
Parameters
name | type | description |
---|---|---|
template | rendertemplate | The render template to add, you can find a list of available render templates in types.template |
render()
Renders this current render_batch, this can only be done once
This method does not have any parameters
vec2f
A two-dimensional float based vector representation
Fields
All fields contained in this type
field | description |
---|---|
x | No description |
y | No description |
Methods
All methods contained in this type
add()
Adds the given parameters to the vector values
Parameters
name | type | description |
---|---|---|
x | float | The value added to x |
y | float | The value added to y |
toString()
This method does not have any parameters
vec3f
A three-dimensional float based vector representation
Fields
All fields contained in this type
field | description |
---|---|
x | No description |
y | No description |
z | No description |
Methods
All methods contained in this type
toString()
This method does not have any parameters
raycastresult
The result returned by ray-cast functions. You cannot instantiate this type yourself!
Fields
All fields contained in this type
field | description |
---|---|
hit_type | No description |
side_hit | No description |
pos | No description |
hit_vec | No description |
hit_entity_id | No description |
Methods
All methods contained in this type
toString()
This method does not have any parameters
enchantment
Contains information about an enchantment
Fields
All fields contained in this type
field | description |
---|---|
id | The id of the enchantment |
level | The level of the enchantment |
Methods
All methods contained in this type
toString()
This method does not have any parameters
block
Contains information about a block retrieved from the local world
Fields
All fields contained in this type
field | description |
---|---|
name | The name of the block |
display_name | The display name of the block |
full_block | Whether the block has a full bounding box or not |
translucent | Whether the block is translucent or not (used while rendering) |
block_hardness | The hardness of the block |
relative_hardness | The relative hardness of the block |
slipperiness | The slipperiness of the block |
Methods
All methods contained in this type
toString()
This method does not have any parameters
vec3d
A three-dimensional double based vector representation
Fields
All fields contained in this type
field | description |
---|---|
x | No description |
y | No description |
z | No description |
Methods
All methods contained in this type
toString()
This method does not have any parameters
vec3i
A three-dimensional integer based vector representation
Fields
All fields contained in this type
field | description |
---|---|
x | No description |
y | No description |
z | No description |
Methods
All methods contained in this type
toString()
This method does not have any parameters
item
Contains information about an item stack
Fields
All fields contained in this type
field | description |
---|---|
name | The item name (locale) |
display_name | The display name of the item |
max_stack_size | The maximum stack size (usually 64) |
stack_size | The current stack size |
max_damage | The max item damage before it breaks |
damage | The current item damage |
solid | Returns whether the block is solid if the item is a block. Will always be false otherwise |
enchantments | The enchantments applied on the item |
potions | The potion effects applied on the item |
Methods
All methods contained in this type
toString()
This method does not have any parameters
potion
Contains information about a potion effect
Fields
All fields contained in this type
field | description |
---|---|
id | The potion id |
name | The potion name (locale) |
duration | The duration of the potion effect |
amplifier | The strength of the potion effect |
bad_effect | Whether the effect is bad or not |
color | The potion color (bottle color) |
Methods
All methods contained in this type
toString()
This method does not have any parameters
functions
render
render/batched
Contains recommended rendering functions for batched rendering, please refer to the rendering examples for a proper tutorial
prepare_batch()
Prepares a batch for future insertion and rendering
prepare_batch(type: templatetype): renderbatch
Parameters
name | type | description |
---|---|---|
type | templatetype | The template type used |
render_batch()
Renders a given batch of templates
render_batch(type: templatetype, templates: rendertemplate[]): void
Parameters
name | type | description |
---|---|---|
type | templatetype | The template type used |
templates | rendertemplate[] | The templates to render |
render/state
Allows you to control OpenGL states in a really simple way. More functionality will be added to this later on, for now it is really basic
enable_depth()
Disables depth
enable_depth(): void
This method does not have any parameters
disable_depth()
Enables depth
disable_depth(): void
This method does not have any parameters
enable_blend()
Enables blending
enable_blend(): void
This method does not have any parameters
disable_blend()
Disables blending
disable_blend(): void
This method does not have any parameters
blend_func()
Applies the given blend function
blend_func(src_factor: int, dst_factor: int): void
Parameters
name | type | description |
---|---|---|
src_factor | int | No description |
dst_factor | int | No description |
blend_func_separate()
Applies the given blend function
blend_func_separate(src_factor: int, dst_factor: int, src_factor_alpha: int, dst_factor_alpha: int): void
Parameters
name | type | description |
---|---|---|
src_factor | int | No description |
dst_factor | int | No description |
src_factor_alpha | int | No description |
dst_factor_alpha | int | No description |
render/immediate
Contains non-recommended rendering functions for immediate rendering
## USAGE NOT RECOMMENDED ##render.batched
for proper rendering unless you want to use minecraft font!
rect()
Renders a rectangle at the given position with the given boundaries and color
rect(x: float, y: float, width: float, height: float, color: int): void
Parameters
name | type | description |
---|---|---|
x | float | The x position |
y | float | The y position |
width | float | The width |
height | float | The height |
color | int | The color |
gradient_rect()
Renders a gradient rectangle at the given position with the given boundaries and colors
gradient_rect(x: float, y: float, width: float, height: float, from: int, to: int, vertical: boolean): void
Parameters
name | type | description |
---|---|---|
x | float | The x position |
y | float | The y position |
width | float | The width |
height | float | The height |
from | int | The from color |
to | int | The to color |
vertical | boolean | Whether the gradient should be vertical or horizontal |
rounded_rect()
Renders a rounded rectangle at the given position with the given boundaries, radius and color
rounded_rect(x: float, y: float, width: float, height: float, radius: float, color: int): void
Parameters
name | type | description |
---|---|---|
x | float | The x position |
y | float | The y position |
width | float | The width |
height | float | The height |
radius | float | The corner radius |
color | int | The color |
outline_rounded_rect()
Renders an outlined rounded rectangle at the given position with the given boundaries, radius, thickness and color
outline_rounded_rect(x: float, y: float, width: float, height: float, radius: float, thickness: float, color: int): void
Parameters
name | type | description |
---|---|---|
x | float | The x position |
y | float | The y position |
width | float | The width |
height | float | The height |
radius | float | The corner radius |
thickness | float | The thickness of the outline |
color | int | The color |
triangle()
Renders a triangle at the given position with the given color
triangle(top_x: float, top_y: float, left_x: float, left_y: float, right_x: float, right_y: float, color: int): void
Parameters
name | type | description |
---|---|---|
top_x | float | The top x of the triangle |
top_y | float | The top y of the triangle |
left_x | float | The left x of the triangle |
left_y | float | The left y of the triangle |
right_x | float | The right x of the triangle |
right_y | float | The right y of the triangle |
color | int | The color |
minecraft_text()
Renders a text with the minecraft font at the given position
minecraft_text(text: string, x: float, y: float, color: int, shadow: boolean): void
Parameters
name | type | description |
---|---|---|
text | string | The text to be rendered |
x | float | The x position |
y | float | The y position |
color | int | The color |
shadow | boolean | Whether to apply a drop-shadow or not |
text()
text(font_type: customfonttype, text: string, size: float, x: float, y: float, color: int, shadow: boolean): void
Parameters
name | type | description |
---|---|---|
font_type | customfonttype | The type of font to render the text with |
text | string | The text to be rendered |
size | float | The font size to use |
x | float | The x position |
y | float | The y position |
color | int | The color |
shadow | boolean | Whether to apply a drop-shadow or not |
modules
Contains functions to create modules and settings for them
register()
Used to register new modules in the client
register(name: string, display_name: string, description: string, table: luatable): void
Parameters
name | type | description |
---|---|---|
name | string | The name of the module |
display_name | string | The display name of the module, used in arraylist and clickgui |
description | string | The description of the module, shown in the clickgui |
table | luatable | The module table containing all event hooks, you can find all available events here |
Example
local module = {
on_enable = function()
client:print('The module has been enabled!')
end
}
-- Register
modules:register("YourModule", "Your Module", module)
is_enabled()
Returns whether a module is enabled or not
is_enabled(name: string): boolean
Parameters
name | type | description |
---|---|---|
name | string | The name of the module |
set_state()
Sets the enabled state of a module
set_state(name: string, state: boolean): void
Parameters
name | type | description |
---|---|---|
name | string | The name of the module to update the state of |
state | boolean | The new module state |
toggle()
Toggles a module
toggle(name: string): void
Parameters
name | type | description |
---|---|---|
name | string | The name of the module to toggle |
set_setting()
Sets the value of a setting
Some settings have to be treated differently:
- Modes / Enums: Please use the number index of the setting (starts from 0)
Multiple Choice: Please use the number index, you can only toggle ONE at a time, please be aware of that (starts from 0)
set_setting(name: string, setting_id: string, value: object): void
Parameters
name | type | description |
---|---|---|
name | string | The name of the module which contains the setting you want to change |
setting_id | string | The id of the setting you want to change, if you don't know what it is just save a config and take a look at that |
value | object | The new value BEWARE: Observe the formats described in the methods description |
create_boolean_setting()
Used to create a boolean setting for a scripting module
create_boolean_setting(module: string, id: string, name: string, default: boolean): void
Parameters
name | type | description |
---|---|---|
module | string | The module the setting will be added to |
id | string | The id of the setting (used for configs) |
name | string | The name of the setting |
default | boolean | The default value of the setting |
create_integer_setting()
Used to create a integer setting for a scripting module
create_integer_setting(module: string, id: string, name: string, default: int, min: int, max: int, increment: int): void
Parameters
name | type | description |
---|---|---|
module | string | The module the setting will be added to |
id | string | The id of the setting (used for configs) |
name | string | The name of the setting |
default | int | The default value of the setting (ideally in-between of min and max) |
min | int | The minimum value allowed |
max | int | The maximum value allowed |
increment | int | The increment amount |
create_float_setting()
Used to create a float setting for a scripting module
create_float_setting(module: string, id: string, name: string, default: float, min: float, max: float, increment: float): void
Parameters
name | type | description |
---|---|---|
module | string | The module the setting will be added to |
id | string | The id of the setting (used for configs) |
name | string | The name of the setting |
default | float | The default value of the setting (ideally in-between of min and max) |
min | float | The minimum value allowed |
max | float | The maximum value allowed |
increment | float | The increment amount |
create_color_setting()
Used to create a color setting for a scripting module
create_color_setting(module: string, id: string, name: string, default: int): void
Parameters
name | type | description |
---|---|---|
module | string | The module the setting will be added to |
id | string | The id of the setting (used for configs) |
name | string | The name of the setting |
default | int | The default value of the setting |
create_text_setting()
Used to create a text setting for a scripting module
create_text_setting(module: string, id: string, name: string, default: string): void
Parameters
name | type | description |
---|---|---|
module | string | The module the setting will be added to |
id | string | The id of the setting (used for configs) |
name | string | The name of the setting |
default | string | The default value of the setting |
get_setting()
Returns the value of a setting
get_setting(module: string, id: string): object
Parameters
name | type | description |
---|---|---|
module | string | The module which contains the setting |
id | string | The id of the setting |
inventory
drop()
Drops a given slot id from the inventory
drop(slot_id: int, stack: boolean): void
Parameters
name | type | description |
---|---|---|
slot_id | int | The slot id to drop |
stack | boolean | Whether to drop the entire stack or a singular item |
shift()
Shifts a slot id in the inventory
shift(slot_id: int): void
Parameters
name | type | description |
---|---|---|
slot_id | int | The slot id to shift |
swap()
Swaps a given slot id with a given hot-bar slot
swap(slot_id: int, hot_bar_slot: int): void
Parameters
name | type | description |
---|---|---|
slot_id | int | The slot id to swap with |
hot_bar_slot | int | The hot-bar slot to swap with |
window_click()
Provides full access to window clicks, used to move around items in inventories
window_click(window_id: int, slot_id: int, mouse_button_clicked: int, mode: int): void
Parameters
name | type | description |
---|---|---|
window_id | int | The window id |
slot_id | int | The slot id |
mouse_button_clicked | int | The mouse button clicked |
mode | int | The clicking mode |
get_item_in_window()
Gets an item out of the given window id
get_item_in_window(window_id: int, slot_id: int): item
Parameters
name | type | description |
---|---|---|
window_id | int | The window id |
slot_id | int | The slot id |
get_item()
Gets an item out of the players inventory
get_item(slot_id: int): item
Parameters
name | type | description |
---|---|---|
slot_id | int | The slot id |
get_damage_reduction()
Gets the damage reduction of the given armor item. Returns 0 if the item is not an armor item
get_damage_reduction(slot_id: int): double
Parameters
name | type | description |
---|---|---|
slot_id | int | The slot id |
get_damage_amount()
Gets the damage amount of the given item
get_damage_amount(slot_id: int): double
Parameters
name | type | description |
---|---|---|
slot_id | int | The slot id |
get_harvest_level()
Gets the harvest level of the given item
get_harvest_level(slot_id: int): double
Parameters
name | type | description |
---|---|---|
slot_id | int | The slot id |
upper_container_id()
Returns the upper chest inventory if a chest gui is currently open
upper_container_id(): int
This method does not have any parameters
lower_container_id()
Returns the lower chest inventory if a chest gui is currently open
lower_container_id(): int
This method does not have any parameters
player_inventory_id()
Returns the player's inventory id
player_inventory_id(): int
This method does not have any parameters
current_inventory()
Returns the current inventory the player is in, returns NIL if player is out of inventory
current_inventory(): string
This method does not have any parameters
client
Contains several functions to control and get information from the client
print()
Prints a message into the minecraft chat
print(message: string): void
Parameters
name | type | description |
---|---|---|
message | string | The message which is going to be printed |
message()
Sends a message into the minecraft chat
message(message: string): void
Parameters
name | type | description |
---|---|---|
message | string | The message which is going to be sent in chat |
set_timer_speed()
Sets the timer speed of the current game
set_timer_speed(speed: double): void
Parameters
name | type | description |
---|---|---|
speed | double | The new timer speed |
force_effects_redraw()
Forces blur effects to re-draw for smooth animations
force_effects_redraw(): void
This method does not have any parameters
is_key_down()
Returns if a given key is pressed
is_key_down(key: int): boolean
Parameters
name | type | description |
---|---|---|
key | int | The key |
is_mouse_down()
Returns if a given mouse button is pressed
is_mouse_down(button: int): boolean
Parameters
name | type | description |
---|---|---|
button | int | The button |
fps()
Returns the current fps
fps(): int
This method does not have any parameters
time()
Returns the current time in millis
time(): long
This method does not have any parameters
current_kill_aura_target()
Returns the current kill-aura target id or -1 if none is present
current_kill_aura_target(): int
This method does not have any parameters
get_scaled_width()
Returns the scaled screen width
get_scaled_width(): float
This method does not have any parameters
get_scaled_height()
Returns the scaled screen height
get_scaled_height(): float
This method does not have any parameters
get_width()
Returns the screen width
get_width(): float
This method does not have any parameters
get_height()
Returns the screen height
get_height(): float
This method does not have any parameters
world
Contains functions to control the local world
remove()
Removes the given entity id from the world
remove(entity_id: int): void
Parameters
name | type | description |
---|---|---|
entity_id | int | The id of the entity to be removed |
get_block_at()
Returns the block at the given coordinates
get_block_at(x: double, y: double, z: double): block
Parameters
name | type | description |
---|---|---|
x | double | The x coordinate |
y | double | The y coordinate |
z | double | The z coordinate |
get_block_at_vec()
Returns the block at the given vector coordinates
get_block_at_vec(vec: vec3d): block
Parameters
name | type | description |
---|---|---|
vec | vec3d | The vector coordinates |
get_entities()
Returns an array of all loaded entity ids
get_entities(): int[]
This method does not have any parameters
get_players()
Returns an array of all loaded player ids
get_players(): int[]
This method does not have any parameters
get_name()
Returns the name of the given entity id
get_name(entity_id: int): string
Parameters
name | type | description |
---|---|---|
entity_id | int | The entity id |
get_display_name()
Returns the display name of the given entity id
get_display_name(entity_id: int): string
Parameters
name | type | description |
---|---|---|
entity_id | int | The entity id |
get_hurt_time()
Returns the current hurt-time of the given entity id
get_hurt_time(entity_id: int): int
Parameters
name | type | description |
---|---|---|
entity_id | int | The entity id |
get_hurt_resistant_time()
Returns the current hurt resistant time of the given entity id
get_hurt_resistant_time(entity_id: int): int
Parameters
name | type | description |
---|---|---|
entity_id | int | The entity id |
get_health()
Returns the current health of the given entity id
get_health(entity_id: int): double
Parameters
name | type | description |
---|---|---|
entity_id | int | The entity id |
get_max_health()
Returns the current max health of the given entity id
get_max_health(entity_id: int): double
Parameters
name | type | description |
---|---|---|
entity_id | int | The entity id |
is_sprinting()
Returns the current sprinting state of the given entity id
is_sprinting(entity_id: int): boolean
Parameters
name | type | description |
---|---|---|
entity_id | int | The entity id |
is_sneaking()
Returns the current sneaking state of the given entity id
is_sneaking(entity_id: int): boolean
Parameters
name | type | description |
---|---|---|
entity_id | int | The entity id |
is_invisible()
Returns the current invisibility state of the given entity id
is_invisible(entity_id: int): boolean
Parameters
name | type | description |
---|---|---|
entity_id | int | The entity id |
is_burning()
Returns the current burning state of the given entity id
is_burning(entity_id: int): boolean
Parameters
name | type | description |
---|---|---|
entity_id | int | The entity id |
is_riding()
Returns the current riding state of the given entity id
is_riding(entity_id: int): boolean
Parameters
name | type | description |
---|---|---|
entity_id | int | The entity id |
get_facing()
Returns the current facing of the given entity id
get_facing(entity_id: int): facing
Parameters
name | type | description |
---|---|---|
entity_id | int | The entity id |
get_yaw()
Returns the current yaw of the given entity id
get_yaw(entity_id: int): float
Parameters
name | type | description |
---|---|---|
entity_id | int | The entity id |
get_pitch()
Returns the current pitch of the given entity id
get_pitch(entity_id: int): float
Parameters
name | type | description |
---|---|---|
entity_id | int | The entity id |
get_ticks_existed()
Returns the current ticks existed of the given entity id
get_ticks_existed(entity_id: int): int
Parameters
name | type | description |
---|---|---|
entity_id | int | The entity id |
is_player()
Returns if the given entity id is a player
is_player(entity_id: int): boolean
Parameters
name | type | description |
---|---|---|
entity_id | int | The entity id |
is_bot()
Returns if the given entity id id is a bot
is_bot(entity_id: int): boolean
Parameters
name | type | description |
---|---|---|
entity_id | int | The entity id |
is_target()
Returns if the given entity id is a target
is_target(entity_id: int): boolean
Parameters
name | type | description |
---|---|---|
entity_id | int | The entity id |
is_friend()
Returns if the given entity id is a friend
is_friend(entity_id: int): boolean
Parameters
name | type | description |
---|---|---|
entity_id | int | The entity id |
held_item()
Returns the item the entity is holding
held_item(entity_id: int): string
Parameters
name | type | description |
---|---|---|
entity_id | int | The entity id |
get_width()
Returns the current width of the given entity id
get_width(entity_id: int): float
Parameters
name | type | description |
---|---|---|
entity_id | int | The entity id |
get_height()
Returns the current height of the given entity id
get_height(entity_id: int): float
Parameters
name | type | description |
---|---|---|
entity_id | int | The entity id |
get_position_x()
Returns the current position x of the given entity id
get_position_x(entity_id: int): double
Parameters
name | type | description |
---|---|---|
entity_id | int | The entity id |
get_position_y()
Returns the current position y of the given entity id
get_position_y(entity_id: int): double
Parameters
name | type | description |
---|---|---|
entity_id | int | The entity id |
get_position_z()
Returns the current position z of the given entity id
get_position_z(entity_id: int): double
Parameters
name | type | description |
---|---|---|
entity_id | int | The entity id |
get_position()
Returns the current position of the given entity id
get_position(entity_id: int): vec3d
Parameters
name | type | description |
---|---|---|
entity_id | int | The entity id |
get_prev_position_x()
Returns the previous position x of the given entity id
get_prev_position_x(entity_id: int): double
Parameters
name | type | description |
---|---|---|
entity_id | int | The entity id |
get_prev_position_y()
Returns the previous position y of the given entity id
get_prev_position_y(entity_id: int): double
Parameters
name | type | description |
---|---|---|
entity_id | int | The entity id |
get_prev_position_z()
Returns the previous position z of the given entity id
get_prev_position_z(entity_id: int): double
Parameters
name | type | description |
---|---|---|
entity_id | int | The entity id |
get_prev_position()
Returns the current position of the given entity id
get_prev_position(entity_id: int): vec3d
Parameters
name | type | description |
---|---|---|
entity_id | int | The entity id |
get_active_effects()
Returns all current potion effects of the given entity id
get_active_effects(entity_id: int): potion[]
Parameters
name | type | description |
---|---|---|
entity_id | int | The entity id |
has_effect()
Returns if the given entity id has a given effect
has_effect(entity_id: int, id: int): boolean
Parameters
name | type | description |
---|---|---|
entity_id | int | The entity id |
id | int | The id of the potion |
get_effect()
Returns a specific potion effect if active otherwise returns nil of the given entity id
get_effect(entity_id: int, id: int): potion
Parameters
name | type | description |
---|---|---|
entity_id | int | The entity id |
id | int | The id of the potion |
get_biome()
Returns the biome of the current world
get_biome(): string
This method does not have any parameters
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 |
font
Contains several functions to receive height and width boundaries of text
minecraft_width()
Returns the width for the given text when rendered with minecraft font
minecraft_width(text: string): float
Parameters
name | type | description |
---|---|---|
text | string | The text |
minecraft_height()
Returns the height of the minecraft font
minecraft_height(): float
This method does not have any parameters
width()
Returns the width for the given text when rendered with the given font and size
width(type: customfonttype, size: float, text: string): float
Parameters
name | type | description |
---|---|---|
type | customfonttype | The custom font type |
size | float | The text size |
text | string | The text |
height()
Returns the height for the given text when rendered with the given font and size
height(type: customfonttype, size: float, text: string): float
Parameters
name | type | description |
---|---|---|
type | customfonttype | The custom font type |
size | float | The text size |
text | string | The text |
examples
Rendering
Trying to render something properly can be complicated, here are some examples and things to know when working with the rendering api.
Important things to know
The overlay render event has a pre and post state, please make sure you only render on one of those two states,
otherwise you render your stuff twice which can cause a major decrease in FPS depending on the amount of render passes.
Please always refer to using the batched renderer, it allows you to render multiple elements of the same type with
ease. You CANNOT render two different types in one render batch. You also cannot render two different font types in
one render batch, different sizes are fine.
The minecraft font is only available in the immediate renderer, this is the only exception where the immediate renderer
should be used.
Basic Batch Example
Below you can find a basic example for rendering the same type in a batched format to save fps by not causing more than one render pass.
render.batched.render_batch(
enums.template_type.RECT,
{
-- We use hex colors for rendering, they MUST always contain an alpha component
-- e.g 0xFFFF0000
types.template.rect.new(0, 0, 100, 100, -1),
types.template.rect.new(100, 0, 100, 100, 0xFF00FF00)
}
)
This example renders two rectangles in one render pass saving a lot of fps. You can add practically infinite elements to one render pass (the amount actually varies by the amount of GPU V-RAM available on the host system, usually you should never notice any limits as this is just basic 2d rendering)
Vectors
There are some methods in the api which use vectors, now you might ask how to create and use them.
This is a full tutorial on how to create and work with vectors!
Create a Vector
An important thing you need to know is that there are multiple types of vectors, you can find them under the types
category.
After you selected the desired vector you have multiple options, either create an empty one with default values or
predefining what values you want to have on each dimension.
Code Example
-- Create a vector with default values (0)
local default = types.vec2f.empty()
local default_x = default.x -- Will be 0 in this case
-- Create a vector with pre-defined values
local defined = types.vec2f.new(5, 10)
local defined_x = defined.x -- Will be 5 in this case
-- Redefining a vectors values
defined.x = 10
local new_defined_x = defined.x -- Will be 10 in this case