File tree Expand file tree Collapse file tree 3 files changed +13
-14
lines changed Expand file tree Collapse file tree 3 files changed +13
-14
lines changed Original file line number Diff line number Diff line change @@ -71,18 +71,17 @@ pub struct InventorySlot {
71
71
72
72
impl InventorySlot {
73
73
/// Converts an [`ItemStack`] and network protocol index into an [`InventorySlot`].
74
- pub fn from_network_index ( network : usize , stack : & ItemStack ) -> Option < Self > {
75
- let slot = if SLOT_HOTBAR_OFFSET <= network && network < SLOT_HOTBAR_OFFSET + HOTBAR_SIZE {
74
+ #[ allow( clippy:: manual_range_contains) ]
75
+ pub fn from_network_index ( index : usize , stack : & ItemStack ) -> Option < Self > {
76
+ let slot = if SLOT_HOTBAR_OFFSET <= index && index < SLOT_HOTBAR_OFFSET + HOTBAR_SIZE {
76
77
// Hotbar
77
- ( network - SLOT_HOTBAR_OFFSET ) as i8
78
- } else if network == SLOT_OFFHAND {
78
+ ( index - SLOT_HOTBAR_OFFSET ) as i8
79
+ } else if index == SLOT_OFFHAND {
79
80
-106
80
- } else if SLOT_ARMOR_MIN <= network && network <= SLOT_ARMOR_MAX {
81
- ( ( SLOT_ARMOR_MAX - network) + 100 ) as i8
82
- } else if SLOT_INVENTORY_OFFSET <= network
83
- && network < SLOT_INVENTORY_OFFSET + INVENTORY_SIZE
84
- {
85
- network as i8
81
+ } else if SLOT_ARMOR_MIN <= index && index <= SLOT_ARMOR_MAX {
82
+ ( ( SLOT_ARMOR_MAX - index) + 100 ) as i8
83
+ } else if SLOT_INVENTORY_OFFSET <= index && index < SLOT_INVENTORY_OFFSET + INVENTORY_SIZE {
84
+ index as i8
86
85
} else {
87
86
return None ;
88
87
} ;
Original file line number Diff line number Diff line change @@ -340,9 +340,9 @@ impl NearbyBiomes {
340
340
let chunk_x = ( x / 16 ) as usize ;
341
341
let chunk_z = ( z / 16 ) as usize ;
342
342
343
- let mut local_x = ( ox % 16 ) . abs ( ) as usize ;
344
- let local_y = ( oy % 16 ) . abs ( ) as usize ;
345
- let mut local_z = ( oz % 16 ) . abs ( ) as usize ;
343
+ let mut local_x = ( ox % 16 ) . unsigned_abs ( ) ;
344
+ let local_y = ( oy % 16 ) . unsigned_abs ( ) ;
345
+ let mut local_z = ( oz % 16 ) . unsigned_abs ( ) ;
346
346
347
347
if ox < 0 {
348
348
local_x = 16 - local_x;
Original file line number Diff line number Diff line change @@ -366,7 +366,7 @@ pub enum ItemStackError {
366
366
367
367
impl Display for ItemStackError {
368
368
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
369
- write ! ( f, "{}" , self )
369
+ write ! ( f, "{:? }" , self )
370
370
}
371
371
}
372
372
You can’t perform that action at this time.
0 commit comments