Skip to content

Commit

Permalink
Bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
Bafran committed Dec 29, 2024
1 parent 98d0cc1 commit e4f95ab
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions pumpkin/src/net/packet/play.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,11 @@ impl Player {
return;
};

if block.item_id == 0 {
// Invalid block id (blocks such as tall seagrass)
return;
}

let mut inventory = self.inventory().lock().await;

let source_slot = inventory.get_slot_with_item(block.item_id);
Expand All @@ -357,7 +362,11 @@ impl Player {
}

match source_slot {
Some(slot_index) if !(slot_index > 36 && slot_index <= 44) => {
Some(slot_index) if (36..=44).contains(&slot_index) => {
// Case where item is in hotbar
dest_slot = slot_index - 36;
}
Some(slot_index) => {
// Case where item is in inventory

// Update destination slot
Expand All @@ -372,10 +381,6 @@ impl Player {
self.update_single_slot(&mut inventory, slot_index, dest_slot_data)
.await;
}
Some(slot_index) => {
// Case where item is in hotbar
dest_slot = slot_index - 36;
}
None if self.gamemode.load() == GameMode::Creative => {
// Case where item is not present, if in creative mode create the item
let item_stack = ItemStack::new(1, block.item_id);
Expand Down

0 comments on commit e4f95ab

Please sign in to comment.