play sound on fall damage
This commit is contained in:
parent
b5bac2926d
commit
deda78231a
@ -32,7 +32,7 @@ debug = true
|
|||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
tokio = { version = "1.42", features = [
|
tokio = { version = "1.43", features = [
|
||||||
"macros",
|
"macros",
|
||||||
"net",
|
"net",
|
||||||
"rt-multi-thread",
|
"rt-multi-thread",
|
||||||
@ -50,7 +50,7 @@ rayon = "1.10.0"
|
|||||||
parking_lot = { version = "0.12.3", features = ["send_guard"] }
|
parking_lot = { version = "0.12.3", features = ["send_guard"] }
|
||||||
crossbeam = "0.8.4"
|
crossbeam = "0.8.4"
|
||||||
|
|
||||||
uuid = { version = "1.11.0", features = ["serde", "v3", "v4"] }
|
uuid = { version = "1.12.1", features = ["serde", "v3", "v4"] }
|
||||||
derive_more = { version = "1.0.0", features = ["full"] }
|
derive_more = { version = "1.0.0", features = ["full"] }
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
|
|||||||
@ -8,7 +8,7 @@ pumpkin-protocol = { path = "../pumpkin-protocol" }
|
|||||||
pumpkin-nbt = { path = "../pumpkin-nbt" }
|
pumpkin-nbt = { path = "../pumpkin-nbt" }
|
||||||
pumpkin-util = { path = "../pumpkin-util" }
|
pumpkin-util = { path = "../pumpkin-util" }
|
||||||
|
|
||||||
indexmap = { version = "2.7.0", features = ["serde"] }
|
indexmap = { version = "2.7.1", features = ["serde"] }
|
||||||
|
|
||||||
serde.workspace = true
|
serde.workspace = true
|
||||||
serde_json.workspace = true
|
serde_json.workspace = true
|
||||||
|
|||||||
@ -27,10 +27,10 @@ num-traits = "0.2"
|
|||||||
|
|
||||||
# Compression
|
# Compression
|
||||||
flate2 = "1.0"
|
flate2 = "1.0"
|
||||||
lz4 = "1.28.0"
|
lz4 = "1.28.1"
|
||||||
|
|
||||||
file-guard = "0.2.0"
|
file-guard = "0.2.0"
|
||||||
indexmap = "2.7.0"
|
indexmap = "2.7.1"
|
||||||
|
|
||||||
enum_dispatch = "0.3.13"
|
enum_dispatch = "0.3.13"
|
||||||
|
|
||||||
|
|||||||
@ -68,7 +68,7 @@ sha2 = "0.10.8"
|
|||||||
base64 = "0.22.1"
|
base64 = "0.22.1"
|
||||||
|
|
||||||
# icon loading
|
# icon loading
|
||||||
png = "0.17.15"
|
png = "0.17.16"
|
||||||
|
|
||||||
# logging
|
# logging
|
||||||
simple_logger = { version = "5.0.0", features = ["threads"] }
|
simple_logger = { version = "5.0.0", features = ["threads"] }
|
||||||
@ -78,10 +78,10 @@ time = "0.3.37"
|
|||||||
chrono = { version = "0.4.39", features = ["serde"]}
|
chrono = { version = "0.4.39", features = ["serde"]}
|
||||||
|
|
||||||
# commands
|
# commands
|
||||||
async-trait = "0.1.83"
|
async-trait = "0.1.85"
|
||||||
|
|
||||||
# plugins
|
# plugins
|
||||||
libloading = "0.8.5"
|
libloading = "0.8.6"
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
git-version = "0.3.9"
|
git-version = "0.3.9"
|
||||||
# This makes it so the entire project doesn't recompile on each build on linux.
|
# This makes it so the entire project doesn't recompile on each build on linux.
|
||||||
|
|||||||
@ -2,6 +2,7 @@ use std::sync::atomic::AtomicI32;
|
|||||||
|
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use crossbeam::atomic::AtomicCell;
|
use crossbeam::atomic::AtomicCell;
|
||||||
|
use pumpkin_data::sound::Sound;
|
||||||
use pumpkin_nbt::tag::NbtTag;
|
use pumpkin_nbt::tag::NbtTag;
|
||||||
use pumpkin_protocol::client::play::{CDamageEvent, CEntityStatus, CSetEntityMetadata, Metadata};
|
use pumpkin_protocol::client::play::{CDamageEvent, CEntityStatus, CSetEntityMetadata, Metadata};
|
||||||
use pumpkin_util::math::vector3::Vector3;
|
use pumpkin_util::math::vector3::Vector3;
|
||||||
@ -135,6 +136,10 @@ impl LivingEntity {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.entity
|
||||||
|
.play_sound(Self::get_fall_sound(fall_distance as i32))
|
||||||
|
.await;
|
||||||
|
// TODO: Play block fall sound
|
||||||
self.damage(damage, 10).await; // Fall
|
self.damage(damage, 10).await; // Fall
|
||||||
} else if y_diff < 0.0 {
|
} else if y_diff < 0.0 {
|
||||||
self.fall_distance.store(0.0);
|
self.fall_distance.store(0.0);
|
||||||
@ -144,6 +149,14 @@ impl LivingEntity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn get_fall_sound(distance: i32) -> Sound {
|
||||||
|
if distance > 4 {
|
||||||
|
Sound::EntityGenericBigFall
|
||||||
|
} else {
|
||||||
|
Sound::EntityGenericSmallFall
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Kills the Entity
|
/// Kills the Entity
|
||||||
///
|
///
|
||||||
/// This is similar to `kill` but Spawn Particles, Animation and plays death sound
|
/// This is similar to `kill` but Spawn Particles, Animation and plays death sound
|
||||||
|
|||||||
@ -3,7 +3,10 @@ use std::sync::{atomic::AtomicBool, Arc};
|
|||||||
|
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use crossbeam::atomic::AtomicCell;
|
use crossbeam::atomic::AtomicCell;
|
||||||
use pumpkin_data::entity::{EntityPose, EntityType};
|
use pumpkin_data::{
|
||||||
|
entity::{EntityPose, EntityType},
|
||||||
|
sound::{Sound, SoundCategory},
|
||||||
|
};
|
||||||
use pumpkin_nbt::{compound::NbtCompound, tag::NbtTag};
|
use pumpkin_nbt::{compound::NbtCompound, tag::NbtTag};
|
||||||
use pumpkin_protocol::{
|
use pumpkin_protocol::{
|
||||||
client::play::{
|
client::play::{
|
||||||
@ -296,6 +299,13 @@ impl Entity {
|
|||||||
self.world.broadcast_packet_all(&packet).await;
|
self.world.broadcast_packet_all(&packet).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Plays sound at this entity's position with the entity's sound category
|
||||||
|
pub async fn play_sound(&self, sound: Sound) {
|
||||||
|
self.world
|
||||||
|
.play_sound(sound, SoundCategory::Neutral, &self.pos.load())
|
||||||
|
.await;
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn set_pose(&self, pose: EntityPose) {
|
pub async fn set_pose(&self, pose: EntityPose) {
|
||||||
self.pose.store(pose);
|
self.pose.store(pose);
|
||||||
let pose = pose as i32;
|
let pose = pose as i32;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user