Added Player inventory (WIP)
This commit is contained in:
1 parent
d6fb4ed121
commit
391d5cbcfc
13 files changed
+79
-10
No files matched your search
@@ -29,7 +29,7 @@ use pumpkin_protocol::{
|
||||
play::{
|
||||
SChatCommand, SChatMessage, SClientInformationPlay, SConfirmTeleport, SInteract,
|
||||
SPlayerAction, SPlayerCommand, SPlayerPosition, SPlayerPositionRotation,
|
||||
SPlayerRotation, SSwingArm, SUseItemOn,
|
||||
SPlayerRotation, SSetHeldItem, SSwingArm, SUseItemOn,
|
||||
},
|
||||
status::{SPingRequest, SStatusRequest},
|
||||
},
|
||||
@@ -301,6 +301,9 @@ impl Client {
|
||||
SUseItemOn::PACKET_ID => {
|
||||
self.handle_use_item_on(server, SUseItemOn::read(bytebuf).unwrap())
|
||||
}
|
||||
SSetHeldItem::PACKET_ID => {
|
||||
self.handle_set_held_item(server, SSetHeldItem::read(bytebuf).unwrap())
|
||||
}
|
||||
_ => log::error!("Failed to handle player packet id {}", packet.id.0),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ use pumpkin_protocol::{
|
||||
server::play::{
|
||||
Action, SChatCommand, SChatMessage, SClientInformationPlay, SConfirmTeleport, SInteract,
|
||||
SPlayerAction, SPlayerCommand, SPlayerPosition, SPlayerPositionRotation, SPlayerRotation,
|
||||
SSwingArm, SUseItemOn,
|
||||
SSetHeldItem, SSwingArm, SUseItemOn,
|
||||
},
|
||||
};
|
||||
use pumpkin_text::TextComponent;
|
||||
@@ -320,4 +320,13 @@ impl Client {
|
||||
location.y += 2;
|
||||
server.broadcast_packet(self, &CBlockUpdate::new(location, 11.into()));
|
||||
}
|
||||
|
||||
pub fn handle_set_held_item(&mut self, _server: &mut Server, held: SSetHeldItem) {
|
||||
let slot = held.slot;
|
||||
if !(0..=8).contains(&slot) {
|
||||
self.kick("Invalid held slot")
|
||||
}
|
||||
let player = self.player.as_mut().unwrap();
|
||||
player.inventory.set_selected(slot);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user