Skip to content

Commit

Permalink
Added todo for pick from entity
Browse files Browse the repository at this point in the history
  • Loading branch information
Bafran committed Dec 28, 2024
1 parent ac58735 commit 1dcf6d6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
8 changes: 8 additions & 0 deletions pumpkin-protocol/src/server/play/s_pick_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,11 @@ pub struct SPickItemFromBlock {
pub pos: WorldPosition,
pub include_data: bool,
}

// TODO: Handler for this packet
#[derive(Deserialize)]
#[server_packet("play:pick_item_from_entity")]
pub struct SPickItemFromEntity {
pub id: i32,
pub include_data: bool,
}
20 changes: 15 additions & 5 deletions pumpkin/src/client/player_packet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ use pumpkin_protocol::{
},
server::play::{
Action, ActionType, SChatCommand, SChatMessage, SClientCommand, SClientInformationPlay,
SConfirmTeleport, SInteract, SPickItemFromBlock, SPlayPingRequest, SPlayerAbilities,
SPlayerAction, SPlayerCommand, SPlayerPosition, SPlayerPositionRotation, SPlayerRotation,
SSetCreativeSlot, SSetHeldItem, SSwingArm, SUseItemOn, Status,
SConfirmTeleport, SInteract, SPickItemFromBlock, SPickItemFromEntity, SPlayPingRequest,
SPlayerAbilities, SPlayerAction, SPlayerCommand, SPlayerPosition, SPlayerPositionRotation,
SPlayerRotation, SSetCreativeSlot, SSetHeldItem, SSwingArm, SUseItemOn, Status,
},
};
use pumpkin_world::block::{block_registry::get_block_by_item, BlockFace};
Expand Down Expand Up @@ -350,7 +350,10 @@ impl Player {
);
self.client.send_packet(&dest_packet).await;

if inventory.set_slot(dest_slot + 36, Some(item_stack), false).is_err() {
if inventory
.set_slot(dest_slot + 36, Some(item_stack), false)
.is_err()
{
log::error!("Pick item set slot error!");
return;
}
Expand Down Expand Up @@ -383,7 +386,10 @@ impl Player {
);
self.client.send_packet(&packet).await;

if inventory.set_slot(dest_slot + 36, Some(item_stack), false).is_err() {
if inventory
.set_slot(dest_slot + 36, Some(item_stack), false)
.is_err()
{
log::error!("Pick item set slot error!");
return;
}
Expand All @@ -398,6 +404,10 @@ impl Player {
.await;
}

pub fn handle_pick_item_from_entity(&self, _pick_item: SPickItemFromEntity) {
// TODO: Implement and merge any redundant code with pick_item_from_block
}

pub async fn handle_player_command(&self, command: SPlayerCommand) {
if command.entity_id != self.entity_id().into() {
return;
Expand Down

0 comments on commit 1dcf6d6

Please sign in to comment.