Skip to content

Commit

Permalink
fix(pumpkin-inventory/src/drag_handler.rs): divide by 0 (#393)
Browse files Browse the repository at this point in the history
* fix(pumpkin-inventory/src/drag_handler.rs): divide by 0

Please work
Also, commit made on mobile using Built-in GitHub editor 🔥

* fix(pumpkin-inventory/src/drag_handler.rs): syntax errors
  • Loading branch information
DataM0del authored Dec 25, 2024
1 parent 2ae6b08 commit 991ac37
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pumpkin-inventory/src/drag_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,12 @@ impl DragHandler {
let changing_slots =
drag.possibly_changing_slots(&slots_cloned, carried_item.item_id);
let amount_of_slots = changing_slots.clone().count();
let (amount_per_slot, remainder) =
(carried_item.item_count as usize).div_rem_euclid(&amount_of_slots);
let (amount_per_slot, remainder) = if amount_of_slots == 0 {
// TODO: please work lol
(1, 0)
} else {
(carried_item.item_count as usize).div_rem_euclid(&amount_of_slots)
};
let mut item_in_each_slot = *carried_item;
item_in_each_slot.item_count = amount_per_slot as u8;
changing_slots.for_each(|slot| *slots[slot] = Some(item_in_each_slot));
Expand Down

0 comments on commit 991ac37

Please sign in to comment.