mirror of
https://github.com/italicsjenga/valence.git
synced 2024-12-23 22:41:30 +11:00
Rename packets
This commit is contained in:
parent
6ef634ca2c
commit
9a87fda211
|
@ -6,7 +6,7 @@ use log::LevelFilter;
|
||||||
use noise::{NoiseFn, Seedable, SuperSimplex};
|
use noise::{NoiseFn, Seedable, SuperSimplex};
|
||||||
use rayon::iter::ParallelIterator;
|
use rayon::iter::ParallelIterator;
|
||||||
use valence::block::{BlockState, PropName, PropValue};
|
use valence::block::{BlockState, PropName, PropValue};
|
||||||
use valence::client::{ChatMessageType, GameMode};
|
use valence::client::{GameMode, PlayerChatType};
|
||||||
use valence::config::{Config, ServerListPing};
|
use valence::config::{Config, ServerListPing};
|
||||||
use valence::text::Color;
|
use valence::text::Color;
|
||||||
use valence::util::chunks_in_view_distance;
|
use valence::util::chunks_in_view_distance;
|
||||||
|
@ -114,7 +114,7 @@ impl Config for Game {
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
|
|
||||||
client.send_message("welcome!", ChatMessageType::Chat);
|
client.send_message("welcome!", PlayerChatType::Chat);
|
||||||
}
|
}
|
||||||
|
|
||||||
let dist = client.view_distance();
|
let dist = client.view_distance();
|
||||||
|
|
16
src/chunk.rs
16
src/chunk.rs
|
@ -10,7 +10,7 @@ use rayon::iter::{IntoParallelRefIterator, IntoParallelRefMutIterator, ParallelI
|
||||||
|
|
||||||
use crate::block::BlockState;
|
use crate::block::BlockState;
|
||||||
use crate::protocol::packets::play::s2c::{
|
use crate::protocol::packets::play::s2c::{
|
||||||
BlockChange, ChunkDataAndUpdateLight, ChunkDataHeightmaps, MultiBlockChange, S2cPlayPacket,
|
BlockUpdate, LevelChunkHeightmaps, LevelChunkWithLight, S2cPlayPacket, SectionBlocksUpdate,
|
||||||
};
|
};
|
||||||
use crate::protocol::{Encode, Nbt, VarInt, VarLong};
|
use crate::protocol::{Encode, Nbt, VarInt, VarLong};
|
||||||
use crate::{BiomeId, BlockPos, ChunkPos, DimensionId, Server, Ticks};
|
use crate::{BiomeId, BlockPos, ChunkPos, DimensionId, Server, Ticks};
|
||||||
|
@ -202,17 +202,17 @@ impl Chunk {
|
||||||
|
|
||||||
/// 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) -> ChunkDataAndUpdateLight {
|
pub(crate) fn chunk_data_packet(&self, pos: ChunkPos) -> LevelChunkWithLight {
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
ChunkDataAndUpdateLight {
|
LevelChunkWithLight {
|
||||||
chunk_x: pos.x,
|
chunk_x: pos.x,
|
||||||
chunk_z: pos.z,
|
chunk_z: pos.z,
|
||||||
heightmaps: Nbt(ChunkDataHeightmaps {
|
heightmaps: Nbt(LevelChunkHeightmaps {
|
||||||
motion_blocking: self.heightmap.clone(),
|
motion_blocking: self.heightmap.clone(),
|
||||||
}),
|
}),
|
||||||
blocks_and_biomes,
|
blocks_and_biomes,
|
||||||
|
@ -250,7 +250,7 @@ impl Chunk {
|
||||||
let global_y = sect_y as i32 * 16 + (idx / (16 * 16)) as i32 + min_y;
|
let global_y = sect_y as i32 * 16 + (idx / (16 * 16)) as i32 + min_y;
|
||||||
let global_z = pos.z * 16 + (idx / 16 % 16) as i32;
|
let global_z = pos.z * 16 + (idx / 16 % 16) as i32;
|
||||||
|
|
||||||
packet(BlockChangePacket::Single(BlockChange {
|
packet(BlockChangePacket::Single(BlockUpdate {
|
||||||
location: BlockPos::new(global_x, global_y, global_z),
|
location: BlockPos::new(global_x, global_y, global_z),
|
||||||
block_id: VarInt((block & BLOCK_STATE_MASK).into()),
|
block_id: VarInt((block & BLOCK_STATE_MASK).into()),
|
||||||
}));
|
}));
|
||||||
|
@ -276,7 +276,7 @@ impl Chunk {
|
||||||
| (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;
|
||||||
|
|
||||||
packet(BlockChangePacket::Multi(MultiBlockChange {
|
packet(BlockChangePacket::Multi(SectionBlocksUpdate {
|
||||||
chunk_section_position,
|
chunk_section_position,
|
||||||
invert_trust_edges: false,
|
invert_trust_edges: false,
|
||||||
blocks,
|
blocks,
|
||||||
|
@ -336,8 +336,8 @@ impl Chunk {
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub(crate) enum BlockChangePacket {
|
pub(crate) enum BlockChangePacket {
|
||||||
Single(BlockChange),
|
Single(BlockUpdate),
|
||||||
Multi(MultiBlockChange),
|
Multi(SectionBlocksUpdate),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<BlockChangePacket> for S2cPlayPacket {
|
impl From<BlockChangePacket> for S2cPlayPacket {
|
||||||
|
|
136
src/client.rs
136
src/client.rs
|
@ -16,16 +16,16 @@ use crate::entity::types::Player;
|
||||||
use crate::entity::{velocity_to_packet_units, EntityType};
|
use crate::entity::{velocity_to_packet_units, EntityType};
|
||||||
use crate::player_textures::SignedPlayerTextures;
|
use crate::player_textures::SignedPlayerTextures;
|
||||||
use crate::protocol::packets::play::c2s::{C2sPlayPacket, DiggingStatus, InteractType};
|
use crate::protocol::packets::play::c2s::{C2sPlayPacket, DiggingStatus, InteractType};
|
||||||
pub use crate::protocol::packets::play::s2c::ChatMessageType;
|
pub use crate::protocol::packets::play::s2c::PlayerChatType;
|
||||||
use crate::protocol::packets::play::s2c::{
|
use crate::protocol::packets::play::s2c::{
|
||||||
AcknowledgeBlockChanges, Biome as BiomeRegistryBiome, BiomeAdditionsSound, BiomeEffects,
|
Biome as BiomeRegistryBiome, BiomeAdditionsSound, BiomeEffects, BiomeMoodSound, BiomeMusic,
|
||||||
BiomeMoodSound, BiomeMusic, BiomeParticle, BiomeParticleOptions, BiomeProperty, BiomeRegistry,
|
BiomeParticle, BiomeParticleOptions, BiomeProperty, BiomeRegistry, BlockChangeAck,
|
||||||
ChangeGameState, ChangeGameStateReason, ChatTypeRegistry, DestroyEntities, DimensionType,
|
ChatTypeRegistry, DimensionType, DimensionTypeRegistry, DimensionTypeRegistryEntry, Disconnect,
|
||||||
DimensionTypeRegistry, DimensionTypeRegistryEntry, Disconnect, EntityHeadLook, EntityMetadata,
|
ForgetLevelChunk, GameEvent, GameEventReason, KeepAlive, Login, MoveEntityPosition,
|
||||||
EntityPosition, EntityPositionAndRotation, EntityRotation, EntityTeleport, EntityVelocity,
|
MoveEntityPositionAndRotation, MoveEntityRotation, PlayerPosition, PlayerPositionFlags,
|
||||||
JoinGame, KeepAlive, PlayerPositionAndLook, PlayerPositionAndLookFlags, RegistryCodec,
|
RegistryCodec, RemoveEntities, RotateHead, S2cPlayPacket, SetChunkCacheCenter,
|
||||||
S2cPlayPacket, SpawnPosition, SystemChatMessage, UnloadChunk, UpdateViewDistance,
|
SetChunkCacheRadius, SetEntityMetadata, SetEntityMotion, SpawnPosition, SystemChat,
|
||||||
UpdateViewPosition,
|
TeleportEntity,
|
||||||
};
|
};
|
||||||
use crate::protocol::{BoundedInt, ByteAngle, Nbt, RawBytes, VarInt};
|
use crate::protocol::{BoundedInt, ByteAngle, Nbt, RawBytes, VarInt};
|
||||||
use crate::server::C2sPacketChannels;
|
use crate::server::C2sPacketChannels;
|
||||||
|
@ -136,7 +136,7 @@ pub struct Client {
|
||||||
old_game_mode: GameMode,
|
old_game_mode: GameMode,
|
||||||
settings: Option<Settings>,
|
settings: Option<Settings>,
|
||||||
dug_blocks: Vec<i32>,
|
dug_blocks: Vec<i32>,
|
||||||
msgs_to_send: Vec<(Text, ChatMessageType)>,
|
msgs_to_send: Vec<(Text, PlayerChatType)>,
|
||||||
/// The metadata for the client's own player entity.
|
/// The metadata for the client's own player entity.
|
||||||
player_meta: Player,
|
player_meta: Player,
|
||||||
}
|
}
|
||||||
|
@ -200,7 +200,7 @@ impl Client {
|
||||||
self.textures.as_ref()
|
self.textures.as_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn send_message(&mut self, msg: impl Into<Text>, typ: ChatMessageType) {
|
pub fn send_message(&mut self, msg: impl Into<Text>, typ: PlayerChatType) {
|
||||||
self.msgs_to_send.push((msg.into(), typ));
|
self.msgs_to_send.push((msg.into(), typ));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -386,7 +386,7 @@ impl Client {
|
||||||
}
|
}
|
||||||
|
|
||||||
match pkt {
|
match pkt {
|
||||||
C2sPlayPacket::TeleportConfirm(p) => {
|
C2sPlayPacket::AcceptTeleportation(p) => {
|
||||||
if self.pending_teleports == 0 {
|
if self.pending_teleports == 0 {
|
||||||
self.disconnect("Unexpected teleport confirmation");
|
self.disconnect("Unexpected teleport confirmation");
|
||||||
return;
|
return;
|
||||||
|
@ -405,16 +405,16 @@ impl Client {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
C2sPlayPacket::QueryBlockNbt(_) => {}
|
C2sPlayPacket::BlockEntityTagQuery(_) => {}
|
||||||
C2sPlayPacket::SetDifficulty(_) => {}
|
C2sPlayPacket::ChangeDifficulty(_) => {}
|
||||||
C2sPlayPacket::ChatCommand(_) => {}
|
C2sPlayPacket::ChatCommand(_) => {}
|
||||||
C2sPlayPacket::ChatMessage(p) => self.events.push(Event::ChatMessage {
|
C2sPlayPacket::Chat(p) => self.events.push(Event::ChatMessage {
|
||||||
message: p.message.0,
|
message: p.message.0,
|
||||||
timestamp: Duration::from_millis(p.timestamp),
|
timestamp: Duration::from_millis(p.timestamp),
|
||||||
}),
|
}),
|
||||||
C2sPlayPacket::ChatPreview(_) => {}
|
C2sPlayPacket::ChatPreview(_) => {}
|
||||||
C2sPlayPacket::ClientStatus(_) => {}
|
C2sPlayPacket::ClientCommand(_) => {}
|
||||||
C2sPlayPacket::ClientSettings(p) => {
|
C2sPlayPacket::ClientInformation(p) => {
|
||||||
let old = self.settings.replace(Settings {
|
let old = self.settings.replace(Settings {
|
||||||
locale: p.locale.0,
|
locale: p.locale.0,
|
||||||
view_distance: p.view_distance.0,
|
view_distance: p.view_distance.0,
|
||||||
|
@ -427,13 +427,13 @@ impl Client {
|
||||||
|
|
||||||
self.events.push(Event::SettingsChanged(old));
|
self.events.push(Event::SettingsChanged(old));
|
||||||
}
|
}
|
||||||
C2sPlayPacket::TabComplete(_) => {}
|
C2sPlayPacket::CommandSuggestion(_) => {}
|
||||||
C2sPlayPacket::ClickWindowButton(_) => {}
|
C2sPlayPacket::ContainerButtonClick(_) => {}
|
||||||
C2sPlayPacket::CloseWindow(_) => {}
|
C2sPlayPacket::ContainerClose(_) => {}
|
||||||
C2sPlayPacket::PluginMessage(_) => {}
|
C2sPlayPacket::CustomPayload(_) => {}
|
||||||
C2sPlayPacket::EditBook(_) => {}
|
C2sPlayPacket::EditBook(_) => {}
|
||||||
C2sPlayPacket::QueryEntityNbt(_) => {}
|
C2sPlayPacket::EntityTagQuery(_) => {}
|
||||||
C2sPlayPacket::InteractEntity(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) {
|
||||||
// TODO: verify that the client has line of sight to the targeted entity and
|
// TODO: verify that the client has line of sight to the targeted entity and
|
||||||
// that the distance is <=4 blocks.
|
// that the distance is <=4 blocks.
|
||||||
|
@ -451,7 +451,7 @@ impl Client {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
C2sPlayPacket::GenerateStructure(_) => {}
|
C2sPlayPacket::JigsawGenerate(_) => {}
|
||||||
C2sPlayPacket::KeepAlive(p) => {
|
C2sPlayPacket::KeepAlive(p) => {
|
||||||
let last_keepalive_id = self.last_keepalive_id;
|
let last_keepalive_id = self.last_keepalive_id;
|
||||||
if self.got_keepalive {
|
if self.got_keepalive {
|
||||||
|
@ -466,16 +466,16 @@ impl Client {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
C2sPlayPacket::LockDifficulty(_) => {}
|
C2sPlayPacket::LockDifficulty(_) => {}
|
||||||
C2sPlayPacket::PlayerPosition(p) => {
|
C2sPlayPacket::MovePlayerPosition(p) => {
|
||||||
handle_movement_packet(self, false, p.position, self.yaw, self.pitch, p.on_ground)
|
handle_movement_packet(self, false, p.position, self.yaw, self.pitch, p.on_ground)
|
||||||
}
|
}
|
||||||
C2sPlayPacket::PlayerPositionAndRotation(p) => {
|
C2sPlayPacket::MovePlayerPositionAndRotation(p) => {
|
||||||
handle_movement_packet(self, false, p.position, p.yaw, p.pitch, p.on_ground)
|
handle_movement_packet(self, false, p.position, p.yaw, p.pitch, p.on_ground)
|
||||||
}
|
}
|
||||||
C2sPlayPacket::PlayerRotation(p) => {
|
C2sPlayPacket::MovePlayerRotation(p) => {
|
||||||
handle_movement_packet(self, false, self.new_position, p.yaw, p.pitch, p.on_ground)
|
handle_movement_packet(self, false, self.new_position, p.yaw, p.pitch, p.on_ground)
|
||||||
}
|
}
|
||||||
C2sPlayPacket::PlayerMovement(p) => handle_movement_packet(
|
C2sPlayPacket::MovePlayerStatusOnly(p) => handle_movement_packet(
|
||||||
self,
|
self,
|
||||||
false,
|
false,
|
||||||
self.new_position,
|
self.new_position,
|
||||||
|
@ -483,19 +483,19 @@ impl Client {
|
||||||
self.pitch,
|
self.pitch,
|
||||||
p.on_ground,
|
p.on_ground,
|
||||||
),
|
),
|
||||||
C2sPlayPacket::VehicleMove(p) => {
|
C2sPlayPacket::MoveVehicle(p) => {
|
||||||
handle_movement_packet(self, true, p.position, p.yaw, p.pitch, self.on_ground);
|
handle_movement_packet(self, true, p.position, p.yaw, p.pitch, self.on_ground);
|
||||||
}
|
}
|
||||||
C2sPlayPacket::SteerBoat(p) => {
|
C2sPlayPacket::PaddleBoat(p) => {
|
||||||
self.events.push(Event::SteerBoat {
|
self.events.push(Event::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::PickItem(_) => {}
|
C2sPlayPacket::PickItem(_) => {}
|
||||||
C2sPlayPacket::CraftRecipeRequest(_) => {}
|
C2sPlayPacket::PlaceRecipe(_) => {}
|
||||||
C2sPlayPacket::PlayerAbilities(_) => {}
|
C2sPlayPacket::PlayerAbilities(_) => {}
|
||||||
C2sPlayPacket::PlayerDigging(p) => {
|
C2sPlayPacket::PlayerAction(p) => {
|
||||||
// TODO: verify dug block is within the correct distance from the client.
|
// TODO: verify dug block is within the correct distance from the client.
|
||||||
// TODO: verify that the broken block is allowed to be broken?
|
// TODO: verify that the broken block is allowed to be broken?
|
||||||
|
|
||||||
|
@ -525,26 +525,26 @@ impl Client {
|
||||||
DiggingStatus::SwapItemInHand => return,
|
DiggingStatus::SwapItemInHand => return,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
C2sPlayPacket::EntityAction(_) => {}
|
C2sPlayPacket::PlayerCommand(_) => {}
|
||||||
C2sPlayPacket::SteerVehicle(_) => {}
|
C2sPlayPacket::PlayerInput(_) => {}
|
||||||
C2sPlayPacket::Pong(_) => {}
|
C2sPlayPacket::Pong(_) => {}
|
||||||
C2sPlayPacket::SetRecipeBookState(_) => {}
|
C2sPlayPacket::RecipeBookChangeSettings(_) => {}
|
||||||
C2sPlayPacket::SetDisplayedRecipe(_) => {}
|
C2sPlayPacket::RecipeBookSeenRecipe(_) => {}
|
||||||
C2sPlayPacket::NameItem(_) => {}
|
C2sPlayPacket::RenameItem(_) => {}
|
||||||
C2sPlayPacket::ResourcePackStatus(_) => {}
|
C2sPlayPacket::ResourcePack(_) => {}
|
||||||
C2sPlayPacket::AdvancementTab(_) => {}
|
C2sPlayPacket::SeenAdvancements(_) => {}
|
||||||
C2sPlayPacket::SelectTrade(_) => {}
|
C2sPlayPacket::SelectTrade(_) => {}
|
||||||
C2sPlayPacket::SetBeaconEffect(_) => {}
|
C2sPlayPacket::SetBeacon(_) => {}
|
||||||
C2sPlayPacket::HeldItemChange(_) => {}
|
C2sPlayPacket::SetCarriedItem(_) => {}
|
||||||
C2sPlayPacket::UpdateCommandBlock(_) => {}
|
C2sPlayPacket::SetCommandBlock(_) => {}
|
||||||
C2sPlayPacket::UpdateCommandBlockMinecart(_) => {}
|
C2sPlayPacket::SetCommandBlockMinecart(_) => {}
|
||||||
C2sPlayPacket::CreativeInventoryAction(_) => {}
|
C2sPlayPacket::SetCreativeModeSlot(_) => {}
|
||||||
C2sPlayPacket::UpdateJigsawBlock(_) => {}
|
C2sPlayPacket::SetJigsawBlock(_) => {}
|
||||||
C2sPlayPacket::UpdateStructureBlock(_) => {}
|
C2sPlayPacket::SetStructureBlock(_) => {}
|
||||||
C2sPlayPacket::UpdateSign(_) => {}
|
C2sPlayPacket::SignUpdate(_) => {}
|
||||||
C2sPlayPacket::PlayerArmSwing(_) => {}
|
C2sPlayPacket::Swing(_) => {}
|
||||||
C2sPlayPacket::Spectate(_) => {}
|
C2sPlayPacket::TeleportToEntity(_) => {}
|
||||||
C2sPlayPacket::PlayerBlockPlacement(_) => {}
|
C2sPlayPacket::UseItemOn(_) => {}
|
||||||
C2sPlayPacket::UseItem(_) => {}
|
C2sPlayPacket::UseItem(_) => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -571,7 +571,7 @@ impl Client {
|
||||||
meta.player_list()
|
meta.player_list()
|
||||||
.initial_packets(|pkt| self.send_packet(pkt));
|
.initial_packets(|pkt| self.send_packet(pkt));
|
||||||
|
|
||||||
self.send_packet(JoinGame {
|
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: false, // TODO
|
||||||
gamemode: self.new_game_mode,
|
gamemode: self.new_game_mode,
|
||||||
|
@ -603,8 +603,8 @@ impl Client {
|
||||||
} else {
|
} else {
|
||||||
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(ChangeGameState {
|
self.send_packet(GameEvent {
|
||||||
reason: ChangeGameStateReason::ChangeGameMode,
|
reason: GameEventReason::ChangeGameMode,
|
||||||
value: self.new_game_mode as i32 as f32,
|
value: self.new_game_mode as i32 as f32,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -626,7 +626,7 @@ impl Client {
|
||||||
if self.old_max_view_distance != self.new_max_view_distance {
|
if self.old_max_view_distance != self.new_max_view_distance {
|
||||||
self.old_max_view_distance = self.new_max_view_distance;
|
self.old_max_view_distance = self.new_max_view_distance;
|
||||||
if self.created_tick != current_tick {
|
if self.created_tick != current_tick {
|
||||||
self.send_packet(UpdateViewDistance {
|
self.send_packet(SetChunkCacheRadius {
|
||||||
view_distance: BoundedInt(VarInt(self.new_max_view_distance as i32)),
|
view_distance: BoundedInt(VarInt(self.new_max_view_distance as i32)),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -655,7 +655,7 @@ impl Client {
|
||||||
let new_section = self.new_position.map(|n| (n / 16.0).floor() as i32);
|
let new_section = self.new_position.map(|n| (n / 16.0).floor() as i32);
|
||||||
|
|
||||||
if old_section != new_section {
|
if old_section != new_section {
|
||||||
self.send_packet(UpdateViewPosition {
|
self.send_packet(SetChunkCacheCenter {
|
||||||
chunk_x: VarInt(new_section.x),
|
chunk_x: VarInt(new_section.x),
|
||||||
chunk_z: VarInt(new_section.z),
|
chunk_z: VarInt(new_section.z),
|
||||||
})
|
})
|
||||||
|
@ -684,7 +684,7 @@ impl Client {
|
||||||
|
|
||||||
send_packet(
|
send_packet(
|
||||||
&mut self.send,
|
&mut self.send,
|
||||||
UnloadChunk {
|
ForgetLevelChunk {
|
||||||
chunk_x: pos.x,
|
chunk_x: pos.x,
|
||||||
chunk_z: pos.z,
|
chunk_z: pos.z,
|
||||||
},
|
},
|
||||||
|
@ -706,7 +706,7 @@ impl Client {
|
||||||
for seq in self.dug_blocks.drain(..) {
|
for seq in self.dug_blocks.drain(..) {
|
||||||
send_packet(
|
send_packet(
|
||||||
&mut self.send,
|
&mut self.send,
|
||||||
AcknowledgeBlockChanges {
|
BlockChangeAck {
|
||||||
sequence: VarInt(seq),
|
sequence: VarInt(seq),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@ -717,11 +717,11 @@ impl Client {
|
||||||
if self.teleported_this_tick {
|
if self.teleported_this_tick {
|
||||||
self.teleported_this_tick = false;
|
self.teleported_this_tick = false;
|
||||||
|
|
||||||
self.send_packet(PlayerPositionAndLook {
|
self.send_packet(PlayerPosition {
|
||||||
position: self.new_position,
|
position: self.new_position,
|
||||||
yaw: self.yaw,
|
yaw: self.yaw,
|
||||||
pitch: self.pitch,
|
pitch: self.pitch,
|
||||||
flags: PlayerPositionAndLookFlags::new(false, false, false, false, false),
|
flags: PlayerPositionFlags::new(false, false, false, false, false),
|
||||||
teleport_id: VarInt((self.teleport_id_counter - 1) as i32),
|
teleport_id: VarInt((self.teleport_id_counter - 1) as i32),
|
||||||
dismount_vehicle: false,
|
dismount_vehicle: false,
|
||||||
});
|
});
|
||||||
|
@ -729,7 +729,7 @@ impl Client {
|
||||||
|
|
||||||
for (msg, typ) in self.msgs_to_send.drain(..) {
|
for (msg, typ) in self.msgs_to_send.drain(..) {
|
||||||
// TODO: wont work without proper chat registry.
|
// TODO: wont work without proper chat registry.
|
||||||
send_packet(&mut self.send, SystemChatMessage { chat: msg, typ });
|
send_packet(&mut self.send, SystemChat { chat: msg, typ });
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut entities_to_unload = Vec::new();
|
let mut entities_to_unload = Vec::new();
|
||||||
|
@ -756,7 +756,7 @@ impl Client {
|
||||||
{
|
{
|
||||||
send_packet(
|
send_packet(
|
||||||
&mut self.send,
|
&mut self.send,
|
||||||
EntityPositionAndRotation {
|
MoveEntityPositionAndRotation {
|
||||||
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()),
|
||||||
|
@ -768,7 +768,7 @@ impl Client {
|
||||||
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,
|
||||||
EntityPosition {
|
MoveEntityPosition {
|
||||||
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(),
|
||||||
|
@ -779,7 +779,7 @@ impl Client {
|
||||||
if flags.yaw_or_pitch_modified() {
|
if flags.yaw_or_pitch_modified() {
|
||||||
send_packet(
|
send_packet(
|
||||||
&mut self.send,
|
&mut self.send,
|
||||||
EntityRotation {
|
MoveEntityRotation {
|
||||||
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()),
|
||||||
|
@ -792,7 +792,7 @@ impl Client {
|
||||||
if needs_teleport {
|
if needs_teleport {
|
||||||
send_packet(
|
send_packet(
|
||||||
&mut self.send,
|
&mut self.send,
|
||||||
EntityTeleport {
|
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()),
|
||||||
|
@ -805,7 +805,7 @@ impl Client {
|
||||||
if flags.velocity_modified() {
|
if flags.velocity_modified() {
|
||||||
send_packet(
|
send_packet(
|
||||||
&mut self.send,
|
&mut self.send,
|
||||||
EntityVelocity {
|
SetEntityMotion {
|
||||||
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()),
|
||||||
},
|
},
|
||||||
|
@ -815,7 +815,7 @@ impl Client {
|
||||||
if flags.head_yaw_modified() {
|
if flags.head_yaw_modified() {
|
||||||
send_packet(
|
send_packet(
|
||||||
&mut self.send,
|
&mut self.send,
|
||||||
EntityHeadLook {
|
RotateHead {
|
||||||
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()),
|
||||||
},
|
},
|
||||||
|
@ -831,7 +831,7 @@ impl Client {
|
||||||
});
|
});
|
||||||
|
|
||||||
if !entities_to_unload.is_empty() {
|
if !entities_to_unload.is_empty() {
|
||||||
self.send_packet(DestroyEntities {
|
self.send_packet(RemoveEntities {
|
||||||
entities: entities_to_unload,
|
entities: entities_to_unload,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -843,7 +843,7 @@ impl Client {
|
||||||
if !data.is_empty() {
|
if !data.is_empty() {
|
||||||
data.push(0xff);
|
data.push(0xff);
|
||||||
|
|
||||||
self.send_packet(EntityMetadata {
|
self.send_packet(SetEntityMetadata {
|
||||||
entity_id: VarInt(0),
|
entity_id: VarInt(0),
|
||||||
metadata: RawBytes(data),
|
metadata: RawBytes(data),
|
||||||
});
|
});
|
||||||
|
|
|
@ -13,7 +13,7 @@ use uuid::Uuid;
|
||||||
use vek::{Aabb, Vec3};
|
use vek::{Aabb, Vec3};
|
||||||
|
|
||||||
use crate::protocol::packets::play::s2c::{
|
use crate::protocol::packets::play::s2c::{
|
||||||
EntityMetadata, S2cPlayPacket, SpawnEntity, SpawnExperienceOrb, SpawnPlayer,
|
AddEntity, AddExperienceOrb, AddPlayer, S2cPlayPacket, SetEntityMetadata,
|
||||||
};
|
};
|
||||||
use crate::protocol::{ByteAngle, RawBytes, VarInt};
|
use crate::protocol::{ByteAngle, RawBytes, VarInt};
|
||||||
use crate::slotmap::{Key, SlotMap};
|
use crate::slotmap::{Key, SlotMap};
|
||||||
|
@ -307,8 +307,8 @@ impl Entity {
|
||||||
/// spawned.
|
/// spawned.
|
||||||
///
|
///
|
||||||
/// Is `None` if there is no initial metadata.
|
/// Is `None` if there is no initial metadata.
|
||||||
pub(crate) fn initial_metadata_packet(&self, this_id: EntityId) -> Option<EntityMetadata> {
|
pub(crate) fn initial_metadata_packet(&self, this_id: EntityId) -> Option<SetEntityMetadata> {
|
||||||
self.meta.initial_metadata().map(|meta| EntityMetadata {
|
self.meta.initial_metadata().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),
|
||||||
})
|
})
|
||||||
|
@ -317,8 +317,8 @@ impl Entity {
|
||||||
/// Gets the metadata packet to send to clients when the entity is modified.
|
/// Gets the metadata packet to send to clients when the entity is modified.
|
||||||
///
|
///
|
||||||
/// Is `None` if this entity's metadata has not been modified.
|
/// Is `None` if this entity's metadata has not been modified.
|
||||||
pub(crate) fn updated_metadata_packet(&self, this_id: EntityId) -> Option<EntityMetadata> {
|
pub(crate) fn updated_metadata_packet(&self, this_id: EntityId) -> Option<SetEntityMetadata> {
|
||||||
self.meta.updated_metadata().map(|meta| EntityMetadata {
|
self.meta.updated_metadata().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),
|
||||||
})
|
})
|
||||||
|
@ -328,20 +328,20 @@ impl Entity {
|
||||||
match &self.meta {
|
match &self.meta {
|
||||||
EntityMeta::Marker(_) => None,
|
EntityMeta::Marker(_) => None,
|
||||||
EntityMeta::ExperienceOrb(_) => {
|
EntityMeta::ExperienceOrb(_) => {
|
||||||
Some(EntitySpawnPacket::SpawnExperienceOrb(SpawnExperienceOrb {
|
Some(EntitySpawnPacket::SpawnExperienceOrb(AddExperienceOrb {
|
||||||
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
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
EntityMeta::Player(_) => Some(EntitySpawnPacket::SpawnPlayer(SpawnPlayer {
|
EntityMeta::Player(_) => Some(EntitySpawnPacket::SpawnPlayer(AddPlayer {
|
||||||
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::SpawnEntity(SpawnEntity {
|
_ => Some(EntitySpawnPacket::SpawnEntity(AddEntity {
|
||||||
entity_id: VarInt(this_id.to_network_id()),
|
entity_id: VarInt(this_id.to_network_id()),
|
||||||
object_uuid: self.uuid,
|
object_uuid: self.uuid,
|
||||||
typ: VarInt(self.typ() as i32),
|
typ: VarInt(self.typ() as i32),
|
||||||
|
@ -505,9 +505,9 @@ pub(crate) fn velocity_to_packet_units(vel: Vec3<f32>) -> Vec3<i16> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) enum EntitySpawnPacket {
|
pub(crate) enum EntitySpawnPacket {
|
||||||
SpawnEntity(SpawnEntity),
|
SpawnEntity(AddEntity),
|
||||||
SpawnExperienceOrb(SpawnExperienceOrb),
|
SpawnExperienceOrb(AddExperienceOrb),
|
||||||
SpawnPlayer(SpawnPlayer),
|
SpawnPlayer(AddPlayer),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<EntitySpawnPacket> for S2cPlayPacket {
|
impl From<EntitySpawnPacket> for S2cPlayPacket {
|
||||||
|
|
|
@ -7,7 +7,7 @@ use uuid::Uuid;
|
||||||
use crate::client::GameMode;
|
use crate::client::GameMode;
|
||||||
use crate::player_textures::SignedPlayerTextures;
|
use crate::player_textures::SignedPlayerTextures;
|
||||||
use crate::protocol::packets::play::s2c::{
|
use crate::protocol::packets::play::s2c::{
|
||||||
PlayerInfo, PlayerInfoAddPlayer, PlayerListHeaderFooter, S2cPlayPacket,
|
PlayerInfo, PlayerInfoAddPlayer, S2cPlayPacket, TabList,
|
||||||
};
|
};
|
||||||
use crate::protocol::packets::Property;
|
use crate::protocol::packets::Property;
|
||||||
use crate::protocol::VarInt;
|
use crate::protocol::VarInt;
|
||||||
|
@ -148,7 +148,7 @@ impl PlayerList {
|
||||||
|
|
||||||
if self.header != Text::default() || self.footer != Text::default() {
|
if self.header != Text::default() || self.footer != Text::default() {
|
||||||
packet(
|
packet(
|
||||||
PlayerListHeaderFooter {
|
TabList {
|
||||||
header: self.header.clone(),
|
header: self.header.clone(),
|
||||||
footer: self.footer.clone(),
|
footer: self.footer.clone(),
|
||||||
}
|
}
|
||||||
|
@ -222,7 +222,7 @@ impl PlayerList {
|
||||||
|
|
||||||
if self.modified_header_or_footer {
|
if self.modified_header_or_footer {
|
||||||
packet(
|
packet(
|
||||||
PlayerListHeaderFooter {
|
TabList {
|
||||||
header: self.header.clone(),
|
header: self.header.clone(),
|
||||||
footer: self.footer.clone(),
|
footer: self.footer.clone(),
|
||||||
}
|
}
|
||||||
|
|
|
@ -372,7 +372,7 @@ pub mod status {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
Pong 0x01 {
|
PongResponse 0x01 {
|
||||||
/// Should be the same as the payload from [`Ping`].
|
/// Should be the same as the payload from [`Ping`].
|
||||||
payload: u64
|
payload: u64
|
||||||
}
|
}
|
||||||
|
@ -383,11 +383,11 @@ pub mod status {
|
||||||
use super::super::*;
|
use super::super::*;
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
Request 0x00 {}
|
StatusRequest 0x00 {}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
Ping 0x01 {
|
PingRequest 0x01 {
|
||||||
payload: u64
|
payload: u64
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -469,7 +469,7 @@ pub mod play {
|
||||||
use super::super::*;
|
use super::super::*;
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
SpawnEntity 0x00 {
|
AddEntity 0x00 {
|
||||||
entity_id: VarInt,
|
entity_id: VarInt,
|
||||||
object_uuid: Uuid,
|
object_uuid: Uuid,
|
||||||
typ: VarInt,
|
typ: VarInt,
|
||||||
|
@ -483,24 +483,15 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
SpawnExperienceOrb 0x01 {
|
AddExperienceOrb 0x01 {
|
||||||
entity_id: VarInt,
|
entity_id: VarInt,
|
||||||
position: Vec3<f64>,
|
position: Vec3<f64>,
|
||||||
count: i16,
|
count: i16,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_enum! {
|
|
||||||
PaintingDirection: u8 {
|
|
||||||
South = 0,
|
|
||||||
West = 1,
|
|
||||||
North = 2,
|
|
||||||
East = 3,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
SpawnPlayer 0x02 {
|
AddPlayer 0x02 {
|
||||||
entity_id: VarInt,
|
entity_id: VarInt,
|
||||||
player_uuid: Uuid,
|
player_uuid: Uuid,
|
||||||
position: Vec3<f64>,
|
position: Vec3<f64>,
|
||||||
|
@ -510,7 +501,7 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
EntityAnimation 0x03 {
|
Animate 0x03 {
|
||||||
entity_id: VarInt,
|
entity_id: VarInt,
|
||||||
animation: Animation,
|
animation: Animation,
|
||||||
}
|
}
|
||||||
|
@ -528,13 +519,13 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
AcknowledgeBlockChanges 0x05 {
|
BlockChangeAck 0x05 {
|
||||||
sequence: VarInt,
|
sequence: VarInt,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
BlockBreakAnimation 0x06 {
|
BlockDestruction 0x06 {
|
||||||
entity_id: VarInt,
|
entity_id: VarInt,
|
||||||
location: BlockPos,
|
location: BlockPos,
|
||||||
destroy_stage: BoundedInt<u8, 0, 10>,
|
destroy_stage: BoundedInt<u8, 0, 10>,
|
||||||
|
@ -550,49 +541,48 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
BlockAction 0x08 {
|
BlockEvent 0x08 {
|
||||||
location: BlockPos,
|
location: BlockPos,
|
||||||
action_id: u8,
|
action_id: u8,
|
||||||
action_param: u8,
|
action_param: u8,
|
||||||
block_type: VarInt,
|
block_type: VarInt, // TODO: use BlockType type.
|
||||||
// TODO: sequence?
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
BlockChange 0x09 {
|
BlockUpdate 0x09 {
|
||||||
location: BlockPos,
|
location: BlockPos,
|
||||||
block_id: VarInt,
|
block_id: VarInt,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
BossBar 0x0a {
|
BossEvent 0x0a {
|
||||||
uuid: Uuid,
|
uuid: Uuid,
|
||||||
action: BossBarAction,
|
action: BossEventAction,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_enum! {
|
def_enum! {
|
||||||
BossBarAction: VarInt {
|
BossEventAction: VarInt {
|
||||||
Add: BossBarActionAdd = 0,
|
Add: BossEventActionAdd = 0,
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
BossBarActionAdd {
|
BossEventActionAdd {
|
||||||
title: Text,
|
title: Text,
|
||||||
health: f32,
|
health: f32,
|
||||||
color: BossBarColor,
|
color: BossEventColor,
|
||||||
division: BossBarDivision,
|
division: BossEventDivision,
|
||||||
/// TODO: bitmask
|
/// TODO: bitmask
|
||||||
flags: u8,
|
flags: u8,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_enum! {
|
def_enum! {
|
||||||
BossBarColor: VarInt {
|
BossEventColor: VarInt {
|
||||||
Pink = 0,
|
Pink = 0,
|
||||||
Blue = 1,
|
Blue = 1,
|
||||||
Red = 2,
|
Red = 2,
|
||||||
|
@ -604,7 +594,7 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_enum! {
|
def_enum! {
|
||||||
BossBarDivision: VarInt {
|
BossEventDivision: VarInt {
|
||||||
NoDivision = 0,
|
NoDivision = 0,
|
||||||
SixNotches = 1,
|
SixNotches = 1,
|
||||||
TenNotches = 2,
|
TenNotches = 2,
|
||||||
|
@ -614,7 +604,7 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
ServerDifficulty 0x0b {
|
ChangeDifficulty 0x0b {
|
||||||
difficulty: Difficulty,
|
difficulty: Difficulty,
|
||||||
locked: bool,
|
locked: bool,
|
||||||
}
|
}
|
||||||
|
@ -629,51 +619,6 @@ pub mod play {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
|
||||||
ClearTitles 0x0d {
|
|
||||||
reset: bool,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def_struct! {
|
|
||||||
TabComplete 0x0e {
|
|
||||||
id: VarInt,
|
|
||||||
start: VarInt,
|
|
||||||
length: VarInt,
|
|
||||||
matches: Vec<TabCompleteMatch>,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def_struct! {
|
|
||||||
TabCompleteMatch {
|
|
||||||
value: String,
|
|
||||||
tooltip: TabCompleteTooltip,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def_enum! {
|
|
||||||
TabCompleteTooltip: u8 {
|
|
||||||
NoTooltip = 0,
|
|
||||||
Tooltip: Text = 1,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def_struct! {
|
|
||||||
WindowProperty 0x12 {
|
|
||||||
// TODO: use enums
|
|
||||||
window_id: u8,
|
|
||||||
property: i16,
|
|
||||||
value: i16,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def_struct! {
|
|
||||||
SetCooldown 0x14 {
|
|
||||||
item_id: VarInt,
|
|
||||||
cooldown_ticks: VarInt,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
Disconnect 0x17 {
|
Disconnect 0x17 {
|
||||||
reason: Text,
|
reason: Text,
|
||||||
|
@ -681,7 +626,7 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
EntityStatus 0x18 {
|
EntityEvent 0x18 {
|
||||||
entity_id: i32,
|
entity_id: i32,
|
||||||
/// TODO: enum
|
/// TODO: enum
|
||||||
entity_status: u8,
|
entity_status: u8,
|
||||||
|
@ -689,21 +634,21 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
UnloadChunk 0x1a {
|
ForgetLevelChunk 0x1a {
|
||||||
chunk_x: i32,
|
chunk_x: i32,
|
||||||
chunk_z: i32
|
chunk_z: i32
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
ChangeGameState 0x1b {
|
GameEvent 0x1b {
|
||||||
reason: ChangeGameStateReason,
|
reason: GameEventReason,
|
||||||
value: f32,
|
value: f32,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_enum! {
|
def_enum! {
|
||||||
ChangeGameStateReason: u8 {
|
GameEventReason: u8 {
|
||||||
NoRespawnBlockAvailable = 0,
|
NoRespawnBlockAvailable = 0,
|
||||||
EndRaining = 1,
|
EndRaining = 1,
|
||||||
BeginRaining = 2,
|
BeginRaining = 2,
|
||||||
|
@ -719,14 +664,6 @@ pub mod play {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
|
||||||
OpenHorseWindow 0x1c {
|
|
||||||
window_id: u8,
|
|
||||||
slot_count: VarInt,
|
|
||||||
entity_id: i32,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
InitializeWorldBorder 0x1d {
|
InitializeWorldBorder 0x1d {
|
||||||
x: f64,
|
x: f64,
|
||||||
|
@ -747,12 +684,12 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
ChunkDataAndUpdateLight 0x1f {
|
LevelChunkWithLight 0x1f {
|
||||||
chunk_x: i32,
|
chunk_x: i32,
|
||||||
chunk_z: i32,
|
chunk_z: i32,
|
||||||
heightmaps: Nbt<ChunkDataHeightmaps>,
|
heightmaps: Nbt<LevelChunkHeightmaps>,
|
||||||
blocks_and_biomes: Vec<u8>,
|
blocks_and_biomes: Vec<u8>,
|
||||||
block_entities: Vec<ChunkDataBlockEntity>,
|
block_entities: Vec<LevelChunkBlockEntity>,
|
||||||
trust_edges: bool,
|
trust_edges: bool,
|
||||||
sky_light_mask: BitVec<u64>,
|
sky_light_mask: BitVec<u64>,
|
||||||
block_light_mask: BitVec<u64>,
|
block_light_mask: BitVec<u64>,
|
||||||
|
@ -764,13 +701,13 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||||
pub struct ChunkDataHeightmaps {
|
pub struct LevelChunkHeightmaps {
|
||||||
#[serde(rename = "MOTION_BLOCKING", serialize_with = "nbt::i64_array")]
|
#[serde(rename = "MOTION_BLOCKING", serialize_with = "nbt::i64_array")]
|
||||||
pub motion_blocking: Vec<i64>,
|
pub motion_blocking: Vec<i64>,
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
ChunkDataBlockEntity {
|
LevelChunkBlockEntity {
|
||||||
packed_xz: i8,
|
packed_xz: i8,
|
||||||
y: i16,
|
y: i16,
|
||||||
typ: VarInt,
|
typ: VarInt,
|
||||||
|
@ -779,7 +716,7 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
JoinGame 0x23 {
|
Login 0x23 {
|
||||||
/// Entity ID of the joining player
|
/// Entity ID of the joining player
|
||||||
entity_id: i32,
|
entity_id: i32,
|
||||||
is_hardcore: bool,
|
is_hardcore: bool,
|
||||||
|
@ -955,7 +892,7 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
EntityPosition 0x26 {
|
MoveEntityPosition 0x26 {
|
||||||
entity_id: VarInt,
|
entity_id: VarInt,
|
||||||
delta: Vec3<i16>,
|
delta: Vec3<i16>,
|
||||||
on_ground: bool,
|
on_ground: bool,
|
||||||
|
@ -963,7 +900,7 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
EntityPositionAndRotation 0x27 {
|
MoveEntityPositionAndRotation 0x27 {
|
||||||
entity_id: VarInt,
|
entity_id: VarInt,
|
||||||
delta: Vec3<i16>,
|
delta: Vec3<i16>,
|
||||||
yaw: ByteAngle,
|
yaw: ByteAngle,
|
||||||
|
@ -973,7 +910,7 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
EntityRotation 0x28 {
|
MoveEntityRotation 0x28 {
|
||||||
entity_id: VarInt,
|
entity_id: VarInt,
|
||||||
yaw: ByteAngle,
|
yaw: ByteAngle,
|
||||||
pitch: ByteAngle,
|
pitch: ByteAngle,
|
||||||
|
@ -982,9 +919,9 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
ChatMessage 0x30 {
|
PlayerChat 0x30 {
|
||||||
message: Text,
|
message: Text,
|
||||||
typ: ChatMessageType,
|
typ: PlayerChatType,
|
||||||
sender: Uuid,
|
sender: Uuid,
|
||||||
// TODO more fields
|
// TODO more fields
|
||||||
}
|
}
|
||||||
|
@ -992,7 +929,7 @@ pub mod play {
|
||||||
|
|
||||||
def_enum! {
|
def_enum! {
|
||||||
#[derive(Copy, PartialEq, Eq, Default)]
|
#[derive(Copy, PartialEq, Eq, Default)]
|
||||||
ChatMessageType: VarInt {
|
PlayerChatType: VarInt {
|
||||||
#[default]
|
#[default]
|
||||||
Chat = 0,
|
Chat = 0,
|
||||||
SystemMessage = 1,
|
SystemMessage = 1,
|
||||||
|
@ -1028,18 +965,18 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
PlayerPositionAndLook 0x36 {
|
PlayerPosition 0x36 {
|
||||||
position: Vec3<f64>,
|
position: Vec3<f64>,
|
||||||
yaw: f32,
|
yaw: f32,
|
||||||
pitch: f32,
|
pitch: f32,
|
||||||
flags: PlayerPositionAndLookFlags,
|
flags: PlayerPositionFlags,
|
||||||
teleport_id: VarInt,
|
teleport_id: VarInt,
|
||||||
dismount_vehicle: bool,
|
dismount_vehicle: bool,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_bitfield! {
|
def_bitfield! {
|
||||||
PlayerPositionAndLookFlags: u8 {
|
PlayerPositionFlags: u8 {
|
||||||
x = 0,
|
x = 0,
|
||||||
y = 1,
|
y = 1,
|
||||||
z = 2,
|
z = 2,
|
||||||
|
@ -1049,20 +986,20 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
DestroyEntities 0x38 {
|
RemoveEntities 0x38 {
|
||||||
entities: Vec<VarInt>,
|
entities: Vec<VarInt>,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
EntityHeadLook 0x3c {
|
RotateHead 0x3c {
|
||||||
entity_id: VarInt,
|
entity_id: VarInt,
|
||||||
head_yaw: ByteAngle,
|
head_yaw: ByteAngle,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
MultiBlockChange 0x3d {
|
SectionBlocksUpdate 0x3d {
|
||||||
chunk_section_position: i64,
|
chunk_section_position: i64,
|
||||||
invert_trust_edges: bool,
|
invert_trust_edges: bool,
|
||||||
blocks: Vec<VarLong>,
|
blocks: Vec<VarLong>,
|
||||||
|
@ -1070,20 +1007,20 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
HeldItemChange 0x47 {
|
SetCarriedItem 0x47 {
|
||||||
slot: BoundedInt<u8, 0, 9>,
|
slot: BoundedInt<u8, 0, 9>,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
UpdateViewPosition 0x48 {
|
SetChunkCacheCenter 0x48 {
|
||||||
chunk_x: VarInt,
|
chunk_x: VarInt,
|
||||||
chunk_z: VarInt,
|
chunk_z: VarInt,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
UpdateViewDistance 0x49 {
|
SetChunkCacheRadius 0x49 {
|
||||||
view_distance: BoundedInt<VarInt, 2, 32>,
|
view_distance: BoundedInt<VarInt, 2, 32>,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1096,21 +1033,21 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
EntityMetadata 0x4d {
|
SetEntityMetadata 0x4d {
|
||||||
entity_id: VarInt,
|
entity_id: VarInt,
|
||||||
metadata: RawBytes,
|
metadata: RawBytes,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
EntityVelocity 0x4f {
|
SetEntityMotion 0x4f {
|
||||||
entity_id: VarInt,
|
entity_id: VarInt,
|
||||||
velocity: Vec3<i16>,
|
velocity: Vec3<i16>,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
TimeUpdate 0x59 {
|
SetTime 0x59 {
|
||||||
/// 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.
|
||||||
|
@ -1121,21 +1058,21 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
SystemChatMessage 0x5f {
|
SystemChat 0x5f {
|
||||||
chat: Text,
|
chat: Text,
|
||||||
typ: ChatMessageType,
|
typ: PlayerChatType,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
PlayerListHeaderFooter 0x60 {
|
TabList 0x60 {
|
||||||
header: Text,
|
header: Text,
|
||||||
footer: Text,
|
footer: Text,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
EntityTeleport 0x63 {
|
TeleportEntity 0x63 {
|
||||||
entity_id: VarInt,
|
entity_id: VarInt,
|
||||||
position: Vec3<f64>,
|
position: Vec3<f64>,
|
||||||
yaw: ByteAngle,
|
yaw: ByteAngle,
|
||||||
|
@ -1200,42 +1137,42 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_s2c_play_packet_enum! {
|
def_s2c_play_packet_enum! {
|
||||||
SpawnEntity,
|
AddEntity,
|
||||||
SpawnExperienceOrb,
|
AddExperienceOrb,
|
||||||
SpawnPlayer,
|
AddPlayer,
|
||||||
EntityAnimation,
|
Animate,
|
||||||
AcknowledgeBlockChanges,
|
BlockChangeAck,
|
||||||
BlockBreakAnimation,
|
BlockDestruction,
|
||||||
BlockEntityData,
|
BlockEntityData,
|
||||||
BlockAction,
|
BlockEvent,
|
||||||
BlockChange,
|
BlockUpdate,
|
||||||
BossBar,
|
BossEvent,
|
||||||
Disconnect,
|
Disconnect,
|
||||||
EntityStatus,
|
EntityEvent,
|
||||||
UnloadChunk,
|
ForgetLevelChunk,
|
||||||
ChangeGameState,
|
GameEvent,
|
||||||
KeepAlive,
|
KeepAlive,
|
||||||
ChunkDataAndUpdateLight,
|
LevelChunkWithLight,
|
||||||
JoinGame,
|
Login,
|
||||||
EntityPosition,
|
MoveEntityPosition,
|
||||||
EntityPositionAndRotation,
|
MoveEntityPositionAndRotation,
|
||||||
EntityRotation,
|
MoveEntityRotation,
|
||||||
ChatMessage,
|
PlayerChat,
|
||||||
PlayerInfo,
|
PlayerInfo,
|
||||||
PlayerPositionAndLook,
|
PlayerPosition,
|
||||||
DestroyEntities,
|
RemoveEntities,
|
||||||
EntityHeadLook,
|
RotateHead,
|
||||||
MultiBlockChange,
|
SectionBlocksUpdate,
|
||||||
HeldItemChange,
|
SetCarriedItem,
|
||||||
UpdateViewPosition,
|
SetChunkCacheCenter,
|
||||||
UpdateViewDistance,
|
SetChunkCacheRadius,
|
||||||
SpawnPosition,
|
SpawnPosition,
|
||||||
EntityMetadata,
|
SetEntityMetadata,
|
||||||
EntityVelocity,
|
SetEntityMotion,
|
||||||
TimeUpdate,
|
SetTime,
|
||||||
SystemChatMessage,
|
SystemChat,
|
||||||
PlayerListHeaderFooter,
|
TabList,
|
||||||
EntityTeleport,
|
TeleportEntity,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1243,20 +1180,20 @@ pub mod play {
|
||||||
use super::super::*;
|
use super::super::*;
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
TeleportConfirm 0x00 {
|
AcceptTeleportation 0x00 {
|
||||||
teleport_id: VarInt
|
teleport_id: VarInt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
QueryBlockNbt 0x01 {
|
BlockEntityTagQuery 0x01 {
|
||||||
transaction_id: VarInt,
|
transaction_id: VarInt,
|
||||||
location: BlockPos,
|
location: BlockPos,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_enum! {
|
def_enum! {
|
||||||
SetDifficulty 0x02: i8 {
|
ChangeDifficulty 0x02: i8 {
|
||||||
Peaceful = 0,
|
Peaceful = 0,
|
||||||
Easy = 1,
|
Easy = 1,
|
||||||
Normal = 2,
|
Normal = 2,
|
||||||
|
@ -1273,7 +1210,7 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
ChatMessage 0x04 {
|
Chat 0x04 {
|
||||||
message: BoundedString<0, 256>,
|
message: BoundedString<0, 256>,
|
||||||
timestamp: u64,
|
timestamp: u64,
|
||||||
salt: u64,
|
salt: u64,
|
||||||
|
@ -1290,7 +1227,7 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_enum! {
|
def_enum! {
|
||||||
ClientStatus 0x06: VarInt {
|
ClientCommand 0x06: 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.
|
||||||
|
@ -1299,7 +1236,7 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
ClientSettings 0x07 {
|
ClientInformation 0x07 {
|
||||||
/// 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.
|
||||||
|
@ -1345,7 +1282,7 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
TabComplete 0x08 {
|
CommandSuggestion 0x08 {
|
||||||
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>
|
||||||
|
@ -1353,20 +1290,20 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
ClickWindowButton 0x09 {
|
ContainerButtonClick 0x09 {
|
||||||
window_id: i8,
|
window_id: i8,
|
||||||
button_id: i8,
|
button_id: i8,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
CloseWindow 0x0b {
|
ContainerClose 0x0b {
|
||||||
window_id: u8,
|
window_id: u8,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
PluginMessage 0x0c {
|
CustomPayload 0x0c {
|
||||||
channel: Ident,
|
channel: Ident,
|
||||||
data: RawBytes,
|
data: RawBytes,
|
||||||
}
|
}
|
||||||
|
@ -1381,14 +1318,14 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
QueryEntityNbt 0x0e {
|
EntityTagQuery 0x0e {
|
||||||
transaction_id: VarInt,
|
transaction_id: VarInt,
|
||||||
entity_id: VarInt,
|
entity_id: VarInt,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
InteractEntity 0x0f {
|
Interact 0x0f {
|
||||||
entity_id: VarInt,
|
entity_id: VarInt,
|
||||||
typ: InteractType,
|
typ: InteractType,
|
||||||
sneaking: bool,
|
sneaking: bool,
|
||||||
|
@ -1412,7 +1349,7 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
GenerateStructure 0x10 {
|
JigsawGenerate 0x10 {
|
||||||
location: BlockPos,
|
location: BlockPos,
|
||||||
levels: VarInt,
|
levels: VarInt,
|
||||||
keep_jigsaws: bool,
|
keep_jigsaws: bool,
|
||||||
|
@ -1432,14 +1369,14 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
PlayerPosition 0x13 {
|
MovePlayerPosition 0x13 {
|
||||||
position: Vec3<f64>,
|
position: Vec3<f64>,
|
||||||
on_ground: bool,
|
on_ground: bool,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
PlayerPositionAndRotation 0x14 {
|
MovePlayerPositionAndRotation 0x14 {
|
||||||
// Absolute position
|
// Absolute position
|
||||||
position: Vec3<f64>,
|
position: Vec3<f64>,
|
||||||
/// Absolute rotation on X axis in degrees.
|
/// Absolute rotation on X axis in degrees.
|
||||||
|
@ -1451,7 +1388,7 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
PlayerRotation 0x15 {
|
MovePlayerRotation 0x15 {
|
||||||
/// 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.
|
||||||
|
@ -1461,13 +1398,13 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
PlayerMovement 0x16 {
|
MovePlayerStatusOnly 0x16 {
|
||||||
on_ground: bool
|
on_ground: bool
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
VehicleMove 0x17 {
|
MoveVehicle 0x17 {
|
||||||
/// Absolute position
|
/// Absolute position
|
||||||
position: Vec3<f64>,
|
position: Vec3<f64>,
|
||||||
/// Degrees
|
/// Degrees
|
||||||
|
@ -1478,7 +1415,7 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
SteerBoat 0x18 {
|
PaddleBoat 0x18 {
|
||||||
left_paddle_turning: bool,
|
left_paddle_turning: bool,
|
||||||
right_paddle_turning: bool,
|
right_paddle_turning: bool,
|
||||||
}
|
}
|
||||||
|
@ -1491,7 +1428,7 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
CraftRecipeRequest 0x1a {
|
PlaceRecipe 0x1a {
|
||||||
window_id: i8,
|
window_id: i8,
|
||||||
recipe: Ident,
|
recipe: Ident,
|
||||||
make_all: bool,
|
make_all: bool,
|
||||||
|
@ -1506,7 +1443,7 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
PlayerDigging 0x1c {
|
PlayerAction 0x1c {
|
||||||
status: DiggingStatus,
|
status: DiggingStatus,
|
||||||
location: BlockPos,
|
location: BlockPos,
|
||||||
face: BlockFace,
|
face: BlockFace,
|
||||||
|
@ -1545,15 +1482,15 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
EntityAction 0x1d {
|
PlayerCommand 0x1d {
|
||||||
entity_id: VarInt,
|
entity_id: VarInt,
|
||||||
action_id: EntityActionId,
|
action_id: PlayerCommandId,
|
||||||
jump_boost: BoundedInt<VarInt, 0, 100>,
|
jump_boost: BoundedInt<VarInt, 0, 100>,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_enum! {
|
def_enum! {
|
||||||
EntityActionId: VarInt {
|
PlayerCommandId: VarInt {
|
||||||
StartSneaking = 0,
|
StartSneaking = 0,
|
||||||
StopSneaking = 1,
|
StopSneaking = 1,
|
||||||
LeaveBed = 2,
|
LeaveBed = 2,
|
||||||
|
@ -1567,15 +1504,15 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
SteerVehicle 0x1e {
|
PlayerInput 0x1e {
|
||||||
sideways: f32,
|
sideways: f32,
|
||||||
forward: f32,
|
forward: f32,
|
||||||
flags: SteerVehicleFlags,
|
flags: PlayerInputFlags,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_bitfield! {
|
def_bitfield! {
|
||||||
SteerVehicleFlags: u8 {
|
PlayerInputFlags: u8 {
|
||||||
jump = 0,
|
jump = 0,
|
||||||
unmount = 1,
|
unmount = 1,
|
||||||
}
|
}
|
||||||
|
@ -1588,7 +1525,7 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
SetRecipeBookState 0x20 {
|
RecipeBookChangeSettings 0x20 {
|
||||||
book_id: RecipeBookId,
|
book_id: RecipeBookId,
|
||||||
book_open: bool,
|
book_open: bool,
|
||||||
filter_active: bool,
|
filter_active: bool,
|
||||||
|
@ -1605,19 +1542,19 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
SetDisplayedRecipe 0x21 {
|
RecipeBookSeenRecipe 0x21 {
|
||||||
recipe_id: Ident,
|
recipe_id: Ident,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
NameItem 0x22 {
|
RenameItem 0x22 {
|
||||||
item_name: BoundedString<0, 50>,
|
item_name: BoundedString<0, 50>,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_enum! {
|
def_enum! {
|
||||||
ResourcePackStatus 0x23: VarInt {
|
ResourcePack 0x23: VarInt {
|
||||||
SuccessfullyLoaded = 0,
|
SuccessfullyLoaded = 0,
|
||||||
Declined = 1,
|
Declined = 1,
|
||||||
FailedDownload = 2,
|
FailedDownload = 2,
|
||||||
|
@ -1626,7 +1563,7 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_enum! {
|
def_enum! {
|
||||||
AdvancementTab 0x24: VarInt {
|
SeenAdvancements 0x24: VarInt {
|
||||||
OpenedTab: Ident = 0,
|
OpenedTab: Ident = 0,
|
||||||
ClosedScreen = 1,
|
ClosedScreen = 1,
|
||||||
}
|
}
|
||||||
|
@ -1639,7 +1576,7 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
SetBeaconEffect 0x26 {
|
SetBeacon 0x26 {
|
||||||
// TODO: potion ids
|
// TODO: potion ids
|
||||||
primary_effect: Option<VarInt>,
|
primary_effect: Option<VarInt>,
|
||||||
secondary_effect: Option<VarInt>,
|
secondary_effect: Option<VarInt>,
|
||||||
|
@ -1647,13 +1584,13 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
HeldItemChange 0x27 {
|
SetCarriedItem 0x27 {
|
||||||
slot: BoundedInt<i16, 0, 8>,
|
slot: BoundedInt<i16, 0, 8>,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
UpdateCommandBlock 0x28 {
|
SetCommandBlock 0x28 {
|
||||||
location: BlockPos,
|
location: BlockPos,
|
||||||
command: String,
|
command: String,
|
||||||
mode: CommandBlockMode,
|
mode: CommandBlockMode,
|
||||||
|
@ -1678,7 +1615,7 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
UpdateCommandBlockMinecart 0x29 {
|
SetCommandBlockMinecart 0x29 {
|
||||||
entity_id: VarInt,
|
entity_id: VarInt,
|
||||||
command: String,
|
command: String,
|
||||||
track_output: bool,
|
track_output: bool,
|
||||||
|
@ -1686,14 +1623,14 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
CreativeInventoryAction 0x2a {
|
SetCreativeModeSlot 0x2a {
|
||||||
slot: i16,
|
slot: i16,
|
||||||
// TODO: clicked_item: Slot,
|
// TODO: clicked_item: Slot,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
UpdateJigsawBlock 0x2b {
|
SetJigsawBlock 0x2b {
|
||||||
location: BlockPos,
|
location: BlockPos,
|
||||||
name: Ident,
|
name: Ident,
|
||||||
target: Ident,
|
target: Ident,
|
||||||
|
@ -1704,7 +1641,7 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
UpdateStructureBlock 0x2c {
|
SetStructureBlock 0x2c {
|
||||||
location: BlockPos,
|
location: BlockPos,
|
||||||
action: StructureBlockAction,
|
action: StructureBlockAction,
|
||||||
mode: StructureBlockMode,
|
mode: StructureBlockMode,
|
||||||
|
@ -1764,26 +1701,26 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
UpdateSign 0x2d {
|
SignUpdate 0x2d {
|
||||||
location: BlockPos,
|
location: BlockPos,
|
||||||
lines: [BoundedString<0, 384>; 4],
|
lines: [BoundedString<0, 384>; 4],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
PlayerArmSwing 0x2e {
|
Swing 0x2e {
|
||||||
hand: Hand,
|
hand: Hand,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
Spectate 0x2f {
|
TeleportToEntity 0x2f {
|
||||||
target: Uuid,
|
target: Uuid,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
PlayerBlockPlacement 0x30 {
|
UseItemOn 0x30 {
|
||||||
hand: Hand,
|
hand: Hand,
|
||||||
location: BlockPos,
|
location: BlockPos,
|
||||||
face: BlockFace,
|
face: BlockFace,
|
||||||
|
@ -1849,54 +1786,54 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_c2s_play_packet_enum! {
|
def_c2s_play_packet_enum! {
|
||||||
TeleportConfirm,
|
AcceptTeleportation,
|
||||||
QueryBlockNbt,
|
BlockEntityTagQuery,
|
||||||
SetDifficulty,
|
ChangeDifficulty,
|
||||||
ChatCommand,
|
ChatCommand,
|
||||||
ChatMessage,
|
Chat,
|
||||||
ChatPreview,
|
ChatPreview,
|
||||||
ClientStatus,
|
ClientCommand,
|
||||||
ClientSettings,
|
ClientInformation,
|
||||||
TabComplete,
|
CommandSuggestion,
|
||||||
ClickWindowButton,
|
ContainerButtonClick,
|
||||||
CloseWindow,
|
ContainerClose,
|
||||||
PluginMessage,
|
CustomPayload,
|
||||||
EditBook,
|
EditBook,
|
||||||
QueryEntityNbt,
|
EntityTagQuery,
|
||||||
InteractEntity,
|
Interact,
|
||||||
GenerateStructure,
|
JigsawGenerate,
|
||||||
KeepAlive,
|
KeepAlive,
|
||||||
LockDifficulty,
|
LockDifficulty,
|
||||||
PlayerPosition,
|
MovePlayerPosition,
|
||||||
PlayerPositionAndRotation,
|
MovePlayerPositionAndRotation,
|
||||||
PlayerRotation,
|
MovePlayerRotation,
|
||||||
PlayerMovement,
|
MovePlayerStatusOnly,
|
||||||
VehicleMove,
|
MoveVehicle,
|
||||||
SteerBoat,
|
PaddleBoat,
|
||||||
PickItem,
|
PickItem,
|
||||||
CraftRecipeRequest,
|
PlaceRecipe,
|
||||||
PlayerAbilities,
|
PlayerAbilities,
|
||||||
PlayerDigging,
|
PlayerAction,
|
||||||
EntityAction,
|
PlayerCommand,
|
||||||
SteerVehicle,
|
PlayerInput,
|
||||||
Pong,
|
Pong,
|
||||||
SetRecipeBookState,
|
RecipeBookChangeSettings,
|
||||||
SetDisplayedRecipe,
|
RecipeBookSeenRecipe,
|
||||||
NameItem,
|
RenameItem,
|
||||||
ResourcePackStatus,
|
ResourcePack,
|
||||||
AdvancementTab,
|
SeenAdvancements,
|
||||||
SelectTrade,
|
SelectTrade,
|
||||||
SetBeaconEffect,
|
SetBeacon,
|
||||||
HeldItemChange,
|
SetCarriedItem,
|
||||||
UpdateCommandBlock,
|
SetCommandBlock,
|
||||||
UpdateCommandBlockMinecart,
|
SetCommandBlockMinecart,
|
||||||
CreativeInventoryAction,
|
SetCreativeModeSlot,
|
||||||
UpdateJigsawBlock,
|
SetJigsawBlock,
|
||||||
UpdateStructureBlock,
|
SetStructureBlock,
|
||||||
UpdateSign,
|
SignUpdate,
|
||||||
PlayerArmSwing,
|
Swing,
|
||||||
Spectate,
|
TeleportToEntity,
|
||||||
PlayerBlockPlacement,
|
UseItemOn,
|
||||||
UseItem,
|
UseItem,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,8 +33,8 @@ use crate::protocol::packets::login::c2s::{EncryptionResponse, LoginStart, Verif
|
||||||
use crate::protocol::packets::login::s2c::{EncryptionRequest, LoginSuccess, SetCompression};
|
use crate::protocol::packets::login::s2c::{EncryptionRequest, LoginSuccess, SetCompression};
|
||||||
use crate::protocol::packets::play::c2s::C2sPlayPacket;
|
use crate::protocol::packets::play::c2s::C2sPlayPacket;
|
||||||
use crate::protocol::packets::play::s2c::S2cPlayPacket;
|
use crate::protocol::packets::play::s2c::S2cPlayPacket;
|
||||||
use crate::protocol::packets::status::c2s::{Ping, Request};
|
use crate::protocol::packets::status::c2s::{PingRequest, StatusRequest};
|
||||||
use crate::protocol::packets::status::s2c::{Pong, Response};
|
use crate::protocol::packets::status::s2c::{PongResponse, Response};
|
||||||
use crate::protocol::packets::{login, Property};
|
use crate::protocol::packets::{login, Property};
|
||||||
use crate::protocol::{BoundedArray, BoundedString, VarInt};
|
use crate::protocol::{BoundedArray, BoundedString, VarInt};
|
||||||
use crate::util::valid_username;
|
use crate::util::valid_username;
|
||||||
|
@ -517,7 +517,7 @@ async fn handle_status(
|
||||||
c: &mut Codec,
|
c: &mut Codec,
|
||||||
remote_addr: SocketAddr,
|
remote_addr: SocketAddr,
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
c.1.read_packet::<Request>().await?;
|
c.1.read_packet::<StatusRequest>().await?;
|
||||||
|
|
||||||
match server.0.cfg.server_list_ping(&server, remote_addr).await {
|
match server.0.cfg.server_list_ping(&server, remote_addr).await {
|
||||||
ServerListPing::Respond {
|
ServerListPing::Respond {
|
||||||
|
@ -555,9 +555,9 @@ async fn handle_status(
|
||||||
ServerListPing::Ignore => return Ok(()),
|
ServerListPing::Ignore => return Ok(()),
|
||||||
}
|
}
|
||||||
|
|
||||||
let Ping { payload } = c.1.read_packet().await?;
|
let PingRequest { payload } = c.1.read_packet().await?;
|
||||||
|
|
||||||
c.0.write_packet(&Pong { payload }).await?;
|
c.0.write_packet(&PongResponse { payload }).await?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue