logo
pub struct Client<C: Config> {
    pub state: C::ClientState,
    /* private fields */
}
Expand description

Represents a remote connection to a client after successfully logging in.

Much like an Entity, clients possess a location, rotation, and UUID. However, clients are handled separately from entities and are partially managed by the library.

By default, clients have no influence over the worlds they reside in. They cannot break blocks, hurt entities, or see other clients. Interactions with the server must be handled explicitly with Self::pop_event.

Additionally, clients possess Player entity data which is only visible to themselves. This can be accessed with Self::player and Self::player_mut.

The Difference Between a “Client” and a “Player”

Normally in Minecraft, players and clients are one and the same. Players are simply a subtype of the entity base class backed by a remote connection.

In Valence however, clients and players are decoupled. This separation allows for greater flexibility and enables parallelism.

Fields

state: C::ClientState

Custom state.

Implementations

If the client joined the game this tick.

Gets the client’s UUID.

Gets the username of this client.

Gets the player textures of this client. If the client does not have a skin, then None is returned.

Gets the world this client is located in.

Gets the player list this client sees.

Sets the player list this client sees.

The previous player list ID is returned.

Sets if this client sees the world as superflat. Superflat worlds have a horizon line lower than normal worlds.

The player must be (re)spawned for changes to take effect.

Gets if this client sees the world as superflat. Superflat worlds have a horizon line lower than normal worlds.

Changes the world this client is located in and respawns the client. This can be used to respawn the client after death.

The given WorldId must be valid. Otherwise, the client is disconnected.

Sends a system message to the player which is visible in the chat. The message is only visible to this client.

Gets the absolute position of this client in the world it is located in.

Changes the position and rotation of this client in the world it is located in.

If you want to change the client’s world, use Self::spawn.

Gets the most recently set velocity of this client in m/s.

Sets the client’s velocity in m/s.

Gets this client’s yaw.

Gets this client’s pitch.

Gets the spawn position. The client will see minecraft:compass items point at the returned position.

Sets the spawn position. The client will see minecraft:compass items point at the provided position.

Gets the last death location of this client. The client will see minecraft:recovery_compass items point at the returned position.

If the client’s current dimension differs from the returned dimension or the location is None then the compass will spin randomly.

Sets the last death location. The client will see minecraft:recovery_compass items point at the provided position. If the client’s current dimension differs from the provided dimension or the location is None then the compass will spin randomly.

Changes to the last death location take effect when the client (re)spawns.

Gets the client’s game mode.

Sets the client’s game mode.

Sets the title this client sees.

A title is a large piece of text displayed in the center of the screen which may also include a subtitle underneath it. The title can be configured to fade in and out using the TitleFade struct.

Gets the attack cooldown speed.

Sets the attack cooldown speed.

Gets the speed at which the client can run on the ground.

Sets the speed at which the client can run on the ground.

Removes the current title from the client’s screen.

Gets whether or not the client is connected to the server.

A disconnected client object will never become reconnected. It is your responsibility to remove disconnected clients from the Clients container.

Returns an iterator over all pending client events in the order they will be removed from the queue.

Removes a ClientEvent from the event queue.

If there are no remaining events, None is returned.

Any remaining client events are deleted at the end of the current tick.

Pushes an entity event to the queue.

The current view distance of this client measured in chunks. The client will not be able to see chunks and entities past this distance.

The result is in 2..=32.

Sets the view distance. The client will not be able to see chunks and entities past this distance.

The new view distance is measured in chunks and is clamped to 2..=32.

Enables hardcore mode. This changes the design of the client’s hearts.

To have any visible effect, this function must be called on the same tick the client joins the server.

Gets if hardcore mode is enabled.

Gets the client’s current settings.

Disconnects this client from the server with the provided reason. This has no effect if the client is already disconnected.

All future calls to Self::is_disconnected will return true.

Like Self::disconnect, but no reason for the disconnect is displayed.

Returns an immutable reference to the client’s own Player data.

Returns a mutable reference to the client’s own Player data.

Changes made to this data is only visible to this client.

Attempts to enqueue a play packet to be sent to this client. The client is disconnected if the clientbound packet buffer is full.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Converts self into T using Into<T>. Read more

Causes self to use its Binary implementation when Debug-formatted. Read more

Causes self to use its Display implementation when Debug-formatted. Read more

Causes self to use its LowerExp implementation when Debug-formatted. Read more

Causes self to use its LowerHex implementation when Debug-formatted. Read more

Causes self to use its Octal implementation when Debug-formatted. Read more

Causes self to use its Pointer implementation when Debug-formatted. Read more

Causes self to use its UpperExp implementation when Debug-formatted. Read more

Causes self to use its UpperHex implementation when Debug-formatted. Read more

Formats each item in a sequence. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Pipes by value. This is generally the method you want to use. Read more

Borrows self and passes that borrow into the pipe function. Read more

Mutably borrows self and passes that borrow into the pipe function. Read more

Borrows self, then passes self.borrow() into the pipe function. Read more

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more

Borrows self, then passes self.as_ref() into the pipe function.

Mutably borrows self, then passes self.as_mut() into the pipe function. Read more

Borrows self, then passes self.deref() into the pipe function.

Mutably borrows self, then passes self.deref_mut() into the pipe function. Read more

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

Should always be Self

Immutable access to a value. Read more

Mutable access to a value. Read more

Immutable access to the Borrow<B> of a value. Read more

Mutable access to the BorrowMut<B> of a value. Read more

Immutable access to the AsRef<R> view of a value. Read more

Mutable access to the AsMut<R> view of a value. Read more

Immutable access to the Deref::Target of a value. Read more

Mutable access to the Deref::Target of a value. Read more

Calls .tap() only in debug builds, and is erased in release builds.

Calls .tap_mut() only in debug builds, and is erased in release builds. Read more

Calls .tap_borrow() only in debug builds, and is erased in release builds. Read more

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds. Read more

Calls .tap_ref() only in debug builds, and is erased in release builds. Read more

Calls .tap_ref_mut() only in debug builds, and is erased in release builds. Read more

Calls .tap_deref() only in debug builds, and is erased in release builds. Read more

Calls .tap_deref_mut() only in debug builds, and is erased in release builds. Read more

Attempts to convert self into T using TryInto<T>. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more