public static ItemStack getItemStackFromParameterString(String parameters)
    {
        // Split into parameters:
        List<String> params = new ArrayList<String>(Arrays.asList(parameters.split(" ")));
        Colour col = null;
        Variation var = null;

        // See if any parameters appear to be a colour:
        Iterator<String> it = params.iterator();
        while (it.hasNext() && col == null)
        {
            col = MinecraftTypeHelper.attemptToGetAsColour(it.next());
            if (col != null)
                it.remove();    // This parameter was a colour - we've parsed it, so remove it.
        }

        // See if any parameters appear to be a variant:
        it = params.iterator();
        while (it.hasNext() && var == null)
        {
            var = MinecraftTypeHelper.attemptToGetAsVariant(it.next());
            if (var != null)
                it.remove();    // This parameter was a variant - we've parsed it, so remove it.
        }

        // Hopefully we have at most one parameter left, which will be the type.
        if (params.size() == 0)
            return null;  // Dunno what to do, really.

        String itemName = params.get(0);
        DrawItem di = new DrawItem();
        di.setColour(col);
        di.setVariant(var);
        di.setType(itemName);
        return getItemStackFromDrawItem(di);
    }
public static ItemStack getItemStackFromParameterString ( String parameters ) { List < String > params = new ArrayList < String > ( Arrays . asList ( parameters . split ( " " ) ) ) ; Colour col = null ; Variation var = null ; Iterator < String > it = params . iterator ( ) ; while ( it . hasNext ( ) && col == null ) { col = MinecraftTypeHelper . attemptToGetAsColour ( it . next ( ) ) ; if ( col != null ) it . remove ( ) ; } it = params . iterator ( ) ; while ( it . hasNext ( ) && var == null ) { var = MinecraftTypeHelper . attemptToGetAsVariant ( it . next ( ) ) ; if ( var != null ) it . remove ( ) ; } if ( params . size ( ) == 0 ) return null ; String itemName = params . get ( 0 ) ; DrawItem di = new DrawItem ( ) ; di . setColour ( col ) ; di . setVariant ( var ) ; di . setType ( itemName ) ; return getItemStackFromDrawItem ( di ) ; }
Take a string of parameters, delimited by spaces, and create an ItemStack from it.
@param parameters the item name, variation, colour etc of the required item, separated by spaces.
@return an Itemstack for these parameters, or null if unrecognised.