Buggy code:
} else { if ( ( ( Main . player . inventory . items [ x ] [ y ] ) instanceof ItemMagic ) && ( ( Main . player . inventory . items [ x ] [ y ] . maxStack ) == 1 ) ) { ItemMagic m = ( ( ItemMagic ) ( Main . player . inventory . items [ x ] [ y ] ) ) ; if ( ( ( m . charges ) != ( - 1 ) ) && ( ( m . charges ) <= 5 ) ) { Main . draw ( Main . slot , ( ( x * 32 ) + 480 ) , ( ( y * 32 ) + 120 ) , red ) ; } else { Main . draw ( Main . slot , ( ( x * 32 ) + 480 ) , ( ( y * 32 ) + 120 ) , white ) ; } } else { Main . draw ( Main . slot , ( ( x * 32 ) + 480 ) , ( ( y * 32 ) + 120 ) , white ) ; } } try { if ( ( Main . player . inventory . items [ x ] [ y ] ) != null ) { Main . drawItem ( Main . player . inventory . items [ x ] [ y ] , ( ( x * 32 ) + 488 ) , ( ( y * 32 ) + 128 ) , white ) ; if ( ( ( Main . player . inventory . items [ x ] [ y ] ) instanceof ItemMagic ) && ( ( Main . player . inventory . items [ x ] [ y ] . maxStack ) == 1 ) ) { ItemMagic m = ( ( ItemMagic ) ( Main . player . inventory . items [ x ] [ y ] ) ) ; if ( ( m . charges ) >= 0 ) { hudFont . drawString ( ( ( x * 32 ) + 482 ) , ( ( y * 32 ) + 121 ) , ( ( m . charges ) + "" ) ) ; } } else { if ( ! ( ( Main . player . inventory . items [ x ] [ y ] ) instanceof ItemElement ) ) { hudFont . drawString ( ( ( x * 32 ) + 482 ) , ( ( y * 32 ) + 121 ) , ( ( Main . player . inventory . stack [ x ] [ y ] ) + "" ) ) ; } else { hudFontSmall . drawString ( ( ( x * 32 ) + 482 ) , ( ( y * 32 ) + 121 ) , ( ( new DecimalFormat ( "#.##" ) . format ( ( ( Main . player . inventory . stack [ x ] [ 0 ] ) * ( ( ( ItemElement ) ( Main . player . inventory . items [ x ] [ 0 ] ) ) . atomicWeight ) ) ) ) + "g" ) ) ; } } } if ( ( ( ( ( Mouse . getX ( ) ) >= ( ( x * 32 ) + 480 ) ) && ( ( Mouse . getX ( ) ) < ( ( x * 32 ) + 512 ) ) ) && ( ( 760 - ( Mouse . getY ( ) ) ) >= ( ( y * 32 ) + 128 ) ) ) && ( ( 760 - ( Mouse . getY ( ) ) ) < ( ( y * 32 ) + 160 ) ) ) { if ( ( ( Mouse . isButtonDown ( 0 ) ) && ( ( Main . mouseItem ) == null ) ) && ( ( WorldEdit . keyCounter ) == 0 ) ) { Main . mouseItem = Main . player . inventory . items [ x ] [ y ] ; Main . mouseStack = Main . player . inventory . stack [ x ] [ y ] ; Main . player . inventory . items [ x ] [ y ] = null ; Main . player . inventory . stack [ x ] [ y ] = 0 ; WorldEdit . keyCounter = 8 ; } if ( ( ( Mouse . isButtonDown ( 0 ) ) && ( ( Main . mouseItem ) != null ) ) && ( ( WorldEdit . keyCounter ) == 0 ) ) { if ( ( Main . player . inventory . items [ x ] [ y ] ) != null ) { <START_BUG> if ( ( Main . player . inventory . items [ x ] [ y ] ) != ( Main . mouseItem ) ) { <END_BUG> Item i = Main . player . inventory . items [ x ] [ y ] ; int s = Main . player . inventory . stack [ x ] [ y ] ; Main . player . inventory . items [ x ] [ y ] = Main . mouseItem ; Main . player . inventory . stack [ x ] [ y ] = Main . mouseStack ; Main . mouseItem = i ; Main . mouseStack = s ; } else { Main . player . inventory . stack [ x ] [ y ] += Main . mouseStack ; Main . mouseItem = null ; Main . mouseStack = 0 ; } } else { Main . player . inventory . items [ x ] [ y ] = Main . mouseItem ; Main . player . inventory . stack [ x ] [ y ] = Main . mouseStack ;

Fix:
if ( ( Main . player . inventory . items [ x ] [ y ] . toJSON ( ) ) != ( Main . mouseItem . toJSON ( ) ) ) {