mirror of
https://github.com/italicsjenga/valence.git
synced 2025-01-11 15:21:31 +11:00
Add hardcore
This commit is contained in:
parent
5fcde5f7ae
commit
a06ba7e645
|
@ -144,7 +144,7 @@ pub struct Client {
|
||||||
player_data: Player,
|
player_data: Player,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[bitfield(u8)]
|
#[bitfield(u16)]
|
||||||
pub(crate) struct ClientFlags {
|
pub(crate) struct ClientFlags {
|
||||||
spawn: bool,
|
spawn: bool,
|
||||||
sneaking: bool,
|
sneaking: bool,
|
||||||
|
@ -158,6 +158,9 @@ pub(crate) struct ClientFlags {
|
||||||
modified_spawn_position: bool,
|
modified_spawn_position: bool,
|
||||||
/// If the last sent keepalive got a response.
|
/// If the last sent keepalive got a response.
|
||||||
got_keepalive: bool,
|
got_keepalive: bool,
|
||||||
|
hardcore: bool,
|
||||||
|
#[bits(7)]
|
||||||
|
_pad: u8
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Client {
|
impl Client {
|
||||||
|
@ -366,6 +369,15 @@ impl Client {
|
||||||
self.new_max_view_distance = dist.clamp(2, 32);
|
self.new_max_view_distance = dist.clamp(2, 32);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Must be set on the same tick the client joins the game.
|
||||||
|
pub fn set_hardcore(&mut self, hardcore: bool) {
|
||||||
|
self.flags.set_hardcore(hardcore);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn is_hardcore(&mut self) -> bool {
|
||||||
|
self.flags.hardcore()
|
||||||
|
}
|
||||||
|
|
||||||
pub fn settings(&self) -> Option<&Settings> {
|
pub fn settings(&self) -> Option<&Settings> {
|
||||||
self.settings.as_ref()
|
self.settings.as_ref()
|
||||||
}
|
}
|
||||||
|
@ -690,7 +702,7 @@ impl Client {
|
||||||
|
|
||||||
self.send_packet(Login {
|
self.send_packet(Login {
|
||||||
entity_id: 0, // EntityId 0 is reserved for clients.
|
entity_id: 0, // EntityId 0 is reserved for clients.
|
||||||
is_hardcore: false, // TODO
|
is_hardcore: self.flags.hardcore(),
|
||||||
gamemode: self.new_game_mode,
|
gamemode: self.new_game_mode,
|
||||||
previous_gamemode: self.old_game_mode,
|
previous_gamemode: self.old_game_mode,
|
||||||
dimension_names,
|
dimension_names,
|
||||||
|
|
Loading…
Reference in a new issue