Basic handling of Set creative mod slot packet
This commit is contained in:
parent
9a10ea4ed9
commit
7b9b35e437
@ -8,6 +8,7 @@ mod s_player_command;
|
||||
mod s_player_position;
|
||||
mod s_player_position_rotation;
|
||||
mod s_player_rotation;
|
||||
mod s_set_creative_slot;
|
||||
mod s_set_held_item;
|
||||
mod s_swing_arm;
|
||||
mod s_use_item_on;
|
||||
@ -22,6 +23,7 @@ pub use s_player_command::*;
|
||||
pub use s_player_position::*;
|
||||
pub use s_player_position_rotation::*;
|
||||
pub use s_player_rotation::*;
|
||||
pub use s_set_creative_slot::*;
|
||||
pub use s_set_held_item::*;
|
||||
pub use s_swing_arm::*;
|
||||
pub use s_use_item_on::*;
|
||||
|
||||
10
pumpkin-protocol/src/server/play/s_set_creative_slot.rs
Normal file
10
pumpkin-protocol/src/server/play/s_set_creative_slot.rs
Normal file
@ -0,0 +1,10 @@
|
||||
use pumpkin_macros::packet;
|
||||
|
||||
use crate::slot::Slot;
|
||||
|
||||
#[derive(serde::Deserialize, Debug)]
|
||||
#[packet(0x32)]
|
||||
pub struct SSetCreativeSlot {
|
||||
slot: i16,
|
||||
clicked_item: Slot,
|
||||
}
|
||||
@ -29,7 +29,7 @@ use pumpkin_protocol::{
|
||||
play::{
|
||||
SChatCommand, SChatMessage, SClientInformationPlay, SConfirmTeleport, SInteract,
|
||||
SPlayerAction, SPlayerCommand, SPlayerPosition, SPlayerPositionRotation,
|
||||
SPlayerRotation, SSetHeldItem, SSwingArm, SUseItemOn,
|
||||
SPlayerRotation, SSetCreativeSlot, SSetHeldItem, SSwingArm, SUseItemOn,
|
||||
},
|
||||
status::{SPingRequest, SStatusRequest},
|
||||
},
|
||||
@ -304,6 +304,9 @@ impl Client {
|
||||
SSetHeldItem::PACKET_ID => {
|
||||
self.handle_set_held_item(server, SSetHeldItem::read(bytebuf).unwrap())
|
||||
}
|
||||
SSetCreativeSlot::PACKET_ID => {
|
||||
self.handle_set_creative_slot(server, SSetCreativeSlot::read(bytebuf).unwrap())
|
||||
}
|
||||
_ => log::error!("Failed to handle player packet id {}", packet.id.0),
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,11 +4,13 @@ use pumpkin_protocol::{
|
||||
client::play::{
|
||||
Animation, CBlockUpdate, CEntityAnimation, CEntityVelocity, CHeadRot, CHurtAnimation,
|
||||
CSystemChatMessge, CUpdateEntityPos, CUpdateEntityPosRot, CUpdateEntityRot,
|
||||
}, position::WorldPosition, server::play::{
|
||||
},
|
||||
position::WorldPosition,
|
||||
server::play::{
|
||||
Action, SChatCommand, SChatMessage, SClientInformationPlay, SConfirmTeleport, SInteract,
|
||||
SPlayerAction, SPlayerCommand, SPlayerPosition, SPlayerPositionRotation, SPlayerRotation,
|
||||
SSetHeldItem, SSwingArm, SUseItemOn,
|
||||
}
|
||||
SSetCreativeSlot, SSetHeldItem, SSwingArm, SUseItemOn,
|
||||
},
|
||||
};
|
||||
use pumpkin_text::TextComponent;
|
||||
use pumpkin_world::block::BlockFace;
|
||||
@ -316,7 +318,7 @@ impl Client {
|
||||
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;
|
||||
let location = use_item_on.location;
|
||||
let face = BlockFace::from_i32(use_item_on.face.0).unwrap();
|
||||
let location = WorldPosition(location.0 + face.to_offset());
|
||||
server.broadcast_packet(self, &CBlockUpdate::new(location, 11.into()));
|
||||
@ -330,4 +332,9 @@ impl Client {
|
||||
let player = self.player.as_mut().unwrap();
|
||||
player.inventory.set_selected(slot);
|
||||
}
|
||||
|
||||
pub fn handle_set_creative_slot(&mut self, _server: &mut Server, packet: SSetCreativeSlot) {
|
||||
// TODO: handle this
|
||||
dbg!(&packet);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user