Skip to content

lib_minecraft.lua

lib_minecraft.lua is a Universe4 script that allows you to directly access JNI inside of Minecraft. Here are some examples of Minecraft scripts that depend on lib_minecraft.lua:

The documentation may not always be up-to-date with the latest functions available from lib_minecraft.lua. If you are looking for a specific function, consider asking in the lib_minecraft.lua thread. If you're looking for JNI documentation or Forge (1.8.9) mappings, see this post (click me).

As it says in the lib_minecraft.lua thread, some of these functions are available to make it easier for developers to maintain and update scripts. If you use the Forge mappings, you can easily add your own. You are free to submit your own functions to the lib_minecraft.lua script by going to the thread and posting your snippet.


on_scripts_loaded

Type

function

Description

Injects fantasy.zombie into javaw.exe (assuming this is Minecraft). Then calibrates Zombie with FC2. This always enables hypermode by the way. This should only be in your script's on_scripts_loaded callback. Do not confuse this function and put it in on_loaded. on_loaded does not allow global variables.

Example

Lua
local minecraft = require( "minecraft" ) -- lib_minecraft

function my_script.on_scripts_loaded()

     if not minecraft.on_scripts_loaded() then
        fantasy.log("lib_minecraft.lua failed to load" )
        return false
     end

end

on_worker

Type

function

Description

Gets the local player, world and other information about the current Minecraft instance. This should only be in your script's on_worker callback.

Example

Lua
1
2
3
4
5
6
7
function my_script.on_worker()

     if not minecraft.on_worker() then
        return false
     end

end

ffind_class

Type

function

Description

Finds a class from the Minecraft instance after calibrating.

Parameters

  • string

Returns

  • address

get_player

Type

function

Description

Gets the current localplayer.

Returns

  • address

get_minecraft

Type

function

Description

Gets the current Minecraft instance / context.

Returns

  • address

get_world

Type

function

Description

Gets the current world instance / context.

Returns

  • address

get_session

Type

function

Description

Gets the net/minecraft/client/util/Session instance / context.

Returns

  • address

get_render_manager

Type

function

Description

Gets the current render manager instance / context.

Returns

  • address

get_timer

Type

function

Description

Gets the current timer instance / context.

Returns

  • address

get_game_settings

Type

function

Description

Gets the current game settings instance / context.

Returns

  • address

get_players

Type

function

Description

Gets all players in the world.

Returns

  • table

get_entities

Type

function

Description

This is like get_players, except it will get all the entities in the world. That includes mobs, dropped items, orbs, etc...

Returns

  • table

is_alive

Type

function

Parameters

  • address entity

Returns

  • boolean

is_on_ground

Type

function

Parameters

  • address entity

Returns

  • boolean

get_hurt_time

Type

function

Parameters

  • address entity

Returns

  • number

get_motion

Type

function

Parameters

  • address entity

Returns

  • vector

set_velocity

Type

function

Parameters

  • address entity
  • number x
  • number y
  • number z

get_entity_id

Type

function

Parameters

  • address entity

Returns

  • number

get_name

Type

function

Parameters

  • address entity

Returns

  • string

get_yaw_pitch

Type

function

Parameters

  • address entity

Returns

  • vector

get_prev_yaw_pitch

Type

function

Parameters

  • address entity

Returns

  • vector

get_position

Type

function

Parameters

  • address entity

Returns

  • vector

get_entities_in_fov

Type

function

Description

This will get all entities that are within the specified FOV range. See the parameters.

The entity_list parameter is looking for the table returned from either get_players or get_entities. Meaning, if you supply that parameter with the table result from get_players, that means this function will scan only for player entities, not all entities.

The max_fov and max_distance is the range to look. Therefore, if you are looking to get all entities within 15 FOV, you would specify that as an argument. max_distance is optional. But if a number argument is applied that isn't nil, the distance between the entity (likely localplayer) will be accounted for. This function will supply an entity in your FOV even if they're an extremely far distance. If you want to limit that, then you would supply an argument for max_distance.

The include_items argument is false by default. It is optional. If you provide true as an argument, dropped items will be considered in the return table.

The table returned will contain numerous inner tables depending on how many entities are in your FOV. Each inner table contains the following structure:

  • address object (the entity's address that is in your FOV)
  • string name
  • vector position
  • number index
  • number distance (distance value between you and the entity in the FOV)
  • vector distance_vector (difference in distance as a vector)
  • vector angle (x is yaw, y is pitch)
  • vector angle_difference (angle, except the difference between the entity's angle and the destination)
  • number fov
  • vector local_position
  • vector local_rotation

Parameters

  • address entity
  • table entity_list
  • number max_fov
  • number max_distance (optional)
  • boolean include_items (optional)

Returns

  • table

Example

See aimbot.lua and reach.lua.


get_bounding_box

Type

function

Parameters

  • address entity

Returns

  • vector min
  • vector max

set_bounding_box

Type

function

Parameters

  • address entity
  • vector min
  • vector max

set_yaw_pitch

Type

function

Parameters

  • address entity
  • number yaw
  • number pitch

is_gui_open

Type

function

Returns

  • boolean

get_session_username

Type

function

Returns

  • string

set_session_username

Type

function

Parameters

  • string

get_network_player_info

Type

function

Description

net/minecraft/client/network/NetworkPlayerInfo

Parameters

  • address entity

get_ping

Type

function

Parameters

  • address entity

set_ping

Type

function

Parameters

  • address entity