Skip to main content

ClientVersion

Trait ClientVersion 

Source
pub trait ClientVersion: Version + Sealed {
    const GAME: GameVersion;
    const CHAT_LIMIT: usize;
    const INVENTORY: Version;

    // Required methods
    fn write_handshake(
        enc: &mut FrameEncoder,
        host: &str,
        port: u16,
    ) -> Result<(), EncodeError>;
    fn write_login_start(
        enc: &mut FrameEncoder,
        username: &str,
    ) -> Result<(), EncodeError>;
    fn write_encryption_response(
        enc: &mut FrameEncoder,
        shared_secret: &[u8],
        verify_token: &[u8],
    ) -> Result<(), EncodeError>;
    fn write_plugin_response(
        enc: &mut FrameEncoder,
        message_id: i32,
    ) -> Result<(), EncodeError>;
    fn decode_login(
        raw: &RawPacket,
    ) -> Result<Option<LoginInbound>, DecodeError>;
    fn play_filter(interests: Interests) -> PacketFilter;
    fn decode_play(raw: &RawPacket) -> Result<Option<Inbound>, DecodeError>;
    fn inventory_packet(
        inv: &mut Inventory,
        raw: &RawPacket,
    ) -> Result<Option<Outgoing>, DecodeError>;
    fn write_play(
        enc: &mut FrameEncoder,
        out: &Outbound,
    ) -> Result<(), EncodeError>;
    fn apply_teleport(pose: &mut Pose, t: &Teleport);
}
Expand description

What a protocol version needs to provide to the client.

Sealed: implemented for V1_8 and V1_16_5 only.

Required Associated Constants§

Source

const GAME: GameVersion

The run-time tag of this version.

Source

const CHAT_LIMIT: usize

Longest chat line the server accepts, in UTF-16 units (vanilla truncates to it).

Source

const INVENTORY: Version

The inventory version.

Required Methods§

Source

fn write_handshake( enc: &mut FrameEncoder, host: &str, port: u16, ) -> Result<(), EncodeError>

Queues the handshake packet (next state = login).

Source

fn write_login_start( enc: &mut FrameEncoder, username: &str, ) -> Result<(), EncodeError>

Queues the login start packet.

Source

fn write_encryption_response( enc: &mut FrameEncoder, shared_secret: &[u8], verify_token: &[u8], ) -> Result<(), EncodeError>

Queues the encryption response.

Source

fn write_plugin_response( enc: &mut FrameEncoder, message_id: i32, ) -> Result<(), EncodeError>

Queues a “not understood” answer to a login plugin request.

Source

fn decode_login(raw: &RawPacket) -> Result<Option<LoginInbound>, DecodeError>

Decodes a login-state packet; Ok(None) for packets the client ignores.

Source

fn play_filter(interests: Interests) -> PacketFilter

The play-state packet filter for the given interests: everything the core needs plus what the interests ask for. Everything else is dropped before it is decoded.

Source

fn decode_play(raw: &RawPacket) -> Result<Option<Inbound>, DecodeError>

Decodes a play-state packet; Ok(None) for packets the core does not use.

Source

fn inventory_packet( inv: &mut Inventory, raw: &RawPacket, ) -> Result<Option<Outgoing>, DecodeError>

Applies an inventory packet (windows, slots, confirms, held slot, login / respawn reset) to the inventory; returns the confirm answer to send now, if any. Other packets are ignored.

Source

fn write_play(enc: &mut FrameEncoder, out: &Outbound) -> Result<(), EncodeError>

Queues a play-state packet.

Source

fn apply_teleport(pose: &mut Pose, t: &Teleport)

Applies a server teleport to the pose the way this version’s client does (onPlayerPositionLook + Entity.updatePositionAndAngles).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl ClientVersion for V1_8

Source§

const GAME: GameVersion = GameVersion::V1_8_9

Source§

const CHAT_LIMIT: usize = 100

Source§

const INVENTORY: Version = ghast_inventory::Version::V1_8

Source§

impl ClientVersion for V1_16_5

Source§

const GAME: GameVersion = GameVersion::V1_16_5

Source§

const CHAT_LIMIT: usize = 256

Source§

const INVENTORY: Version = ghast_inventory::Version::V1_16_5