aboutsummaryrefslogtreecommitdiff
path: root/azalea-entity/src
diff options
context:
space:
mode:
Diffstat (limited to 'azalea-entity/src')
-rw-r--r--azalea-entity/src/attributes.rs19
-rw-r--r--azalea-entity/src/lib.rs27
2 files changed, 35 insertions, 11 deletions
diff --git a/azalea-entity/src/attributes.rs b/azalea-entity/src/attributes.rs
index 12c9b908..7af845f8 100644
--- a/azalea-entity/src/attributes.rs
+++ b/azalea-entity/src/attributes.rs
@@ -12,6 +12,9 @@ pub struct Attributes {
pub speed: AttributeInstance,
pub attack_speed: AttributeInstance,
pub water_movement_efficiency: AttributeInstance,
+
+ pub block_interaction_range: AttributeInstance,
+ pub entity_interaction_range: AttributeInstance,
}
#[derive(Clone, Debug)]
@@ -93,7 +96,6 @@ pub fn sprinting_modifier() -> AttributeModifier {
operation: AttributeModifierOperation::MultiplyTotal,
}
}
-
pub fn base_attack_speed_modifier(amount: f64) -> AttributeModifier {
AttributeModifier {
id: ResourceLocation::new("base_attack_speed"),
@@ -101,3 +103,18 @@ pub fn base_attack_speed_modifier(amount: f64) -> AttributeModifier {
operation: AttributeModifierOperation::Addition,
}
}
+pub fn creative_block_interaction_range_modifier() -> AttributeModifier {
+ AttributeModifier {
+ id: ResourceLocation::new("creative_mode_block_range"),
+ amount: 0.5,
+ operation: AttributeModifierOperation::Addition,
+ }
+}
+
+pub fn creative_entity_interaction_range_modifier() -> AttributeModifier {
+ AttributeModifier {
+ id: ResourceLocation::new("creative_mode_entity_range"),
+ amount: 2.0,
+ operation: AttributeModifierOperation::Addition,
+ }
+}
diff --git a/azalea-entity/src/lib.rs b/azalea-entity/src/lib.rs
index cf2222d4..b8644546 100644
--- a/azalea-entity/src/lib.rs
+++ b/azalea-entity/src/lib.rs
@@ -25,6 +25,7 @@ use azalea_core::{
position::{BlockPos, ChunkPos, Vec3},
resource_location::ResourceLocation,
};
+use azalea_registry::EntityKind;
use azalea_world::{ChunkStorage, InstanceName};
use bevy_ecs::{bundle::Bundle, component::Component};
pub use data::*;
@@ -426,13 +427,13 @@ impl From<&EyeHeight> for f64 {
/// Most of the time, you should be using `azalea_registry::EntityKind`
/// directly instead.
#[derive(Component, Clone, Copy, Debug, PartialEq, Deref)]
-pub struct EntityKind(pub azalea_registry::EntityKind);
+pub struct EntityKindComponent(pub azalea_registry::EntityKind);
/// A bundle of components that every entity has. This doesn't contain metadata,
/// that has to be added separately.
#[derive(Bundle)]
pub struct EntityBundle {
- pub kind: EntityKind,
+ pub kind: EntityKindComponent,
pub uuid: EntityUuid,
pub world_name: InstanceName,
pub position: Position,
@@ -465,7 +466,7 @@ impl EntityBundle {
};
Self {
- kind: EntityKind(kind),
+ kind: EntityKindComponent(kind),
uuid: EntityUuid(uuid),
world_name: InstanceName(world_name),
position: Position(pos),
@@ -475,13 +476,7 @@ impl EntityBundle {
eye_height: EyeHeight(eye_height),
direction: LookDirection::default(),
- attributes: Attributes {
- // TODO: do the correct defaults for everything, some
- // entities have different defaults
- speed: AttributeInstance::new(0.1),
- attack_speed: AttributeInstance::new(4.0),
- water_movement_efficiency: AttributeInstance::new(0.0),
- },
+ attributes: default_attributes(EntityKind::Player),
jumping: Jumping(false),
fluid_on_eyes: FluidOnEyes(FluidKind::Empty),
@@ -490,6 +485,18 @@ impl EntityBundle {
}
}
+pub fn default_attributes(_entity_kind: EntityKind) -> Attributes {
+ // TODO: do the correct defaults for everything, some
+ // entities have different defaults
+ Attributes {
+ speed: AttributeInstance::new(0.1),
+ attack_speed: AttributeInstance::new(4.0),
+ water_movement_efficiency: AttributeInstance::new(0.0),
+ block_interaction_range: AttributeInstance::new(4.5),
+ entity_interaction_range: AttributeInstance::new(3.0),
+ }
+}
+
/// A marker component that signifies that this entity is "local" and shouldn't
/// be updated by other clients.
///