class

Rosegold::Bot

Inherits Rosegold::EventEmitter / Reference / Object

Constructors

Class methods

join_game(address : String, timeout_ticks = 1200)

Connects to the server and waits for being ingame.

Source

Instance methods

attack(target : Vec3d | Nil | Look | Nil = nil)

Looks in the direction of target, then activates and immediately deactivates the attack button.

Source
auto_respawn=(auto_respawn : Bool)
Source
auto_respawn?
Source
can_craft?(recipe : RecipeDisplayEntry) : Bool
Source
chat(message : String)

Send a message or slash command.

Source
connect(*args, **options)
Source
connect(*args, **options, &)
Source
connected?(*args, **options)
Source
connected?(*args, **options, &)
Source
container_type
Source
craft(item_name : String, count : Int32 = 1, table : Vec3i | Nil = nil)
Source
craft(recipe : RecipeDisplayEntry, count : Int32 = 1, table : Vec3i | Nil = nil)
Source
craft_all(item_name : String, table : Vec3i | Nil = nil)
Source
craft_all(recipe : RecipeDisplayEntry, table : Vec3i | Nil = nil)
Source
craft_pattern(pattern : Array(Array(String | Nil)), count : Int32 = 1, table : Vec3i | Nil = nil)

Craft by manually placing items into the grid. Use this for custom/modded recipes or when the recipe book doesn't have what you need.

bot.craft_pattern([
  ["iron_ingot", "iron_ingot", "iron_ingot"],
  [nil, "stick", nil],
  [nil, "stick", nil],
])
Source
dead?
Source
dig(ticks : Int32, target : Vec3d | Nil | Look | Nil = nil)

Looks in the direction of target, then activates the attack button, waits ticks, and deactivates it again.

Source
disconnect(*args, **options)
Source
disconnect(*args, **options, &)
Source
disconnect_reason
Source
drop_hand_full
Source
drop_hand_single
Source
eat!
Source
effect_by_name(*args, **options)
Source
effect_by_name(*args, **options, &)
Source
effects(*args, **options)
Source
effects(*args, **options, &)
Source
estimated_break_ticks(block_name : String, *, buffer_ticks : Int32 = 10) : Int32

Estimates how many ticks it will take this bot to break the named block.

Uses the bot's current main-hand item and live player state (Haste, gamemode, on_ground, etc.), so the estimate reflects what the bot would actually experience right now — not a fresh Player.new baseline.

buffer_ticks is added on top of the computed mining time to absorb network latency and server tick variance; tune it down to 0 for a pure client-side estimate, or up if you're seeing the bot release dig too early.

Raises ArgumentError if block_name isn't in the active version's MCData.

bot.estimated_break_ticks("stone")                  # => e.g. 160
bot.estimated_break_ticks("stone", buffer_ticks: 0) # => e.g. 150
Source
eyes(*args, **options)
Source
eyes(*args, **options, &)
Source
feet

DEPRECATED Use bot.location instead of bot.feet

Source
food(*args, **options)
Source
food(*args, **options, &)
Source
full_health?
Source
gamemode(*args, **options)
Source
gamemode(*args, **options, &)
Source
has_slow_falling?(*args, **options)
Source
has_slow_falling?(*args, **options, &)
Source
health(*args, **options)
Source
health(*args, **options, &)
Source
host(*args, **options)
Source
host(*args, **options, &)
Source
hotbar_selection

The active (main hand) hotbar slot number (1-9).

Source
hotbar_selection=(index : UInt8)

Selects the active (main hand) hotbar slot number (1-9).

Source
inventory
Source
join_game(*args, **options)
Source
join_game(*args, **options, &)
Source
jump_boost_level(*args, **options)
Source
jump_boost_level(*args, **options, &)
Source
jump_by_height(height = 1, timeout_ticks = 20)

Jumps and waits until the bot is height above the ground. Fails if the bot lands before reaching this height.

Source
keys
Source
land_on_ground(timeout_ticks = 120)

Waits until the bot's y level stops changing.

Source
leave_bed

Use #interact_block to enter a bed.

Source
levitation_level(*args, **options)
Source
levitation_level(*args, **options, &)
Source
location
Source
look

Direction the player is looking.

Source
look

Computes the new look from the current look. Waits for the new look to be sent to the server.

Source
look=(look : Look)

Waits for the new look to be sent to the server.

Source
look=(vec : Vec3d)

Waits for the new look to be sent to the server.

Source
look_at(location : Vec3d)

Waits for the new look to be sent to the server.

Source
look_at_horizontal(location : Vec3d)

Ignores y coordinate; useful for looking straight while moving. Waits for the new look to be sent to the server.

Source
main_hand(*args, **options)
Source
main_hand(*args, **options, &)
Source
move_to(location : Vec3d, stuck_timeout_ticks : Int32 = 60)

Moves straight towards the exact location (decimal coordinates are honored verbatim). Waits for arrival. stuck_timeout_ticks specifies how many consecutive stuck ticks before throwing MovementStuck.

Source
move_to(location : Vec3i, stuck_timeout_ticks : Int32 = 60)

Moves to the center of the given block coordinate (x + 0.5, z + 0.5), preserving the bot's current feet y. Use a Vec3d overload if you need to land on an exact non-centered position.

Source
move_to(x : Float, z : Float, stuck_timeout_ticks : Int32 = 60)

