class
Rosegold::Client
- Rosegold::Client
- Rosegold::EventEmitter
- Reference
- Object
Overview
Forward declaration to avoid circular dependency
Defined in:
rosegold/client.crrosegold/spectate/server.cr
Constant Summary
-
LATEST_PROTOCOL =
775_u32 -
SUPPORTED_PROTOCOLS =
{772_u32, 774_u32, 775_u32}
Constructors
Class Method Summary
-
.protocol_version
TODO @@protocol_version is global state shared across all Client instances.
- .protocol_version=(version : UInt32)
- .protocol_version_explicit?
- .reset_protocol_version!
- .status(host : String, port : UInt16 = 25565)
Instance Method Summary
- #access_token : String
- #access_token=(access_token : String)
- #add_chunk_batch_sample(millis_per_chunk : Float64, batch_size : Int32)
-
#add_tick_steps(steps : UInt32)
Add tick steps when ticking is frozen
- #average_millis_per_chunk : Float64
- #chat_manager : ChatManager
- #chat_manager=(chat_manager : ChatManager)
- #chunk_batch_samples : Array(ChunkBatchSample)
- #chunk_batch_samples=(chunk_batch_samples : Array(ChunkBatchSample))
- #chunk_batch_start_time : Time | Nil
- #chunk_batch_start_time=(chunk_batch_start_time : Time | Nil)
- #clear_cookies
- #connect
- #connected?
-
#connection : Connection::Client
Internal engine state — not exposed through Bot API.
- #connection? : Connection::Client | Nil
- #container_menu : Menu
- #container_menu=(container_menu : Menu)
- #cookies : Hash(String, Bytes)
- #cookies=(cookies : Hash(String, Bytes))
- #current_protocol_state : ProtocolState
- #current_protocol_state=(current_protocol_state : ProtocolState)
- #disconnect(*args, **options)
- #disconnect(*args, **options, &)
- #get_cookie(identifier : String) : Bytes | Nil
- #host : String
- #host=(host : String)
- #inventory_menu : PlayerMenu
- #inventory_menu=(inventory_menu : PlayerMenu)
-
#join_game(timeout_ticks = 1200)
Waits for the client to be fully spawned, ie.
- #join_game(*args, &)
- #known_packs : Array(NamedTuple(namespace: String, id: String, version: String))
- #known_packs=(known_packs : Array(NamedTuple(namespace: String, id: String, version: String)))
- #next_sequence : Int32
- #offline : NamedTuple(uuid: String, username: String) | Nil
- #offline=(offline : NamedTuple(uuid: String, username: String) | Nil)
- #pending_block_operations : Hash(Int32, BlockOperation)
- #pending_block_operations=(pending_block_operations : Hash(Int32, BlockOperation))
- #pending_tick_steps : UInt32
- #pending_tick_steps=(pending_tick_steps : UInt32)
- #player : Player
- #player=(player : Player)
- #player_inventory : PlayerInventory
- #player_inventory=(player_inventory : PlayerInventory)
- #player_list : Hash(UUID, PlayerList::Entry)
- #player_list=(player_list : Hash(UUID, PlayerList::Entry))
- #port : Int32
- #port=(port : Int32)
- #protocol_version
-
#queue_packet(packet : Serverbound::Packet)
Send a packet to the server concurrently.
- #recipe_registry : RecipeRegistry
- #recipe_registry=(recipe_registry : RecipeRegistry)
- #registries : Hash(String, Clientbound::RegistryData)
- #registries=(registries : Hash(String, Clientbound::RegistryData))
-
#send_packet!(packet : Serverbound::Packet)
Send a packet in the current fiber.
- #sequence_counter : Int32
- #sequence_counter=(sequence_counter : Int32)
- #set_protocol_state(protocol_state : ProtocolState)
- #spawned?
- #start_ticker
-
#state=(state)
Legacy method - deprecated, use set_protocol_state instead
- #status
- #store_cookie(identifier : String, data : Bytes)
- #tags : Clientbound::UpdateTags | Nil
- #tags=(tags : Clientbound::UpdateTags | Nil)
-
#tick_interval : Time::Span
Calculate tick interval based on current tick rate Vanilla client never ticks faster than 20 TPS (Minecraft.java:getTickTargetMillis)
- #tick_rate : Float32
- #tick_rate=(tick_rate : Float32)
- #ticker_done : Channel(Nil)
- #ticker_done=(ticker_done : Channel(Nil))
- #ticking_frozen : Bool
- #ticking_frozen=(ticking_frozen : Bool)
- #transfer_to(new_host : String, new_port : UInt32)
-
#update_ticking_state(new_tick_rate : Float32, frozen : Bool)
Update client ticking state from server
- #wait_tick
- #wait_ticks(ticks : Int32)
Instance methods inherited from class Rosegold::EventEmitter
emit_event(event : Event)
emit_event,
event_handlers : Handlers
event_handlers,
off(event_type : T.class, id : UUID) forall T
off,
on(event_type : T.class, id : UUID = UUID.random, &block : T -> ) forall T
on,
once(event_type : T.class, &block : T -> ) forall T
once,
wait_for(event_type : T.class, timeout : Time::Span = 5.seconds) forall Twait_for(event_type : T.class, timeout : Time::Span = 5.seconds, &) forall T wait_for
Constructor Detail
Class Method Detail
TODO @@protocol_version is global state shared across all Client instances. This prevents connecting to servers with different protocol versions concurrently. To fix, protocol_version should become an instance variable set during handshake.
Instance Method Detail
Internal engine state — not exposed through Bot API. Protected: accessible within Rosegold:: namespace only.
Waits for the client to be fully spawned, ie. physics and inventory being ready.
Send a packet in the current fiber. Useful for things like EncryptionRequest, because it must change the IO socket only AFTER a EncryptionResponse has been sent.
Calculate tick interval based on current tick rate Vanilla client never ticks faster than 20 TPS (Minecraft.java:getTickTargetMillis)
Update client ticking state from server