Explain event validation

This commit is contained in:
Ryan 2022-09-12 21:53:07 -07:00
parent 51cb3bd277
commit 7878793629
2 changed files with 12 additions and 7 deletions

View file

@ -750,9 +750,6 @@ impl<C: Config> Client<C> {
C2sPlayPacket::QueryEntityNbt(_) => {}
C2sPlayPacket::PlayerInteractEntity(p) => {
if let Some(id) = entities.get_with_network_id(p.entity_id.0) {
// TODO: verify that the client has line of sight to the targeted entity and
// that the distance is <=4 blocks.
self.events.push_back(ClientEvent::InteractWithEntity {
id,
sneaking: p.sneaking,
@ -851,9 +848,6 @@ impl<C: Config> Client<C> {
C2sPlayPacket::CraftRequest(_) => {}
C2sPlayPacket::UpdatePlayerAbilities(_) => {}
C2sPlayPacket::PlayerAction(p) => {
// TODO: verify dug block is within the correct distance from the client.
// TODO: verify that the broken block is allowed to be broken?
if p.sequence.0 != 0 {
self.dug_blocks.push(p.sequence.0);
}

View file

@ -16,7 +16,18 @@ use crate::protocol::VarInt;
/// Represents an action performed by a client.
///
/// Client events can be obtained from
/// [`pop_event`](crate::client::Client::pop_event).
/// [`pop_event`](super::Client::pop_event).
///
/// # Event Validation
///
/// [`Client`](super::Client) makes no attempt to validate events against the
/// expected rules for players. Malicious clients can teleport through walls,
/// interact with distant entities, sneak and sprint backwards, break
/// bedrock in survival mode, etc.
///
/// It is best to think of events from clients as _requests_ to interact with
/// the server. It is then your responsibility to decide if the request should
/// be honored.
#[derive(Debug)]
pub enum ClientEvent {
/// A regular message was sent to the chat.