Skip to content

Commit

Permalink
organize azalea_core and re-export it from azalea
Browse files Browse the repository at this point in the history
  • Loading branch information
mat-1 committed Oct 1, 2023
1 parent 33e823d commit befa33a
Show file tree
Hide file tree
Showing 109 changed files with 199 additions and 156 deletions.
2 changes: 1 addition & 1 deletion azalea-client/src/attack.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use azalea_core::GameMode;
use azalea_core::game_type::GameMode;
use azalea_entity::{
metadata::{ShiftKeyDown, Sprinting},
update_bounding_box, Attributes, Physics,
Expand Down
2 changes: 1 addition & 1 deletion azalea-client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use crate::{
use azalea_auth::{game_profile::GameProfile, sessionserver::ClientSessionServerError};
use azalea_buf::McBufWritable;
use azalea_chat::FormattedText;
use azalea_core::{ResourceLocation, Vec3};
use azalea_core::{position::Vec3, resource_location::ResourceLocation};
use azalea_entity::{
indexing::{EntityIdIndex, EntityUuidIndex},
metadata::Health,
Expand Down
7 changes: 6 additions & 1 deletion azalea-client/src/interact.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
use std::ops::AddAssign;

use azalea_block::BlockState;
use azalea_core::{BlockHitResult, BlockPos, Direction, GameMode, Vec3};
use azalea_core::{
block_hit_result::BlockHitResult,
direction::Direction,
game_type::GameMode,
position::{BlockPos, Vec3},
};
use azalea_entity::{
clamp_look_direction, view_vector, Attributes, EyeHeight, LocalEntity, LookDirection, Position,
};
Expand Down
2 changes: 1 addition & 1 deletion azalea-client/src/local_player.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::{collections::HashMap, io, sync::Arc};

use azalea_auth::game_profile::GameProfile;
use azalea_core::GameMode;
use azalea_core::game_type::GameMode;
use azalea_entity::Dead;
use azalea_protocol::packets::game::{
clientbound_player_abilities_packet::ClientboundPlayerAbilitiesPacket, ServerboundGamePacket,
Expand Down
2 changes: 1 addition & 1 deletion azalea-client/src/mining.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use azalea_block::{Block, BlockState, FluidState};
use azalea_core::{BlockPos, Direction, GameMode};
use azalea_core::{direction::Direction, game_type::GameMode, position::BlockPos};
use azalea_entity::{mining::get_mine_progress, FluidOnEyes, Physics};
use azalea_inventory::ItemSlot;
use azalea_physics::PhysicsSet;
Expand Down
6 changes: 5 additions & 1 deletion azalea-client/src/packet_handling/game.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ use std::{
};

use azalea_chat::FormattedText;
use azalea_core::{ChunkPos, GameMode, ResourceLocation, Vec3};
use azalea_core::{
game_type::GameMode,
position::{ChunkPos, Vec3},
resource_location::ResourceLocation,
};
use azalea_entity::{
indexing::{EntityIdIndex, EntityUuidIndex},
metadata::{apply_metadata, Health, PlayerMetadataBundle},
Expand Down
2 changes: 1 addition & 1 deletion azalea-client/src/player.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use azalea_auth::game_profile::GameProfile;
use azalea_chat::FormattedText;
use azalea_core::GameMode;
use azalea_core::game_type::GameMode;
use azalea_entity::indexing::EntityUuidIndex;
use bevy_ecs::{
event::EventReader,
Expand Down
2 changes: 1 addition & 1 deletion azalea-client/src/received_registries.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::collections::HashMap;

use azalea_core::ResourceLocation;
use azalea_core::resource_location::ResourceLocation;
use azalea_nbt::Nbt;
use azalea_protocol::packets::configuration::clientbound_registry_data_packet::registry::{
DimensionTypeElement, RegistryType,
Expand Down
9 changes: 6 additions & 3 deletions azalea-core/src/aabb.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use crate::{Axis, BlockHitResult, BlockPos, Direction, Vec3};

pub const EPSILON: f64 = 1.0E-7;
use crate::{
block_hit_result::BlockHitResult,
direction::{Axis, Direction},
math::EPSILON,
position::{BlockPos, Vec3},
};

/// A rectangular prism with a starting and ending point.
#[derive(Copy, Clone, Debug, PartialEq, Default)]
Expand Down
5 changes: 4 additions & 1 deletion azalea-core/src/block_hit_result.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use crate::{BlockPos, Direction, Vec3};
use crate::{
direction::Direction,
position::{BlockPos, Vec3},
};

#[derive(Debug, Clone, Copy, PartialEq)]
pub struct BlockHitResult {
Expand Down
2 changes: 1 addition & 1 deletion azalea-core/src/cursor3d.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::BlockPos;
use crate::position::BlockPos;

pub struct Cursor3d {
index: usize,
Expand Down
2 changes: 1 addition & 1 deletion azalea-core/src/delta.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::Vec3;
use crate::position::Vec3;
pub use azalea_buf::McBuf;

pub trait PositionDeltaTrait {
Expand Down
2 changes: 1 addition & 1 deletion azalea-core/src/direction.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use azalea_buf::McBuf;

use crate::Vec3;
use crate::position::Vec3;

#[derive(Clone, Copy, Debug, McBuf, Default, Eq, PartialEq)]
pub enum Direction {
Expand Down
43 changes: 11 additions & 32 deletions azalea-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,16 @@
#![allow(incomplete_features)]
#![feature(generic_const_exprs)]

mod difficulty;
pub use difficulty::*;

mod resource_location;
pub use resource_location::*;

mod game_type;
pub use game_type::*;

mod position;
pub use position::*;

mod direction;
pub use direction::*;

mod delta;
pub use delta::*;

pub mod particle;

mod cursor3d;
pub use cursor3d::*;

mod bitset;
pub use bitset::*;

mod aabb;
pub use aabb::*;

mod block_hit_result;
pub use block_hit_result::*;

pub mod aabb;
pub mod bitset;
pub mod block_hit_result;
pub mod cursor3d;
pub mod delta;
pub mod difficulty;
pub mod direction;
pub mod game_type;
pub mod math;
pub mod particle;
pub mod position;
pub mod resource_location;
pub mod tier;
2 changes: 2 additions & 0 deletions azalea-core/src/math.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use std::{f64::consts::PI, sync::LazyLock};

pub const EPSILON: f64 = 1.0E-7;

pub static SIN: LazyLock<[f32; 65536]> = LazyLock::new(|| {
let mut sin = [0.0; 65536];
for (i, item) in sin.iter_mut().enumerate() {
Expand Down
2 changes: 1 addition & 1 deletion azalea-core/src/particle.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::BlockPos;
use crate::position::BlockPos;
use azalea_buf::McBuf;
use azalea_inventory::ItemSlot;

Expand Down
8 changes: 7 additions & 1 deletion azalea-core/src/position.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
use crate::ResourceLocation;
//! Representations of positions of various things in Minecraft.
//!
//! The most common ones are [`Vec3`] and [`BlockPos`], which are usually used
//! for entity positions and block positions, respectively.
use azalea_buf::{BufReadError, McBuf, McBufReadable, McBufWritable};
use std::{
io::{Cursor, Write},
ops::{Add, AddAssign, Mul, Rem, Sub},
};

use crate::resource_location::ResourceLocation;

macro_rules! vec3_impl {
($name:ident, $type:ty) => {
impl $name {
Expand Down
6 changes: 5 additions & 1 deletion azalea-entity/src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ use azalea_buf::{
BufReadError, McBuf, McBufReadable, McBufVarReadable, McBufVarWritable, McBufWritable,
};
use azalea_chat::FormattedText;
use azalea_core::{particle::Particle, BlockPos, Direction, GlobalPos, Vec3};
use azalea_core::{
direction::Direction,
particle::Particle,
position::{BlockPos, GlobalPos, Vec3},
};
use azalea_inventory::ItemSlot;
use bevy_ecs::component::Component;
use derive_more::Deref;
Expand Down
2 changes: 1 addition & 1 deletion azalea-entity/src/dimensions.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use azalea_core::{Vec3, AABB};
use azalea_core::{aabb::AABB, position::Vec3};

#[derive(Debug, Default, Clone)]
pub struct EntityDimensions {
Expand Down
7 changes: 6 additions & 1 deletion azalea-entity/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ mod plugin;
use self::attributes::AttributeInstance;
pub use attributes::Attributes;
use azalea_block::BlockState;
use azalea_core::{math, BlockPos, ChunkPos, ResourceLocation, Vec3, AABB};
use azalea_core::{
aabb::AABB,
math,
position::{BlockPos, ChunkPos, Vec3},
resource_location::ResourceLocation,
};
use azalea_world::{ChunkStorage, InstanceName};
use bevy_ecs::{bundle::Bundle, component::Component};
pub use data::*;
Expand Down
6 changes: 5 additions & 1 deletion azalea-entity/src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ use super::{
SnifferState, VillagerData,
};
use azalea_chat::FormattedText;
use azalea_core::{particle::Particle, BlockPos, Direction, Vec3};
use azalea_core::{
direction::Direction,
particle::Particle,
position::{BlockPos, Vec3},
};
use azalea_inventory::ItemSlot;
use bevy_ecs::{bundle::Bundle, component::Component};
use derive_more::{Deref, DerefMut};
Expand Down
2 changes: 1 addition & 1 deletion azalea-entity/src/plugin/indexing.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Stuff related to entity indexes and keeping track of entities in the world.
use azalea_core::ChunkPos;
use azalea_core::position::ChunkPos;
use azalea_world::{Instance, InstanceContainer, InstanceName, MinecraftEntityId};
use bevy_ecs::{
component::Component,
Expand Down
2 changes: 1 addition & 1 deletion azalea-entity/src/plugin/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ mod relative_updates;

use std::collections::HashSet;

use azalea_core::{BlockPos, ChunkPos, Vec3};
use azalea_core::position::{BlockPos, ChunkPos, Vec3};
use azalea_world::{InstanceContainer, InstanceName, MinecraftEntityId};
use bevy_app::{App, Plugin, PreUpdate, Update};
use bevy_ecs::prelude::*;
Expand Down
7 changes: 6 additions & 1 deletion azalea-physics/src/clip.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
use azalea_block::BlockState;
use azalea_core::{math::lerp, BlockHitResult, BlockPos, Direction, Vec3, EPSILON};
use azalea_core::{
block_hit_result::BlockHitResult,
direction::Direction,
math::{lerp, EPSILON},
position::{BlockPos, Vec3},
};
use azalea_inventory::ItemSlot;
use azalea_world::ChunkStorage;
use bevy_ecs::entity::Entity;
Expand Down
6 changes: 5 additions & 1 deletion azalea-physics/src/collision/discrete_voxel_shape.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
use azalea_core::{
bitset::BitSet,
direction::{Axis, AxisCycle},
};

use super::mergers::IndexMerger;
use azalea_core::{Axis, AxisCycle, BitSet};

pub trait IntLineConsumer = FnMut(u32, u32, u32, u32, u32, u32);

Expand Down
5 changes: 1 addition & 4 deletions azalea-physics/src/collision/mergers.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
use std::{cmp::Ordering, convert::TryInto};

use super::CubePointRange;
use azalea_core::{
math::{gcd, lcm},
EPSILON,
};
use azalea_core::math::{gcd, lcm, EPSILON};

#[derive(Debug)]
pub enum IndexMerger {
Expand Down
2 changes: 1 addition & 1 deletion azalea-physics/src/collision/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ mod world_collisions;

use std::ops::Add;

use azalea_core::{Axis, Vec3, AABB, EPSILON};
use azalea_core::{aabb::AABB, direction::Axis, math::EPSILON, position::Vec3};
use azalea_world::{Instance, MoveEntityError};
use bevy_ecs::world::Mut;
pub use blocks::BlockWithShape;
Expand Down
5 changes: 4 additions & 1 deletion azalea-physics/src/collision/shape.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
use super::mergers::IndexMerger;
use crate::collision::{BitSetDiscreteVoxelShape, DiscreteVoxelShape, AABB};
use azalea_core::{
math::binary_search, Axis, AxisCycle, BlockHitResult, BlockPos, Direction, Vec3, EPSILON,
block_hit_result::BlockHitResult,
direction::{Axis, AxisCycle, Direction},
math::{binary_search, EPSILON},
position::{BlockPos, Vec3},
};
use std::{cmp, num::NonZeroU32};

Expand Down
6 changes: 5 additions & 1 deletion azalea-physics/src/collision/world_collisions.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
use super::Shapes;
use crate::collision::{BlockWithShape, VoxelShape, AABB};
use azalea_block::BlockState;
use azalea_core::{ChunkPos, ChunkSectionPos, Cursor3d, CursorIterationType, EPSILON};
use azalea_core::{
cursor3d::{Cursor3d, CursorIterationType},
math::EPSILON,
position::{ChunkPos, ChunkSectionPos},
};
use azalea_world::{Chunk, Instance};
use parking_lot::RwLock;
use std::sync::Arc;
Expand Down
7 changes: 5 additions & 2 deletions azalea-physics/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ pub mod clip;
pub mod collision;

use azalea_block::{Block, BlockState};
use azalea_core::{math, BlockPos, Vec3};
use azalea_core::{
math,
position::{BlockPos, Vec3},
};
use azalea_entity::{
metadata::Sprinting, move_relative, Attributes, InLoadedChunk, Jumping, LocalEntity,
LookDirection, Physics, Position,
Expand Down Expand Up @@ -334,7 +337,7 @@ mod tests {
use std::time::Duration;

use super::*;
use azalea_core::{ChunkPos, ResourceLocation};
use azalea_core::{position::ChunkPos, resource_location::ResourceLocation};
use azalea_entity::{EntityBundle, EntityPlugin};
use azalea_world::{Chunk, MinecraftEntityId, PartialInstance};
use bevy_app::App;
Expand Down
6 changes: 5 additions & 1 deletion azalea-protocol/src/packets/common.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
use azalea_buf::McBuf;
use azalea_core::{GameMode, GlobalPos, OptionalGameType, ResourceLocation};
use azalea_core::{
game_type::{GameMode, OptionalGameType},
position::GlobalPos,
resource_location::ResourceLocation,
};

#[derive(Clone, Debug, McBuf)]
pub struct CommonPlayerSpawnInfo {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use azalea_buf::McBuf;
use azalea_buf::UnsizedByteArray;
use azalea_core::ResourceLocation;
use azalea_core::resource_location::ResourceLocation;
use azalea_protocol_macros::ClientboundConfigurationPacket;

#[derive(Clone, Debug, McBuf, ClientboundConfigurationPacket)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub mod registry {
//! biomes.
use azalea_buf::{BufReadError, McBufReadable, McBufWritable};
use azalea_core::ResourceLocation;
use azalea_core::resource_location::ResourceLocation;
use azalea_nbt::Nbt;
use serde::{de, Deserialize, Deserializer, Serialize, Serializer};
use std::{collections::HashMap, io::Cursor};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use azalea_buf::McBuf;
use azalea_core::ResourceLocation;
use azalea_core::resource_location::ResourceLocation;
use azalea_protocol_macros::ClientboundConfigurationPacket;

#[derive(Clone, Debug, McBuf, ClientboundConfigurationPacket)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use azalea_buf::{BufReadError, McBuf, McBufVarReadable, McBufVarWritable};
use azalea_buf::{McBufReadable, McBufWritable};
use azalea_core::ResourceLocation;
use azalea_core::resource_location::ResourceLocation;
use azalea_protocol_macros::ClientboundConfigurationPacket;
use std::io::Cursor;
use std::ops::Deref;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use azalea_buf::{McBuf, McBufReadable, McBufWritable};
use azalea_core::FixedBitSet;
use azalea_core::bitset::FixedBitSet;
use azalea_protocol_macros::ServerboundConfigurationPacket;
use bevy_ecs::component::Component;

Expand Down
Loading

0 comments on commit befa33a

Please sign in to comment.