Jump to content

Observation on RecipeManager$RMRecipeSource B41.50 (Bug?)


Tchernobill

Recommended Posts

Hi,

 

In the decompiled java function of RecipeManager$RMRecipeSource.java (at the end of that post),

this.itemLists.get(index) could still be called with index being -1.

 

It occures when a mod uses multiple instances of an ingredient in a recipe, when this ingredient is available in too small quantity for completing the recipe and with the recipe selected.

e.g.

    recipe Create My10Cherry
    {
        Cherry,

        Cherry, /*here is what can cause the error whith craft window open and that recipe selected if the player has only one cherry available*/

        Result:My2CherryResult=1,
        Time:60.0,
        Category:Farming,
    }

 

It does not occure with a correct definition of recipe, so I do not know if you wanna consider that as a bug.

    recipe Create My10Cherry
    {
        Cherry=2,

        Result:My2CherryResult=1,
        Time:60.0,
        Category:Farming,
    }

I still guess the last line should not be called if index < 0

 

 

decompiled RecipeManager$RMRecipeSource.java

    void getAvailableItems(final RecipeManager.SourceItems sourceItems, final boolean b) {
        if (b) {
            for (int i = 0; i < this.itemLists.size(); ++i) {
                this.itemLists.get(i).getAvailableItems(sourceItems, b);
            }
            return;
        }
        int index = -1;
        for (int j = 0; j < this.itemLists.size(); ++j) {
            final RecipeManager.RMRecipeItemList list = this.itemLists.get(j);
            if (list.hasItems()) {
                if (sourceItems.selectedItem != null && list.indexOf(sourceItems.selectedItem) != -1) {
                    index = j;
                    break;
                }
                if (index == -1) {
                    index = j;
                }
            }
        }
        this.itemLists.get(index).getAvailableItems(sourceItems, b);
    }

Edited by Tchernobill
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...