use of com.minecolonies.api.crafting.IGenericRecipe in project minecolonies by ldtteam.
the class JEIPlugin method buildVanillaRecipesMap.
private Map<IRecipeType<?>, List<IGenericRecipe>> buildVanillaRecipesMap() {
final RecipeManager recipeManager = Minecraft.getInstance().level.getRecipeManager();
final List<IGenericRecipe> craftingRecipes = new ArrayList<>();
for (final IRecipe<CraftingInventory> recipe : recipeManager.byType(IRecipeType.CRAFTING).values()) {
if (!recipe.canCraftInDimensions(3, 3))
continue;
tryAddingVanillaRecipe(craftingRecipes, recipe);
}
final List<IGenericRecipe> smeltingRecipes = new ArrayList<>();
for (final IRecipe<IInventory> recipe : recipeManager.byType(IRecipeType.SMELTING).values()) {
tryAddingVanillaRecipe(smeltingRecipes, recipe);
}
return new ImmutableMap.Builder<IRecipeType<?>, List<IGenericRecipe>>().put(IRecipeType.CRAFTING, craftingRecipes).put(IRecipeType.SMELTING, smeltingRecipes).build();
}
use of com.minecolonies.api.crafting.IGenericRecipe in project minecolonies by ldtteam.
the class JEIPlugin method tryAddingVanillaRecipe.
private void tryAddingVanillaRecipe(@NotNull final List<IGenericRecipe> recipes, @NotNull final IRecipe<?> recipe) {
// invalid or special recipes
if (recipe.getResultItem().isEmpty())
return;
try {
final IGenericRecipe genericRecipe = GenericRecipeUtils.create(recipe);
if (genericRecipe.getInputs().isEmpty())
return;
recipes.add(genericRecipe);
} catch (final Exception ex) {
Log.getLogger().warn("Error evaluating recipe " + recipe.getId() + "; ignoring.", ex);
}
}
use of com.minecolonies.api.crafting.IGenericRecipe in project minecolonies by Minecolonies.
the class GenericRecipeUtils method create.
@NotNull
public static IGenericRecipe create(@NotNull final IRecipe<?> recipe) {
final IGenericRecipe original = Objects.requireNonNull(GenericRecipe.of(recipe));
final List<List<ItemStack>> inputs = compact(recipe.getIngredients());
return new GenericRecipe(original.getPrimaryOutput(), original.getAdditionalOutputs(), inputs, original.getGridSize(), original.getIntermediate(), original.getLootTable(), new ArrayList<>(), -1);
}
Aggregations