-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1e70985
commit 785c1eb
Showing
8 changed files
with
105 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use evenio::{prelude::*, rayon::prelude::*}; | ||
use valence_protocol::VarInt; | ||
|
||
use crate::{KillAllEntities, MinecraftEntity, Player}; | ||
|
||
pub fn kill_all( | ||
_r: ReceiverMut<KillAllEntities>, | ||
entities: Fetcher<(EntityId, &MinecraftEntity, Not<&Player>)>, | ||
mut players: Fetcher<&mut Player>, | ||
mut s: Sender<Despawn>, | ||
) { | ||
let ids = entities.iter().map(|(id, ..)| id).collect::<Vec<_>>(); | ||
|
||
#[allow(clippy::cast_possible_wrap)] | ||
let entity_ids = ids.iter().map(|id| VarInt(id.index().0 as i32)).collect(); | ||
|
||
let despawn_packet = valence_protocol::packets::play::EntitiesDestroyS2c { entity_ids }; | ||
|
||
players.par_iter_mut().for_each(|player| { | ||
// todo: handle error | ||
let _ = player.packets.writer.send_packet(&despawn_packet); | ||
}); | ||
|
||
for &id in &ids { | ||
s.send(Despawn(id)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
use evenio::prelude::*; | ||
use evenio::rayon::prelude::*; | ||
|
||
use crate::{Player, TpsEvent}; | ||
|
||
pub fn call( | ||
r: Receiver<TpsEvent>, | ||
mut players: Fetcher<&mut Player>, | ||
) { | ||
let ms_per_tick = r.event.ms_per_tick; | ||
|
||
// with 4 zeroes | ||
// lead 2 zeroes | ||
let message = format!("MSPT: {ms_per_tick:07.4}"); | ||
|
||
players.par_iter_mut().for_each(|player| { | ||
// todo: handle error | ||
let _ = player.packets.writer.send_chat_message(&message); | ||
}); | ||
} |