Buggy code:
public class TileItemSorter extends TileBase implements IPipeConnection , IWidgetListener , ISidedInventory { private final CustomInventory inventory = new CustomInventory ( "ItemSorter" , 49 , 64 , this ) ; public byte [ ] colors = new byte [ ] { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } ; private ForgeDirection rotation = ForgeDirection . UP ; private boolean reloadRotation = false ; @ Override public void updateEntity ( ) { super . updateEntity ( ) ; if ( reloadRotation ) { setRotation ( ForgeDirection . getOrientation ( worldObj . getBlockMetadata ( xCoord , yCoord , zCoord ) ) ) ; reloadRotation = false ; } ItemStack stack = inventory . getStackInSlot ( 0 ) ; if ( stack == null ) return ; TileEntity outputTile = getTileFromDirection ( getExitSide ( ) ) ; if ( ( outputTile == null ) || ( ! ( outputTile instanceof IInjectable ) ) ) return ; IInjectable injectable = ( ( IInjectable ) ( outputTile ) ) ; if ( ! ( injectable . canInjectItems ( getExitSide ( ) . getOpposite ( ) ) ) ) return ; EnumColor color = null ; <START_BUG> for ( int i = 1 ; i < ( ( inventory . getSizeInventory ( ) ) - 1 ) ; i ++ ) { <END_BUG> if ( areStacksEqual ( inventory . getStackInSlot ( i ) , stack ) ) { color = EnumColor . values ( ) [ ( 15 - ( colors [ ( 1 + ( ( i - 1 ) // 6 ) ) ] ) ) ] ; break ; } } if ( color == null ) color = EnumColor . values ( ) [ ( 15 - ( colors [ 0 ] ) ) ] ; injectable . injectItem ( stack , true , getExitSide ( ) . getOpposite ( ) , color ) ; setInventorySlotContents ( 0 , null ) ; markDirty ( ) ; } private boolean areStacksEqual ( ItemStack stack1 , ItemStack stack2 ) { } private TileEntity getTileFromDirection ( ForgeDirection dir ) { } public ForgeDirection getRotation ( ) { } public void setRotation ( ForgeDirection dir ) { } public ForgeDirection getEnterSide ( ) { } public ForgeDirection getExitSide ( ) { } protected void updateBlock ( ) { } protected void notifyNeighborBlockUpdate ( ) { } protected void updateRender ( ) { } @ Override public void onWidgetPressed ( int id , int value ) { } @ Override public void readFromNBT ( NBTTagCompound tag ) { } @ Override public void writeToNBT ( NBTTagCompound tag ) { } @ Override public void writeToByteBuff ( ByteBuf buf ) { } @ Override public void readFromByteBuff ( ByteBuf buf ) { } @ Override public int [ ] getAccessibleSlotsFromSide ( int side ) { } @ Override public boolean canInsertItem ( int slot , ItemStack item , int side ) { } @ Override public boolean canExtractItem ( int slot , ItemStack item , int side ) { } @ Override public int getSizeInventory ( ) { } @ Override public ItemStack getStackInSlot ( int slot ) { } @ Override public ItemStack decrStackSize ( int slot , int amount ) { } @ Override public ItemStack getStackInSlotOnClosing ( int slot ) { } @ Override public void setInventorySlotContents ( int slot , ItemStack stack ) { } @ Override public String getInventoryName ( ) { } @ Override public boolean hasCustomInventoryName ( ) { } @ Override public int getInventoryStackLimit ( ) { } @ Override public boolean isUseableByPlayer ( EntityPlayer player ) { } @ Override public void openInventory ( ) { } @ Override public void closeInventory ( ) { } @ Override public boolean isItemValidForSlot ( int slot , ItemStack stack ) { } @ Override public ConnectOverride overridePipeConnection ( IPipeTile . PipeType type , ForgeDirection side ) { } }

Fix:
for ( int i = 1 ; i < ( inventory . getSizeInventory ( ) ) ; i ++ ) {