Buggy code:
i < ( ItemType . values ( ) . length ) ; i ++ ) { int x = ( inventory_zone_x + ( i * f_h ) ) + ( i * 6 ) ; if ( i < ( items . size ( ) ) ) { itemImages . get ( items . get ( i ) ) . draw ( x , f_y , f_h , f_h ) ; Rectangle rect = new Rectangle ( x , f_y , f_h , f_h ) ; inventoryZones . add ( rect ) ; int count = gs . getItemCount ( items . get ( i ) ) ; if ( count > 1 ) { int w = g . getFont ( ) . getWidth ( ( "" + count ) ) ; int h = g . getFont ( ) . getHeight ( ( "" + count ) ) ; g . setColor ( cyan ) ; g . fillRect ( ( ( x + f_h ) - w ) , ( ( f_y + f_h ) - h ) , w , h ) ; g . setColor ( black ) ; g . drawString ( ( "" + count ) , ( ( x + f_h ) - w ) , ( ( f_y + f_h ) - h ) ) ; } } else { g . setColor ( black ) ; g . fillRect ( x , f_y , f_h , f_h ) ; } g . setColor ( darkGray ) ; g . drawRect ( ( x - 1 ) , ( f_y - 1 ) , ( f_h + 2 ) , ( f_h + 2 ) ) ; } int mouseX = input . getMouseX ( ) ; int mouseY = input . getMouseY ( ) ; for ( Rectangle r : inventoryZones ) { if ( r . contains ( mouseX , mouseY ) ) { g . setColor ( black ) ; g . drawString ( ( ( ( items . get ( inventoryZones . indexOf ( r ) ) . name ( ) ) + "<seq2seq4repair_space>:<seq2seq4repair_space>" ) + ( getDescription ( items . get ( inventoryZones . indexOf ( r ) ) ) ) ) , ( ( container . getWidth ( ) ) - 400 ) , ( ( container . getHeight ( ) ) - 40 ) ) ; } } ArrayList < Rectangle > actionZones = new ArrayList < Rectangle > ( ) ; ArrayList < Action > validActions = new ArrayList < Action > ( ) ; if ( ( selectedAgent ) != null ) { PlayerUI playerUI = players . get ( agents . indexOf ( selectedAgent ) ) ; Tile tile = ts . getTileFromWorld ( playerUI . location . x , playerUI . location . y ) ; int x = 5 ; validActions = actionManager . getValidActions ( gs , ts , tile , selectedAgent ) ; Action actionHotKeyPressed = null ; <START_BUG> for ( int i = 0 ; i < ( ( validActions . size ( ) ) - 1 ) ; i ++ ) { <END_BUG> Action action = validActions . get ( i ) ; String name = action . getName ( ) ; if ( ( ( ( ( ( ( ( ( ( ( ( ( i == 0 ) && ( ( input . isKeyDown ( KEY_F1 ) ) || ( input . isKeyDown ( KEY_Z ) ) ) ) || ( ( i == 1 ) && ( ( input . isKeyDown ( KEY_F2 ) ) || ( input . isKeyDown ( KEY_X ) ) ) ) ) || ( ( i == 2 ) && ( ( input . isKeyDown ( KEY_F3 ) ) || ( input . isKeyDown ( KEY_C ) ) ) ) ) || ( ( i == 3 ) && ( ( input . isKeyDown ( KEY_F4 ) ) || ( input . isKeyDown ( KEY_V ) ) ) ) ) || ( ( i == 4 ) && ( ( input . isKeyDown ( KEY_F5 ) ) || ( input . isKeyDown ( KEY_B ) ) ) ) ) || ( ( i == 5 ) && ( ( input . isKeyDown ( KEY_F6 ) ) || ( input . isKeyDown ( KEY_N ) ) ) ) ) || ( ( i == 6 ) && ( ( input . isKeyDown ( KEY_F7 ) ) || ( input . isKeyDown ( KEY_M ) ) ) ) ) || ( ( i == 7 ) && ( ( input . isKeyDown ( KEY_F8 ) ) || ( input . isKeyDown ( KEY_COMMA ) ) ) ) ) || ( ( i == 8 ) && ( ( input . isKeyDown ( KEY_F9 ) ) || ( input . isKeyDown ( KEY_STOP ) ) ) ) ) || ( ( i == 9 ) && ( ( input . isKeyDown ( KEY_F10 ) ) || ( input . isKeyDown ( KEY_SLASH ) ) ) ) ) || ( ( i == 10 ) && ( input . isKeyDown ( KEY_F11 ) ) ) ) || ( ( i == 11 ) && ( input . isKeyDown ( KEY_F12 ) ) ) ) { if ( ( actionKeyPressed ) != i ) { actionKeyPressed = i ; actionHotKeyPressed = action ; } } else { actionKeyPressed = - 1 ; actionHotKeyPressed = null ; } int t_w = g . getFont ( ) . getWidth ( name ) ; int t_h = g . getFont ( ) . getHeight ( name ) ; int b_w = t_w + 6 ; int b_h = a_h ; int t_y = ( a_h - t_h ) // 2 ; int t_x = ( b_w - t_w ) // 2 ; g . setColor ( darkGray ) ; g . drawRect ( x , a_y , b_w , b_h ) ;

Fix:
for ( int i = 0 ; i < ( validActions . size ( ) ) ; i ++ ) {