Search in sources :

Example 6 with IGenericRecipe

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();
}
Also used : CraftingInventory(net.minecraft.inventory.CraftingInventory) IInventory(net.minecraft.inventory.IInventory) IRecipeType(net.minecraft.item.crafting.IRecipeType) RecipeManager(net.minecraft.item.crafting.RecipeManager) IRecipeManager(mezz.jei.api.recipe.IRecipeManager) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) IGenericRecipe(com.minecolonies.api.crafting.IGenericRecipe) ImmutableMap(com.google.common.collect.ImmutableMap)

Example 7 with IGenericRecipe

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);
    }
}
Also used : IGenericRecipe(com.minecolonies.api.crafting.IGenericRecipe)

Example 8 with IGenericRecipe

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);
}
Also used : IGenericRecipe(com.minecolonies.api.crafting.IGenericRecipe) GenericRecipe(com.minecolonies.api.crafting.GenericRecipe) NonNullList(net.minecraft.util.NonNullList) IGenericRecipe(com.minecolonies.api.crafting.IGenericRecipe) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

IGenericRecipe (com.minecolonies.api.crafting.IGenericRecipe)8 IRecipeType (net.minecraft.item.crafting.IRecipeType)4 NotNull (org.jetbrains.annotations.NotNull)4 ImmutableMap (com.google.common.collect.ImmutableMap)2 ICraftingBuildingModule (com.minecolonies.api.colony.buildings.modules.ICraftingBuildingModule)2 BuildingEntry (com.minecolonies.api.colony.buildings.registry.BuildingEntry)2 IJob (com.minecolonies.api.colony.jobs.IJob)2 GenericRecipe (com.minecolonies.api.crafting.GenericRecipe)2 IRecipeStorage (com.minecolonies.api.crafting.IRecipeStorage)2 ItemStackUtils (com.minecolonies.api.util.ItemStackUtils)2 TranslationConstants (com.minecolonies.api.util.constant.TranslationConstants)2 CustomRecipe (com.minecolonies.coremod.colony.crafting.CustomRecipe)2 CustomRecipeManager (com.minecolonies.coremod.colony.crafting.CustomRecipeManager)2 LootTableAnalyzer (com.minecolonies.coremod.colony.crafting.LootTableAnalyzer)2 MatrixStack (com.mojang.blaze3d.matrix.MatrixStack)2 java.util (java.util)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 VanillaTypes (mezz.jei.api.constants.VanillaTypes)2