Don't export items arbitrarily at the crate root

This commit is contained in:
Ryan 2022-07-06 18:27:59 -07:00
parent 70476973b6
commit 24cf864ed1
22 changed files with 68 additions and 58 deletions

View file

@ -7,15 +7,16 @@ use std::sync::Mutex;
use log::LevelFilter;
use num::Integer;
use rayon::iter::{IndexedParallelIterator, IntoParallelRefMutIterator, ParallelIterator};
use valence::biome::Biome;
use valence::block::BlockState;
use valence::client::{ClientEvent, ClientId, GameMode, Hand};
use valence::config::{Config, ServerListPing};
use valence::dimension::{Dimension, DimensionId};
use valence::entity::meta::Pose;
use valence::entity::EntityData;
use valence::text::Color;
use valence::{
async_trait, ident, Biome, BlockState, Dimension, DimensionId, EntityId, EntityKind, Server,
SharedServer, ShutdownResult, TextFormat,
};
use valence::entity::{EntityData, EntityId, EntityKind};
use valence::server::{Server, SharedServer, ShutdownResult};
use valence::text::{Color, TextFormat};
use valence::{async_trait, ident};
pub fn main() -> ShutdownResult {
env_logger::Builder::new()

View file

@ -4,14 +4,14 @@ use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::Mutex;
use log::LevelFilter;
use valence::async_trait;
use valence::client::GameMode;
use valence::config::{Config, ServerListPing};
use valence::text::Color;
use valence::dimension::DimensionId;
use valence::entity::{EntityId, EntityKind};
use valence::server::{Server, SharedServer, ShutdownResult};
use valence::text::{Color, TextFormat};
use valence::util::to_yaw_and_pitch;
use valence::{
async_trait, DimensionId, EntityId, EntityKind, Server, SharedServer, ShutdownResult,
TextFormat,
};
use vek::{Mat3, Vec3};
pub fn main() -> ShutdownResult {

View file

@ -5,14 +5,15 @@ use std::sync::atomic::{AtomicUsize, Ordering};
use log::LevelFilter;
use noise::{NoiseFn, Seedable, SuperSimplex};
use rayon::iter::ParallelIterator;
use valence::async_trait;
use valence::block::{BlockState, PropName, PropValue};
use valence::chunk::ChunkPos;
use valence::client::GameMode;
use valence::config::{Config, ServerListPing};
use valence::text::Color;
use valence::dimension::DimensionId;
use valence::server::{Server, SharedServer, ShutdownResult};
use valence::text::{Color, TextFormat};
use valence::util::chunks_in_view_distance;
use valence::{
async_trait, ChunkPos, DimensionId, Server, SharedServer, ShutdownResult, TextFormat,
};
use vek::Lerp;
pub fn main() -> ShutdownResult {

View file

@ -1,4 +1,5 @@
use crate::{ident, Ident};
use crate::ident;
use crate::ident::Ident;
/// Identifies a particular [`Biome`].
///

View file

@ -5,6 +5,7 @@ use std::io::{Read, Write};
use anyhow::Context;
pub use crate::block_pos::BlockPos;
use crate::protocol::{Decode, Encode, VarInt};
include!(concat!(env!("OUT_DIR"), "/block.rs"));

View file

@ -9,12 +9,17 @@ use bitvec::vec::BitVec;
use num::Integer;
use rayon::iter::{IntoParallelRefIterator, IntoParallelRefMutIterator, ParallelIterator};
use crate::biome::BiomeId;
use crate::block::BlockState;
use crate::block_pos::BlockPos;
pub use crate::chunk_pos::ChunkPos;
use crate::dimension::DimensionId;
use crate::protocol::packets::play::s2c::{
BlockUpdate, LevelChunkHeightmaps, LevelChunkWithLight, S2cPlayPacket, SectionBlocksUpdate,
};
use crate::protocol::{Encode, Nbt, VarInt, VarLong};
use crate::{BiomeId, BlockPos, ChunkPos, DimensionId, SharedServer, Ticks};
use crate::server::SharedServer;
use crate::Ticks;
pub struct Chunks {
chunks: HashMap<ChunkPos, Chunk>,

View file

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

View file

@ -12,9 +12,11 @@ use uuid::Uuid;
use vek::Vec3;
use crate::biome::{Biome, BiomeGrassColorModifier, BiomePrecipitation};
use crate::dimension::{Dimension, DimensionEffects};
use crate::block_pos::BlockPos;
use crate::chunk_pos::ChunkPos;
use crate::dimension::{Dimension, DimensionEffects, DimensionId};
use crate::entity::data::Player;
use crate::entity::{velocity_to_packet_units, EntityKind};
use crate::entity::{velocity_to_packet_units, Entities, Entity, EntityId, EntityKind};
use crate::player_textures::SignedPlayerTextures;
use crate::protocol::packets::play::c2s::{
C2sPlayPacket, DiggingStatus, InteractKind, PlayerCommandId,
@ -32,13 +34,12 @@ use crate::protocol::packets::play::s2c::{
SetTitleText, SpawnPosition, SystemChat, TeleportEntity, ENTITY_EVENT_MAX_BOUND,
};
use crate::protocol::{BoundedInt, ByteAngle, Nbt, RawBytes, VarInt};
use crate::server::C2sPacketChannels;
use crate::server::{C2sPacketChannels, NewClientData, SharedServer};
use crate::slotmap::{Key, SlotMap};
use crate::text::Text;
use crate::util::{chunks_in_view_distance, is_chunk_in_view_distance};
use crate::{
ident, BlockPos, ChunkPos, DimensionId, Entities, Entity, EntityId, NewClientData,
SharedServer, Text, Ticks, WorldId, Worlds, LIBRARY_NAMESPACE,
};
use crate::world::{WorldId, Worlds};
use crate::{ident, Ticks, LIBRARY_NAMESPACE};
pub struct Clients {
sm: SlotMap<Client>,

View file

@ -2,10 +2,11 @@ use std::time::Duration;
use vek::Vec3;
use crate::block_pos::BlockPos;
use crate::entity::EntityId;
use crate::protocol::packets::play::c2s::BlockFace;
pub use crate::protocol::packets::play::c2s::{ChatMode, DisplayedSkinParts, Hand, MainHand};
pub use crate::protocol::packets::play::s2c::GameMode;
use crate::{BlockPos, EntityId};
#[derive(Debug)]
pub enum ClientEvent {

View file

@ -5,7 +5,11 @@ use std::panic::{RefUnwindSafe, UnwindSafe};
use async_trait::async_trait;
use tokio::runtime::Handle as TokioHandle;
use crate::{Biome, Dimension, NewClientData, Server, SharedServer, Text, Ticks};
use crate::biome::Biome;
use crate::dimension::Dimension;
use crate::server::{NewClientData, Server, SharedServer};
use crate::text::Text;
use crate::Ticks;
/// A trait containing callbacks which are invoked by the running Minecraft
/// server.

View file

@ -18,7 +18,7 @@ use crate::protocol::packets::play::s2c::{
use crate::protocol::{ByteAngle, RawBytes, VarInt};
use crate::slotmap::{Key, SlotMap};
use crate::util::aabb_from_bottom_and_size;
use crate::WorldId;
use crate::world::WorldId;
pub struct Entities {
sm: SlotMap<Entity>,

View file

@ -1,8 +1,10 @@
#![allow(clippy::all, missing_docs)]
use crate::block::BlockState;
use crate::block::{BlockPos, BlockState};
use crate::entity::meta::*;
use crate::entity::EntityId;
use crate::protocol::{Encode, VarInt};
use crate::{BlockPos, EntityId, Text, Uuid};
use crate::text::Text;
use crate::uuid::Uuid;
include!(concat!(env!("OUT_DIR"), "/entity.rs"));

View file

@ -249,8 +249,8 @@ macro_rules! ident {
let errmsg = "invalid identifier in `ident` macro";
#[allow(clippy::redundant_closure_call)]
(|args: ::std::fmt::Arguments| match args.as_str() {
Some(s) => $crate::Ident::new(s).expect(errmsg),
None => $crate::Ident::new(args.to_string()).expect(errmsg),
Some(s) => $crate::ident::Ident::new(s).expect(errmsg),
None => $crate::ident::Ident::new(args.to_string()).expect(errmsg),
})(format_args!($($arg)*))
}}
}

View file

@ -33,21 +33,8 @@ pub mod util;
pub mod world;
pub use async_trait::async_trait;
pub use biome::{Biome, BiomeId};
pub use block::BlockState;
pub use block_pos::BlockPos;
pub use chunk::{Chunk, Chunks};
pub use chunk_pos::ChunkPos;
pub use client::{Client, Clients};
pub use config::Config;
pub use dimension::{Dimension, DimensionId};
pub use entity::{Entities, Entity, EntityId, EntityKind};
pub use ident::Ident;
pub use server::{start_server, NewClientData, Server, SharedServer, ShutdownResult};
pub use server::start_server;
pub use spatial_index::SpatialIndex;
pub use text::{Text, TextFormat};
pub use uuid::Uuid;
pub use world::{WorldId, WorldMeta, Worlds};
pub use {nbt, uuid, vek};
/// The Minecraft protocol version that this library targets.

View file

@ -11,7 +11,7 @@ use crate::protocol::packets::play::s2c::{
};
use crate::protocol::packets::Property;
use crate::protocol::VarInt;
use crate::Text;
use crate::text::Text;
pub struct PlayerList {
entries: HashMap<Uuid, PlayerListEntry>,

View file

@ -19,7 +19,7 @@ pub use var_int::VarInt;
pub use var_long::VarLong;
use vek::{Vec2, Vec3, Vec4};
use crate::EntityId;
use crate::entity::EntityId;
/// Trait for types that can be written to the Minecraft protocol.
pub trait Encode {

View file

@ -16,11 +16,12 @@ use uuid::Uuid;
use vek::Vec3;
use crate::block_pos::BlockPos;
use crate::ident::Ident;
use crate::protocol::{
BoundedArray, BoundedInt, BoundedString, ByteAngle, Decode, Encode, Nbt, RawBytes, VarInt,
VarLong,
};
use crate::{Ident, Text};
use crate::text::Text;
/// Trait for types that can be written to the Minecraft protocol as a complete
/// packet.

View file

@ -4,8 +4,8 @@ use std::iter::FusedIterator;
use std::net::SocketAddr;
use std::sync::atomic::{AtomicI64, Ordering};
use std::sync::{Arc, Mutex};
use std::{thread, io};
use std::time::{Duration, Instant};
use std::{io, thread};
use anyhow::{bail, ensure, Context};
use flume::{Receiver, Sender};
@ -25,7 +25,11 @@ use tokio::runtime::{Handle, Runtime};
use tokio::sync::{oneshot, Semaphore};
use uuid::Uuid;
use crate::biome::{Biome, BiomeId};
use crate::client::{Client, Clients};
use crate::config::{Config, ServerListPing};
use crate::dimension::{Dimension, DimensionId};
use crate::entity::Entities;
use crate::player_textures::SignedPlayerTextures;
use crate::protocol::codec::{Decoder, Encoder};
use crate::protocol::packets::handshake::{Handshake, HandshakeNextState};
@ -39,10 +43,7 @@ use crate::protocol::packets::{login, Property};
use crate::protocol::{BoundedArray, BoundedString, VarInt};
use crate::util::valid_username;
use crate::world::Worlds;
use crate::{
Biome, BiomeId, Client, Clients, Dimension, DimensionId, Entities, Ticks, PROTOCOL_VERSION,
VERSION_NAME,
};
use crate::{Ticks, PROTOCOL_VERSION, VERSION_NAME};
pub struct Server {
pub shared: SharedServer,

View file

@ -2,7 +2,8 @@ use vek::{Aabb, Vec3};
use crate::bvh::Bvh;
pub use crate::bvh::TraverseStep;
use crate::{Entities, EntityId, WorldId};
use crate::entity::{Entities, EntityId};
use crate::world::WorldId;
pub struct SpatialIndex {
bvh: Bvh<EntityId>,

View file

@ -8,8 +8,8 @@ use std::io::{Read, Write};
use serde::de::Visitor;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use crate::ident::Ident;
use crate::protocol::{BoundedString, Decode, Encode};
use crate::Ident;
/// Represents formatted text in Minecraft's JSON text format.
///

View file

@ -4,7 +4,7 @@ use num::cast::AsPrimitive;
use num::Float;
use vek::{Aabb, Vec3};
use crate::ChunkPos;
use crate::chunk_pos::ChunkPos;
/// Returns true if the given string meets the criteria for a valid Minecraft
/// username.

View file

@ -2,9 +2,12 @@ use std::iter::FusedIterator;
use rayon::iter::ParallelIterator;
use crate::chunk::Chunks;
use crate::dimension::DimensionId;
use crate::player_list::PlayerList;
use crate::server::SharedServer;
use crate::slotmap::{Key, SlotMap};
use crate::{Chunks, DimensionId, SharedServer, SpatialIndex};
use crate::SpatialIndex;
pub struct Worlds {
sm: SlotMap<World>,