Client & Player
The client and player APIs give access to the local game session, HUD info, player state, and actions.
Guards
Section titled “Guards”player and client are always available as objects, but many methods return nil or false when not in a game. Use player.is_present before reading player state:
return unless player.is_presentclient
Section titled “client”client.get_version # => String e.g. "1.21.4"client.get_username # => String current session nameclient.get_fps # => Integer current frame rateclient.get_ping # => Integer ping to server in msclient.get_server_address # => String or nilclient.is_in_game # => Boolean player and world both presentclient.is_screen_open # => Boolean a GUI screen is openclient.now # => Integer System.currentTimeMillisChat & clipboard
Section titled “Chat & clipboard”client.message("Hello") # info message in chat (prefixed [Scripts])client.warn("Something odd") # same, styled as warningclient.error("Something broke") # same, styled as error
client.send_chat("/say hi") # sends a chat message as the playerclient.copy_to_clipboard("text") # copies text to system clipboardActions
Section titled “Actions”client.do_attack # triggers the attack actionclient.do_item_use # triggers the use-item actionRandomness
Section titled “Randomness”client.random_int(1, 10) # => Integer in [1, 10]client.random_float(0.0, 1.0) # => Float in [0.0, 1.0]player
Section titled “player”Presence
Section titled “Presence”player.is_present # => Boolean — check this before anything elseIdentity
Section titled “Identity”player.get_id # => Integer entity IDplayer.get_name # => Stringplayer.get_display_name # => String formatted display nameHealth & hunger
Section titled “Health & hunger”player.get_health # => Floatplayer.get_max_health # => Floatplayer.get_absorption # => Float absorption heartsplayer.get_hunger # => Integer 0–20player.has_status_effect("speed") # => Booleanplayer.get_hurt_time # => Integer frames since last hit (0 = not hurt)player.get_fall_distance # => FloatPosition & rotation
Section titled “Position & rotation”player.get_x # => Floatplayer.get_y # => Floatplayer.get_z # => Floatplayer.get_yaw # => Floatplayer.get_pitch # => Float
player.get_velocity_x # => Floatplayer.get_velocity_y # => Floatplayer.get_velocity_z # => FloatMovement flags
Section titled “Movement flags”player.is_on_ground # => Booleanplayer.is_sprinting # => Booleanplayer.is_sneaking # => Booleanplayer.is_using_item # => Booleanplayer.is_in_water # => Booleanplayer.is_in_cobweb # => BooleanCombat
Section titled “Combat”player.is_holding_weapon # => Booleanplayer.can_crit # => Booleanplayer.get_attack_cooldown # => Float 0.0–1.0 (base_time defaults to 0.5)player.get_attack_cooldown(0.0) # Float, custom base_timeActions
Section titled “Actions”player.jumpplayer.swingplayer.set_sprinting(true)player.set_yaw(90.0)player.set_pitch(-30.0)player.set_rotation(90.0, -30.0) # yaw, pitchplayer.send_chat("/say hi")rotation
Section titled “rotation”The rotation API provides helpers for aim assistance, including calculating rotations to entities and positions.
Rotation calculations
Section titled “Rotation calculations”rotation.get_rotation_to(entity) # => {yaw, pitch, x, y, z} to target an entityrotation.get_rotation_to(block) # block hit / block-pos table with x,y,zrotation.get_rotation_to(x, y, z) # exact world position
rotation.get_rotation_to_entity(entity) # explicit aliasrotation.get_rotation_to_entity(entity, "Head")rotation.get_rotation_to_entity(entity, "Body", 50.0) # multipoint accuracy (0-100)rotation.get_rotation_to_block(block)rotation.get_rotation_to_block(x, y, z)
rotation.get_to_entity(entity) # legacy aliasrotation.get_to_entity(entity, "Head")rotation.get_to_entity(entity, "Body", 50.0)rotation.get_to_position(x, y, z)rotation.get_to_block(block)rotation.get_to_block(x, y, z)All rotation methods return a table with yaw, pitch, x, y, and z keys.
Angle difference helpers
Section titled “Angle difference helpers”rotation.get_angle_diff(entity) # => {yaw, pitch, total} angle difference from current rotationrotation.get_yaw_diff(entity) # => Float yaw difference in degrees (-180 to 180)rotation.get_pitch_diff(entity) # => Float pitch difference in degreesrotation.get_abs_angle_diff(entity) # => Float combined Euclidean angle differencerotation.apply_gcd(current, target) # => Float snapped to the client's mouse GCD steprotation.apply_gcd(current, target) is useful before player.set_yaw, player.set_pitch, or player.set_rotation if you want your scripted rotations to look like native client input.
Distance
Section titled “Distance”rotation.get_distance_to(entity) # => Float distance to entity in blocksExample — session HUD
Section titled “Example — session HUD”script = { name: "Session HUD", description: "Shows username, health, and ping.", category: "RENDER",
on_render_2d: lambda do |event| return unless player.is_present
white = render.color(255, 255, 255, 255) yellow = render.color(255, 220, 50, 255)
render.text("#{player.get_name} HP #{player.get_health.round(1)}", 8, 8, white, true) render.text("Ping: #{client.get_ping} ms", 8, 20, yellow, true) end}Example — auto-sprint
Section titled “Example — auto-sprint”script = { name: "Auto Sprint", description: "Keeps sprinting while moving forward.", category: "MISC",
on_tick: lambda do |_event| return unless player.is_present return if player.is_sprinting return unless input.is_forward_pressed
player.set_sprinting(true) end}Example — aim assist
Section titled “Example — aim assist”script = { name: "Aim Assist", description: "Smoothly aims at the nearest player.", category: "COMBAT", max_range: 5.0, smoothing: 3.0,
on_tick: lambda do |_event| return unless player.is_present
target = nil min_dist = 100.0
world.get_players.each do |p| next if p.is_player == false next if p.get_name == player.get_name next if friends.is_friend(p.get_name)
dist = rotation.get_distance_to(p) if dist and dist < min_dist min_dist = dist target = p end end
return unless target
rot = rotation.get_rotation_to_entity(target, "Head") if rot current_yaw = player.get_yaw current_pitch = player.get_pitch
yaw_diff = rot.yaw - current_yaw yaw_diff = yaw_diff - 360.0 if yaw_diff > 180.0 yaw_diff = yaw_diff + 360.0 if yaw_diff < -180.0
pitch_diff = rot.pitch - current_pitch
smoothing = 3.0 new_yaw = current_yaw + (yaw_diff / smoothing) new_pitch = current_pitch + (pitch_diff / smoothing)
player.set_rotation(new_yaw, new_pitch) end end}