pub struct Client {
pub read_conn: Arc<Mutex<ReadConnection<ClientboundGamePacket>>>,
pub write_conn: Arc<Mutex<WriteConnection<ServerboundGamePacket>>>,
pub player: Arc<Mutex<RawMutex, Player>>,
pub dimension: Arc<Mutex<RawMutex, Dimension>>,
pub physics_state: Arc<Mutex<RawMutex, PhysicsState>>,
/* private fields */
}
Expand description
A player that you can control that is currently in a Minecraft server.
Fields
read_conn: Arc<Mutex<ReadConnection<ClientboundGamePacket>>>
write_conn: Arc<Mutex<WriteConnection<ServerboundGamePacket>>>
player: Arc<Mutex<RawMutex, Player>>
dimension: Arc<Mutex<RawMutex, Dimension>>
physics_state: Arc<Mutex<RawMutex, PhysicsState>>
Implementations
sourceimpl Client
impl Client
sourcepub async fn send_chat_packet(
&self,
message: &str
) -> impl Future<Output = Result<(), Error>>
pub async fn send_chat_packet(
&self,
message: &str
) -> impl Future<Output = Result<(), Error>>
Sends chat message to the server. This only sends the chat packet and
not the command packet. The chat
function handles checking whether
the message is a command and using the proper packet for you.
sourcepub async fn send_command_packet(
&self,
command: &str
) -> impl Future<Output = Result<(), Error>>
pub async fn send_command_packet(
&self,
command: &str
) -> impl Future<Output = Result<(), Error>>
Send a command packet to the server. The command
argument should not
include the slash at the front.
pub async fn chat(
&self,
message: &str
) -> impl Future<Output = Result<(), Error>>
sourceimpl Client
impl Client
sourcepub async fn join(
account: &Account,
address: &ServerAddress
) -> impl Future<Output = Result<(Client, UnboundedReceiver<Event>), JoinError>>
pub async fn join(
account: &Account,
address: &ServerAddress
) -> impl Future<Output = Result<(Client, UnboundedReceiver<Event>), JoinError>>
Connect to a Minecraft server with an account.
sourcepub async fn write_packet(
&self,
packet: ServerboundGamePacket
) -> impl Future<Output = Result<(), Error>>
pub async fn write_packet(
&self,
packet: ServerboundGamePacket
) -> impl Future<Output = Result<(), Error>>
Write a packet directly to the server.
sourcepub async fn shutdown(self) -> impl Future<Output = Result<(), Error>>
pub async fn shutdown(self) -> impl Future<Output = Result<(), Error>>
Disconnect from the server, ending all tasks.
sourcepub fn entity_mut(&self, dimension: &'d mut Dimension) -> EntityMut<'d>
pub fn entity_mut(&self, dimension: &'d mut Dimension) -> EntityMut<'d>
Returns the entity associated to the player.
sourceimpl Client
impl Client
sourcepub async fn send_position(
&mut self
) -> impl Future<Output = Result<(), MovePlayerError>>
pub async fn send_position(
&mut self
) -> impl Future<Output = Result<(), MovePlayerError>>
This gets called every tick.
pub async fn set_pos(
&mut self,
new_pos: Vec3
) -> impl Future<Output = Result<(), MovePlayerError>>
pub async fn move_entity(
&mut self,
movement: &Vec3
) -> impl Future<Output = Result<(), MovePlayerError>>
pub fn ai_step(&mut self)
sourcepub fn walk(&mut self, direction: MoveDirection)
pub fn walk(&mut self, direction: MoveDirection)
Start walking in the given direction.
sourcepub fn set_jumping(&mut self, jumping: bool)
pub fn set_jumping(&mut self, jumping: bool)
Toggle whether we’re jumping. This acts as if you held space in
vanilla. If you want to jump once, use the jump
function.
If you’re making a realistic client, calling this function every tick is recommended.