-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented &tested sneakevent & sneak component. (#428)
- Loading branch information
1 parent
e04b640
commit 6dd9750
Showing
9 changed files
with
114 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
use common::Game; | ||
use ecs::{Entity, SysResult}; | ||
use protocol::packets::client::{EntityAction, EntityActionKind}; | ||
use quill_common::{components::Sneaking, events::SneakEvent}; | ||
|
||
/// From [wiki](https://wiki.vg/Protocol#Entity_Action) | ||
/// Sent by the client to indicate that it has performed certain actions: | ||
/// *) sneaking (crouching), | ||
/// *) sprinting, | ||
/// *) exiting a bed, | ||
/// *) jumping with a horse, | ||
/// *) opening a horse's inventory while riding it. | ||
/// | ||
pub fn handle_entity_action(game: &mut Game, player: Entity, packet: EntityAction) -> SysResult { | ||
match packet.action_id { | ||
EntityActionKind::StartSneaking => { | ||
let is_sneaking = game.ecs.get_mut::<Sneaking>(player)?.0; | ||
if !is_sneaking { | ||
game.ecs | ||
.insert_entity_event(player, SneakEvent::new(true))?; | ||
game.ecs.get_mut::<Sneaking>(player)?.0 = true; | ||
} | ||
} | ||
EntityActionKind::StopSneaking => { | ||
let is_sneaking = game.ecs.get_mut::<Sneaking>(player)?.0; | ||
if is_sneaking { | ||
game.ecs | ||
.insert_entity_event(player, SneakEvent::new(false))?; | ||
game.ecs.get_mut::<Sneaking>(player)?.0 = false; | ||
} | ||
} | ||
EntityActionKind::LeaveBed => { | ||
//TODO issue #423 | ||
// Note that the leave bed packet is not sent if the server changes night to day | ||
// and all players are kicked out of the bed. We have to seperatly send out | ||
// a notice that bed state might have changed. | ||
} | ||
EntityActionKind::StartSprinting => { | ||
//TODO issue #423 | ||
} | ||
EntityActionKind::StopSprinting => { | ||
//TODO issue #423 | ||
} | ||
EntityActionKind::StartHorseJump => { | ||
//TODO issue #423 | ||
} | ||
EntityActionKind::StopJorseJump => { | ||
//TODO issue #423 | ||
} | ||
EntityActionKind::OpenHorseInventory => { | ||
//TODO issue #423 | ||
} | ||
EntityActionKind::StartElytraFlight => { | ||
//TODO issue #423 | ||
} | ||
} | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters