MineColonies

MineColonies

53M Downloads

Incorrect amount of amountOfValidBlocks in teachRecipe

averman opened this issue ยท 1 comments

commented

for(final int id: OreDictionary.getOreIDs(stack))
{
final String name = OreDictionary.getOreName(id);
if(name.contains("Wood"))
{
amountOfValidBlocks++;

This code count the amount of OreDictionary entries with word wood in it. But one stack can have multiple entries of OreDictionary, in my case my oak wood plank have these 2 entries: plankWood and plankLightWood

for(final ItemStack stack : storage.getInput())
{
if(!ItemStackUtils.isEmpty(stack))
{
for(final int id: OreDictionary.getOreIDs(stack))
{
final String name = OreDictionary.getOreName(id);
if(name.contains("Wood"))
{
amountOfValidBlocks++;
}
else if(name.contains("ingot") || name.contains("stone") || name.contains("redstone") || name.contains("string"))
{
return false;
}
}
blocks++;

but the count of the blocks are outside this, so if I make a button using oak wood plank, the value of amountOfValidBlocks will be 2 but the blocks will be 1

I think this will solve the problem
`

    for(final ItemStack stack : storage.getInput())
    {
        if(!ItemStackUtils.isEmpty(stack))
        {
            boolean isWood = false;
            for(final int id: OreDictionary.getOreIDs(stack))
            {
                final String name = OreDictionary.getOreName(id);
                if(name.contains("Wood"))
                {
                    isWood = true;
                }
                else if(name.contains("ingot") || name.contains("stone") || name.contains("redstone") || name.contains("string"))
                {
                    return false;
                }
            }
            if(isWood) amountOfValidBlocks++;
            blocks++;
        }
    }

`

commented

Good catch, just a break at the amountOfValidBlocks++ also solves it.