Re-export common items at the root of valence_protocol (#156)

This commit is contained in:
Ryan Johnson 2022-11-14 22:30:20 -08:00 committed by GitHub
parent 74e4f10ec5
commit ab2e1081ed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 58 additions and 91 deletions

View file

@ -15,7 +15,6 @@ use tokio::net::{TcpListener, TcpStream};
use tokio::sync::Semaphore;
use tokio::task::JoinHandle;
use tokio::time::timeout;
use valence_protocol::codec::{PacketDecoder, PacketEncoder};
use valence_protocol::packets::c2s::handshake::Handshake;
use valence_protocol::packets::c2s::login::{EncryptionResponse, LoginStart};
use valence_protocol::packets::c2s::play::C2sPlayPacket;
@ -24,7 +23,7 @@ use valence_protocol::packets::s2c::login::{LoginSuccess, S2cLoginPacket};
use valence_protocol::packets::s2c::play::S2cPlayPacket;
use valence_protocol::packets::s2c::status::{PingResponse, StatusResponse};
use valence_protocol::types::HandshakeNextState;
use valence_protocol::{Decode, Encode, Packet};
use valence_protocol::{Decode, Encode, Packet, PacketDecoder, PacketEncoder};
#[derive(Parser, Clone, Debug)]
#[clap(author, version, about)]

View file

@ -14,14 +14,10 @@ use std::iter::FusedIterator;
use paletted_container::PalettedContainer;
use rayon::iter::{IntoParallelRefIterator, IntoParallelRefMutIterator, ParallelIterator};
use valence_nbt::compound;
use valence_protocol::block::BlockState;
use valence_protocol::block_pos::BlockPos;
use valence_protocol::packets::s2c::play::{
BlockUpdate, ChunkDataAndUpdateLight, UpdateSectionBlocks,
};
use valence_protocol::var_int::VarInt;
use valence_protocol::var_long::VarLong;
use valence_protocol::Encode;
use valence_protocol::{BlockPos, BlockState, Encode, VarInt, VarLong};
use crate::biome::BiomeId;
pub use crate::chunk_pos::ChunkPos;

View file

@ -1,4 +1,4 @@
use valence_protocol::block_pos::BlockPos;
use valence_protocol::BlockPos;
/// The X and Z position of a chunk in a world.
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]

View file

