aboutsummaryrefslogtreecommitdiff
path: root/azalea-physics/src
diff options
context:
space:
mode:
authormat <27899617+mat-1@users.noreply.github.com>2023-07-14 22:20:40 -0500
committerGitHub <noreply@github.com>2023-07-14 22:20:40 -0500
commit7405427199e5a994d4a6a706f84434a69cb7a7d9 (patch)
treeca537e5d761bc053187d952fced0915c850b92aa /azalea-physics/src
parentd1afd02aa84e7b4450c1607277f078eb2a0f1bf3 (diff)
downloadazalea-drasl-7405427199e5a994d4a6a706f84434a69cb7a7d9.tar.xz
Mining (#95)
* more mining stuff * initialize azalea-tags crate * more mining stuff 2 * mining in ecs * well technically mining works but no codegen for how long it takes to mine each block yet * rename downloads to __cache__ it was bothering me since it's not *just* downloads * codegen block behavior * fix not sending packet to finish breaking block * mining animation 🎉 * clippy * cleanup, move Client::mine into a client extension * add azalea/src/mining.rs --------- Co-authored-by: mat <git@matdoes.dev>
Diffstat (limited to 'azalea-physics/src')
-rw-r--r--azalea-physics/src/clip.rs2
-rwxr-xr-xazalea-physics/src/collision/mergers.rs5
-rw-r--r--azalea-physics/src/collision/mod.rs10
-rwxr-xr-xazalea-physics/src/collision/shape.rs2
-rw-r--r--azalea-physics/src/collision/world_collisions.rs4
-rw-r--r--azalea-physics/src/lib.rs23
6 files changed, 22 insertions, 24 deletions
diff --git a/azalea-physics/src/clip.rs b/azalea-physics/src/clip.rs
index ca85c32a..d6e0f6bb 100644
--- a/azalea-physics/src/clip.rs
+++ b/azalea-physics/src/clip.rs
@@ -1,5 +1,5 @@
use azalea_block::BlockState;
-use azalea_core::{lerp, BlockHitResult, BlockPos, Direction, Vec3, EPSILON};
+use azalea_core::{math::lerp, BlockHitResult, BlockPos, Direction, Vec3, EPSILON};
use azalea_inventory::ItemSlot;
use azalea_world::ChunkStorage;
use bevy_ecs::entity::Entity;
diff --git a/azalea-physics/src/collision/mergers.rs b/azalea-physics/src/collision/mergers.rs
index 483cb55f..e2381c49 100755
--- a/azalea-physics/src/collision/mergers.rs
+++ b/azalea-physics/src/collision/mergers.rs
@@ -1,7 +1,10 @@
use std::{cmp::Ordering, convert::TryInto};
use super::CubePointRange;
-use azalea_core::{gcd, lcm, EPSILON};
+use azalea_core::{
+ math::{gcd, lcm},
+ EPSILON,
+};
#[derive(Debug)]
pub enum IndexMerger {
diff --git a/azalea-physics/src/collision/mod.rs b/azalea-physics/src/collision/mod.rs
index a99b5710..e24df378 100644
--- a/azalea-physics/src/collision/mod.rs
+++ b/azalea-physics/src/collision/mod.rs
@@ -5,7 +5,7 @@ mod shape;
mod world_collisions;
use azalea_core::{Axis, Vec3, AABB, EPSILON};
-use azalea_world::{entity, Instance, MoveEntityError};
+use azalea_world::{Instance, MoveEntityError};
pub use blocks::BlockWithShape;
pub use discrete_voxel_shape::*;
pub use shape::*;
@@ -49,7 +49,7 @@ pub enum MoverType {
// return var4;
// }
-fn collide(movement: &Vec3, world: &Instance, physics: &entity::Physics) -> Vec3 {
+fn collide(movement: &Vec3, world: &Instance, physics: &azalea_entity::Physics) -> Vec3 {
let entity_bounding_box = physics.bounding_box;
// TODO: get_entity_collisions
// let entity_collisions = world.get_entity_collisions(self,
@@ -71,8 +71,8 @@ pub fn move_colliding(
_mover_type: &MoverType,
movement: &Vec3,
world: &Instance,
- position: &mut entity::Position,
- physics: &mut entity::Physics,
+ position: &mut azalea_entity::Position,
+ physics: &mut azalea_entity::Physics,
) -> Result<(), MoveEntityError> {
// TODO: do all these
@@ -122,7 +122,7 @@ pub fn move_colliding(
// TODO: minecraft checks for a "minor" horizontal collision here
- let _block_pos_below = entity::on_pos_legacy(&world.chunks, position);
+ let _block_pos_below = azalea_entity::on_pos_legacy(&world.chunks, position);
// let _block_state_below = self
// .world
// .get_block_state(&block_pos_below)
diff --git a/azalea-physics/src/collision/shape.rs b/azalea-physics/src/collision/shape.rs
index 29c1b440..a39a86cf 100755
--- a/azalea-physics/src/collision/shape.rs
+++ b/azalea-physics/src/collision/shape.rs
@@ -1,7 +1,7 @@
use super::mergers::IndexMerger;
use crate::collision::{BitSetDiscreteVoxelShape, DiscreteVoxelShape, AABB};
use azalea_core::{
- binary_search, Axis, AxisCycle, BlockHitResult, BlockPos, Direction, Vec3, EPSILON,
+ math::binary_search, Axis, AxisCycle, BlockHitResult, BlockPos, Direction, Vec3, EPSILON,
};
use std::{cmp, num::NonZeroU32};
diff --git a/azalea-physics/src/collision/world_collisions.rs b/azalea-physics/src/collision/world_collisions.rs
index aa55150e..e640f0ce 100644
--- a/azalea-physics/src/collision/world_collisions.rs
+++ b/azalea-physics/src/collision/world_collisions.rs
@@ -71,9 +71,7 @@ impl<'a> Iterator for BlockCollisions<'a> {
}
let chunk = self.get_chunk(item.pos.x, item.pos.z);
- let Some(chunk) = chunk else {
- continue
- };
+ let Some(chunk) = chunk else { continue };
let pos = item.pos;
let block_state: BlockState = chunk
diff --git a/azalea-physics/src/lib.rs b/azalea-physics/src/lib.rs
index 0d9f3be4..6b451dd6 100644
--- a/azalea-physics/src/lib.rs
+++ b/azalea-physics/src/lib.rs
@@ -6,13 +6,12 @@ pub mod collision;
use azalea_block::{Block, BlockState};
use azalea_core::{BlockPos, Vec3};
-use azalea_world::{
- entity::{
- clamp_look_direction, metadata::Sprinting, move_relative, Attributes, Jumping, Local,
- LookDirection, Physics, Position, WorldName,
- },
- Instance, InstanceContainer,
+use azalea_entity::update_bounding_box;
+use azalea_entity::{
+ clamp_look_direction, metadata::Sprinting, move_relative, Attributes, Jumping, Local,
+ LookDirection, Physics, Position,
};
+use azalea_world::{Instance, InstanceContainer, InstanceName};
use bevy_app::{App, FixedUpdate, Plugin, Update};
use bevy_ecs::{
entity::Entity,
@@ -35,7 +34,7 @@ impl Plugin for PhysicsPlugin {
.add_systems(
Update,
force_jump_listener
- .before(azalea_world::entity::update_bounding_box)
+ .before(update_bounding_box)
.after(clamp_look_direction),
)
.add_systems(FixedUpdate, (ai_step, travel).chain().in_set(PhysicsSet));
@@ -51,7 +50,7 @@ fn travel(
&mut LookDirection,
&mut Position,
&Attributes,
- &WorldName,
+ &InstanceName,
),
With<Local>,
>,
@@ -176,7 +175,7 @@ pub fn force_jump_listener(
&Position,
&LookDirection,
&Sprinting,
- &WorldName,
+ &InstanceName,
)>,
instance_container: Res<InstanceContainer>,
mut events: EventReader<ForceJumpEvent>,
@@ -327,10 +326,8 @@ mod tests {
use super::*;
use azalea_core::{ChunkPos, ResourceLocation};
- use azalea_world::{
- entity::{EntityBundle, EntityPlugin, MinecraftEntityId},
- Chunk, PartialInstance,
- };
+ use azalea_entity::{EntityBundle, EntityPlugin};
+ use azalea_world::{Chunk, MinecraftEntityId, PartialInstance};
use bevy_app::App;
use bevy_time::fixed_timestep::FixedTime;
use uuid::Uuid;