Search in sources :

Example 1 with SimpleCraftingModule

use of com.minecolonies.coremod.colony.buildings.modules.SimpleCraftingModule in project minecolonies by Minecolonies.

the class CraftingTagAuditor method doRecipeAudit.

private static void doRecipeAudit(@NotNull final BufferedWriter writer, @NotNull final MinecraftServer server, @NotNull final CustomRecipeManager customRecipeManager) throws IOException {
    final Map<CraftingType, List<IGenericRecipe>> vanillaRecipesMap = RecipeAnalyzer.buildVanillaRecipesMap(server.getRecipeManager(), server.overworld());
    final List<ICraftingBuildingModule> crafters = getCraftingModules().stream().sorted(Comparator.comparing(m -> m instanceof SimpleCraftingModule).reversed()).collect(// sort the simple modules first (2x2 crafting, personal only)
    Collectors.toList());
    final Map<ItemStorage, Map<ICraftingBuildingModule, List<IGenericRecipe>>> craftingMap = new HashMap<>();
    // initially map every vanilla craftable
    for (final List<IGenericRecipe> recipeList : vanillaRecipesMap.values()) {
        for (final IGenericRecipe recipe : recipeList) {
            add(customRecipeManager, craftingMap, null, recipe);
        }
    }
    writeItemHeaders(writer);
    writer.write(",player");
    for (final ICraftingBuildingModule crafter : crafters) {
        writer.write(',');
        writer.write(crafter.getCustomRecipeKey());
        final List<IGenericRecipe> recipes = RecipeAnalyzer.findRecipes(vanillaRecipesMap, crafter);
        for (final IGenericRecipe recipe : recipes) {
            add(customRecipeManager, craftingMap, crafter, recipe);
        }
    }
    writer.newLine();
    for (final ItemStack item : getAllItems()) {
        writeItemData(writer, item);
        final Map<ICraftingBuildingModule, List<IGenericRecipe>> crafterMap = craftingMap.getOrDefault(new ItemStorage(item, true, false), Collections.emptyMap());
        writeCrafterValue(writer, crafterMap, null);
        for (final ICraftingBuildingModule crafter : crafters) {
            writeCrafterValue(writer, crafterMap, crafter);
        }
        writer.newLine();
    }
}
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) SimpleCraftingModule(com.minecolonies.coremod.colony.buildings.modules.SimpleCraftingModule) ItemStorage(com.minecolonies.api.crafting.ItemStorage) IGenericRecipe(com.minecolonies.api.crafting.IGenericRecipe) CraftingType(com.minecolonies.api.crafting.registry.CraftingType) ICraftingBuildingModule(com.minecolonies.api.colony.buildings.modules.ICraftingBuildingModule) ItemStack(net.minecraft.item.ItemStack)

Aggregations

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 ICompatibilityManager (com.minecolonies.api.compatibility.ICompatibilityManager)1 IGenericRecipe (com.minecolonies.api.crafting.IGenericRecipe)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 Files (java.nio.file.Files)1 Path (java.nio.file.Path)1 java.util (java.util)1