@@ -1391,7 +1391,7 @@ private void takeEntry(GearEntry entry, ScreenHandler handler)
13911391 if (entry .slotId < 0 )
13921392 return ;
13931393
1394- Slot slot = handler . getSlot ( entry .slotId );
1394+ Slot slot = getSlotSafe ( handler , entry .slotId );
13951395 if (slot == null || !slot .hasStack ())
13961396 return ;
13971397
@@ -1408,7 +1408,7 @@ private void takeEntry(BookEntry entry, ScreenHandler handler)
14081408 if (entry .slotId < 0 )
14091409 return ;
14101410
1411- Slot slot = handler . getSlot ( entry .slotId );
1411+ Slot slot = getSlotSafe ( handler , entry .slotId );
14121412 if (slot == null || !slot .hasStack ())
14131413 return ;
14141414
@@ -1425,7 +1425,7 @@ private void takeEntry(PotionEntry entry, ScreenHandler handler)
14251425 if (entry .slotId < 0 )
14261426 return ;
14271427
1428- Slot slot = handler . getSlot ( entry .slotId );
1428+ Slot slot = getSlotSafe ( handler , entry .slotId );
14291429 if (slot == null || !slot .hasStack ())
14301430 return ;
14311431
@@ -1460,7 +1460,7 @@ private void takeGearCategory(GearCategory category, ScreenHandler handler,
14601460 {
14611461 if (entry .slotId < 0 )
14621462 continue ; // display-only (in shulker)
1463- Slot slot = handler . getSlot ( entry .slotId );
1463+ Slot slot = getSlotSafe ( handler , entry .slotId );
14641464 if (slot == null || !slot .hasStack ())
14651465 continue ;
14661466
@@ -1497,7 +1497,7 @@ private void takeBookCategory(BookCategory category, ScreenHandler handler,
14971497 {
14981498 if (entry .slotId < 0 )
14991499 continue ;
1500- Slot slot = handler . getSlot ( entry .slotId );
1500+ Slot slot = getSlotSafe ( handler , entry .slotId );
15011501 if (slot == null || !slot .hasStack ())
15021502 continue ;
15031503 MC .interactionManager .clickSlot (handler .syncId , entry .slotId , 0 ,
@@ -1533,7 +1533,7 @@ private void takePotionCategory(PotionCategory category,
15331533 {
15341534 if (entry .slotId < 0 )
15351535 continue ;
1536- Slot slot = handler . getSlot ( entry .slotId );
1536+ Slot slot = getSlotSafe ( handler , entry .slotId );
15371537 if (slot == null || !slot .hasStack ())
15381538 continue ;
15391539 MC .interactionManager .clickSlot (handler .syncId , entry .slotId , 0 ,
@@ -1543,6 +1543,18 @@ private void takePotionCategory(PotionCategory category,
15431543 needsRescan = true ;
15441544 }
15451545
1546+ private Slot getSlotSafe (ScreenHandler handler , int slotId )
1547+ {
1548+ if (handler == null || slotId < 0 )
1549+ return null ;
1550+
1551+ List <Slot > slots = handler .slots ;
1552+ if (slots == null || slotId >= slots .size ())
1553+ return null ;
1554+
1555+ return handler .getSlot (slotId );
1556+ }
1557+
15461558 private int panelInnerHeight ()
15471559 {
15481560 float scale = MathHelper .clamp (textScale .getValueF (), 0.5F , 1.25F );
0 commit comments