NuclearCraft: Neoteric

NuclearCraft: Neoteric

371k Downloads

Incorrect item result comparison in AbstractRecipe

Closed this issue ยท 6 comments

commented

AbstractRecipe uses direct equality checks (equals) instead of ItemStack.is() for result item comparison. This causes issues with item variant (such as the item replaced by using OEI).

Image
commented

can you please point me where this equality check is happening?

commented

Yes,
src/main/java/igentuman/nc/recipes/AbstractRecipe.java

L200
This is where I believed that caused the issue.

commented

It doesn't have such checks here.

    public List<ItemStack> getResultItems() {
        if(cachedOutputItems == null) {
            cachedOutputItems = new ArrayList<>();
            for (ItemStackIngredient outputItem : outputItems) {
                if(outputItem == null) continue;
                List<ItemStack> items = outputItem.getRepresentations();
                if(items.size() == 1) {
                    cachedOutputItems.add(items.get(0));
                    continue;
                }
                resolve:
                for(String mod: MATERIAL_PRODUCTS.MODS_PRIORITY.get()) {
                    for(ItemStack item: items) {
                        if(getModId(item).equals(mod)) {
                            cachedOutputItems.add(item);
                            break resolve;
                        }
                    }
                }
            }
        }
        return cachedOutputItems;
    }
commented

public List<ItemStack> getResultItems() {
if(cachedOutputItems == null) {
cachedOutputItems = new ArrayList<>();
for (ItemStackIngredient outputItem : outputItems) {
if(outputItem == null) continue;
List<ItemStack> items = outputItem.getRepresentations();
if(items.size() == 1) {
cachedOutputItems.add(items.get(0));
continue;
}
resolve:
for(String mod: MATERIAL_PRODUCTS.MODS_PRIORITY.get()) {
for(ItemStack item: items) {
if(getModId(item).equals(mod)) {
cachedOutputItems.add(item);
break resolve;
}
}
}
}
}
return cachedOutputItems;
}

and is here:

commented

This is not equality check. This is logic where we select item by mod priority config.
Anyways there's some potential problem, i've commited changes. Should fix the problem.
Please try out latest build. If this fixes the problem, we can close this issue.

commented
Image

Seems like it's working now! Sorry for the bad description.