|
|
|
@ -7,12 +7,12 @@ use once_cell::sync::Lazy;
|
|
|
|
|
use valence::{
|
|
|
|
|
entity::{living::Health, player::PlayerEntityBundle, EntityId},
|
|
|
|
|
packet::WritePacket,
|
|
|
|
|
prelude::{event::PlayerMove, *},
|
|
|
|
|
prelude::{*, event::PerformRespawn},
|
|
|
|
|
};
|
|
|
|
|
use valence_protocol::{
|
|
|
|
|
packet::s2c::play::{
|
|
|
|
|
synchronize_tags::{Tag, TagGroup},
|
|
|
|
|
ChunkRenderDistanceCenterS2c, SynchronizeTagsS2c,
|
|
|
|
|
ChunkRenderDistanceCenterS2c, SynchronizeTagsS2c
|
|
|
|
|
},
|
|
|
|
|
var_int::VarInt,
|
|
|
|
|
Encode,
|
|
|
|
@ -28,17 +28,17 @@ pub fn fall_damage(
|
|
|
|
|
(
|
|
|
|
|
&mut Client,
|
|
|
|
|
&OnGround,
|
|
|
|
|
&mut EntityId,
|
|
|
|
|
&EntityId,
|
|
|
|
|
&mut Health,
|
|
|
|
|
&GameMode,
|
|
|
|
|
&Position,
|
|
|
|
|
),
|
|
|
|
|
Changed<Position>,
|
|
|
|
|
>,
|
|
|
|
|
mut instances: Query<&Instance>,
|
|
|
|
|
instances: Query<&Instance>,
|
|
|
|
|
) {
|
|
|
|
|
let instance = instances.single();
|
|
|
|
|
for (client, on_ground, id, mut health, gamemode, position) in &mut clients {
|
|
|
|
|
for (_client, on_ground, id, mut health, gamemode, position) in &mut clients {
|
|
|
|
|
let current_block = instance
|
|
|
|
|
.block(BlockPos {
|
|
|
|
|
x: position.0.x.floor() as i32,
|
|
|
|
@ -62,6 +62,7 @@ pub fn fall_damage(
|
|
|
|
|
|
|
|
|
|
if delta_y > 3.0 {
|
|
|
|
|
health.0 -= (delta_y - 3.0) as f32;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
hashmap.insert(id.get(), position.0.y);
|
|
|
|
|
}
|
|
|
|
@ -164,3 +165,22 @@ pub fn despawn_disconnected_clients(
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn respawn(
|
|
|
|
|
mut clients: Query<(&mut Position, &mut Look, &mut Location)>,
|
|
|
|
|
mut events: EventReader<PerformRespawn>,
|
|
|
|
|
instances: Query<Entity, With<Instance>>,
|
|
|
|
|
) {
|
|
|
|
|
for event in events.iter() {
|
|
|
|
|
if let Ok((mut pos, mut look, mut loc)) = clients.get_mut(event.client) {
|
|
|
|
|
pos.set(DVec3 {
|
|
|
|
|
x: -214.0,
|
|
|
|
|
y: 83.0,
|
|
|
|
|
z: 276.0,
|
|
|
|
|
});
|
|
|
|
|
look.yaw = 0.0;
|
|
|
|
|
look.pitch = 0.0;
|
|
|
|
|
loc.0 = instances.single();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|