mirror of
https://github.com/italicsjenga/valence.git
synced 2024-12-23 22:41:30 +11:00
Migrating the packets to wiki.vg (#62)
Addresses #56. Migrating all the packet names to wiki.vg's instead of fabric's.
This commit is contained in:
parent
0a75f103aa
commit
419d317736
|
@ -17,10 +17,10 @@ use valence::protocol::codec::Decoder;
|
||||||
use valence::protocol::packets::c2s::handshake::{Handshake, HandshakeNextState};
|
use valence::protocol::packets::c2s::handshake::{Handshake, HandshakeNextState};
|
||||||
use valence::protocol::packets::c2s::login::{EncryptionResponse, LoginStart};
|
use valence::protocol::packets::c2s::login::{EncryptionResponse, LoginStart};
|
||||||
use valence::protocol::packets::c2s::play::C2sPlayPacket;
|
use valence::protocol::packets::c2s::play::C2sPlayPacket;
|
||||||
use valence::protocol::packets::c2s::status::{QueryPing, QueryRequest};
|
use valence::protocol::packets::c2s::status::{PingRequest, StatusRequest};
|
||||||
use valence::protocol::packets::s2c::login::{LoginSuccess, S2cLoginPacket};
|
use valence::protocol::packets::s2c::login::{LoginSuccess, S2cLoginPacket};
|
||||||
use valence::protocol::packets::s2c::play::S2cPlayPacket;
|
use valence::protocol::packets::s2c::play::S2cPlayPacket;
|
||||||
use valence::protocol::packets::s2c::status::{QueryPong, QueryResponse};
|
use valence::protocol::packets::s2c::status::{PingResponse, StatusResponse};
|
||||||
use valence::protocol::packets::{DecodePacket, EncodePacket, PacketName};
|
use valence::protocol::packets::{DecodePacket, EncodePacket, PacketName};
|
||||||
use valence::protocol::{Encode, VarInt};
|
use valence::protocol::{Encode, VarInt};
|
||||||
|
|
||||||
|
@ -132,14 +132,14 @@ async fn handle_connection(client: TcpStream, cli: Cli) -> anyhow::Result<()> {
|
||||||
|
|
||||||
match handshake.next_state {
|
match handshake.next_state {
|
||||||
HandshakeNextState::Status => {
|
HandshakeNextState::Status => {
|
||||||
cli.rw_packet::<QueryRequest>(&mut client_read, &mut server_write)
|
cli.rw_packet::<StatusRequest>(&mut client_read, &mut server_write)
|
||||||
.await?;
|
.await?;
|
||||||
cli.rw_packet::<QueryResponse>(&mut server_read, &mut client_write)
|
cli.rw_packet::<StatusResponse>(&mut server_read, &mut client_write)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
cli.rw_packet::<QueryPing>(&mut client_read, &mut server_write)
|
cli.rw_packet::<PingRequest>(&mut client_read, &mut server_write)
|
||||||
.await?;
|
.await?;
|
||||||
cli.rw_packet::<QueryPong>(&mut server_read, &mut client_write)
|
cli.rw_packet::<PingResponse>(&mut server_read, &mut client_write)
|
||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
HandshakeNextState::Login => {
|
HandshakeNextState::Login => {
|
||||||
|
@ -161,7 +161,7 @@ async fn handle_connection(client: TcpStream, cli: Cli) -> anyhow::Result<()> {
|
||||||
s2c = passthrough(server_read.into_inner(), client_write) => s2c,
|
s2c = passthrough(server_read.into_inner(), client_write) => s2c,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
S2cLoginPacket::LoginCompression(pkt) => {
|
S2cLoginPacket::SetCompression(pkt) => {
|
||||||
let threshold = pkt.threshold.0 as u32;
|
let threshold = pkt.threshold.0 as u32;
|
||||||
client_read.enable_compression(threshold);
|
client_read.enable_compression(threshold);
|
||||||
server_read.enable_compression(threshold);
|
server_read.enable_compression(threshold);
|
||||||
|
@ -170,7 +170,7 @@ async fn handle_connection(client: TcpStream, cli: Cli) -> anyhow::Result<()> {
|
||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
S2cLoginPacket::LoginSuccess(_) => {}
|
S2cLoginPacket::LoginSuccess(_) => {}
|
||||||
S2cLoginPacket::LoginDisconnect(_) => return Ok(()),
|
S2cLoginPacket::DisconnectLogin(_) => return Ok(()),
|
||||||
S2cLoginPacket::LoginPluginRequest(_) => {
|
S2cLoginPacket::LoginPluginRequest(_) => {
|
||||||
bail!("got login plugin request. Don't know how to proceed.")
|
bail!("got login plugin request. Don't know how to proceed.")
|
||||||
}
|
}
|
||||||
|
|
10
src/chunk.rs
10
src/chunk.rs
|
@ -24,7 +24,7 @@ pub use crate::chunk_pos::ChunkPos;
|
||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
use crate::dimension::DimensionId;
|
use crate::dimension::DimensionId;
|
||||||
use crate::protocol::packets::s2c::play::{
|
use crate::protocol::packets::s2c::play::{
|
||||||
BlockUpdate, ChunkData, ChunkDataHeightmaps, ChunkSectionUpdate, S2cPlayPacket,
|
BlockUpdate, ChunkDataAndUpdateLight, ChunkDataHeightmaps, S2cPlayPacket, UpdateSectionBlocks,
|
||||||
};
|
};
|
||||||
use crate::protocol::{Encode, NbtBridge, VarInt, VarLong};
|
use crate::protocol::{Encode, NbtBridge, VarInt, VarLong};
|
||||||
use crate::server::SharedServer;
|
use crate::server::SharedServer;
|
||||||
|
@ -468,14 +468,14 @@ impl<C: Config> LoadedChunk<C> {
|
||||||
|
|
||||||
/// Gets the chunk data packet for this chunk with the given position. This
|
/// Gets the chunk data packet for this chunk with the given position. This
|
||||||
/// does not include unapplied changes.
|
/// does not include unapplied changes.
|
||||||
pub(crate) fn chunk_data_packet(&self, pos: ChunkPos) -> ChunkData {
|
pub(crate) fn chunk_data_packet(&self, pos: ChunkPos) -> ChunkDataAndUpdateLight {
|
||||||
let mut blocks_and_biomes = Vec::new();
|
let mut blocks_and_biomes = Vec::new();
|
||||||
|
|
||||||
for sect in self.sections.iter() {
|
for sect in self.sections.iter() {
|
||||||
blocks_and_biomes.extend_from_slice(§.compact_data);
|
blocks_and_biomes.extend_from_slice(§.compact_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
ChunkData {
|
ChunkDataAndUpdateLight {
|
||||||
chunk_x: pos.x,
|
chunk_x: pos.x,
|
||||||
chunk_z: pos.z,
|
chunk_z: pos.z,
|
||||||
heightmaps: NbtBridge(ChunkDataHeightmaps {
|
heightmaps: NbtBridge(ChunkDataHeightmaps {
|
||||||
|
@ -542,7 +542,7 @@ impl<C: Config> LoadedChunk<C> {
|
||||||
| (pos.z as i64 & 0x3fffff) << 20
|
| (pos.z as i64 & 0x3fffff) << 20
|
||||||
| (sect_y as i64 + min_y.div_euclid(16) as i64) & 0xfffff;
|
| (sect_y as i64 + min_y.div_euclid(16) as i64) & 0xfffff;
|
||||||
|
|
||||||
push_packet(BlockChangePacket::Multi(ChunkSectionUpdate {
|
push_packet(BlockChangePacket::Multi(UpdateSectionBlocks {
|
||||||
chunk_section_position,
|
chunk_section_position,
|
||||||
invert_trust_edges: false,
|
invert_trust_edges: false,
|
||||||
blocks,
|
blocks,
|
||||||
|
@ -655,7 +655,7 @@ impl<C: Config> Chunk for LoadedChunk<C> {
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub(crate) enum BlockChangePacket {
|
pub(crate) enum BlockChangePacket {
|
||||||
Single(BlockUpdate),
|
Single(BlockUpdate),
|
||||||
Multi(ChunkSectionUpdate),
|
Multi(UpdateSectionBlocks),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<BlockChangePacket> for S2cPlayPacket {
|
impl From<BlockChangePacket> for S2cPlayPacket {
|
||||||
|
|
189
src/client.rs
189
src/client.rs
|
@ -19,22 +19,23 @@ use crate::config::Config;
|
||||||
use crate::dimension::DimensionId;
|
use crate::dimension::DimensionId;
|
||||||
use crate::entity::data::Player;
|
use crate::entity::data::Player;
|
||||||
use crate::entity::{
|
use crate::entity::{
|
||||||
velocity_to_packet_units, Entities, EntityEvent, EntityId, EntityKind, StatusOrAnimation,
|
self, velocity_to_packet_units, Entities, EntityId, EntityKind, StatusOrAnimation,
|
||||||
};
|
};
|
||||||
use crate::ident::Ident;
|
use crate::ident::Ident;
|
||||||
use crate::player_list::{PlayerListId, PlayerLists};
|
use crate::player_list::{PlayerListId, PlayerLists};
|
||||||
use crate::player_textures::SignedPlayerTextures;
|
use crate::player_textures::SignedPlayerTextures;
|
||||||
use crate::protocol::packets::c2s::play::{self, C2sPlayPacket, InteractKind, PlayerCommandId};
|
use crate::protocol::packets::c2s::play::{self, C2sPlayPacket, InteractKind, PlayerCommandId};
|
||||||
pub use crate::protocol::packets::s2c::play::TitleFade;
|
pub use crate::protocol::packets::s2c::play::SetTitleAnimationTimes;
|
||||||
use crate::protocol::packets::s2c::play::{
|
use crate::protocol::packets::s2c::play::{
|
||||||
BiomeRegistry, ChatTypeRegistry, ChunkLoadDistance, ChunkRenderDistanceCenter, ClearTitles,
|
AcknowledgeBlockChange, BiomeRegistry, ChatTypeRegistry, ClearTitles, CustomSoundEffect,
|
||||||
DimensionTypeRegistry, DimensionTypeRegistryEntry, Disconnect, EntitiesDestroy,
|
DimensionTypeRegistry, DimensionTypeRegistryEntry, DisconnectPlay, EntityAnimationS2c,
|
||||||
EntityAnimation, EntityAttributes, EntityAttributesProperty, EntityPosition, EntitySetHeadYaw,
|
EntityAttributesProperty, EntityEvent, GameEvent, GameStateChangeReason, KeepAliveS2c,
|
||||||
EntityStatus, EntityTrackerUpdate, EntityVelocityUpdate, ExperienceBarUpdate, GameJoin,
|
LoginPlay, PlayerPositionLookFlags, RegistryCodec, RemoveEntities, Respawn, S2cPlayPacket,
|
||||||
GameMessage, GameStateChange, GameStateChangeReason, HealthUpdate, KeepAlive, MoveRelative,
|
SetActionBarText, SetCenterChunk, SetDefaultSpawnPosition, SetEntityMetadata,
|
||||||
OverlayMessage, PlaySoundId, PlayerActionResponse, PlayerPositionLook, PlayerPositionLookFlags,
|
SetEntityVelocity, SetExperience, SetHeadRotation, SetHealth, SetRenderDistance,
|
||||||
PlayerRespawn, PlayerSpawnPosition, RegistryCodec, Rotate, RotateAndMoveRelative,
|
SetSubtitleText, SetTitleText, SoundCategory, SynchronizePlayerPosition, SystemChatMessage,
|
||||||
S2cPlayPacket, SoundCategory, UnloadChunk, UpdateSubtitle, UpdateTitle,
|
TeleportEntity, UnloadChunk, UpdateAttributes, UpdateEntityPosition,
|
||||||
|
UpdateEntityPositionAndRotation, UpdateEntityRotation,
|
||||||
};
|
};
|
||||||
use crate::protocol::{BoundedInt, ByteAngle, NbtBridge, RawBytes, VarInt};
|
use crate::protocol::{BoundedInt, ByteAngle, NbtBridge, RawBytes, VarInt};
|
||||||
use crate::server::{C2sPacketChannels, NewClientData, S2cPlayMessage, SharedServer};
|
use crate::server::{C2sPacketChannels, NewClientData, S2cPlayMessage, SharedServer};
|
||||||
|
@ -229,7 +230,7 @@ pub struct Client<C: Config> {
|
||||||
bits: ClientBits,
|
bits: ClientBits,
|
||||||
/// The data for the client's own player entity.
|
/// The data for the client's own player entity.
|
||||||
player_data: Player,
|
player_data: Player,
|
||||||
entity_events: Vec<EntityEvent>,
|
entity_events: Vec<entity::EntityEvent>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[bitfield(u16)]
|
#[bitfield(u16)]
|
||||||
|
@ -468,7 +469,7 @@ impl<C: Config> Client<C> {
|
||||||
volume: f32,
|
volume: f32,
|
||||||
pitch: f32,
|
pitch: f32,
|
||||||
) {
|
) {
|
||||||
self.send_packet(PlaySoundId {
|
self.send_packet(CustomSoundEffect {
|
||||||
name,
|
name,
|
||||||
category,
|
category,
|
||||||
position: pos.iter().map(|x| *x as i32 * 8).collect(),
|
position: pos.iter().map(|x| *x as i32 * 8).collect(),
|
||||||
|
@ -488,15 +489,15 @@ impl<C: Config> Client<C> {
|
||||||
&mut self,
|
&mut self,
|
||||||
title: impl Into<Text>,
|
title: impl Into<Text>,
|
||||||
subtitle: impl Into<Text>,
|
subtitle: impl Into<Text>,
|
||||||
animation: impl Into<Option<TitleFade>>,
|
animation: impl Into<Option<SetTitleAnimationTimes>>,
|
||||||
) {
|
) {
|
||||||
let title = title.into();
|
let title = title.into();
|
||||||
let subtitle = subtitle.into();
|
let subtitle = subtitle.into();
|
||||||
|
|
||||||
self.send_packet(UpdateTitle { text: title });
|
self.send_packet(SetTitleText { text: title });
|
||||||
|
|
||||||
if !subtitle.is_empty() {
|
if !subtitle.is_empty() {
|
||||||
self.send_packet(UpdateSubtitle {
|
self.send_packet(SetSubtitleText {
|
||||||
subtitle_text: subtitle,
|
subtitle_text: subtitle,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -550,7 +551,7 @@ impl<C: Config> Client<C> {
|
||||||
/// * `level` - Number above the XP bar.
|
/// * `level` - Number above the XP bar.
|
||||||
/// * `total_xp` - TODO.
|
/// * `total_xp` - TODO.
|
||||||
pub fn set_level(&mut self, bar: f32, level: i32, total_xp: i32) {
|
pub fn set_level(&mut self, bar: f32, level: i32, total_xp: i32) {
|
||||||
self.send_packet(ExperienceBarUpdate {
|
self.send_packet(SetExperience {
|
||||||
bar,
|
bar,
|
||||||
level: level.into(),
|
level: level.into(),
|
||||||
total_xp: total_xp.into(),
|
total_xp: total_xp.into(),
|
||||||
|
@ -566,7 +567,7 @@ impl<C: Config> Client<C> {
|
||||||
/// * `food` - Integer in range `0..=20`.
|
/// * `food` - Integer in range `0..=20`.
|
||||||
/// * `food_saturation` - Float in range `0.0..=5.0`.
|
/// * `food_saturation` - Float in range `0.0..=5.0`.
|
||||||
pub fn set_health_and_food(&mut self, health: f32, food: i32, food_saturation: f32) {
|
pub fn set_health_and_food(&mut self, health: f32, food: i32, food_saturation: f32) {
|
||||||
self.send_packet(HealthUpdate {
|
self.send_packet(SetHealth {
|
||||||
health,
|
health,
|
||||||
food: food.into(),
|
food: food.into(),
|
||||||
food_saturation,
|
food_saturation,
|
||||||
|
@ -602,7 +603,7 @@ impl<C: Config> Client<C> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Pushes an entity event to the queue.
|
/// Pushes an entity event to the queue.
|
||||||
pub fn push_entity_event(&mut self, event: EntityEvent) {
|
pub fn push_entity_event(&mut self, event: entity::EntityEvent) {
|
||||||
self.entity_events.push(event);
|
self.entity_events.push(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -654,7 +655,7 @@ impl<C: Config> Client<C> {
|
||||||
let txt = reason.into();
|
let txt = reason.into();
|
||||||
log::info!("disconnecting client '{}': \"{txt}\"", self.username);
|
log::info!("disconnecting client '{}': \"{txt}\"", self.username);
|
||||||
|
|
||||||
self.send_packet(Disconnect { reason: txt });
|
self.send_packet(DisconnectPlay { reason: txt });
|
||||||
|
|
||||||
self.send = None;
|
self.send = None;
|
||||||
}
|
}
|
||||||
|
@ -696,7 +697,7 @@ impl<C: Config> Client<C> {
|
||||||
|
|
||||||
fn handle_serverbound_packet(&mut self, entities: &Entities<C>, pkt: C2sPlayPacket) {
|
fn handle_serverbound_packet(&mut self, entities: &Entities<C>, pkt: C2sPlayPacket) {
|
||||||
match pkt {
|
match pkt {
|
||||||
C2sPlayPacket::TeleportConfirm(p) => {
|
C2sPlayPacket::ConfirmTeleport(p) => {
|
||||||
if self.pending_teleports == 0 {
|
if self.pending_teleports == 0 {
|
||||||
log::warn!("unexpected teleport confirmation from {}", self.username());
|
log::warn!("unexpected teleport confirmation from {}", self.username());
|
||||||
self.disconnect_no_reason();
|
self.disconnect_no_reason();
|
||||||
|
@ -718,17 +719,17 @@ impl<C: Config> Client<C> {
|
||||||
self.disconnect_no_reason();
|
self.disconnect_no_reason();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
C2sPlayPacket::QueryBlockNbt(_) => {}
|
C2sPlayPacket::QueryBlockEntityTag(_) => {}
|
||||||
C2sPlayPacket::UpdateDifficulty(_) => {}
|
C2sPlayPacket::ChangeDifficulty(_) => {}
|
||||||
C2sPlayPacket::MessageAcknowledgment(_) => {}
|
C2sPlayPacket::MessageAcknowledgment(_) => {}
|
||||||
C2sPlayPacket::CommandExecution(_) => {}
|
C2sPlayPacket::ChatCommand(_) => {}
|
||||||
C2sPlayPacket::ChatMessage(p) => self.events.push_back(ClientEvent::ChatMessage {
|
C2sPlayPacket::ChatMessage(p) => self.events.push_back(ClientEvent::ChatMessage {
|
||||||
message: p.message.0,
|
message: p.message.0,
|
||||||
timestamp: Duration::from_millis(p.timestamp),
|
timestamp: Duration::from_millis(p.timestamp),
|
||||||
}),
|
}),
|
||||||
C2sPlayPacket::RequestChatPreview(_) => {}
|
C2sPlayPacket::ChatPreviewC2s(_) => {}
|
||||||
C2sPlayPacket::ClientStatus(_) => {}
|
C2sPlayPacket::ClientCommand(_) => {}
|
||||||
C2sPlayPacket::ClientSettings(p) => {
|
C2sPlayPacket::ClientInformation(p) => {
|
||||||
self.events.push_back(ClientEvent::SettingsChanged {
|
self.events.push_back(ClientEvent::SettingsChanged {
|
||||||
locale: p.locale.0,
|
locale: p.locale.0,
|
||||||
view_distance: p.view_distance.0,
|
view_distance: p.view_distance.0,
|
||||||
|
@ -739,14 +740,14 @@ impl<C: Config> Client<C> {
|
||||||
allow_server_listings: p.allow_server_listings,
|
allow_server_listings: p.allow_server_listings,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
C2sPlayPacket::RequestCommandCompletion(_) => {}
|
C2sPlayPacket::CommandSuggestionsRequest(_) => {}
|
||||||
C2sPlayPacket::ClickContainerButton(_) => {}
|
C2sPlayPacket::ClickContainerButton(_) => {}
|
||||||
C2sPlayPacket::ClickContainer(_) => {}
|
C2sPlayPacket::ClickContainer(_) => {}
|
||||||
C2sPlayPacket::CloseHandledScreen(_) => {}
|
C2sPlayPacket::CloseContainerC2s(_) => {}
|
||||||
C2sPlayPacket::CustomPayload(_) => {}
|
C2sPlayPacket::PluginMessageC2s(_) => {}
|
||||||
C2sPlayPacket::BookUpdate(_) => {}
|
C2sPlayPacket::EditBook(_) => {}
|
||||||
C2sPlayPacket::QueryEntityNbt(_) => {}
|
C2sPlayPacket::QueryEntityTag(_) => {}
|
||||||
C2sPlayPacket::PlayerInteractEntity(p) => {
|
C2sPlayPacket::Interact(p) => {
|
||||||
if let Some(id) = entities.get_with_network_id(p.entity_id.0) {
|
if let Some(id) = entities.get_with_network_id(p.entity_id.0) {
|
||||||
self.events.push_back(ClientEvent::InteractWithEntity {
|
self.events.push_back(ClientEvent::InteractWithEntity {
|
||||||
id,
|
id,
|
||||||
|
@ -762,7 +763,7 @@ impl<C: Config> Client<C> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
C2sPlayPacket::JigsawGenerate(_) => {}
|
C2sPlayPacket::JigsawGenerate(_) => {}
|
||||||
C2sPlayPacket::KeepAlive(p) => {
|
C2sPlayPacket::KeepAliveC2s(p) => {
|
||||||
let last_keepalive_id = self.last_keepalive_id;
|
let last_keepalive_id = self.last_keepalive_id;
|
||||||
if self.bits.got_keepalive() {
|
if self.bits.got_keepalive() {
|
||||||
log::warn!("unexpected keepalive from player {}", self.username());
|
log::warn!("unexpected keepalive from player {}", self.username());
|
||||||
|
@ -779,8 +780,8 @@ impl<C: Config> Client<C> {
|
||||||
self.bits.set_got_keepalive(true);
|
self.bits.set_got_keepalive(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
C2sPlayPacket::UpdateDifficultyLock(_) => {}
|
C2sPlayPacket::LockDifficulty(_) => {}
|
||||||
C2sPlayPacket::MovePlayerPosition(p) => {
|
C2sPlayPacket::SetPlayerPosition(p) => {
|
||||||
if self.pending_teleports == 0 {
|
if self.pending_teleports == 0 {
|
||||||
self.position = p.position;
|
self.position = p.position;
|
||||||
|
|
||||||
|
@ -790,7 +791,7 @@ impl<C: Config> Client<C> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
C2sPlayPacket::MovePlayerPositionAndRotation(p) => {
|
C2sPlayPacket::SetPlayerPositionAndRotation(p) => {
|
||||||
if self.pending_teleports == 0 {
|
if self.pending_teleports == 0 {
|
||||||
self.position = p.position;
|
self.position = p.position;
|
||||||
self.yaw = p.yaw;
|
self.yaw = p.yaw;
|
||||||
|
@ -804,7 +805,7 @@ impl<C: Config> Client<C> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
C2sPlayPacket::MovePlayerRotation(p) => {
|
C2sPlayPacket::SetPlayerRotation(p) => {
|
||||||
if self.pending_teleports == 0 {
|
if self.pending_teleports == 0 {
|
||||||
self.yaw = p.yaw;
|
self.yaw = p.yaw;
|
||||||
self.pitch = p.pitch;
|
self.pitch = p.pitch;
|
||||||
|
@ -816,14 +817,14 @@ impl<C: Config> Client<C> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
C2sPlayPacket::MovePlayerOnGround(p) => {
|
C2sPlayPacket::SetPlayerOnGround(p) => {
|
||||||
if self.pending_teleports == 0 {
|
if self.pending_teleports == 0 {
|
||||||
self.events.push_back(ClientEvent::MoveOnGround {
|
self.events.push_back(ClientEvent::MoveOnGround {
|
||||||
on_ground: p.on_ground,
|
on_ground: p.on_ground,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
C2sPlayPacket::MoveVehicle(p) => {
|
C2sPlayPacket::MoveVehicleC2s(p) => {
|
||||||
if self.pending_teleports == 0 {
|
if self.pending_teleports == 0 {
|
||||||
self.position = p.position;
|
self.position = p.position;
|
||||||
self.yaw = p.yaw;
|
self.yaw = p.yaw;
|
||||||
|
@ -836,15 +837,15 @@ impl<C: Config> Client<C> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
C2sPlayPacket::BoatPaddleState(p) => {
|
C2sPlayPacket::PaddleBoat(p) => {
|
||||||
self.events.push_back(ClientEvent::SteerBoat {
|
self.events.push_back(ClientEvent::SteerBoat {
|
||||||
left_paddle_turning: p.left_paddle_turning,
|
left_paddle_turning: p.left_paddle_turning,
|
||||||
right_paddle_turning: p.right_paddle_turning,
|
right_paddle_turning: p.right_paddle_turning,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
C2sPlayPacket::PickFromInventory(_) => {}
|
C2sPlayPacket::PickItem(_) => {}
|
||||||
C2sPlayPacket::CraftRequest(_) => {}
|
C2sPlayPacket::PlaceRecipe(_) => {}
|
||||||
C2sPlayPacket::UpdatePlayerAbilities(_) => {}
|
C2sPlayPacket::PlayerAbilitiesC2s(_) => {}
|
||||||
C2sPlayPacket::PlayerAction(p) => {
|
C2sPlayPacket::PlayerAction(p) => {
|
||||||
if p.sequence.0 != 0 {
|
if p.sequence.0 != 0 {
|
||||||
self.dug_blocks.push(p.sequence.0);
|
self.dug_blocks.push(p.sequence.0);
|
||||||
|
@ -888,34 +889,32 @@ impl<C: Config> Client<C> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
C2sPlayPacket::PlayerInput(_) => {}
|
C2sPlayPacket::PlayerInput(_) => {}
|
||||||
C2sPlayPacket::PlayPong(_) => {}
|
C2sPlayPacket::PongPlay(_) => {}
|
||||||
C2sPlayPacket::RecipeBookChangeSettings(_) => {}
|
C2sPlayPacket::ChangeRecipeBookSettings(_) => {}
|
||||||
C2sPlayPacket::RecipeBookSeenRecipe(_) => {}
|
C2sPlayPacket::SetSeenRecipe(_) => {}
|
||||||
C2sPlayPacket::RenameItem(_) => {}
|
C2sPlayPacket::RenameItem(_) => {}
|
||||||
C2sPlayPacket::ResourcePackStatus(_) => {}
|
C2sPlayPacket::ResourcePackC2s(_) => {}
|
||||||
C2sPlayPacket::AdvancementTab(_) => {}
|
C2sPlayPacket::SeenAdvancements(_) => {}
|
||||||
C2sPlayPacket::SelectMerchantTrade(_) => {}
|
C2sPlayPacket::SelectTrade(_) => {}
|
||||||
C2sPlayPacket::UpdateBeacon(_) => {}
|
C2sPlayPacket::SetBeaconEffect(_) => {}
|
||||||
C2sPlayPacket::UpdateSelectedSlot(_) => {}
|
C2sPlayPacket::SetHeldItemS2c(_) => {}
|
||||||
C2sPlayPacket::UpdateCommandBlock(_) => {}
|
C2sPlayPacket::ProgramCommandBlock(_) => {}
|
||||||
C2sPlayPacket::UpdateCommandBlockMinecart(_) => {}
|
C2sPlayPacket::ProgramCommandBlockMinecart(_) => {}
|
||||||
C2sPlayPacket::UpdateCreativeModeSlot(_) => {}
|
C2sPlayPacket::SetCreativeModeSlot(_) => {}
|
||||||
C2sPlayPacket::UpdateJigsaw(_) => {}
|
C2sPlayPacket::ProgramJigsawBlock(_) => {}
|
||||||
C2sPlayPacket::UpdateStructureBlock(_) => {}
|
C2sPlayPacket::ProgramStructureBlock(_) => {}
|
||||||
C2sPlayPacket::UpdateSign(_) => {}
|
C2sPlayPacket::UpdateSign(_) => {}
|
||||||
C2sPlayPacket::HandSwing(p) => self.events.push_back(ClientEvent::ArmSwing(p.hand)),
|
C2sPlayPacket::SwingArm(p) => self.events.push_back(ClientEvent::ArmSwing(p.hand)),
|
||||||
C2sPlayPacket::SpectatorTeleport(_) => {}
|
C2sPlayPacket::TeleportToEntity(_) => {}
|
||||||
C2sPlayPacket::PlayerInteractBlock(p) => {
|
C2sPlayPacket::UseItemOn(p) => self.events.push_back(ClientEvent::InteractWithBlock {
|
||||||
self.events.push_back(ClientEvent::InteractWithBlock {
|
hand: p.hand,
|
||||||
hand: p.hand,
|
location: p.location,
|
||||||
location: p.location,
|
face: p.face,
|
||||||
face: p.face,
|
cursor_pos: p.cursor_pos,
|
||||||
cursor_pos: p.cursor_pos,
|
head_inside_block: p.head_inside_block,
|
||||||
head_inside_block: p.head_inside_block,
|
sequence: p.sequence,
|
||||||
sequence: p.sequence,
|
}),
|
||||||
})
|
C2sPlayPacket::UseItem(_) => {}
|
||||||
}
|
|
||||||
C2sPlayPacket::PlayerInteractItem(_) => {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -965,7 +964,7 @@ impl<C: Config> Client<C> {
|
||||||
|
|
||||||
dimension_names.push(ident!("{LIBRARY_NAMESPACE}:dummy_dimension"));
|
dimension_names.push(ident!("{LIBRARY_NAMESPACE}:dummy_dimension"));
|
||||||
|
|
||||||
self.send_packet(GameJoin {
|
self.send_packet(LoginPlay {
|
||||||
entity_id: 0, // EntityId 0 is reserved for clients.
|
entity_id: 0, // EntityId 0 is reserved for clients.
|
||||||
is_hardcore: self.bits.hardcore(),
|
is_hardcore: self.bits.hardcore(),
|
||||||
gamemode: self.new_game_mode,
|
gamemode: self.new_game_mode,
|
||||||
|
@ -1002,7 +1001,7 @@ impl<C: Config> Client<C> {
|
||||||
|
|
||||||
// Client bug workaround: send the client to a dummy dimension first.
|
// Client bug workaround: send the client to a dummy dimension first.
|
||||||
// TODO: is there actually a bug?
|
// TODO: is there actually a bug?
|
||||||
self.send_packet(PlayerRespawn {
|
self.send_packet(Respawn {
|
||||||
dimension_type_name: ident!("{LIBRARY_NAMESPACE}:dimension_type_0"),
|
dimension_type_name: ident!("{LIBRARY_NAMESPACE}:dimension_type_0"),
|
||||||
dimension_name: ident!("{LIBRARY_NAMESPACE}:dummy_dimension"),
|
dimension_name: ident!("{LIBRARY_NAMESPACE}:dummy_dimension"),
|
||||||
hashed_seed: 0,
|
hashed_seed: 0,
|
||||||
|
@ -1014,7 +1013,7 @@ impl<C: Config> Client<C> {
|
||||||
last_death_location: None,
|
last_death_location: None,
|
||||||
});
|
});
|
||||||
|
|
||||||
self.send_packet(PlayerRespawn {
|
self.send_packet(Respawn {
|
||||||
dimension_type_name: ident!(
|
dimension_type_name: ident!(
|
||||||
"{LIBRARY_NAMESPACE}:dimension_type_{}",
|
"{LIBRARY_NAMESPACE}:dimension_type_{}",
|
||||||
world.meta.dimension().0
|
world.meta.dimension().0
|
||||||
|
@ -1040,7 +1039,7 @@ impl<C: Config> Client<C> {
|
||||||
// Update game mode
|
// Update game mode
|
||||||
if self.old_game_mode != self.new_game_mode {
|
if self.old_game_mode != self.new_game_mode {
|
||||||
self.old_game_mode = self.new_game_mode;
|
self.old_game_mode = self.new_game_mode;
|
||||||
self.send_packet(GameStateChange {
|
self.send_packet(GameEvent {
|
||||||
reason: GameStateChangeReason::ChangeGameMode,
|
reason: GameStateChangeReason::ChangeGameMode,
|
||||||
value: self.new_game_mode as i32 as f32,
|
value: self.new_game_mode as i32 as f32,
|
||||||
});
|
});
|
||||||
|
@ -1075,7 +1074,7 @@ impl<C: Config> Client<C> {
|
||||||
if self.bits.attack_speed_modified() {
|
if self.bits.attack_speed_modified() {
|
||||||
self.bits.set_attack_speed_modified(false);
|
self.bits.set_attack_speed_modified(false);
|
||||||
|
|
||||||
self.send_packet(EntityAttributes {
|
self.send_packet(UpdateAttributes {
|
||||||
entity_id: VarInt(0),
|
entity_id: VarInt(0),
|
||||||
properties: vec![EntityAttributesProperty {
|
properties: vec![EntityAttributesProperty {
|
||||||
key: ident!("generic.attack_speed"),
|
key: ident!("generic.attack_speed"),
|
||||||
|
@ -1088,7 +1087,7 @@ impl<C: Config> Client<C> {
|
||||||
if self.bits.movement_speed_modified() {
|
if self.bits.movement_speed_modified() {
|
||||||
self.bits.set_movement_speed_modified(false);
|
self.bits.set_movement_speed_modified(false);
|
||||||
|
|
||||||
self.send_packet(EntityAttributes {
|
self.send_packet(UpdateAttributes {
|
||||||
entity_id: VarInt(0),
|
entity_id: VarInt(0),
|
||||||
properties: vec![EntityAttributesProperty {
|
properties: vec![EntityAttributesProperty {
|
||||||
key: ident!("generic.movement_speed"),
|
key: ident!("generic.movement_speed"),
|
||||||
|
@ -1102,7 +1101,7 @@ impl<C: Config> Client<C> {
|
||||||
if self.bits.modified_spawn_position() {
|
if self.bits.modified_spawn_position() {
|
||||||
self.bits.set_modified_spawn_position(false);
|
self.bits.set_modified_spawn_position(false);
|
||||||
|
|
||||||
self.send_packet(PlayerSpawnPosition {
|
self.send_packet(SetDefaultSpawnPosition {
|
||||||
location: self.spawn_position,
|
location: self.spawn_position,
|
||||||
angle: self.spawn_position_yaw,
|
angle: self.spawn_position_yaw,
|
||||||
})
|
})
|
||||||
|
@ -1113,7 +1112,7 @@ impl<C: Config> Client<C> {
|
||||||
self.bits.set_view_distance_modified(false);
|
self.bits.set_view_distance_modified(false);
|
||||||
|
|
||||||
if !self.created_this_tick() {
|
if !self.created_this_tick() {
|
||||||
self.send_packet(ChunkLoadDistance {
|
self.send_packet(SetRenderDistance {
|
||||||
view_distance: BoundedInt(VarInt(self.view_distance() as i32)),
|
view_distance: BoundedInt(VarInt(self.view_distance() as i32)),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1123,7 +1122,7 @@ impl<C: Config> Client<C> {
|
||||||
if current_tick % (shared.tick_rate() * 8) == 0 {
|
if current_tick % (shared.tick_rate() * 8) == 0 {
|
||||||
if self.bits.got_keepalive() {
|
if self.bits.got_keepalive() {
|
||||||
let id = rand::random();
|
let id = rand::random();
|
||||||
self.send_packet(KeepAlive { id });
|
self.send_packet(KeepAliveS2c { id });
|
||||||
self.last_keepalive_id = id;
|
self.last_keepalive_id = id;
|
||||||
self.bits.set_got_keepalive(false);
|
self.bits.set_got_keepalive(false);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1144,7 +1143,7 @@ impl<C: Config> Client<C> {
|
||||||
let new_section = self.position.map(|n| (n / 16.0).floor() as i32);
|
let new_section = self.position.map(|n| (n / 16.0).floor() as i32);
|
||||||
|
|
||||||
if old_section != new_section {
|
if old_section != new_section {
|
||||||
self.send_packet(ChunkRenderDistanceCenter {
|
self.send_packet(SetCenterChunk {
|
||||||
chunk_x: VarInt(new_section.x),
|
chunk_x: VarInt(new_section.x),
|
||||||
chunk_z: VarInt(new_section.z),
|
chunk_z: VarInt(new_section.z),
|
||||||
})
|
})
|
||||||
|
@ -1195,7 +1194,7 @@ impl<C: Config> Client<C> {
|
||||||
for seq in self.dug_blocks.drain(..) {
|
for seq in self.dug_blocks.drain(..) {
|
||||||
send_packet(
|
send_packet(
|
||||||
&mut self.send,
|
&mut self.send,
|
||||||
PlayerActionResponse {
|
AcknowledgeBlockChange {
|
||||||
sequence: VarInt(seq),
|
sequence: VarInt(seq),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@ -1208,7 +1207,7 @@ impl<C: Config> Client<C> {
|
||||||
if self.bits.teleported_this_tick() {
|
if self.bits.teleported_this_tick() {
|
||||||
self.bits.set_teleported_this_tick(false);
|
self.bits.set_teleported_this_tick(false);
|
||||||
|
|
||||||
self.send_packet(PlayerPositionLook {
|
self.send_packet(SynchronizePlayerPosition {
|
||||||
position: self.position,
|
position: self.position,
|
||||||
yaw: self.yaw,
|
yaw: self.yaw,
|
||||||
pitch: self.pitch,
|
pitch: self.pitch,
|
||||||
|
@ -1233,7 +1232,7 @@ impl<C: Config> Client<C> {
|
||||||
if self.bits.velocity_modified() {
|
if self.bits.velocity_modified() {
|
||||||
self.bits.set_velocity_modified(false);
|
self.bits.set_velocity_modified(false);
|
||||||
|
|
||||||
self.send_packet(EntityVelocityUpdate {
|
self.send_packet(SetEntityVelocity {
|
||||||
entity_id: VarInt(0),
|
entity_id: VarInt(0),
|
||||||
velocity: velocity_to_packet_units(self.velocity),
|
velocity: velocity_to_packet_units(self.velocity),
|
||||||
});
|
});
|
||||||
|
@ -1243,7 +1242,7 @@ impl<C: Config> Client<C> {
|
||||||
for msg in self.msgs_to_send.drain(..) {
|
for msg in self.msgs_to_send.drain(..) {
|
||||||
send_packet(
|
send_packet(
|
||||||
&mut self.send,
|
&mut self.send,
|
||||||
GameMessage {
|
SystemChatMessage {
|
||||||
chat: msg,
|
chat: msg,
|
||||||
kind: VarInt(0),
|
kind: VarInt(0),
|
||||||
},
|
},
|
||||||
|
@ -1251,7 +1250,7 @@ impl<C: Config> Client<C> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(bar) = self.bar_to_send.take() {
|
if let Some(bar) = self.bar_to_send.take() {
|
||||||
send_packet(&mut self.send, OverlayMessage { text: bar });
|
send_packet(&mut self.send, SetActionBarText { text: bar });
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut entities_to_unload = Vec::new();
|
let mut entities_to_unload = Vec::new();
|
||||||
|
@ -1276,7 +1275,7 @@ impl<C: Config> Client<C> {
|
||||||
{
|
{
|
||||||
send_packet(
|
send_packet(
|
||||||
&mut self.send,
|
&mut self.send,
|
||||||
RotateAndMoveRelative {
|
UpdateEntityPositionAndRotation {
|
||||||
entity_id: VarInt(id.to_network_id()),
|
entity_id: VarInt(id.to_network_id()),
|
||||||
delta: (position_delta * 4096.0).as_(),
|
delta: (position_delta * 4096.0).as_(),
|
||||||
yaw: ByteAngle::from_degrees(entity.yaw()),
|
yaw: ByteAngle::from_degrees(entity.yaw()),
|
||||||
|
@ -1288,7 +1287,7 @@ impl<C: Config> Client<C> {
|
||||||
if entity.position() != entity.old_position() && !needs_teleport {
|
if entity.position() != entity.old_position() && !needs_teleport {
|
||||||
send_packet(
|
send_packet(
|
||||||
&mut self.send,
|
&mut self.send,
|
||||||
MoveRelative {
|
UpdateEntityPosition {
|
||||||
entity_id: VarInt(id.to_network_id()),
|
entity_id: VarInt(id.to_network_id()),
|
||||||
delta: (position_delta * 4096.0).as_(),
|
delta: (position_delta * 4096.0).as_(),
|
||||||
on_ground: entity.on_ground(),
|
on_ground: entity.on_ground(),
|
||||||
|
@ -1299,7 +1298,7 @@ impl<C: Config> Client<C> {
|
||||||
if flags.yaw_or_pitch_modified() {
|
if flags.yaw_or_pitch_modified() {
|
||||||
send_packet(
|
send_packet(
|
||||||
&mut self.send,
|
&mut self.send,
|
||||||
Rotate {
|
UpdateEntityRotation {
|
||||||
entity_id: VarInt(id.to_network_id()),
|
entity_id: VarInt(id.to_network_id()),
|
||||||
yaw: ByteAngle::from_degrees(entity.yaw()),
|
yaw: ByteAngle::from_degrees(entity.yaw()),
|
||||||
pitch: ByteAngle::from_degrees(entity.pitch()),
|
pitch: ByteAngle::from_degrees(entity.pitch()),
|
||||||
|
@ -1312,7 +1311,7 @@ impl<C: Config> Client<C> {
|
||||||
if needs_teleport {
|
if needs_teleport {
|
||||||
send_packet(
|
send_packet(
|
||||||
&mut self.send,
|
&mut self.send,
|
||||||
EntityPosition {
|
TeleportEntity {
|
||||||
entity_id: VarInt(id.to_network_id()),
|
entity_id: VarInt(id.to_network_id()),
|
||||||
position: entity.position(),
|
position: entity.position(),
|
||||||
yaw: ByteAngle::from_degrees(entity.yaw()),
|
yaw: ByteAngle::from_degrees(entity.yaw()),
|
||||||
|
@ -1325,7 +1324,7 @@ impl<C: Config> Client<C> {
|
||||||
if flags.velocity_modified() {
|
if flags.velocity_modified() {
|
||||||
send_packet(
|
send_packet(
|
||||||
&mut self.send,
|
&mut self.send,
|
||||||
EntityVelocityUpdate {
|
SetEntityVelocity {
|
||||||
entity_id: VarInt(id.to_network_id()),
|
entity_id: VarInt(id.to_network_id()),
|
||||||
velocity: velocity_to_packet_units(entity.velocity()),
|
velocity: velocity_to_packet_units(entity.velocity()),
|
||||||
},
|
},
|
||||||
|
@ -1335,7 +1334,7 @@ impl<C: Config> Client<C> {
|
||||||
if flags.head_yaw_modified() {
|
if flags.head_yaw_modified() {
|
||||||
send_packet(
|
send_packet(
|
||||||
&mut self.send,
|
&mut self.send,
|
||||||
EntitySetHeadYaw {
|
SetHeadRotation {
|
||||||
entity_id: VarInt(id.to_network_id()),
|
entity_id: VarInt(id.to_network_id()),
|
||||||
head_yaw: ByteAngle::from_degrees(entity.head_yaw()),
|
head_yaw: ByteAngle::from_degrees(entity.head_yaw()),
|
||||||
},
|
},
|
||||||
|
@ -1353,7 +1352,7 @@ impl<C: Config> Client<C> {
|
||||||
});
|
});
|
||||||
|
|
||||||
if !entities_to_unload.is_empty() {
|
if !entities_to_unload.is_empty() {
|
||||||
self.send_packet(EntitiesDestroy {
|
self.send_packet(RemoveEntities {
|
||||||
entities: entities_to_unload,
|
entities: entities_to_unload,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1365,7 +1364,7 @@ impl<C: Config> Client<C> {
|
||||||
if !data.is_empty() {
|
if !data.is_empty() {
|
||||||
data.push(0xff);
|
data.push(0xff);
|
||||||
|
|
||||||
self.send_packet(EntityTrackerUpdate {
|
self.send_packet(SetEntityMetadata {
|
||||||
entity_id: VarInt(0),
|
entity_id: VarInt(0),
|
||||||
metadata: RawBytes(data),
|
metadata: RawBytes(data),
|
||||||
});
|
});
|
||||||
|
@ -1428,19 +1427,19 @@ fn send_packet(send_opt: &mut SendOpt, pkt: impl Into<S2cPlayMessage>) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn send_entity_events(send_opt: &mut SendOpt, entity_id: i32, events: &[EntityEvent]) {
|
fn send_entity_events(send_opt: &mut SendOpt, entity_id: i32, events: &[entity::EntityEvent]) {
|
||||||
for &event in events {
|
for &event in events {
|
||||||
match event.status_or_animation() {
|
match event.status_or_animation() {
|
||||||
StatusOrAnimation::Status(code) => send_packet(
|
StatusOrAnimation::Status(code) => send_packet(
|
||||||
send_opt,
|
send_opt,
|
||||||
EntityStatus {
|
EntityEvent {
|
||||||
entity_id,
|
entity_id,
|
||||||
entity_status: code,
|
entity_status: code,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
StatusOrAnimation::Animation(code) => send_packet(
|
StatusOrAnimation::Animation(code) => send_packet(
|
||||||
send_opt,
|
send_opt,
|
||||||
EntityAnimation {
|
EntityAnimationS2c {
|
||||||
entity_id: VarInt(entity_id),
|
entity_id: VarInt(entity_id),
|
||||||
animation: code,
|
animation: code,
|
||||||
},
|
},
|
||||||
|
|
|
@ -13,7 +13,7 @@ use vek::{Aabb, Vec3};
|
||||||
|
|
||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
use crate::protocol::packets::s2c::play::{
|
use crate::protocol::packets::s2c::play::{
|
||||||
EntitySpawn, EntityTrackerUpdate, ExperienceOrbSpawn, PlayerSpawn, S2cPlayPacket,
|
S2cPlayPacket, SetEntityMetadata, SpawnEntity, SpawnExperienceOrb, SpawnPlayer,
|
||||||
};
|
};
|
||||||
use crate::protocol::{ByteAngle, RawBytes, VarInt};
|
use crate::protocol::{ByteAngle, RawBytes, VarInt};
|
||||||
use crate::slab_versioned::{Key, VersionedSlab};
|
use crate::slab_versioned::{Key, VersionedSlab};
|
||||||
|
@ -571,10 +571,10 @@ impl<C: Config> Entity<C> {
|
||||||
pub(crate) fn initial_tracked_data_packet(
|
pub(crate) fn initial_tracked_data_packet(
|
||||||
&self,
|
&self,
|
||||||
this_id: EntityId,
|
this_id: EntityId,
|
||||||
) -> Option<EntityTrackerUpdate> {
|
) -> Option<SetEntityMetadata> {
|
||||||
self.variants
|
self.variants
|
||||||
.initial_tracked_data()
|
.initial_tracked_data()
|
||||||
.map(|meta| EntityTrackerUpdate {
|
.map(|meta| SetEntityMetadata {
|
||||||
entity_id: VarInt(this_id.to_network_id()),
|
entity_id: VarInt(this_id.to_network_id()),
|
||||||
metadata: RawBytes(meta),
|
metadata: RawBytes(meta),
|
||||||
})
|
})
|
||||||
|
@ -587,10 +587,10 @@ impl<C: Config> Entity<C> {
|
||||||
pub(crate) fn updated_tracked_data_packet(
|
pub(crate) fn updated_tracked_data_packet(
|
||||||
&self,
|
&self,
|
||||||
this_id: EntityId,
|
this_id: EntityId,
|
||||||
) -> Option<EntityTrackerUpdate> {
|
) -> Option<SetEntityMetadata> {
|
||||||
self.variants
|
self.variants
|
||||||
.updated_tracked_data()
|
.updated_tracked_data()
|
||||||
.map(|meta| EntityTrackerUpdate {
|
.map(|meta| SetEntityMetadata {
|
||||||
entity_id: VarInt(this_id.to_network_id()),
|
entity_id: VarInt(this_id.to_network_id()),
|
||||||
metadata: RawBytes(meta),
|
metadata: RawBytes(meta),
|
||||||
})
|
})
|
||||||
|
@ -600,20 +600,20 @@ impl<C: Config> Entity<C> {
|
||||||
match &self.variants {
|
match &self.variants {
|
||||||
TrackedData::Marker(_) => None,
|
TrackedData::Marker(_) => None,
|
||||||
TrackedData::ExperienceOrb(_) => {
|
TrackedData::ExperienceOrb(_) => {
|
||||||
Some(EntitySpawnPacket::ExperienceOrb(ExperienceOrbSpawn {
|
Some(EntitySpawnPacket::ExperienceOrb(SpawnExperienceOrb {
|
||||||
entity_id: VarInt(this_id.to_network_id()),
|
entity_id: VarInt(this_id.to_network_id()),
|
||||||
position: self.new_position,
|
position: self.new_position,
|
||||||
count: 0, // TODO
|
count: 0, // TODO
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
TrackedData::Player(_) => Some(EntitySpawnPacket::Player(PlayerSpawn {
|
TrackedData::Player(_) => Some(EntitySpawnPacket::Player(SpawnPlayer {
|
||||||
entity_id: VarInt(this_id.to_network_id()),
|
entity_id: VarInt(this_id.to_network_id()),
|
||||||
player_uuid: self.uuid,
|
player_uuid: self.uuid,
|
||||||
position: self.new_position,
|
position: self.new_position,
|
||||||
yaw: ByteAngle::from_degrees(self.yaw),
|
yaw: ByteAngle::from_degrees(self.yaw),
|
||||||
pitch: ByteAngle::from_degrees(self.pitch),
|
pitch: ByteAngle::from_degrees(self.pitch),
|
||||||
})),
|
})),
|
||||||
_ => Some(EntitySpawnPacket::Entity(EntitySpawn {
|
_ => Some(EntitySpawnPacket::Entity(SpawnEntity {
|
||||||
entity_id: VarInt(this_id.to_network_id()),
|
entity_id: VarInt(this_id.to_network_id()),
|
||||||
object_uuid: self.uuid,
|
object_uuid: self.uuid,
|
||||||
kind: VarInt(self.kind() as i32),
|
kind: VarInt(self.kind() as i32),
|
||||||
|
@ -634,9 +634,9 @@ pub(crate) fn velocity_to_packet_units(vel: Vec3<f32>) -> Vec3<i16> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) enum EntitySpawnPacket {
|
pub(crate) enum EntitySpawnPacket {
|
||||||
Entity(EntitySpawn),
|
Entity(SpawnEntity),
|
||||||
ExperienceOrb(ExperienceOrbSpawn),
|
ExperienceOrb(SpawnExperienceOrb),
|
||||||
Player(PlayerSpawn),
|
Player(SpawnPlayer),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<EntitySpawnPacket> for S2cPlayPacket {
|
impl From<EntitySpawnPacket> for S2cPlayPacket {
|
||||||
|
|
|
@ -10,7 +10,7 @@ use crate::client::GameMode;
|
||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
use crate::player_textures::SignedPlayerTextures;
|
use crate::player_textures::SignedPlayerTextures;
|
||||||
use crate::protocol::packets::s2c::play::{
|
use crate::protocol::packets::s2c::play::{
|
||||||
PlayerListAddPlayer, PlayerListHeaderFooter, S2cPlayPacket, UpdatePlayerList,
|
PlayerInfo, PlayerListAddPlayer, S2cPlayPacket, SetTabListHeaderAndFooter,
|
||||||
};
|
};
|
||||||
use crate::protocol::packets::Property;
|
use crate::protocol::packets::Property;
|
||||||
use crate::protocol::VarInt;
|
use crate::protocol::VarInt;
|
||||||
|
@ -258,12 +258,12 @@ impl<C: Config> PlayerList<C> {
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
if !add_player.is_empty() {
|
if !add_player.is_empty() {
|
||||||
push_packet(UpdatePlayerList::AddPlayer(add_player).into());
|
push_packet(PlayerInfo::AddPlayer(add_player).into());
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.header != Text::default() || self.footer != Text::default() {
|
if self.header != Text::default() || self.footer != Text::default() {
|
||||||
push_packet(
|
push_packet(
|
||||||
PlayerListHeaderFooter {
|
SetTabListHeaderAndFooter {
|
||||||
header: self.header.clone(),
|
header: self.header.clone(),
|
||||||
footer: self.footer.clone(),
|
footer: self.footer.clone(),
|
||||||
}
|
}
|
||||||
|
@ -274,9 +274,7 @@ impl<C: Config> PlayerList<C> {
|
||||||
|
|
||||||
pub(crate) fn update_packets(&self, mut push_packet: impl FnMut(S2cPlayPacket)) {
|
pub(crate) fn update_packets(&self, mut push_packet: impl FnMut(S2cPlayPacket)) {
|
||||||
if !self.removed.is_empty() {
|
if !self.removed.is_empty() {
|
||||||
push_packet(
|
push_packet(PlayerInfo::RemovePlayer(self.removed.iter().cloned().collect()).into());
|
||||||
UpdatePlayerList::RemovePlayer(self.removed.iter().cloned().collect()).into(),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut add_player = Vec::new();
|
let mut add_player = Vec::new();
|
||||||
|
@ -322,24 +320,24 @@ impl<C: Config> PlayerList<C> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if !add_player.is_empty() {
|
if !add_player.is_empty() {
|
||||||
push_packet(UpdatePlayerList::AddPlayer(add_player).into());
|
push_packet(PlayerInfo::AddPlayer(add_player).into());
|
||||||
}
|
}
|
||||||
|
|
||||||
if !game_mode.is_empty() {
|
if !game_mode.is_empty() {
|
||||||
push_packet(UpdatePlayerList::UpdateGameMode(game_mode).into());
|
push_packet(PlayerInfo::UpdateGameMode(game_mode).into());
|
||||||
}
|
}
|
||||||
|
|
||||||
if !ping.is_empty() {
|
if !ping.is_empty() {
|
||||||
push_packet(UpdatePlayerList::UpdateLatency(ping).into());
|
push_packet(PlayerInfo::UpdateLatency(ping).into());
|
||||||
}
|
}
|
||||||
|
|
||||||
if !display_name.is_empty() {
|
if !display_name.is_empty() {
|
||||||
push_packet(UpdatePlayerList::UpdateDisplayName(display_name).into());
|
push_packet(PlayerInfo::UpdateDisplayName(display_name).into());
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.modified_header_or_footer {
|
if self.modified_header_or_footer {
|
||||||
push_packet(
|
push_packet(
|
||||||
PlayerListHeaderFooter {
|
SetTabListHeaderAndFooter {
|
||||||
header: self.header.clone(),
|
header: self.header.clone(),
|
||||||
footer: self.footer.clone(),
|
footer: self.footer.clone(),
|
||||||
}
|
}
|
||||||
|
@ -349,7 +347,7 @@ impl<C: Config> PlayerList<C> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn clear_packets(&self, mut push_packet: impl FnMut(S2cPlayPacket)) {
|
pub(crate) fn clear_packets(&self, mut push_packet: impl FnMut(S2cPlayPacket)) {
|
||||||
push_packet(UpdatePlayerList::RemovePlayer(self.entries.keys().cloned().collect()).into());
|
push_packet(PlayerInfo::RemovePlayer(self.entries.keys().cloned().collect()).into());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,19 +32,19 @@ pub mod status {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
QueryRequest {}
|
StatusRequest {}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
QueryPing {
|
PingRequest {
|
||||||
payload: u64
|
payload: u64
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_packet_group! {
|
def_packet_group! {
|
||||||
C2sStatusPacket {
|
C2sStatusPacket {
|
||||||
QueryRequest = 0,
|
StatusRequest = 0,
|
||||||
QueryPing = 1,
|
PingRequest = 1,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -101,20 +101,20 @@ pub mod play {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
TeleportConfirm {
|
ConfirmTeleport {
|
||||||
teleport_id: VarInt
|
teleport_id: VarInt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
QueryBlockNbt {
|
QueryBlockEntityTag {
|
||||||
transaction_id: VarInt,
|
transaction_id: VarInt,
|
||||||
location: BlockPos,
|
location: BlockPos,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_enum! {
|
def_enum! {
|
||||||
UpdateDifficulty: i8 {
|
ChangeDifficulty: i8 {
|
||||||
Peaceful = 0,
|
Peaceful = 0,
|
||||||
Easy = 1,
|
Easy = 1,
|
||||||
Normal = 2,
|
Normal = 2,
|
||||||
|
@ -150,7 +150,7 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
CommandExecution {
|
ChatCommand {
|
||||||
command: BoundedString<0, 256>,
|
command: BoundedString<0, 256>,
|
||||||
timestamp: u64,
|
timestamp: u64,
|
||||||
salt: u64,
|
salt: u64,
|
||||||
|
@ -172,14 +172,14 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
RequestChatPreview {
|
ChatPreviewC2s {
|
||||||
query: i32, // TODO: is this an i32 or a varint?
|
query: i32, // TODO: is this an i32 or a varint?
|
||||||
message: BoundedString<0, 256>,
|
message: BoundedString<0, 256>,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_enum! {
|
def_enum! {
|
||||||
ClientStatus: VarInt {
|
ClientCommand: VarInt {
|
||||||
/// Sent when ready to complete login and ready to respawn after death.
|
/// Sent when ready to complete login and ready to respawn after death.
|
||||||
PerformRespawn = 0,
|
PerformRespawn = 0,
|
||||||
/// Sent when the statistics menu is opened.
|
/// Sent when the statistics menu is opened.
|
||||||
|
@ -188,7 +188,7 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
ClientSettings {
|
ClientInformation {
|
||||||
/// e.g. en_US
|
/// e.g. en_US
|
||||||
locale: BoundedString<0, 16>,
|
locale: BoundedString<0, 16>,
|
||||||
/// Client-side render distance in chunks.
|
/// Client-side render distance in chunks.
|
||||||
|
@ -234,7 +234,7 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
RequestCommandCompletion {
|
CommandSuggestionsRequest {
|
||||||
transaction_id: VarInt,
|
transaction_id: VarInt,
|
||||||
/// Text behind the cursor without the '/'.
|
/// Text behind the cursor without the '/'.
|
||||||
text: BoundedString<0, 32500>
|
text: BoundedString<0, 32500>
|
||||||
|
@ -271,20 +271,20 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
CloseHandledScreen {
|
CloseContainerC2s {
|
||||||
window_id: u8,
|
window_id: u8,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
CustomPayload {
|
PluginMessageC2s {
|
||||||
channel: Ident,
|
channel: Ident,
|
||||||
data: RawBytes,
|
data: RawBytes,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
BookUpdate {
|
EditBook {
|
||||||
slot: VarInt,
|
slot: VarInt,
|
||||||
entries: Vec<String>,
|
entries: Vec<String>,
|
||||||
title: Option<String>,
|
title: Option<String>,
|
||||||
|
@ -292,14 +292,14 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
QueryEntityNbt {
|
QueryEntityTag {
|
||||||
transaction_id: VarInt,
|
transaction_id: VarInt,
|
||||||
entity_id: VarInt,
|
entity_id: VarInt,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
PlayerInteractEntity {
|
Interact {
|
||||||
entity_id: VarInt,
|
entity_id: VarInt,
|
||||||
kind: InteractKind,
|
kind: InteractKind,
|
||||||
sneaking: bool,
|
sneaking: bool,
|
||||||
|
@ -331,26 +331,26 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
KeepAlive {
|
KeepAliveC2s {
|
||||||
id: i64,
|
id: i64,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
UpdateDifficultyLock {
|
LockDifficulty {
|
||||||
locked: bool
|
locked: bool
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
MovePlayerPosition {
|
SetPlayerPosition {
|
||||||
position: Vec3<f64>,
|
position: Vec3<f64>,
|
||||||
on_ground: bool,
|
on_ground: bool,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
MovePlayerPositionAndRotation {
|
SetPlayerPositionAndRotation {
|
||||||
// Absolute position
|
// Absolute position
|
||||||
position: Vec3<f64>,
|
position: Vec3<f64>,
|
||||||
/// Absolute rotation on X axis in degrees.
|
/// Absolute rotation on X axis in degrees.
|
||||||
|
@ -362,7 +362,7 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
MovePlayerRotation {
|
SetPlayerRotation {
|
||||||
/// Absolute rotation on X axis in degrees.
|
/// Absolute rotation on X axis in degrees.
|
||||||
yaw: f32,
|
yaw: f32,
|
||||||
/// Absolute rotation on Y axis in degrees.
|
/// Absolute rotation on Y axis in degrees.
|
||||||
|
@ -372,13 +372,13 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
MovePlayerOnGround {
|
SetPlayerOnGround {
|
||||||
on_ground: bool
|
on_ground: bool
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
MoveVehicle {
|
MoveVehicleC2s {
|
||||||
/// Absolute position
|
/// Absolute position
|
||||||
position: Vec3<f64>,
|
position: Vec3<f64>,
|
||||||
/// Degrees
|
/// Degrees
|
||||||
|
@ -389,20 +389,20 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
BoatPaddleState {
|
PaddleBoat {
|
||||||
left_paddle_turning: bool,
|
left_paddle_turning: bool,
|
||||||
right_paddle_turning: bool,
|
right_paddle_turning: bool,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
PickFromInventory {
|
PickItem {
|
||||||
slot_to_use: VarInt,
|
slot_to_use: VarInt,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
CraftRequest {
|
PlaceRecipe {
|
||||||
window_id: i8,
|
window_id: i8,
|
||||||
recipe: Ident,
|
recipe: Ident,
|
||||||
make_all: bool,
|
make_all: bool,
|
||||||
|
@ -410,7 +410,7 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_enum! {
|
def_enum! {
|
||||||
UpdatePlayerAbilities: i8 {
|
PlayerAbilitiesC2s: i8 {
|
||||||
NotFlying = 0,
|
NotFlying = 0,
|
||||||
Flying = 0b10,
|
Flying = 0b10,
|
||||||
}
|
}
|
||||||
|
@ -493,13 +493,13 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
PlayPong {
|
PongPlay {
|
||||||
id: i32,
|
id: i32,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
RecipeBookChangeSettings {
|
ChangeRecipeBookSettings {
|
||||||
book_id: RecipeBookId,
|
book_id: RecipeBookId,
|
||||||
book_open: bool,
|
book_open: bool,
|
||||||
filter_active: bool,
|
filter_active: bool,
|
||||||
|
@ -516,7 +516,7 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
RecipeBookSeenRecipe {
|
SetSeenRecipe {
|
||||||
recipe_id: Ident,
|
recipe_id: Ident,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -528,7 +528,7 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_enum! {
|
def_enum! {
|
||||||
ResourcePackStatus: VarInt {
|
ResourcePackC2s: VarInt {
|
||||||
SuccessfullyLoaded = 0,
|
SuccessfullyLoaded = 0,
|
||||||
Declined = 1,
|
Declined = 1,
|
||||||
FailedDownload = 2,
|
FailedDownload = 2,
|
||||||
|
@ -537,20 +537,20 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_enum! {
|
def_enum! {
|
||||||
AdvancementTab: VarInt {
|
SeenAdvancements: VarInt {
|
||||||
OpenedTab: Ident = 0,
|
OpenedTab: Ident = 0,
|
||||||
ClosedScreen = 1,
|
ClosedScreen = 1,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
SelectMerchantTrade {
|
SelectTrade {
|
||||||
selected_slot: VarInt,
|
selected_slot: VarInt,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
UpdateBeacon {
|
SetBeaconEffect {
|
||||||
// TODO: potion ids
|
// TODO: potion ids
|
||||||
primary_effect: Option<VarInt>,
|
primary_effect: Option<VarInt>,
|
||||||
secondary_effect: Option<VarInt>,
|
secondary_effect: Option<VarInt>,
|
||||||
|
@ -558,13 +558,13 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
UpdateSelectedSlot {
|
SetHeldItemS2c {
|
||||||
slot: BoundedInt<i16, 0, 8>,
|
slot: BoundedInt<i16, 0, 8>,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
UpdateCommandBlock {
|
ProgramCommandBlock {
|
||||||
location: BlockPos,
|
location: BlockPos,
|
||||||
command: String,
|
command: String,
|
||||||
mode: CommandBlockMode,
|
mode: CommandBlockMode,
|
||||||
|
@ -589,7 +589,7 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
UpdateCommandBlockMinecart {
|
ProgramCommandBlockMinecart {
|
||||||
entity_id: VarInt,
|
entity_id: VarInt,
|
||||||
command: String,
|
command: String,
|
||||||
track_output: bool,
|
track_output: bool,
|
||||||
|
@ -597,14 +597,14 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
UpdateCreativeModeSlot {
|
SetCreativeModeSlot {
|
||||||
slot: i16,
|
slot: i16,
|
||||||
clicked_item: Slot,
|
clicked_item: Slot,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
UpdateJigsaw {
|
ProgramJigsawBlock {
|
||||||
location: BlockPos,
|
location: BlockPos,
|
||||||
name: Ident,
|
name: Ident,
|
||||||
target: Ident,
|
target: Ident,
|
||||||
|
@ -615,7 +615,7 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
UpdateStructureBlock {
|
ProgramStructureBlock {
|
||||||
location: BlockPos,
|
location: BlockPos,
|
||||||
action: StructureBlockAction,
|
action: StructureBlockAction,
|
||||||
mode: StructureBlockMode,
|
mode: StructureBlockMode,
|
||||||
|
@ -682,19 +682,19 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
HandSwing {
|
SwingArm {
|
||||||
hand: Hand,
|
hand: Hand,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
SpectatorTeleport {
|
TeleportToEntity {
|
||||||
target: Uuid,
|
target: Uuid,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
PlayerInteractBlock {
|
UseItemOn {
|
||||||
hand: Hand,
|
hand: Hand,
|
||||||
location: BlockPos,
|
location: BlockPos,
|
||||||
face: BlockFace,
|
face: BlockFace,
|
||||||
|
@ -705,7 +705,7 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
PlayerInteractItem {
|
UseItem {
|
||||||
hand: Hand,
|
hand: Hand,
|
||||||
sequence: VarInt,
|
sequence: VarInt,
|
||||||
}
|
}
|
||||||
|
@ -713,57 +713,57 @@ pub mod play {
|
||||||
|
|
||||||
def_packet_group! {
|
def_packet_group! {
|
||||||
C2sPlayPacket {
|
C2sPlayPacket {
|
||||||
TeleportConfirm = 0,
|
ConfirmTeleport = 0,
|
||||||
QueryBlockNbt = 1,
|
QueryBlockEntityTag = 1,
|
||||||
UpdateDifficulty = 2,
|
ChangeDifficulty = 2,
|
||||||
MessageAcknowledgment = 3,
|
MessageAcknowledgment = 3,
|
||||||
CommandExecution = 4,
|
ChatCommand = 4,
|
||||||
ChatMessage = 5,
|
ChatMessage = 5,
|
||||||
RequestChatPreview = 6,
|
ChatPreviewC2s = 6,
|
||||||
ClientStatus = 7,
|
ClientCommand = 7,
|
||||||
ClientSettings = 8,
|
ClientInformation = 8,
|
||||||
RequestCommandCompletion = 9,
|
CommandSuggestionsRequest = 9,
|
||||||
ClickContainerButton = 10,
|
ClickContainerButton = 10,
|
||||||
ClickContainer = 11,
|
ClickContainer = 11,
|
||||||
CloseHandledScreen = 12,
|
CloseContainerC2s = 12,
|
||||||
CustomPayload = 13,
|
PluginMessageC2s = 13,
|
||||||
BookUpdate = 14,
|
EditBook = 14,
|
||||||
QueryEntityNbt = 15,
|
QueryEntityTag = 15,
|
||||||
PlayerInteractEntity = 16,
|
Interact = 16,
|
||||||
JigsawGenerate = 17,
|
JigsawGenerate = 17,
|
||||||
KeepAlive = 18,
|
KeepAliveC2s = 18,
|
||||||
UpdateDifficultyLock = 19,
|
LockDifficulty = 19,
|
||||||
MovePlayerPosition = 20,
|
SetPlayerPosition = 20,
|
||||||
MovePlayerPositionAndRotation = 21,
|
SetPlayerPositionAndRotation = 21,
|
||||||
MovePlayerRotation = 22,
|
SetPlayerRotation = 22,
|
||||||
MovePlayerOnGround = 23,
|
SetPlayerOnGround = 23,
|
||||||
MoveVehicle = 24,
|
MoveVehicleC2s = 24,
|
||||||
BoatPaddleState = 25,
|
PaddleBoat = 25,
|
||||||
PickFromInventory = 26,
|
PickItem = 26,
|
||||||
CraftRequest = 27,
|
PlaceRecipe = 27,
|
||||||
UpdatePlayerAbilities = 28,
|
PlayerAbilitiesC2s = 28,
|
||||||
PlayerAction = 29,
|
PlayerAction = 29,
|
||||||
PlayerCommand = 30,
|
PlayerCommand = 30,
|
||||||
PlayerInput = 31,
|
PlayerInput = 31,
|
||||||
PlayPong = 32,
|
PongPlay = 32,
|
||||||
RecipeBookChangeSettings = 33,
|
ChangeRecipeBookSettings = 33,
|
||||||
RecipeBookSeenRecipe = 34,
|
SetSeenRecipe = 34,
|
||||||
RenameItem = 35,
|
RenameItem = 35,
|
||||||
ResourcePackStatus = 36,
|
ResourcePackC2s = 36,
|
||||||
AdvancementTab = 37,
|
SeenAdvancements = 37,
|
||||||
SelectMerchantTrade = 38,
|
SelectTrade = 38,
|
||||||
UpdateBeacon = 39,
|
SetBeaconEffect = 39,
|
||||||
UpdateSelectedSlot = 40,
|
SetHeldItemS2c = 40,
|
||||||
UpdateCommandBlock = 41,
|
ProgramCommandBlock = 41,
|
||||||
UpdateCommandBlockMinecart = 42,
|
ProgramCommandBlockMinecart = 42,
|
||||||
UpdateCreativeModeSlot = 43,
|
SetCreativeModeSlot = 43,
|
||||||
UpdateJigsaw = 44,
|
ProgramJigsawBlock = 44,
|
||||||
UpdateStructureBlock = 45,
|
ProgramStructureBlock = 45,
|
||||||
UpdateSign = 46,
|
UpdateSign = 46,
|
||||||
HandSwing = 47,
|
SwingArm = 47,
|
||||||
SpectatorTeleport = 48,
|
TeleportToEntity = 48,
|
||||||
PlayerInteractBlock = 49,
|
UseItemOn = 49,
|
||||||
PlayerInteractItem = 50,
|
UseItem = 50,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,13 +6,13 @@ pub mod status {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
QueryResponse {
|
StatusResponse {
|
||||||
json_response: String
|
json_response: String
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
QueryPong {
|
PingResponse {
|
||||||
/// Should be the same as the payload from ping.
|
/// Should be the same as the payload from ping.
|
||||||
payload: u64
|
payload: u64
|
||||||
}
|
}
|
||||||
|
@ -20,8 +20,8 @@ pub mod status {
|
||||||
|
|
||||||
def_packet_group! {
|
def_packet_group! {
|
||||||
S2cStatusPacket {
|
S2cStatusPacket {
|
||||||
QueryResponse = 0,
|
StatusResponse = 0,
|
||||||
QueryPong = 1,
|
PingResponse = 1,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ pub mod login {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
LoginDisconnect {
|
DisconnectLogin {
|
||||||
reason: Text,
|
reason: Text,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ pub mod login {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
LoginCompression {
|
SetCompression {
|
||||||
threshold: VarInt
|
threshold: VarInt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,10 +69,10 @@ pub mod login {
|
||||||
|
|
||||||
def_packet_group! {
|
def_packet_group! {
|
||||||
S2cLoginPacket {
|
S2cLoginPacket {
|
||||||
LoginDisconnect = 0,
|
DisconnectLogin = 0,
|
||||||
EncryptionRequest = 1,
|
EncryptionRequest = 1,
|
||||||
LoginSuccess = 2,
|
LoginSuccess = 2,
|
||||||
LoginCompression = 3,
|
SetCompression = 3,
|
||||||
LoginPluginRequest = 4,
|
LoginPluginRequest = 4,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,7 @@ pub mod play {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
EntitySpawn {
|
SpawnEntity {
|
||||||
entity_id: VarInt,
|
entity_id: VarInt,
|
||||||
object_uuid: Uuid,
|
object_uuid: Uuid,
|
||||||
kind: VarInt,
|
kind: VarInt,
|
||||||
|
@ -96,7 +96,7 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
ExperienceOrbSpawn {
|
SpawnExperienceOrb {
|
||||||
entity_id: VarInt,
|
entity_id: VarInt,
|
||||||
position: Vec3<f64>,
|
position: Vec3<f64>,
|
||||||
count: i16,
|
count: i16,
|
||||||
|
@ -104,7 +104,7 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
PlayerSpawn {
|
SpawnPlayer {
|
||||||
entity_id: VarInt,
|
entity_id: VarInt,
|
||||||
player_uuid: Uuid,
|
player_uuid: Uuid,
|
||||||
position: Vec3<f64>,
|
position: Vec3<f64>,
|
||||||
|
@ -114,20 +114,20 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
EntityAnimation {
|
EntityAnimationS2c {
|
||||||
entity_id: VarInt,
|
entity_id: VarInt,
|
||||||
animation: u8,
|
animation: u8,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
PlayerActionResponse {
|
AcknowledgeBlockChange {
|
||||||
sequence: VarInt,
|
sequence: VarInt,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
BlockBreakingProgress {
|
SetBlockDestroyStage {
|
||||||
entity_id: VarInt,
|
entity_id: VarInt,
|
||||||
location: BlockPos,
|
location: BlockPos,
|
||||||
destroy_stage: BoundedInt<u8, 0, 10>,
|
destroy_stage: BoundedInt<u8, 0, 10>,
|
||||||
|
@ -135,7 +135,7 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
BlockEntityUpdate {
|
BlockEntityData {
|
||||||
location: BlockPos,
|
location: BlockPos,
|
||||||
kind: VarInt, // TODO: use enum here
|
kind: VarInt, // TODO: use enum here
|
||||||
data: Compound,
|
data: Compound,
|
||||||
|
@ -143,7 +143,7 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
BlockEvent {
|
BlockAction {
|
||||||
location: BlockPos,
|
location: BlockPos,
|
||||||
action_id: u8,
|
action_id: u8,
|
||||||
action_param: u8,
|
action_param: u8,
|
||||||
|
@ -276,7 +276,7 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
PlaySoundId {
|
CustomSoundEffect {
|
||||||
name: Ident,
|
name: Ident,
|
||||||
category: SoundCategory,
|
category: SoundCategory,
|
||||||
position: Vec3<i32>,
|
position: Vec3<i32>,
|
||||||
|
@ -287,13 +287,13 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
Disconnect {
|
DisconnectPlay {
|
||||||
reason: Text,
|
reason: Text,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
EntityStatus {
|
EntityEvent {
|
||||||
entity_id: i32,
|
entity_id: i32,
|
||||||
entity_status: u8,
|
entity_status: u8,
|
||||||
}
|
}
|
||||||
|
@ -307,7 +307,7 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
GameStateChange {
|
GameEvent {
|
||||||
reason: GameStateChangeReason,
|
reason: GameStateChangeReason,
|
||||||
value: f32,
|
value: f32,
|
||||||
}
|
}
|
||||||
|
@ -344,13 +344,13 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
KeepAlive {
|
KeepAliveS2c {
|
||||||
id: i64,
|
id: i64,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
ChunkData {
|
ChunkDataAndUpdateLight {
|
||||||
chunk_x: i32,
|
chunk_x: i32,
|
||||||
chunk_z: i32,
|
chunk_z: i32,
|
||||||
heightmaps: NbtBridge<ChunkDataHeightmaps>,
|
heightmaps: NbtBridge<ChunkDataHeightmaps>,
|
||||||
|
@ -382,7 +382,7 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
GameJoin {
|
LoginPlay {
|
||||||
/// Entity ID of the joining player
|
/// Entity ID of the joining player
|
||||||
entity_id: i32,
|
entity_id: i32,
|
||||||
is_hardcore: bool,
|
is_hardcore: bool,
|
||||||
|
@ -574,7 +574,7 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
MoveRelative {
|
UpdateEntityPosition {
|
||||||
entity_id: VarInt,
|
entity_id: VarInt,
|
||||||
delta: Vec3<i16>,
|
delta: Vec3<i16>,
|
||||||
on_ground: bool,
|
on_ground: bool,
|
||||||
|
@ -582,7 +582,7 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
RotateAndMoveRelative {
|
UpdateEntityPositionAndRotation {
|
||||||
entity_id: VarInt,
|
entity_id: VarInt,
|
||||||
delta: Vec3<i16>,
|
delta: Vec3<i16>,
|
||||||
yaw: ByteAngle,
|
yaw: ByteAngle,
|
||||||
|
@ -592,7 +592,7 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
Rotate {
|
UpdateEntityRotation {
|
||||||
entity_id: VarInt,
|
entity_id: VarInt,
|
||||||
yaw: ByteAngle,
|
yaw: ByteAngle,
|
||||||
pitch: ByteAngle,
|
pitch: ByteAngle,
|
||||||
|
@ -609,7 +609,7 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
ChatMessage {
|
PlayerChatMessage {
|
||||||
// TODO: more 1.19 stuff.
|
// TODO: more 1.19 stuff.
|
||||||
message: Text,
|
message: Text,
|
||||||
/// Index into the chat type registry
|
/// Index into the chat type registry
|
||||||
|
@ -619,7 +619,7 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_enum! {
|
def_enum! {
|
||||||
UpdatePlayerList: VarInt {
|
PlayerInfo: VarInt {
|
||||||
AddPlayer: Vec<PlayerListAddPlayer> = 0,
|
AddPlayer: Vec<PlayerListAddPlayer> = 0,
|
||||||
UpdateGameMode: Vec<(Uuid, GameMode)> = 1,
|
UpdateGameMode: Vec<(Uuid, GameMode)> = 1,
|
||||||
UpdateLatency: Vec<(Uuid, VarInt)> = 2,
|
UpdateLatency: Vec<(Uuid, VarInt)> = 2,
|
||||||
|
@ -641,7 +641,7 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
PlayerPositionLook {
|
SynchronizePlayerPosition {
|
||||||
position: Vec3<f64>,
|
position: Vec3<f64>,
|
||||||
yaw: f32,
|
yaw: f32,
|
||||||
pitch: f32,
|
pitch: f32,
|
||||||
|
@ -662,13 +662,13 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
EntitiesDestroy {
|
RemoveEntities {
|
||||||
entities: Vec<VarInt>,
|
entities: Vec<VarInt>,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
PlayerRespawn {
|
Respawn {
|
||||||
dimension_type_name: Ident,
|
dimension_type_name: Ident,
|
||||||
dimension_name: Ident,
|
dimension_name: Ident,
|
||||||
hashed_seed: u64,
|
hashed_seed: u64,
|
||||||
|
@ -682,14 +682,14 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
EntitySetHeadYaw {
|
SetHeadRotation {
|
||||||
entity_id: VarInt,
|
entity_id: VarInt,
|
||||||
head_yaw: ByteAngle,
|
head_yaw: ByteAngle,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
ChunkSectionUpdate {
|
UpdateSectionBlocks {
|
||||||
chunk_section_position: i64,
|
chunk_section_position: i64,
|
||||||
invert_trust_edges: bool,
|
invert_trust_edges: bool,
|
||||||
blocks: Vec<VarLong>,
|
blocks: Vec<VarLong>,
|
||||||
|
@ -697,53 +697,53 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
OverlayMessage {
|
SetActionBarText {
|
||||||
text: Text
|
text: Text
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
UpdateSelectedSlot {
|
SetHeldItemS2c {
|
||||||
slot: BoundedInt<u8, 0, 9>,
|
slot: BoundedInt<u8, 0, 9>,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
ChunkRenderDistanceCenter {
|
SetCenterChunk {
|
||||||
chunk_x: VarInt,
|
chunk_x: VarInt,
|
||||||
chunk_z: VarInt,
|
chunk_z: VarInt,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
ChunkLoadDistance {
|
SetRenderDistance {
|
||||||
view_distance: BoundedInt<VarInt, 2, 32>,
|
view_distance: BoundedInt<VarInt, 2, 32>,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
PlayerSpawnPosition {
|
SetDefaultSpawnPosition {
|
||||||
location: BlockPos,
|
location: BlockPos,
|
||||||
angle: f32,
|
angle: f32,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
EntityTrackerUpdate {
|
SetEntityMetadata {
|
||||||
entity_id: VarInt,
|
entity_id: VarInt,
|
||||||
metadata: RawBytes,
|
metadata: RawBytes,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
EntityVelocityUpdate {
|
SetEntityVelocity {
|
||||||
entity_id: VarInt,
|
entity_id: VarInt,
|
||||||
velocity: Vec3<i16>,
|
velocity: Vec3<i16>,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
ExperienceBarUpdate {
|
SetExperience {
|
||||||
bar: f32,
|
bar: f32,
|
||||||
level: VarInt,
|
level: VarInt,
|
||||||
total_xp: VarInt,
|
total_xp: VarInt,
|
||||||
|
@ -751,7 +751,7 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
HealthUpdate {
|
SetHealth {
|
||||||
health: f32,
|
health: f32,
|
||||||
food: VarInt,
|
food: VarInt,
|
||||||
food_saturation: f32,
|
food_saturation: f32,
|
||||||
|
@ -759,13 +759,13 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
UpdateSubtitle {
|
SetSubtitleText {
|
||||||
subtitle_text: Text,
|
subtitle_text: Text,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
WorldTimeUpdate {
|
UpdateTime {
|
||||||
/// The age of the world in 1/20ths of a second.
|
/// The age of the world in 1/20ths of a second.
|
||||||
world_age: i64,
|
world_age: i64,
|
||||||
/// The current time of day in 1/20ths of a second.
|
/// The current time of day in 1/20ths of a second.
|
||||||
|
@ -776,14 +776,14 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
UpdateTitle {
|
SetTitleText {
|
||||||
text: Text,
|
text: Text,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
#[derive(Copy, PartialEq, Eq)]
|
#[derive(Copy, PartialEq, Eq)]
|
||||||
TitleFade {
|
SetTitleAnimationTimes {
|
||||||
/// Ticks to spend fading in.
|
/// Ticks to spend fading in.
|
||||||
fade_in: u32,
|
fade_in: u32,
|
||||||
/// Ticks to keep the title displayed.
|
/// Ticks to keep the title displayed.
|
||||||
|
@ -794,7 +794,7 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
PlaySoundFromEntity {
|
EntitySoundEffect {
|
||||||
id: VarInt,
|
id: VarInt,
|
||||||
category: SoundCategory,
|
category: SoundCategory,
|
||||||
entity_id: VarInt,
|
entity_id: VarInt,
|
||||||
|
@ -804,7 +804,7 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
PlaySound {
|
SoundEffect {
|
||||||
id: VarInt,
|
id: VarInt,
|
||||||
category: SoundCategory,
|
category: SoundCategory,
|
||||||
position: Vec3<i32>,
|
position: Vec3<i32>,
|
||||||
|
@ -815,7 +815,7 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
GameMessage {
|
SystemChatMessage {
|
||||||
chat: Text,
|
chat: Text,
|
||||||
/// Index into the chat type registry.
|
/// Index into the chat type registry.
|
||||||
kind: VarInt,
|
kind: VarInt,
|
||||||
|
@ -823,14 +823,14 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
PlayerListHeaderFooter {
|
SetTabListHeaderAndFooter {
|
||||||
header: Text,
|
header: Text,
|
||||||
footer: Text,
|
footer: Text,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
EntityPosition {
|
TeleportEntity {
|
||||||
entity_id: VarInt,
|
entity_id: VarInt,
|
||||||
position: Vec3<f64>,
|
position: Vec3<f64>,
|
||||||
yaw: ByteAngle,
|
yaw: ByteAngle,
|
||||||
|
@ -840,7 +840,7 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
EntityAttributes {
|
UpdateAttributes {
|
||||||
entity_id: VarInt,
|
entity_id: VarInt,
|
||||||
properties: Vec<EntityAttributesProperty>,
|
properties: Vec<EntityAttributesProperty>,
|
||||||
}
|
}
|
||||||
|
@ -864,14 +864,14 @@ pub mod play {
|
||||||
|
|
||||||
def_packet_group! {
|
def_packet_group! {
|
||||||
S2cPlayPacket {
|
S2cPlayPacket {
|
||||||
EntitySpawn = 0,
|
SpawnEntity = 0,
|
||||||
ExperienceOrbSpawn = 1,
|
SpawnExperienceOrb = 1,
|
||||||
PlayerSpawn = 2,
|
SpawnPlayer = 2,
|
||||||
EntityAnimation = 3,
|
EntityAnimationS2c = 3,
|
||||||
PlayerActionResponse = 5,
|
AcknowledgeBlockChange = 5,
|
||||||
BlockBreakingProgress = 6,
|
SetBlockDestroyStage = 6,
|
||||||
BlockEntityUpdate = 7,
|
BlockEntityData = 7,
|
||||||
BlockEvent = 8,
|
BlockAction = 8,
|
||||||
BlockUpdate = 9,
|
BlockUpdate = 9,
|
||||||
BossBar = 10,
|
BossBar = 10,
|
||||||
ClearTitles = 13,
|
ClearTitles = 13,
|
||||||
|
@ -879,44 +879,44 @@ pub mod play {
|
||||||
SetContainerProperty = 18,
|
SetContainerProperty = 18,
|
||||||
SetContainerSlot = 19,
|
SetContainerSlot = 19,
|
||||||
SetCooldown = 20,
|
SetCooldown = 20,
|
||||||
PlaySoundId = 23,
|
CustomSoundEffect = 23,
|
||||||
Disconnect = 25,
|
DisconnectPlay = 25,
|
||||||
EntityStatus = 26,
|
EntityEvent = 26,
|
||||||
UnloadChunk = 28,
|
UnloadChunk = 28,
|
||||||
GameStateChange = 29,
|
GameEvent = 29,
|
||||||
KeepAlive = 32,
|
KeepAliveS2c = 32,
|
||||||
ChunkData = 33,
|
ChunkDataAndUpdateLight = 33,
|
||||||
GameJoin = 37,
|
LoginPlay = 37,
|
||||||
MoveRelative = 40,
|
UpdateEntityPosition = 40,
|
||||||
RotateAndMoveRelative = 41,
|
UpdateEntityPositionAndRotation = 41,
|
||||||
Rotate = 42,
|
UpdateEntityRotation = 42,
|
||||||
OpenScreen = 45,
|
OpenScreen = 45,
|
||||||
ChatMessage = 51,
|
PlayerChatMessage = 51,
|
||||||
UpdatePlayerList = 55,
|
PlayerInfo = 55,
|
||||||
PlayerPositionLook = 57,
|
SynchronizePlayerPosition = 57,
|
||||||
EntitiesDestroy = 59,
|
RemoveEntities = 59,
|
||||||
PlayerRespawn = 62,
|
Respawn = 62,
|
||||||
EntitySetHeadYaw = 63,
|
SetHeadRotation = 63,
|
||||||
ChunkSectionUpdate = 64,
|
UpdateSectionBlocks = 64,
|
||||||
OverlayMessage = 67,
|
SetActionBarText = 67,
|
||||||
UpdateSelectedSlot = 74,
|
SetHeldItemS2c = 74,
|
||||||
ChunkRenderDistanceCenter = 75,
|
SetCenterChunk = 75,
|
||||||
ChunkLoadDistance = 76,
|
SetRenderDistance = 76,
|
||||||
PlayerSpawnPosition = 77,
|
SetDefaultSpawnPosition = 77,
|
||||||
EntityTrackerUpdate = 80,
|
SetEntityMetadata = 80,
|
||||||
EntityVelocityUpdate = 82,
|
SetEntityVelocity = 82,
|
||||||
ExperienceBarUpdate = 84,
|
SetExperience = 84,
|
||||||
HealthUpdate = 85,
|
SetHealth = 85,
|
||||||
UpdateSubtitle = 91,
|
SetSubtitleText = 91,
|
||||||
WorldTimeUpdate = 92,
|
UpdateTime = 92,
|
||||||
UpdateTitle = 93,
|
SetTitleText = 93,
|
||||||
TitleFade = 94,
|
SetTitleAnimationTimes = 94,
|
||||||
PlaySoundFromEntity = 95,
|
EntitySoundEffect = 95,
|
||||||
PlaySound = 96,
|
SoundEffect = 96,
|
||||||
GameMessage = 98,
|
SystemChatMessage = 98,
|
||||||
PlayerListHeaderFooter = 99,
|
SetTabListHeaderAndFooter = 99,
|
||||||
EntityPosition = 102,
|
TeleportEntity = 102,
|
||||||
EntityAttributes = 104,
|
UpdateAttributes = 104,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,12 +38,12 @@ use crate::protocol::codec::{Decoder, Encoder};
|
||||||
use crate::protocol::packets::c2s::handshake::{Handshake, HandshakeNextState};
|
use crate::protocol::packets::c2s::handshake::{Handshake, HandshakeNextState};
|
||||||
use crate::protocol::packets::c2s::login::{EncryptionResponse, LoginStart, VerifyTokenOrMsgSig};
|
use crate::protocol::packets::c2s::login::{EncryptionResponse, LoginStart, VerifyTokenOrMsgSig};
|
||||||
use crate::protocol::packets::c2s::play::C2sPlayPacket;
|
use crate::protocol::packets::c2s::play::C2sPlayPacket;
|
||||||
use crate::protocol::packets::c2s::status::{QueryPing, QueryRequest};
|
use crate::protocol::packets::c2s::status::{PingRequest, StatusRequest};
|
||||||
use crate::protocol::packets::s2c::login::{
|
use crate::protocol::packets::s2c::login::{
|
||||||
EncryptionRequest, LoginCompression, LoginDisconnect, LoginSuccess,
|
DisconnectLogin, EncryptionRequest, LoginSuccess, SetCompression,
|
||||||
};
|
};
|
||||||
use crate::protocol::packets::s2c::play::S2cPlayPacket;
|
use crate::protocol::packets::s2c::play::S2cPlayPacket;
|
||||||
use crate::protocol::packets::s2c::status::{QueryPong, QueryResponse};
|
use crate::protocol::packets::s2c::status::{PingResponse, StatusResponse};
|
||||||
use crate::protocol::packets::Property;
|
use crate::protocol::packets::Property;
|
||||||
use crate::protocol::{BoundedArray, BoundedString, VarInt};
|
use crate::protocol::{BoundedArray, BoundedString, VarInt};
|
||||||
use crate::util::valid_username;
|
use crate::util::valid_username;
|
||||||
|
@ -573,7 +573,7 @@ async fn handle_status<C: Config>(
|
||||||
remote_addr: SocketAddr,
|
remote_addr: SocketAddr,
|
||||||
handshake: Handshake,
|
handshake: Handshake,
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
c.dec.read_packet::<QueryRequest>().await?;
|
c.dec.read_packet::<StatusRequest>().await?;
|
||||||
|
|
||||||
match server
|
match server
|
||||||
.0
|
.0
|
||||||
|
@ -610,7 +610,7 @@ async fn handle_status<C: Config>(
|
||||||
}
|
}
|
||||||
|
|
||||||
c.enc
|
c.enc
|
||||||
.write_packet(&QueryResponse {
|
.write_packet(&StatusResponse {
|
||||||
json_response: json.to_string(),
|
json_response: json.to_string(),
|
||||||
})
|
})
|
||||||
.await?;
|
.await?;
|
||||||
|
@ -618,9 +618,9 @@ async fn handle_status<C: Config>(
|
||||||
ServerListPing::Ignore => return Ok(()),
|
ServerListPing::Ignore => return Ok(()),
|
||||||
}
|
}
|
||||||
|
|
||||||
let QueryPing { payload } = c.dec.read_packet().await?;
|
let PingRequest { payload } = c.dec.read_packet().await?;
|
||||||
|
|
||||||
c.enc.write_packet(&QueryPong { payload }).await?;
|
c.enc.write_packet(&PingResponse { payload }).await?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -739,7 +739,7 @@ async fn handle_login<C: Config>(
|
||||||
|
|
||||||
let compression_threshold = 256;
|
let compression_threshold = 256;
|
||||||
c.enc
|
c.enc
|
||||||
.write_packet(&LoginCompression {
|
.write_packet(&SetCompression {
|
||||||
threshold: VarInt(compression_threshold as i32),
|
threshold: VarInt(compression_threshold as i32),
|
||||||
})
|
})
|
||||||
.await?;
|
.await?;
|
||||||
|
@ -756,7 +756,7 @@ async fn handle_login<C: Config>(
|
||||||
|
|
||||||
if let Err(reason) = server.0.cfg.login(server, &ncd).await {
|
if let Err(reason) = server.0.cfg.login(server, &ncd).await {
|
||||||
log::info!("Disconnect at login: \"{reason}\"");
|
log::info!("Disconnect at login: \"{reason}\"");
|
||||||
c.enc.write_packet(&LoginDisconnect { reason }).await?;
|
c.enc.write_packet(&DisconnectLogin { reason }).await?;
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue