Add Serverbound Use Item On
This commit is contained in:
parent
4562570f92
commit
9d3ee1de9b
@ -9,3 +9,9 @@ pub struct CBlockUpdate {
|
|||||||
location: WorldPosition,
|
location: WorldPosition,
|
||||||
block_id: VarInt,
|
block_id: VarInt,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl CBlockUpdate {
|
||||||
|
pub fn new(location: WorldPosition, block_id: VarInt) -> Self {
|
||||||
|
Self { location, block_id }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
pub struct WorldPosition {
|
pub struct WorldPosition {
|
||||||
x: i32,
|
pub x: i32,
|
||||||
y: i32,
|
pub y: i32,
|
||||||
z: i32,
|
pub z: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Serialize for WorldPosition {
|
impl Serialize for WorldPosition {
|
||||||
|
|||||||
@ -9,6 +9,7 @@ mod s_player_position;
|
|||||||
mod s_player_position_rotation;
|
mod s_player_position_rotation;
|
||||||
mod s_player_rotation;
|
mod s_player_rotation;
|
||||||
mod s_swing_arm;
|
mod s_swing_arm;
|
||||||
|
mod s_use_item_on;
|
||||||
|
|
||||||
pub use c_client_information::*;
|
pub use c_client_information::*;
|
||||||
pub use c_interact::*;
|
pub use c_interact::*;
|
||||||
@ -21,3 +22,4 @@ pub use s_player_position::*;
|
|||||||
pub use s_player_position_rotation::*;
|
pub use s_player_position_rotation::*;
|
||||||
pub use s_player_rotation::*;
|
pub use s_player_rotation::*;
|
||||||
pub use s_swing_arm::*;
|
pub use s_swing_arm::*;
|
||||||
|
pub use s_use_item_on::*;
|
||||||
|
|||||||
17
pumpkin-protocol/src/server/play/s_use_item_on.rs
Normal file
17
pumpkin-protocol/src/server/play/s_use_item_on.rs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
use pumpkin_macros::packet;
|
||||||
|
use serde::Deserialize;
|
||||||
|
|
||||||
|
use crate::{position::WorldPosition, VarInt};
|
||||||
|
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
#[packet(0x38)]
|
||||||
|
pub struct SUseItemOn {
|
||||||
|
pub hand: VarInt,
|
||||||
|
pub location: WorldPosition,
|
||||||
|
pub face: VarInt,
|
||||||
|
pub cursor_pos_x: f32,
|
||||||
|
pub cursor_pos_y: f32,
|
||||||
|
pub cursor_pos_z: f32,
|
||||||
|
pub inside_block: bool,
|
||||||
|
pub sequene: VarInt,
|
||||||
|
}
|
||||||
@ -29,7 +29,7 @@ use pumpkin_protocol::{
|
|||||||
play::{
|
play::{
|
||||||
SChatCommand, SChatMessage, SClientInformationPlay, SConfirmTeleport, SInteract,
|
SChatCommand, SChatMessage, SClientInformationPlay, SConfirmTeleport, SInteract,
|
||||||
SPlayerAction, SPlayerCommand, SPlayerPosition, SPlayerPositionRotation,
|
SPlayerAction, SPlayerCommand, SPlayerPosition, SPlayerPositionRotation,
|
||||||
SPlayerRotation, SSwingArm,
|
SPlayerRotation, SSwingArm, SUseItemOn,
|
||||||
},
|
},
|
||||||
status::{SPingRequest, SStatusRequest},
|
status::{SPingRequest, SStatusRequest},
|
||||||
},
|
},
|
||||||
@ -298,6 +298,9 @@ impl Client {
|
|||||||
SPlayerAction::PACKET_ID => {
|
SPlayerAction::PACKET_ID => {
|
||||||
self.handle_player_action(server, SPlayerAction::read(bytebuf).unwrap())
|
self.handle_player_action(server, SPlayerAction::read(bytebuf).unwrap())
|
||||||
}
|
}
|
||||||
|
SUseItemOn::PACKET_ID => {
|
||||||
|
self.handle_use_item_on(server, SUseItemOn::read(bytebuf).unwrap())
|
||||||
|
}
|
||||||
_ => log::error!("Failed to handle player packet id {}", packet.id.0),
|
_ => log::error!("Failed to handle player packet id {}", packet.id.0),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,13 +2,13 @@ use num_traits::FromPrimitive;
|
|||||||
use pumpkin_entity::EntityId;
|
use pumpkin_entity::EntityId;
|
||||||
use pumpkin_protocol::{
|
use pumpkin_protocol::{
|
||||||
client::play::{
|
client::play::{
|
||||||
Animation, CEntityAnimation, CEntityVelocity, CHeadRot, CHurtAnimation, CSystemChatMessge,
|
Animation, CBlockUpdate, CEntityAnimation, CEntityVelocity, CHeadRot, CHurtAnimation,
|
||||||
CUpdateEntityPos, CUpdateEntityPosRot, CUpdateEntityRot,
|
CSystemChatMessge, CUpdateEntityPos, CUpdateEntityPosRot, CUpdateEntityRot,
|
||||||
},
|
},
|
||||||
server::play::{
|
server::play::{
|
||||||
Action, SChatCommand, SChatMessage, SClientInformationPlay, SConfirmTeleport, SInteract,
|
Action, SChatCommand, SChatMessage, SClientInformationPlay, SConfirmTeleport, SInteract,
|
||||||
SPlayerAction, SPlayerCommand, SPlayerPosition, SPlayerPositionRotation, SPlayerRotation,
|
SPlayerAction, SPlayerCommand, SPlayerPosition, SPlayerPositionRotation, SPlayerRotation,
|
||||||
SSwingArm,
|
SSwingArm, SUseItemOn,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use pumpkin_text::TextComponent;
|
use pumpkin_text::TextComponent;
|
||||||
@ -314,4 +314,10 @@ impl Client {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn handle_player_action(&mut self, _server: &mut Server, player_action: SPlayerAction) {}
|
pub fn handle_player_action(&mut self, _server: &mut Server, player_action: SPlayerAction) {}
|
||||||
|
|
||||||
|
pub fn handle_use_item_on(&mut self, server: &mut Server, use_item_on: SUseItemOn) {
|
||||||
|
let mut location = use_item_on.location;
|
||||||
|
location.y += 2;
|
||||||
|
server.broadcast_packet(self, &CBlockUpdate::new(location, 11.into()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user