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

namedescription
RECTApplies the rectangle rendering type
GRADIENTApplies the gradient rendering type
ROUNDED_RECTApplies the rounded rectangle rendering type
OUTLINED_ROUNDED_RECTApplies the outlined rounded rectangle rendering type
TEXTApplies the text rendering type
TRIANGLEApplies the triangle rendering type

entity_action

The different entity actions which can be sent in a 0x0B packet

namedescription
START_SNEAKINGStarts sneaking on the server
STOP_SNEAKINGStops sneaking on the server
STOP_SLEEPINGStops sleeping on the server
START_SPRINTINGStarts sprinting on the server
STOP_SPRINTINGStops sprinting on the server
RIDING_JUMPExecutes a riding jump on the server
OPEN_INVENTORYExecuted an open inventory request on the server

interact_actions

The different entity interact actions which can be sent in a 0x02 packet

namedescription
INTERACTInteracts with the target entity
ATTACKAttacks the target entity
INTERACT_ATInteracts with the entity at the given hit vector

digging_action

The different digging actions which can be sent in a 0x07 packet

namedescription
START_DESTROY_BLOCKStarts destroying a block
ABORT_DESTROY_BLOCKAborts destroying a block
STOP_DESTROY_BLOCKStops destroying a block, indicating its broken
DROP_ALL_ITEMSDrops all items
DROP_ITEMDrops one item
RELEASE_USE_ITEMReleases the current item

client_status_actions

The different types of status actions which can be sent in a client status packet

namedescription
PERFORM_RESPAWNNo description
REQUEST_STATSNo description
OPEN_INVENTORY_ACHIEVEMENTNo description

hittype

The different hit types a ray-cast can have

namedescription
MISSNot hitting anything
BLOCKHitting block
ENITTYHitting entity

facing

The different face values used in several functions

namedescription
DOWNNo description
UPNo description
NORTHNo description
SOUTHNo description
WESTNo description
EASTNo description

custom_font_type

The different custom font types which can be used to render text

