use of net.minecraft.world.item.crafting.Ingredient.TagValue in project MinecraftForge by MinecraftForge.
the class ForgeRecipeProvider method enhance.
private Ingredient enhance(ResourceLocation name, Ingredient vanilla) {
if (excludes.contains(name))
return null;
boolean modified = false;
List<Value> items = new ArrayList<>();
// This will probably crash between versions, if null fix index
Value[] vanillaItems = getField(Ingredient.class, vanilla, 2);
for (Value entry : vanillaItems) {
if (entry instanceof ItemValue) {
ItemStack stack = entry.getItems().stream().findFirst().orElse(ItemStack.EMPTY);
Tag<Item> replacement = replacements.get(stack.getItem());
if (replacement != null) {
items.add(new TagValue(replacement));
modified = true;
} else
items.add(entry);
} else
items.add(entry);
}
return modified ? Ingredient.fromValues(items.stream()) : null;
}