Search in sources :

Example 1 with ICompatibilityManager

use of com.minecolonies.api.compatibility.ICompatibilityManager in project minecolonies by Minecolonies.

the class CraftingTagAuditor method getAllItems.

private static List<ItemStack> getAllItems() {
    final ICompatibilityManager compatibility = IColonyManager.getInstance().getCompatibilityManager();
    final List<ItemStack> items = new ArrayList<>(compatibility.getListOfAllItems());
    items.sort(Comparator.comparing(stack -> stack.getItem().getRegistryName().toString()));
    return items;
}
Also used : BuildingEntry(com.minecolonies.api.colony.buildings.registry.BuildingEntry) java.util(java.util) SimpleCraftingModule(com.minecolonies.coremod.colony.buildings.modules.SimpleCraftingModule) IGenericRecipe(com.minecolonies.api.crafting.IGenericRecipe) Supplier(java.util.function.Supplier) ItemStack(net.minecraft.item.ItemStack) MinecraftServer(net.minecraft.server.MinecraftServer) IMinecoloniesAPI(com.minecolonies.api.IMinecoloniesAPI) FolderName(net.minecraft.world.storage.FolderName) MOD_ID(com.minecolonies.api.util.constant.Constants.MOD_ID) CraftingType(com.minecolonies.api.crafting.registry.CraftingType) Log(com.minecolonies.api.util.Log) LootTableAnalyzer(com.minecolonies.coremod.colony.crafting.LootTableAnalyzer) Path(java.nio.file.Path) ICompatibilityManager(com.minecolonies.api.compatibility.ICompatibilityManager) Files(java.nio.file.Files) BufferedWriter(java.io.BufferedWriter) ICraftingBuildingModule(com.minecolonies.api.colony.buildings.modules.ICraftingBuildingModule) IColonyManager(com.minecolonies.api.colony.IColonyManager) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) RecipeAnalyzer(com.minecolonies.coremod.colony.crafting.RecipeAnalyzer) Nullable(org.jetbrains.annotations.Nullable) ResourceLocation(net.minecraft.util.ResourceLocation) CustomRecipeManager(com.minecolonies.coremod.colony.crafting.CustomRecipeManager) ItemStorage(com.minecolonies.api.crafting.ItemStorage) NotNull(org.jetbrains.annotations.NotNull) IBuildingModule(com.minecolonies.api.colony.buildings.modules.IBuildingModule) ICompatibilityManager(com.minecolonies.api.compatibility.ICompatibilityManager) ItemStack(net.minecraft.item.ItemStack)

Example 2 with ICompatibilityManager

use of com.minecolonies.api.compatibility.ICompatibilityManager in project minecolonies by Minecolonies.

the class BrewingCraftingType method findRecipes.

@Override
@NotNull
public List<IGenericRecipe> findRecipes(@NotNull RecipeManager recipeManager, @Nullable World world) {
    final List<IGenericRecipe> recipes = new ArrayList<>();
    final ICompatibilityManager compatibilityManager = MinecoloniesAPIProxy.getInstance().getColonyManager().getCompatibilityManager();
    for (final IBrewingRecipe recipe : BrewingRecipeRegistry.getRecipes()) {
        final List<ItemStack> inputs = compatibilityManager.getListOfAllItems().stream().filter(recipe::isInput).collect(Collectors.toList());
        final List<ItemStack> ingredients = compatibilityManager.getListOfAllItems().stream().filter(recipe::isIngredient).collect(Collectors.toList());
        for (final ItemStack input : inputs) {
            for (final ItemStack ingredient : ingredients) {
                final ItemStack output = recipe.getOutput(input, ingredient);
                if (!output.isEmpty()) {
                    final ItemStack actualInput = input.copy();
                    actualInput.setCount(3);
                    final ItemStack actualOutput = output.copy();
                    actualOutput.setCount(3);
                    recipes.add(new GenericRecipe(null, actualOutput, Collections.emptyList(), Arrays.asList(Collections.singletonList(ingredient), Collections.singletonList(actualInput)), 1, Blocks.BREWING_STAND, null, Collections.emptyList(), -1));
                }
            }
        }
    }
    return recipes;
}
Also used : IGenericRecipe(com.minecolonies.api.crafting.IGenericRecipe) GenericRecipe(com.minecolonies.api.crafting.GenericRecipe) ICompatibilityManager(com.minecolonies.api.compatibility.ICompatibilityManager) ArrayList(java.util.ArrayList) IBrewingRecipe(net.minecraftforge.common.brewing.IBrewingRecipe) ItemStack(net.minecraft.item.ItemStack) IGenericRecipe(com.minecolonies.api.crafting.IGenericRecipe) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

ICompatibilityManager (com.minecolonies.api.compatibility.ICompatibilityManager)2 IGenericRecipe (com.minecolonies.api.crafting.IGenericRecipe)2 ItemStack (net.minecraft.item.ItemStack)2 NotNull (org.jetbrains.annotations.NotNull)2 IMinecoloniesAPI (com.minecolonies.api.IMinecoloniesAPI)1 IColonyManager (com.minecolonies.api.colony.IColonyManager)1 IBuildingModule (com.minecolonies.api.colony.buildings.modules.IBuildingModule)1 ICraftingBuildingModule (com.minecolonies.api.colony.buildings.modules.ICraftingBuildingModule)1 BuildingEntry (com.minecolonies.api.colony.buildings.registry.BuildingEntry)1 GenericRecipe (com.minecolonies.api.crafting.GenericRecipe)1 ItemStorage (com.minecolonies.api.crafting.ItemStorage)1 CraftingType (com.minecolonies.api.crafting.registry.CraftingType)1 Log (com.minecolonies.api.util.Log)1 MOD_ID (com.minecolonies.api.util.constant.Constants.MOD_ID)1 SimpleCraftingModule (com.minecolonies.coremod.colony.buildings.modules.SimpleCraftingModule)1 CustomRecipeManager (com.minecolonies.coremod.colony.crafting.CustomRecipeManager)1 LootTableAnalyzer (com.minecolonies.coremod.colony.crafting.LootTableAnalyzer)1 RecipeAnalyzer (com.minecolonies.coremod.colony.crafting.RecipeAnalyzer)1 BufferedWriter (java.io.BufferedWriter)1 IOException (java.io.IOException)1