namedescription
ROBOTO_MEDIUMRoboto Medium
INTER_MEDIUMInter Medium
TAHOMATahoma
VERDANAVerdana
SFSan Francisco
PRODUCT_SANSProduct Sans
MATERIAL_ICONSMaterial Icons (https://fonts.google.com/icons for more information)
MATERIAL_SYMBOLS_OUTLINED_REGULARMaterial Symbols Outlined Regular (https://fonts.google.com/icons for more information)
VOLTE_SEMI_BOLDVolte 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

nametypedescription
prebooleanDefines 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

nametypedescription
prebooleanWhether 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
xdoubleThe x position sent to the server
ydoubleThe y position sent to the server
zdoubleThe z position sent to the server
yawfloatThe yaw rotation sent to the server (Will update the third-person rotations once modified)
pitchfloatThe pitch rotation sent to the server (Will update the third-person rotations once modified)
groundbooleanThe 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

nametypedescription
xdoubleThe x motion used to apply the move
ydoubleThe y motion used to apply the move
zdoubleThe 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

nametypedescription
packet_idintThe packet id
cancelbooleanWhether 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

nametypedescription
packet_idintThe packet id
cancelbooleanWhether the packet processing should be canceled or not

on_overlay_render()

Called once the overlay of the client is being rendered

Parameters

nametypedescription
partial_ticksfloatThe partial ticks
prebooleanWhether its pre or post overlay render

on_world_render()

Called once the world is rendered

Parameters

nametypedescription
partial_ticksfloatThe partial ticks

on_effect_render()

Called once any blur effects are rendered (shadow, blur)

Parameters

nametypedescription
blurbooleanWhether the blur or shadow is called
partial_ticksfloatThe 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

fielddescription
xNo description
yNo description
widthNo description
heightNo description
radiusNo description
thicknessNo description
colorNo 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

fielddescription
xNo description
yNo description
widthNo description
heightNo description
fromNo description
toNo description
verticalNo 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

fielddescription
xNo description
yNo description
widthNo description
heightNo description
colorNo 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

fielddescription
xNo description
yNo description
widthNo description
heightNo description
radiusNo description
colorNo 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

fielddescription
font_typeNo description
textNo description
sizeNo description
xNo description
yNo description
colorNo description
shadowNo 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

fielddescription
top_xNo description
top_yNo description
left_xNo description
left_yNo description
right_xNo description
right_yNo description
colorNo 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

nametypedescription
templaterendertemplateThe 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

fielddescription
xNo description
yNo description

Methods

All methods contained in this type

add()

Adds the given parameters to the vector values

Parameters

nametypedescription
xfloatThe value added to x
yfloatThe 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

fielddescription
xNo description
yNo description
zNo 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

fielddescription
hit_typeNo description
side_hitNo description
posNo description
hit_vecNo description
hit_entity_idNo 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

fielddescription
idThe id of the enchantment
levelThe 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

fielddescription
nameThe name of the block
display_nameThe display name of the block
full_blockWhether the block has a full bounding box or not
translucentWhether the block is translucent or not (used while rendering)
block_hardnessThe hardness of the block
relative_hardnessThe relative hardness of the block
slipperinessThe 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

fielddescription
xNo description
yNo description
zNo 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

fielddescription
xNo description
yNo description
zNo 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

fielddescription
nameThe item name (locale)
display_nameThe display name of the item
max_stack_sizeThe maximum stack size (usually 64)
stack_sizeThe current stack size
max_damageThe max item damage before it breaks
damageThe current item damage
solidReturns whether the block is solid if the item is a block. Will always be false otherwise
enchantmentsThe enchantments applied on the item
potionsThe 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

fielddescription
idThe potion id
nameThe potion name (locale)
durationThe duration of the potion effect
amplifierThe strength of the potion effect
bad_effectWhether the effect is bad or not
colorThe 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

nametypedescription
typetemplatetypeThe template type used

render_batch()

Renders a given batch of templates

render_batch(type: templatetype, templates: rendertemplate[]): void

Parameters

nametypedescription
typetemplatetypeThe template type used
templatesrendertemplate[]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

nametypedescription
src_factorintNo description
dst_factorintNo 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

nametypedescription
src_factorintNo description
dst_factorintNo description
src_factor_alphaintNo description
dst_factor_alphaintNo description

render/immediate

Contains non-recommended rendering functions for immediate rendering

## USAGE NOT RECOMMENDED ##
Please refer to 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

nametypedescription
xfloatThe x position
yfloatThe y position
widthfloatThe width
heightfloatThe height
colorintThe 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

nametypedescription
xfloatThe x position
yfloatThe y position
widthfloatThe width
heightfloatThe height
fromintThe from color
tointThe to color
verticalbooleanWhether 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

nametypedescription
xfloatThe x position
yfloatThe y position
widthfloatThe width
heightfloatThe height
radiusfloatThe corner radius
colorintThe 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

nametypedescription
xfloatThe x position
yfloatThe y position
widthfloatThe width
heightfloatThe height
radiusfloatThe corner radius
thicknessfloatThe thickness of the outline
colorintThe 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

nametypedescription
top_xfloatThe top x of the triangle
top_yfloatThe top y of the triangle
left_xfloatThe left x of the triangle
left_yfloatThe left y of the triangle
right_xfloatThe right x of the triangle
right_yfloatThe right y of the triangle
colorintThe 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

nametypedescription
textstringThe text to be rendered
xfloatThe x position
yfloatThe y position
colorintThe color
shadowbooleanWhether 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

nametypedescription
font_typecustomfonttypeThe type of font to render the text with
textstringThe text to be rendered
sizefloatThe font size to use
xfloatThe x position
yfloatThe y position
colorintThe color
shadowbooleanWhether 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

nametypedescription
namestringThe name of the module
display_namestringThe display name of the module, used in arraylist and clickgui
descriptionstringThe description of the module, shown in the clickgui
tableluatableThe 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

nametypedescription
namestringThe name of the module

set_state()

Sets the enabled state of a module

set_state(name: string, state: boolean): void

Parameters

nametypedescription
namestringThe name of the module to update the state of
statebooleanThe new module state

toggle()

Toggles a module

toggle(name: string): void

Parameters

nametypedescription
namestringThe 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

nametypedescription
namestringThe name of the module which contains the setting you want to change
setting_idstringThe 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
valueobjectThe 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

nametypedescription
modulestringThe module the setting will be added to
idstringThe id of the setting (used for configs)
namestringThe name of the setting
defaultbooleanThe 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

nametypedescription
modulestringThe module the setting will be added to
idstringThe id of the setting (used for configs)
namestringThe name of the setting
defaultintThe default value of the setting (ideally in-between of min and max)
minintThe minimum value allowed
maxintThe maximum value allowed
incrementintThe 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

nametypedescription
modulestringThe module the setting will be added to
idstringThe id of the setting (used for configs)
namestringThe name of the setting
defaultfloatThe default value of the setting (ideally in-between of min and max)
minfloatThe minimum value allowed
maxfloatThe maximum value allowed
incrementfloatThe 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

nametypedescription
modulestringThe module the setting will be added to
idstringThe id of the setting (used for configs)
namestringThe name of the setting
defaultintThe 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

nametypedescription
modulestringThe module the setting will be added to
idstringThe id of the setting (used for configs)
namestringThe name of the setting
defaultstringThe default value of the setting

get_setting()

Returns the value of a setting

get_setting(module: string, id: string): object

Parameters

nametypedescription
modulestringThe module which contains the setting
idstringThe id of the setting

inventory

drop()

Drops a given slot id from the inventory

drop(slot_id: int, stack: boolean): void

Parameters

nametypedescription
slot_idintThe slot id to drop
stackbooleanWhether to drop the entire stack or a singular item

shift()

Shifts a slot id in the inventory

shift(slot_id: int): void

Parameters

nametypedescription
slot_idintThe 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

nametypedescription
slot_idintThe slot id to swap with
hot_bar_slotintThe 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

nametypedescription
window_idintThe window id
slot_idintThe slot id
mouse_button_clickedintThe mouse button clicked
modeintThe 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

nametypedescription
window_idintThe window id
slot_idintThe slot id

get_item()

Gets an item out of the players inventory

get_item(slot_id: int): item

Parameters

nametypedescription
slot_idintThe 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

nametypedescription
slot_idintThe slot id

get_damage_amount()

Gets the damage amount of the given item

get_damage_amount(slot_id: int): double

Parameters

nametypedescription
slot_idintThe slot id

get_harvest_level()

Gets the harvest level of the given item

get_harvest_level(slot_id: int): double

Parameters

nametypedescription
slot_idintThe 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

nametypedescription
messagestringThe message which is going to be printed

message()

Sends a message into the minecraft chat

message(message: string): void

Parameters

nametypedescription
messagestringThe 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

nametypedescription
speeddoubleThe 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

nametypedescription
keyintThe key

is_mouse_down()

Returns if a given mouse button is pressed

is_mouse_down(button: int): boolean

Parameters

nametypedescription
buttonintThe 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

nametypedescription
entity_idintThe 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

nametypedescription
xdoubleThe x coordinate
ydoubleThe y coordinate
zdoubleThe z coordinate

get_block_at_vec()

Returns the block at the given vector coordinates

get_block_at_vec(vec: vec3d): block

Parameters

nametypedescription
vecvec3dThe 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

nametypedescription
entity_idintThe entity id

get_display_name()

Returns the display name of the given entity id

get_display_name(entity_id: int): string

Parameters

nametypedescription
entity_idintThe entity id

get_hurt_time()

Returns the current hurt-time of the given entity id

get_hurt_time(entity_id: int): int

Parameters

nametypedescription
entity_idintThe 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

nametypedescription
entity_idintThe entity id

get_health()

Returns the current health of the given entity id

get_health(entity_id: int): double

Parameters

nametypedescription
entity_idintThe entity id

get_max_health()

Returns the current max health of the given entity id

get_max_health(entity_id: int): double

Parameters

nametypedescription
entity_idintThe entity id

is_sprinting()

Returns the current sprinting state of the given entity id

is_sprinting(entity_id: int): boolean

Parameters

nametypedescription
entity_idintThe entity id

is_sneaking()

Returns the current sneaking state of the given entity id

is_sneaking(entity_id: int): boolean

Parameters

nametypedescription
entity_idintThe entity id

is_invisible()

Returns the current invisibility state of the given entity id

is_invisible(entity_id: int): boolean

Parameters

nametypedescription
entity_idintThe entity id

is_burning()

Returns the current burning state of the given entity id

is_burning(entity_id: int): boolean

Parameters

nametypedescription
entity_idintThe entity id

is_riding()

Returns the current riding state of the given entity id

is_riding(entity_id: int): boolean

Parameters

nametypedescription
entity_idintThe entity id

get_facing()

Returns the current facing of the given entity id

get_facing(entity_id: int): facing

Parameters

nametypedescription
entity_idintThe entity id

get_yaw()

Returns the current yaw of the given entity id

get_yaw(entity_id: int): float

Parameters

nametypedescription
entity_idintThe entity id

get_pitch()

Returns the current pitch of the given entity id

get_pitch(entity_id: int): float

Parameters

nametypedescription
entity_idintThe entity id

get_ticks_existed()

Returns the current ticks existed of the given entity id

get_ticks_existed(entity_id: int): int

Parameters

nametypedescription
entity_idintThe entity id

is_player()

Returns if the given entity id is a player

is_player(entity_id: int): boolean

Parameters

nametypedescription
entity_idintThe entity id

is_bot()

Returns if the given entity id id is a bot

is_bot(entity_id: int): boolean

Parameters

nametypedescription
entity_idintThe entity id

is_target()

Returns if the given entity id is a target

is_target(entity_id: int): boolean

Parameters

nametypedescription
entity_idintThe entity id

is_friend()

Returns if the given entity id is a friend

is_friend(entity_id: int): boolean

Parameters

nametypedescription
entity_idintThe entity id

held_item()

Returns the item the entity is holding

held_item(entity_id: int): string

Parameters

nametypedescription
entity_idintThe entity id

get_width()

Returns the current width of the given entity id

get_width(entity_id: int): float

Parameters

nametypedescription
entity_idintThe entity id

get_height()

Returns the current height of the given entity id

get_height(entity_id: int): float

Parameters

nametypedescription
entity_idintThe entity id

get_position_x()

Returns the current position x of the given entity id

get_position_x(entity_id: int): double

Parameters

nametypedescription
entity_idintThe entity id

get_position_y()

Returns the current position y of the given entity id

get_position_y(entity_id: int): double

Parameters

nametypedescription
entity_idintThe entity id

get_position_z()

Returns the current position z of the given entity id

get_position_z(entity_id: int): double

Parameters

nametypedescription
entity_idintThe entity id

get_position()

Returns the current position of the given entity id

get_position(entity_id: int): vec3d

Parameters

nametypedescription
entity_idintThe 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

nametypedescription
entity_idintThe 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

nametypedescription
entity_idintThe 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

nametypedescription
entity_idintThe entity id

get_prev_position()

Returns the current position of the given entity id

get_prev_position(entity_id: int): vec3d

Parameters

nametypedescription
entity_idintThe entity id

get_active_effects()

Returns all current potion effects of the given entity id

get_active_effects(entity_id: int): potion[]

Parameters

nametypedescription
entity_idintThe entity id

has_effect()

Returns if the given entity id has a given effect

has_effect(entity_id: int, id: int): boolean

Parameters

nametypedescription
entity_idintThe entity id
idintThe 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

nametypedescription
entity_idintThe entity id
idintThe 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

nametypedescription
slotintThe slot number you are holding (any others will not work properly)
block_posvec3iThe position of the block to place on
hit_vecvec3dThe hit vector
facingfacingThe 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

nametypedescription
yawfloatThe yaw used to fire the ray-cast
pitchfloatThe pitch used to fire the ray-cast
reachfloatThe reach used to fire the ray-cast

set_yaw()

Sets the players client-side yaw

set_yaw(yaw: float): void

Parameters

nametypedescription
yawfloatThe new yaw

set_pitch()

Sets the players client-side pitch

set_pitch(pitch: float): void

Parameters

nametypedescription
pitchfloatThe new pitch

set_held_item()

Sets the players hot-bar slot

set_held_item(slot: int): void

Parameters

nametypedescription
slotintThe new slot

set_speed()

Sets the speed of the player using the move event

set_speed(event: luatable, speed: double): void

Parameters

nametypedescription
eventluatableThe move event (if you want to set the speed outside of the move event, use set_motion_speed)
speeddoubleThe speed to move with

set_motion_speed()

Sets the speed of the player using motions

set_motion_speed(speed: double): void

Parameters

nametypedescription
speeddoubleThe speed to move with

set_sprinting()

Sets the players sprinting state

set_sprinting(sprinting: boolean): void

Parameters

nametypedescription
sprintingbooleanThe new sprinting state

set_motion_x()

Sets the players motion x

set_motion_x(x: double): void

Parameters

nametypedescription
xdoubleThe new motion x

set_motion_y()

Sets the players motion y

set_motion_y(y: double): void

Parameters

nametypedescription
ydoubleThe new motion y

set_motion_z()

Sets the players motion z

set_motion_z(z: double): void

Parameters

nametypedescription
zdoubleThe new motion z

set_motion()

Sets the players motion

set_motion(motion: vec3d): void

Parameters

nametypedescription
motionvec3dThe new motion as a vector

set_position()

Sets the players position

set_position(position: vec3d): void

Parameters

nametypedescription
positionvec3dThe 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

nametypedescription
positionvec3dThe 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

nametypedescription
statebooleanThe 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

nametypedescription
idintThe packet id
argumentsobject[]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

nametypedescription
idintThe packet id
argumentsobject[]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

nametypedescription
xfloatThe x coordinate
yfloatThe y coordinate
zfloatThe z coordinate

distance_to_vec()

Calculates the distance between the given vector and the player position

distance_to_vec(vec: vec3d): double

Parameters

nametypedescription
vecvec3dThe target vector

distance_to_entity()

Calculates the distance between the given entity and the player

distance_to_entity(entity_id: int): double

Parameters

nametypedescription
entity_idintThe target entity's id

rotations_to()

Calculates the yaw and pitch for looking at the given position

rotations_to(position: vec3d): vec2f

Parameters

nametypedescription
positionvec3dThe 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

nametypedescription
idintThe id of the potion

get_effect()

Returns a specific potion effect if active otherwise returns nil

get_effect(id: int): potion

Parameters

nametypedescription
idintThe 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

nametypedescription
textstringThe 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

nametypedescription
typecustomfonttypeThe custom font type
sizefloatThe text size
textstringThe 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

nametypedescription
typecustomfonttypeThe custom font type
sizefloatThe text size
textstringThe 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