-
-
Notifications
You must be signed in to change notification settings - Fork 193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle player packet id 0x23 #163
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
use pumpkin_macros::packet; | ||
use serde::Deserialize; | ||
|
||
//The vanilla client sends this packet when the player starts/stops flying. Bitmask 0x02 is set when the player is flying. | ||
|
||
#[derive(Deserialize)] | ||
#[packet(0x23)] | ||
pub struct SPlayerAbilities { | ||
pub flags: i8, | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,18 +15,17 @@ use pumpkin_core::{ | |
}; | ||
use pumpkin_entity::EntityId; | ||
use pumpkin_inventory::{InventoryError, WindowType}; | ||
use pumpkin_protocol::server::play::{SCloseContainer, SSetPlayerGround, SUseItem}; | ||
use pumpkin_protocol::{ | ||
client::play::{ | ||
Animation, CAcknowledgeBlockChange, CBlockUpdate, CEntityAnimation, CEntityVelocity, | ||
CHeadRot, CHurtAnimation, CPingResponse, CPlayerChatMessage, CUpdateEntityPos, | ||
CUpdateEntityPosRot, CUpdateEntityRot, CWorldEvent, FilterType, | ||
}, | ||
server::play::{ | ||
Action, ActionType, SChatCommand, SChatMessage, SClientInformationPlay, SConfirmTeleport, | ||
SInteract, SPlayPingRequest, SPlayerAction, SPlayerCommand, SPlayerPosition, | ||
SPlayerPositionRotation, SPlayerRotation, SSetCreativeSlot, SSetHeldItem, SSwingArm, | ||
SUseItemOn, Status, | ||
Action, ActionType, SChatCommand, SChatMessage, SClientInformationPlay, SCloseContainer, | ||
SConfirmTeleport, SInteract, SPlayPingRequest, SPlayerAbilities, SPlayerAction, | ||
SPlayerCommand, SPlayerPosition, SPlayerPositionRotation, SPlayerRotation, | ||
SSetCreativeSlot, SSetHeldItem, SSetPlayerGround, SSwingArm, SUseItem, SUseItemOn, Status, | ||
}, | ||
}; | ||
use pumpkin_world::block::{BlockFace, BlockState}; | ||
|
@@ -466,6 +465,7 @@ impl Player { | |
None => self.kick(TextComponent::text("Invalid action type")).await, | ||
} | ||
} | ||
|
||
pub async fn handle_player_action(&self, player_action: SPlayerAction) { | ||
match Status::from_i32(player_action.status.0) { | ||
Some(status) => match status { | ||
|
@@ -539,6 +539,13 @@ impl Player { | |
} | ||
} | ||
|
||
pub async fn handle_player_abilities(&self, player_abilities: SPlayerAbilities) { | ||
let mut abilities = self.abilities.lock().await; | ||
|
||
// Set the flying ability | ||
abilities.flying = player_abilities.flags & 0x02 != 0 && abilities.allow_flying; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The abilities have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've seen that this packet is sent by the client only when the player starts/stops flying and is not sending the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, Just looked at vanilla code and your right!, nvm then |
||
} | ||
|
||
pub async fn handle_play_ping_request(&self, request: SPlayPingRequest) { | ||
self.client | ||
.send_packet(&CPingResponse::new(request.payload)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why you modified the .gitignore ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I've used the "decompile.sh" file and that folder for save researches, to prevent any accidental upload I've changed to include any file and subfolder