Moves straight towards the exact (x, z) (decimal coordinates are honored verbatim). y is taken from the bot's current feet location. Waits for arrival. stuck_timeout_ticks specifies how many consecutive stuck ticks before throwing MovementStuck.

Source
move_to(x : Int, z : Int, stuck_timeout_ticks : Int32 = 60)

Moves to the center of the given block column (x + 0.5, z + 0.5). Use the Float overload to target an exact non-centered position.

Source
move_to(stuck_timeout_ticks : Int32 = 10, &block : Vec3d -> Vec3d)

Computes the destination location from the current feet location. Moves straight towards the destination. Waits for arrival. stuck_timeout_ticks specifies how many consecutive stuck ticks before throwing MovementStuck.

Source
new(address : String)

Does not connect immediately.

Source
open_container(timeout : Time::Span = 5.seconds, &)

Opens a container (chest, barrel, etc.) and yields control for interaction. Automatically uses the main hand, waits for container content to load, executes the provided block, then closes the container.

bot.open_container do
  bot.inventory.deposit_at_least(10, "diamond")
  bot.inventory.withdraw_at_least(5, "emerald")
end

Caller must already be looking at the container block.

Source
open_container_handle(timeout : Time::Span = 5.seconds, &)

Opens a container and yields a ContainerHandle for typed interaction. The handle provides intent-level operations (withdraw, deposit) and typed menu access (as_chest, as_furnace, etc.).

bot.open_container_handle do |handle|
  handle.deposit("diamond", 10)
  handle.withdraw("emerald", 5)
  if chest = handle.as_chest
    chest.contents.each { |slot| puts slot.name }
  end
end

Caller must already be looking at the container block.

Source
open_container_handle(command : String, timeout : Time::Span = 5.seconds, &)
Source
pick_item_from_block(pos : Vec3i, include_data : Bool = false)

Pick the item at the given block position (middle-click on a block). The server finds the matching item in the player's inventory, moves it to the hotbar, and sends the appropriate slot update packets.

Source
pitch
Source
pitch=(pitch : Float64)

Sets the pitch of the look Waits for the new look to be sent to the server

Source
place_block_against(block : Vec3i, face : BlockFace)

Looks at that face of that block, then activates and immediately deactivates the use button.

Source
port(*args, **options)
Source
port(*args, **options, &)
Source
recipe_registry(*args, **options)
Source
recipe_registry(*args, **options, &)
Source
recipes_for(item_name : String) : Array(RecipeDisplayEntry)
Source
respawn(timeout_ticks = 1200)

Revive the player if dead. Does nothing if alive.

Source
run_command_with_confirmation(command : String, expected_message : String, max_tries : Int32 = 3, inverse_message : String | Nil = nil)

Runs a slash command and waits for a confirmation message from the server.

Use this for non-idempotent commands (like toggles) or when you want to force retries on idempotent commands until confirmation. Retries automatically if the command fails or returns an inverse message.

The expected_message is matched after stripping formatting codes. If inverse_message is provided and received, the command will retry, which is useful for toggle commands where the bot may be in the wrong state.

Returns true if the expected message is received within max_tries attempts, false otherwise.

bot.run_command_with_confirmation(
  "/ignoregroup !",
  "You stopped ignoring !.",
  3,
  "You are now ignoring !"
)
Source
saturation(*args, **options)
Source
saturation(*args, **options, &)
Source
slowness_level(*args, **options)
Source
slowness_level(*args, **options, &)
Source
sneak(*args, **options)
Source
sneak(*args, **options, &)
Source
sneaking?(*args, **options)
Source
sneaking?(*args, **options, &)
Source
spawned?(*args, **options)
Source
spawned?(*args, **options, &)
Source
speed_level(*args, **options)
Source
speed_level(*args, **options, &)
Source
sprint(*args, **options)
Source
sprint(*args, **options, &)
Source
sprinting?(*args, **options)
Source
sprinting?(*args, **options, &)
Source
start_digging(target : Vec3d | Nil | Look | Nil = nil)

Looks at that target, then activates the attack button.

Source
start_jump

Jumps the next time the player is on the ground.

Source
start_using_hand(hand : Hand = :main_hand)

Activates the "use" button.

Source
stop_digging(*args, **options)
Source
stop_digging(*args, **options, &)
Source
stop_moving

Stop moving towards the target specified in #move_to Also releases all movement keys and dequeues any pending jump.

Source
stop_using_hand(*args, **options)
Source
stop_using_hand(*args, **options, &)
Source
subscribe(event_class : Class)
Source
swap_hands
Source
unsneak
Source
unsprint
Source
use_hand(target : Vec3d | Nil | Look | Nil = nil, hand : Hand = :main_hand)

Looks in the direction of target, then activates and immediately deactivates the use button.

Source
username(*args, **options)
Source
username(*args, **options, &)
Source
uuid(*args, **options)
Source
uuid(*args, **options, &)
Source
wait_tick(*args, **options)
Source
wait_tick(*args, **options, &)
Source
wait_ticks(*args, **options)
Source
wait_ticks(*args, **options, &)
Source
x(*args, **options)
Source
x(*args, **options, &)
Source
y(*args, **options)
Source
y(*args, **options, &)
Source
yaw=(yaw : Float64)

Sets the yaw of the look Waits for the new look to be sent to the server

Source
z(*args, **options)
Source
z(*args, **options, &)
Source

Nested types