use super::*;
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub struct RawInbound {
pub id: i32,
pub body: bytes::Bytes,
pub at: Instant,
}
#[derive(Debug, Clone, Copy, PartialEq)]
#[non_exhaustive]
pub struct TeleportEvent {
pub teleport: crate::common::Teleport,
pub sent_before: Pose,
pub pose_before: Pose,
pub after: Pose,
}
pub(super) const MAX_PENDING_TELEPORTS: usize = 64;
pub(super) const MAX_PENDING_KNOCKBACK: usize = 64;
pub(super) const MAX_PENDING_RAW: usize = 4096;
pub(super) const MAX_PENDING_ENTITY_EVENTS: usize = 4096;
pub(super) const MAX_PENDING_DIALOGS: usize = 64;
pub(super) const MAX_PENDING_HUD: usize = 256;
pub(super) const MAX_PENDING_TABS: usize = 64;
pub(super) const MAX_PENDING_SIGNS: usize = 16;
#[derive(Debug, Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct TickEvents {
pub chat: Vec<ChatMessage>,
pub chat_dropped: usize,
pub teleported: bool,
pub teleports: Vec<TeleportEvent>,
pub joined: bool,
pub respawned: bool,
pub died: bool,
pub health_changed: bool,
pub game_mode_changed: bool,
pub inventory: ghast_inventory::Events,
pub block_updates: Vec<(ghast_protocol::BlockPos, u32)>,
pub block_updates_dropped: usize,
pub raw: Vec<RawInbound>,
pub raw_dropped: usize,
more: Box<MoreEvents>,
}
impl TickEvents {
pub(super) fn clear(&mut self) {
self.chat.clear();
self.chat_dropped = 0;
self.teleported = false;
self.teleports.clear();
self.joined = false;
self.respawned = false;
self.died = false;
self.health_changed = false;
self.game_mode_changed = false;
if self.more.any {
*self.more = MoreEvents::default();
}
self.inventory = ghast_inventory::Events::default();
self.block_updates.clear();
self.block_updates_dropped = 0;
self.raw.clear();
self.raw_dropped = 0;
}
#[inline]
pub(super) fn more(&mut self) -> &mut MoreEvents {
self.more.any = true;
&mut self.more
}
#[must_use]
pub fn effects(&self) -> &[crate::common::EffectEvent] {
&self.more.effects
}
#[must_use]
pub fn hurt(&self) -> &[crate::common::Hurt] {
&self.more.hurt
}
#[must_use]
pub fn knockback(&self) -> &[crate::common::Knockback] {
&self.more.knockback
}
#[must_use]
pub fn deaths(&self) -> &[crate::common::Death] {
&self.more.deaths
}
#[must_use]
pub fn entities(&self) -> &[ghast_entity::Event] {
&self.more.entities
}
#[must_use]
pub fn entities_dropped(&self) -> usize {
self.more.entities_dropped
}
#[must_use]
pub fn item_use(&self) -> &[crate::common::UseEvent] {
&self.more.item_use
}
#[must_use]
pub fn cooldowns(&self) -> &[crate::cooldown::CooldownEvent] {
&self.more.cooldowns
}
#[must_use]
pub fn hud(&self) -> &[crate::hud::HudEvent] {
&self.more.hud
}
#[must_use]
pub fn hud_dropped(&self) -> usize {
self.more.hud_dropped
}
#[must_use]
pub fn tab_completions(&self) -> &[crate::hud::TabCompletion] {
&self.more.tabs
}
#[must_use]
pub fn signs(&self) -> &[crate::sign::SignEvent] {
&self.more.signs
}
#[must_use]
pub fn sleep(&self) -> &[crate::common::SleepEvent] {
&self.more.sleep
}
#[must_use]
pub fn fishing(&self) -> &[crate::fishing::FishingEvent] {
&self.more.fishing
}
}
#[derive(Debug, Clone, Default, PartialEq)]
pub(super) struct MoreEvents {
pub(super) any: bool,
pub(super) effects: Vec<crate::common::EffectEvent>,
pub(super) hurt: Vec<crate::common::Hurt>,
pub(super) knockback: Vec<crate::common::Knockback>,
pub(super) deaths: Vec<crate::common::Death>,
pub(super) entities: Vec<ghast_entity::Event>,
pub(super) entities_dropped: usize,
pub(super) item_use: Vec<crate::common::UseEvent>,
pub(super) cooldowns: Vec<crate::cooldown::CooldownEvent>,
pub(super) hud: Vec<crate::hud::HudEvent>,
pub(super) hud_dropped: usize,
pub(super) tabs: Vec<crate::hud::TabCompletion>,
pub(super) signs: Vec<crate::sign::SignEvent>,
pub(super) sleep: Vec<crate::common::SleepEvent>,
pub(super) fishing: Vec<crate::fishing::FishingEvent>,
}