pub enum Event {
Init,
Login,
Chat(ChatPacket),
Tick,
Packet(Arc<ClientboundGamePacket>),
AddPlayer(PlayerInfo),
RemovePlayer(PlayerInfo),
UpdatePlayer(PlayerInfo),
Death(Option<Arc<ClientboundPlayerCombatKillPacket>>),
KeepAlive(u64),
Disconnect(Option<FormattedText>),
}
Expand description
Something that happened in-game, such as a tick passing or chat message being sent.
Note: Events are sent before they’re processed, so for example game ticks happen at the beginning of a tick before anything has happened.
Variants§
Init
Happens right after the bot switches into the Game state, but before
it’s actually spawned. This can be useful for setting the client
information with Client::set_client_information
, so the packet
doesn’t have to be sent twice.
Login
The client is now in the world. Fired when we receive a login packet.
Chat(ChatPacket)
A chat message was sent in the game chat.
Tick
Happens 20 times per second, but only when the world is loaded.
Packet(Arc<ClientboundGamePacket>)
We received a packet from the server.
Event::Packet(packet) => match *packet {
ClientboundGamePacket::Login(_) => {
println!("login packet");
}
_ => {}
},
AddPlayer(PlayerInfo)
A player joined the game (or more specifically, was added to the tab list).
RemovePlayer(PlayerInfo)
A player left the game (or maybe is still in the game and was just removed from the tab list).
UpdatePlayer(PlayerInfo)
A player was updated in the tab list (gamemode, display name, or latency changed).
Death(Option<Arc<ClientboundPlayerCombatKillPacket>>)
The client player died in-game.
KeepAlive(u64)
A KeepAlive
packet was sent by the server.
Disconnect(Option<FormattedText>)
The client disconnected from the server.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Event
impl !RefUnwindSafe for Event
impl Send for Event
impl Sync for Event
impl Unpin for Event
impl !UnwindSafe for Event
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> Downcast for Twhere
T: AsAny + ?Sized,
impl<T> Downcast for Twhere
T: AsAny + ?Sized,
§fn downcast_ref<T>(&self) -> Option<&T>where
T: AsAny,
fn downcast_ref<T>(&self) -> Option<&T>where
T: AsAny,
Any
.§fn downcast_mut<T>(&mut self) -> Option<&mut T>where
T: AsAny,
fn downcast_mut<T>(&mut self) -> Option<&mut T>where
T: AsAny,
Any
.