@ -10,10 +10,6 @@ pub use bitfield_struct::bitfield;
pub use event::*;
use rayon::iter::ParallelIterator;
use uuid::Uuid;
use valence_protocol::block_pos::BlockPos;
use valence_protocol::byte_angle::ByteAngle;
use valence_protocol::ident::Ident;
use valence_protocol::item::ItemStack;
use valence_protocol::packets::c2s::play::ClientCommand;
use valence_protocol::packets::s2c::play::{
AcknowledgeBlockChange, ClearTitles, CombatDeath, CustomSoundEffect, DisconnectPlay,
@ -26,15 +22,14 @@ use valence_protocol::packets::s2c::play::{
UpdateEntityPositionAndRotation, UpdateEntityRotation, UpdateTime,
};
use valence_protocol::packets::C2sPlayPacket;
use valence_protocol::raw_bytes::RawBytes;
use valence_protocol::text::Text;
use valence_protocol::types::{
Action, AttributeProperty, GameMode, GameStateChangeReason, SoundCategory,
SyncPlayerPosLookFlags,
};
use valence_protocol::username::Username;
use valence_protocol::var_int::VarInt;
use valence_protocol::{ident, types, Encode, Packet};
use valence_protocol::{
ident, types, BlockPos, ByteAngle, Encode, Ident, ItemStack, Packet, RawBytes, Text, Username,
VarInt,
};
use vek::Vec3;
use crate::chunk_pos::ChunkPos;

View file

@ -1,15 +1,11 @@
use std::time::Duration;
use valence_protocol::block::BlockFace;
use valence_protocol::block_pos::BlockPos;
use valence_protocol::entity_meta::Pose;
use valence_protocol::ident::Ident;
use valence_protocol::item::ItemStack;
use valence_protocol::packets::c2s::play::ResourcePackC2s;
use valence_protocol::types::{
ChatMode, ClickContainerMode, DisplayedSkinParts, EntityInteraction, Hand, MainHand,
};
use valence_protocol::var_int::VarInt;
use valence_protocol::{BlockFace, BlockPos, Ident, ItemStack, VarInt};
use vek::Vec3;
use super::Client;

View file

@ -9,13 +9,11 @@ use bitfield_struct::bitfield;
pub use data::{EntityKind, TrackedData};
use rayon::iter::ParallelIterator;
use uuid::Uuid;
use valence_protocol::byte_angle::ByteAngle;
use valence_protocol::entity_meta::{Facing, PaintingKind, Pose};
use valence_protocol::packets::s2c::play::{
SetEntityMetadata, SetHeadRotation, SpawnEntity, SpawnExperienceOrb, SpawnPlayer,
};
use valence_protocol::raw_bytes::RawBytes;
use valence_protocol::var_int::VarInt;
use valence_protocol::{ByteAngle, RawBytes, VarInt};
use vek::{Aabb, Vec3};
use crate::config::Config;

View file

@ -3,11 +3,7 @@
#![allow(clippy::all, missing_docs, trivial_numeric_casts)]
use uuid::Uuid;
use valence_protocol::block::BlockState;
use valence_protocol::block_pos::BlockPos;
use valence_protocol::entity_meta::*;
use valence_protocol::text::Text;
use valence_protocol::var_int::VarInt;
use valence_protocol::Encode;
use valence_protocol::{BlockPos, BlockState, Encode, Text, VarInt};
include!(concat!(env!("OUT_DIR"), "/entity.rs"));

View file

@ -1,8 +1,7 @@
use std::ops::Range;
use thiserror::Error;
use valence_protocol::item::ItemStack;
use valence_protocol::var_int::VarInt;
use valence_protocol::{ItemStack, VarInt};
use crate::slab_versioned::{Key, VersionedSlab};
@ -277,7 +276,7 @@ pub struct InventoryError;
#[cfg(test)]
mod test {
use valence_protocol::item::{ItemKind, ItemStack};
use valence_protocol::{ItemKind, ItemStack};
use super::*;

View file

@ -140,16 +140,16 @@ pub mod prelude {
};
pub use uuid::Uuid;
pub use valence_nbt::Compound;
pub use valence_protocol::block::{BlockKind, BlockState, PropName, PropValue};
pub use valence_protocol::block_pos::BlockPos;
pub use valence_protocol::block::{PropName, PropValue};
pub use valence_protocol::entity_meta::Pose;
pub use valence_protocol::ident::{Ident, IdentError};
pub use valence_protocol::item::{ItemKind, ItemStack};
pub use valence_protocol::ident::IdentError;
pub use valence_protocol::packets::s2c::play::SetTitleAnimationTimes;
pub use valence_protocol::text::{Color, Text, TextFormat};
pub use valence_protocol::text::Color;
pub use valence_protocol::types::{GameMode, Hand, SoundCategory};
pub use valence_protocol::username::Username;
pub use valence_protocol::{ident, MINECRAFT_VERSION, PROTOCOL_VERSION};
pub use valence_protocol::{
ident, BlockKind, BlockPos, BlockState, Ident, ItemKind, ItemStack, Text, TextFormat,
Username, MINECRAFT_VERSION, PROTOCOL_VERSION,
};
pub use vek::{Aabb, Mat2, Mat3, Mat4, Vec2, Vec3, Vec4};
pub use world::{World, WorldId, WorldMeta, Worlds};

View file

@ -22,16 +22,15 @@ use tokio::runtime::{Handle, Runtime};
use tokio::sync::Semaphore;
use uuid::Uuid;
use valence_nbt::{compound, Compound, List};
use valence_protocol::codec::{PacketDecoder, PacketEncoder};
use valence_protocol::packets::c2s::handshake::HandshakeOwned;
use valence_protocol::packets::c2s::login::LoginStart;
use valence_protocol::packets::c2s::status::{PingRequest, StatusRequest};
use valence_protocol::packets::s2c::login::{DisconnectLogin, LoginSuccess, SetCompression};
use valence_protocol::packets::s2c::status::{PingResponse, StatusResponse};
use valence_protocol::types::HandshakeNextState;
use valence_protocol::username::Username;
use valence_protocol::var_int::VarInt;
use valence_protocol::{ident, MINECRAFT_VERSION, PROTOCOL_VERSION};
use valence_protocol::{
ident, PacketDecoder, PacketEncoder, Username, VarInt, MINECRAFT_VERSION, PROTOCOL_VERSION,
};
use crate::biome::{validate_biomes, Biome, BiomeId};
use crate::client::{Client, Clients};

View file

@ -15,17 +15,12 @@ use sha1::Sha1;
use sha2::{Digest, Sha256};
use tokio::net::tcp::{OwnedReadHalf, OwnedWriteHalf};
use uuid::Uuid;
use valence_protocol::ident::Ident;
use valence_protocol::packets::c2s::login::{EncryptionResponse, LoginPluginResponse};
use valence_protocol::packets::s2c::login::{
DisconnectLogin, EncryptionRequest, LoginPluginRequest,
};
use valence_protocol::raw_bytes::RawBytes;
use valence_protocol::text::Text;
use valence_protocol::types::{MsgSigOrVerifyToken, SignedProperty, SignedPropertyOwned};
use valence_protocol::username::Username;
use valence_protocol::var_int::VarInt;
use valence_protocol::Decode;
use valence_protocol::{Decode, Ident, RawBytes, Text, Username, VarInt};
use crate::config::Config;
use crate::player_textures::SignedPlayerTextures;

View file

@ -7,8 +7,7 @@ use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt};
use tokio::runtime::Handle;
use tokio::task::JoinHandle;
use tokio::time::timeout;
use valence_protocol::codec::{PacketDecoder, PacketEncoder};
use valence_protocol::{Decode, Encode, Packet};
use valence_protocol::{Decode, Encode, Packet, PacketDecoder, PacketEncoder};
use crate::server::byte_channel::{byte_channel, ByteReceiver, ByteSender, TryRecvError};

View file

@ -7,9 +7,7 @@ use std::iter::FusedIterator;
use anyhow::Context;
use crate::item::ItemKind;
use crate::var_int::VarInt;
use crate::{Decode, Encode, Result};
use crate::{Decode, Encode, ItemKind, Result, VarInt};
include!(concat!(env!("OUT_DIR"), "/block.rs"));

View file

@ -2,8 +2,7 @@ use std::io::Write;
use anyhow::bail;
use crate::block::BlockFace;
use crate::{Decode, Encode};
use crate::{BlockFace, Decode, Encode};
/// Represents an absolute block position in world space.
#[derive(Clone, Copy, Default, PartialEq, Eq, Hash, Debug)]
@ -28,8 +27,7 @@ impl BlockPos {
/// direction.
///
/// ```
/// use valence_protocol::block::BlockFace;
/// use valence_protocol::block_pos::BlockPos;
/// use valence_protocol::{BlockFace, BlockPos};
///
/// let pos = BlockPos::new(0, 0, 0);
/// let adj = pos.get_in_direction(BlockFace::South);

View file

@ -18,6 +18,7 @@ use crate::{Decode, Encode, Result};
///
/// [`EncodedBuf<T>`]: EncodedBuf
/// [^note]: Assuming `T` does not use internal mutability.
#[derive(Debug)]
pub struct Cached<T> {
val: T,
buf: EncodedBuf<T>,
@ -85,8 +86,7 @@ where
/// # Examples
///
/// ```
/// use valence_protocol::cache::EncodedBuf;
/// use valence_protocol::Encode;
/// use valence_protocol::{Encode, EncodedBuf};
///
/// let mut buf1 = Vec::new();
/// let mut buf2 = Vec::new();
@ -101,6 +101,7 @@ where
///
/// [`Text`]: crate::text::Text
/// [`Compound`]: valence_nbt::Compound
#[derive(Debug)]
pub struct EncodedBuf<T: ?Sized> {
buf: Vec<u8>,
res: Result<()>,

View file

@ -10,8 +10,7 @@ use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt};
use uuid::Uuid;
use valence_nbt::Compound;
use crate::var_int::VarInt;
use crate::{Decode, Encode, Result, MAX_PACKET_SIZE};
use crate::{Decode, Encode, Result, VarInt, MAX_PACKET_SIZE};
// ==== Primitive ==== //

View file

@ -3,9 +3,7 @@ use std::io::Write;
use anyhow::{ensure, Context};
use valence_nbt::Compound;
use crate::block::BlockKind;
use crate::var_int::VarInt;
use crate::{Decode, Encode, Result};
use crate::{BlockKind, Decode, Encode, Result, VarInt};
include!(concat!(env!("OUT_DIR"), "/item.rs"));

View file

@ -8,8 +8,8 @@
//! # Examples
//!
//! ```
//! use valence_protocol::codec::{PacketDecoder, PacketEncoder};
//! use valence_protocol::packets::c2s::play::RenameItem;
//! use valence_protocol::{PacketDecoder, PacketEncoder};
//!
//! let mut enc = PacketEncoder::new();
//!
@ -43,9 +43,6 @@
//! # Feature Flags
//!
//! TODO
//!
//! [`PacketEncoder`]: codec::PacketEncoder
//! [`PacketDecoder`]: codec::PacketDecoder
#![forbid(unsafe_code)]
#![deny(
@ -75,31 +72,45 @@ extern crate self as valence_protocol;
use std::io::Write;
pub use anyhow::{Error, Result};
pub use block::{BlockFace, BlockKind, BlockState};
pub use block_pos::BlockPos;
pub use byte_angle::ByteAngle;
pub use cache::{Cached, EncodedBuf};
pub use codec::{PacketDecoder, PacketEncoder};
pub use ident::Ident;
pub use item::{ItemKind, ItemStack};
pub use raw_bytes::RawBytes;
pub use text::{Text, TextFormat};
pub use username::Username;
pub use uuid::Uuid;
pub use valence_derive::{Decode, Encode, Packet};
pub use valence_nbt as nbt;
pub use var_int::VarInt;
pub use var_long::VarLong;
pub use {uuid, valence_nbt as nbt};
use crate::byte_counter::ByteCounter;
/// The Minecraft protocol version this library currently targets.
pub const PROTOCOL_VERSION: i32 = 760;
/// The stringized name of the Minecraft version this library currently targets.
/// The stringified name of the Minecraft version this library currently
/// targets.
pub const MINECRAFT_VERSION: &str = "1.19.2";
pub mod block;
pub mod block_pos;
pub mod bounded;
pub mod byte_angle;
mod block_pos;
mod bounded;
mod byte_angle;
mod byte_counter;
pub mod cache;
pub mod codec;
mod cache;
mod codec;
pub mod enchant;
pub mod entity_meta;
pub mod ident;
mod impls;
pub mod item;
mod item;
pub mod packets;
pub mod raw_bytes;
mod raw_bytes;
pub mod text;
pub mod types;
pub mod username;
@ -230,8 +241,6 @@ pub trait Encode {
/// ...]` attribute on the variant in question. Discriminant values are assigned
/// to variants using rules similar to regular enum discriminants.
///
/// [`VarInt`]: var_int::VarInt
///
/// ```
/// use valence_protocol::Decode;
///
@ -277,8 +286,6 @@ pub trait Decode<'a>: Sized {
/// A complete packet is data starting with a [`VarInt`] packet ID. [`Encode`]
/// and [`Decode`] implementations on `Self`, if present, are expected to handle
/// this leading `VarInt`.
///
/// [`VarInt`]: var_int::VarInt
pub trait Packet {
/// The name of this packet.
///

View file

@ -8,9 +8,7 @@ use serde::de::Visitor;
use serde::{de, Deserialize, Deserializer, Serialize, Serializer};
use crate::byte_counter::ByteCounter;
use crate::ident::Ident;
use crate::var_int::VarInt;
use crate::{Decode, Encode, Result};
use crate::{Decode, Encode, Ident, Result, VarInt};
/// Represents formatted text in Minecraft's JSON text format.
///

View file

@ -4,12 +4,8 @@ use bitfield_struct::bitfield;
use serde::{Deserialize, Serialize};
use uuid::Uuid;
use valence_nbt::Compound;
use valence_protocol::text::Text;
use crate::__private::VarInt;
use crate::block_pos::BlockPos;
use crate::ident::Ident;
use crate::{Decode, Encode};
use crate::{BlockPos, Decode, Encode, Ident, Text, VarInt};
#[derive(Copy, Clone, Debug, PartialEq, Eq, Encode, Decode)]
pub enum HandshakeNextState {