class Rosegold::Client

Overview

Holds world state (player, chunks, etc.) and control state (physics, open window, etc.). Can be reconnected.

Defined in:

rosegold/client.cr

Constructors

Class Method Summary

Instance Method Summary

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) #

[View source]

Class Method Detail

def self.protocol_version #

[View source]
def self.protocol_version=(version : UInt32) #

[View source]
def self.status(host : String, port : UInt16 = 25565) #

[View source]

Instance Method Detail

def access_token : String #

[View source]
def access_token=(access_token : String) #

[View source]
def add_chunk_batch_sample(millis_per_chunk : Float64, batch_size : Int32) #

[View source]
def add_tick_steps(steps : UInt32) #

Add tick steps when ticking is frozen


[View source]
def average_millis_per_chunk : Float64 #

[View source]
def chat_manager : ChatManager #

[View source]
def chat_manager=(chat_manager : ChatManager) #

[View source]
def chunk_batch_samples : Array(ChunkBatchSample) #

[View source]
def chunk_batch_samples=(chunk_batch_samples : Array(ChunkBatchSample)) #

[View source]
def chunk_batch_start_time : Time | Nil #

[View source]
def chunk_batch_start_time=(chunk_batch_start_time : Time | Nil) #

[View source]
def clear_cookies #

[View source]
def connect #

[View source]
def connected? #

[View source]
def connection : Connection::Client #

[View source]
def connection=(connection : Connection::Client | Nil) #

[View source]
def connection? : Connection::Client | Nil #

[View source]
def container_menu : ContainerMenu | InventoryMenu #

[View source]
def container_menu=(container_menu : ContainerMenu | InventoryMenu) #

[View source]
def cookies : Hash(String, Bytes) #

[View source]
def cookies=(cookies : Hash(String, Bytes)) #

[View source]
def current_protocol_state : ProtocolState #

[View source]
def current_protocol_state=(current_protocol_state : ProtocolState) #

[View source]
def detected_protocol_version : UInt32 | Nil #

[View source]
def detected_protocol_version=(detected_protocol_version : UInt32 | Nil) #

[View source]
def dimension : Dimension #

[View source]
def dimension=(dimension : Dimension) #

[View source]
def disconnect(*args, **options) #

[View source]
def disconnect(*args, **options, &) #

[View source]
def get_cookie(identifier : String) : Bytes | Nil #

[View source]
def host : String #

[View source]
def host=(host : String) #

[View source]
def interactions : Interactions #

[View source]
def interactions=(interactions : Interactions) #

[View source]
def inventory_menu : InventoryMenu #

[View source]
def inventory_menu=(inventory_menu : InventoryMenu) #

[View source]
def join_game(timeout_ticks = 1200) #

Waits for the client to be fully spawned, ie. physics and inventory being ready.


[View source]
def join_game(*args, &) #

[View source]
def next_sequence : Int32 #

[View source]
def offline : NamedTuple(uuid: String, username: String) | Nil #

[View source]
def offline=(offline : NamedTuple(uuid: String, username: String) | Nil) #

[View source]
def pending_block_operations : Hash(Int32, BlockOperation) #

[View source]
def pending_block_operations=(pending_block_operations : Hash(Int32, BlockOperation)) #

[View source]
def pending_tick_steps : UInt32 #

[View source]
def pending_tick_steps=(pending_tick_steps : UInt32) #

[View source]
def physics : Physics #

[View source]
def physics=(physics : Physics) #

[View source]
def player : Player #

[View source]
def player=(player : Player) #

[View source]
def player_inventory : PlayerInventory #

[View source]
def player_inventory=(player_inventory : PlayerInventory) #

[View source]
def port : Int32 #

[View source]
def port=(port : Int32) #

[View source]
def protocol_version #

[View source]
def queue_packet(packet : Serverbound::Packet) #

Send a packet to the server concurrently.


[View source]
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.


[View source]
def sequence_counter : Int32 #

[View source]
def sequence_counter=(sequence_counter : Int32) #

[View source]
def set_protocol_state(protocol_state : ProtocolState) #

[View source]
def spawned? #

[View source]
def start_ticker #

[View source]
def state=(state) #

Legacy method - deprecated, use set_protocol_state instead


[View source]
def status #

[View source]
def store_cookie(identifier : String, data : Bytes) #

[View source]
def tick_interval : Time::Span #

Calculate tick interval based on current tick rate


[View source]
def tick_rate : Float32 #

[View source]
def tick_rate=(tick_rate : Float32) #

[View source]
def ticking_frozen : Bool #

[View source]
def ticking_frozen=(ticking_frozen : Bool) #

[View source]
def transfer_to(new_host : String, new_port : UInt32) #

[View source]
def update_ticking_state(new_tick_rate : Float32, frozen : Bool) #

Update client ticking state from server


[View source]
def wait_tick #

[View source]
def wait_ticks(ticks : Int32) #

[View source]