@@ -322,6 +322,15 @@ private static String getStorageName(IChestOrDrive storage, String defaultName)
322322 }
323323
324324 public static IItemHandler getCellInventory (IChestOrDrive storage ) {
325+ // TileChest has a combined internal inventory (input + cell), so we need special handling
326+ // to return only the cell inventory portion.
327+ if (storage instanceof TileChest ) {
328+ TileChest chest = (TileChest ) storage ;
329+ IItemHandler wrapper = new TileChestCellInventoryWrapper (chest );
330+
331+ return wrapper ;
332+ }
333+
325334 // Modular handling of Storage Drive-like tiles via AENetworkInvTile
326335 if (storage instanceof AENetworkInvTile ) return ((AENetworkInvTile ) storage ).getInternalInventory ();
327336
@@ -332,6 +341,60 @@ public static IItemHandler getCellInventory(IChestOrDrive storage) {
332341 return null ;
333342 }
334343
344+ /**
345+ * Wrapper for TileChest's cell inventory.
346+ * TileChest has getInternalInventory() returning a combined inventory where:
347+ * - slot 0 = input inventory (for items to be stored)
348+ * - slot 1 = cell inventory (the actual storage cell)
349+ *
350+ * This wrapper maps slot 0 to the cell slot (slot 1 of the internal inventory).
351+ */
352+ private static class TileChestCellInventoryWrapper implements IItemHandler {
353+ private final TileChest chest ;
354+ private final IItemHandler internalInv ;
355+
356+ public TileChestCellInventoryWrapper (TileChest chest ) {
357+ this .chest = chest ;
358+ this .internalInv = chest .getInternalInventory ();
359+ }
360+
361+ @ Override
362+ public int getSlots () {
363+ return 1 ; // TileChest has exactly 1 cell slot
364+ }
365+
366+ @ Override
367+ public ItemStack getStackInSlot (int slot ) {
368+ if (slot != 0 ) return ItemStack .EMPTY ;
369+ // Slot 1 in the combined inventory is the cell slot
370+ return internalInv .getStackInSlot (1 );
371+ }
372+
373+ @ Override
374+ public ItemStack insertItem (int slot , ItemStack stack , boolean simulate ) {
375+ if (slot != 0 ) return stack ;
376+ return internalInv .insertItem (1 , stack , simulate );
377+ }
378+
379+ @ Override
380+ public ItemStack extractItem (int slot , int amount , boolean simulate ) {
381+ if (slot != 0 ) return ItemStack .EMPTY ;
382+ return internalInv .extractItem (1 , amount , simulate );
383+ }
384+
385+ @ Override
386+ public int getSlotLimit (int slot ) {
387+ if (slot != 0 ) return 0 ;
388+ return internalInv .getSlotLimit (1 );
389+ }
390+
391+ @ Override
392+ public boolean isItemValid (int slot , ItemStack stack ) {
393+ if (slot != 0 ) return false ;
394+ return internalInv .isItemValid (1 , stack );
395+ }
396+ }
397+
335398 /**
336399 * Get cell inventory from ECOAEExtension's wrapped drive.
337400 */
0 commit comments