class
Rosegold::Client
- Rosegold::Client
- Rosegold::EventEmitter
- Reference
- Object
Overview
Holds world state (player, chunks, etc.) and control state (physics, open window, etc.). Can be reconnected.
Defined in:
rosegold/client.crConstructors
Class Method Summary
- .protocol_version
- .protocol_version=(version : UInt32)
- .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
- #connection=(connection : Connection::Client | Nil)
- #connection? : Connection::Client | Nil
- #container_menu : ContainerMenu | InventoryMenu
- #container_menu=(container_menu : ContainerMenu | InventoryMenu)
- #cookies : Hash(String, Bytes)
- #cookies=(cookies : Hash(String, Bytes))
- #current_protocol_state : ProtocolState
- #current_protocol_state=(current_protocol_state : ProtocolState)
- #detected_protocol_version : UInt32 | Nil
- #detected_protocol_version=(detected_protocol_version : UInt32 | Nil)
- #dimension : Dimension
- #dimension=(dimension : Dimension)
- #disconnect(*args, **options)
- #disconnect(*args, **options, &)
- #get_cookie(identifier : String) : Bytes | Nil
- #host : String
- #host=(host : String)
- #interactions : Interactions
- #interactions=(interactions : Interactions)
- #inventory_menu : InventoryMenu
- #inventory_menu=(inventory_menu : InventoryMenu)
-
#join_game(timeout_ticks = 1200)
Waits for the client to be fully spawned, ie.
- #join_game(*args, &)
- #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)
- #physics : Physics
- #physics=(physics : Physics)
- #player : Player
- #player=(player : Player)
- #player_inventory : PlayerInventory
- #player_inventory=(player_inventory : PlayerInventory)
- #port : Int32
- #port=(port : Int32)
- #protocol_version
-
#queue_packet(packet : Serverbound::Packet)
Send a packet to the server concurrently.
-
#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)
-
#tick_interval : Time::Span
Calculate tick interval based on current tick rate
- #tick_rate : Float32
- #tick_rate=(tick_rate : Float32)
- #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 | Nil = nil) forall T
wait_for
Constructor Detail
def self.new(host : String, port : Int32 = 25565, offline : NamedTuple(uuid: String, username: String) | Nil = nil)
#
Class Method Detail
Instance Method Detail
def join_game(timeout_ticks = 1200)
#
Waits for the client to be fully spawned, ie. physics and inventory being ready.
def send_packet!(packet : Serverbound::Packet)
#
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.
def update_ticking_state(new_tick_rate : Float32, frozen : Bool)
#
Update client ticking state from server