Search in sources :

Example 1 with AnimalHerdingModule

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

the class CustomRecipeManager method buildLootData.

/**
 * Analyses and builds an approximate list of possible loot drops from registered recipes.
 * @param lootTableManager the loot table manager
 */
public void buildLootData(@NotNull final LootTableManager lootTableManager) {
    final List<ResourceLocation> lootIds = new ArrayList<>();
    for (final Map<ResourceLocation, CustomRecipe> recipes : recipeMap.values()) {
        for (final CustomRecipe recipe : recipes.values()) {
            final ResourceLocation lootTable = recipe.getLootTable();
            if (lootTable != null) {
                lootIds.add(lootTable);
            }
        }
    }
    for (final BuildingEntry building : IMinecoloniesAPI.getInstance().getBuildingRegistry()) {
        building.getModuleProducers().stream().map(Supplier::get).filter(m -> m instanceof AnimalHerdingModule).map(m -> (AnimalHerdingModule) m).forEach(herding -> lootIds.add(herding.getDefaultLootTable()));
    }
    lootIds.add(ModLootTables.FISHING);
    lootIds.addAll(ModLootTables.FISHERMAN_BONUS.values());
    lootTables.clear();
    lootTables.putAll(lootIds.stream().filter(// just in case
    Objects::nonNull).distinct().collect(Collectors.toConcurrentMap(Function.identity(), id -> LootTableAnalyzer.toDrops(lootTableManager, id))));
}
Also used : AnimalHerdingModule(com.minecolonies.coremod.colony.buildings.modules.AnimalHerdingModule) BuildingEntry(com.minecolonies.api.colony.buildings.registry.BuildingEntry) java.util(java.util) Item(net.minecraft.item.Item) Function(java.util.function.Function) Supplier(java.util.function.Supplier) Collectors(java.util.stream.Collectors) LootTableManager(net.minecraft.loot.LootTableManager) Unpooled(io.netty.buffer.Unpooled) StandardFactoryController(com.minecolonies.api.colony.requestsystem.StandardFactoryController) ItemStack(net.minecraft.item.ItemStack) Nullable(org.jetbrains.annotations.Nullable) MinecraftForge(net.minecraftforge.common.MinecraftForge) IMinecoloniesAPI(com.minecolonies.api.IMinecoloniesAPI) ResourceLocation(net.minecraft.util.ResourceLocation) Network(com.minecolonies.coremod.Network) ItemStorage(com.minecolonies.api.crafting.ItemStorage) NotNull(org.jetbrains.annotations.NotNull) PacketBuffer(net.minecraft.network.PacketBuffer) ModLootTables(com.minecolonies.api.loot.ModLootTables) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) BuildingEntry(com.minecolonies.api.colony.buildings.registry.BuildingEntry) ResourceLocation(net.minecraft.util.ResourceLocation) AnimalHerdingModule(com.minecolonies.coremod.colony.buildings.modules.AnimalHerdingModule)

Example 2 with AnimalHerdingModule

use of com.minecolonies.coremod.colony.buildings.modules.AnimalHerdingModule in project minecolonies by ldtteam.

the class JEIPlugin method registerCategories.

@Override
public void registerCategories(@NotNull final IRecipeCategoryRegistration registration) {
    final IJeiHelpers jeiHelpers = registration.getJeiHelpers();
    final IGuiHelper guiHelper = jeiHelpers.getGuiHelper();
    registration.addRecipeCategories(new CompostRecipeCategory(guiHelper));
    registration.addRecipeCategories(new FishermanRecipeCategory(guiHelper));
    categories.clear();
    for (final BuildingEntry building : IMinecoloniesAPI.getInstance().getBuildingRegistry()) {
        for (final Supplier<IBuildingModule> producer : building.getModuleProducers()) {
            final IBuildingModule module = producer.get();
            if (module instanceof ICraftingBuildingModule) {
                final ICraftingBuildingModule crafting = (ICraftingBuildingModule) module;
                final IJob<?> job = crafting.getCraftingJob();
                if (job != null) {
                    registerCategory(registration, new GenericRecipeCategory(building, job, crafting, guiHelper));
                }
            }
            if (module instanceof AnimalHerdingModule) {
                final AnimalHerdingModule herding = (AnimalHerdingModule) module;
                registerCategory(registration, new HerderRecipeCategory(building, herding.getHerdingJob(), herding, guiHelper));
            }
        }
    }
}
Also used : IGuiHelper(mezz.jei.api.helpers.IGuiHelper) BuildingEntry(com.minecolonies.api.colony.buildings.registry.BuildingEntry) IBuildingModule(com.minecolonies.api.colony.buildings.modules.IBuildingModule) AnimalHerdingModule(com.minecolonies.coremod.colony.buildings.modules.AnimalHerdingModule) ICraftingBuildingModule(com.minecolonies.api.colony.buildings.modules.ICraftingBuildingModule) IJeiHelpers(mezz.jei.api.helpers.IJeiHelpers)

Example 3 with AnimalHerdingModule

use of com.minecolonies.coremod.colony.buildings.modules.AnimalHerdingModule in project minecolonies by ldtteam.

the class CustomRecipeManager method buildLootData.

/**
 * Analyses and builds an approximate list of possible loot drops from registered recipes.
 * @param lootTableManager the loot table manager
 */
public void buildLootData(@NotNull final LootTableManager lootTableManager) {
    final List<ResourceLocation> lootIds = new ArrayList<>();
    for (final Map<ResourceLocation, CustomRecipe> recipes : recipeMap.values()) {
        for (final CustomRecipe recipe : recipes.values()) {
            final ResourceLocation lootTable = recipe.getLootTable();
            if (lootTable != null) {
                lootIds.add(lootTable);
            }
        }
    }
    for (final BuildingEntry building : IMinecoloniesAPI.getInstance().getBuildingRegistry()) {
        building.getModuleProducers().stream().map(Supplier::get).filter(m -> m instanceof AnimalHerdingModule).map(m -> (AnimalHerdingModule) m).forEach(herding -> lootIds.add(herding.getDefaultLootTable()));
    }
    lootIds.add(ModLootTables.FISHING);
    lootIds.addAll(ModLootTables.FISHERMAN_BONUS.values());
    lootTables.clear();
    lootTables.putAll(lootIds.stream().filter(// just in case
    Objects::nonNull).distinct().collect(Collectors.toConcurrentMap(Function.identity(), id -> LootTableAnalyzer.toDrops(lootTableManager, id))));
}
Also used : AnimalHerdingModule(com.minecolonies.coremod.colony.buildings.modules.AnimalHerdingModule) BuildingEntry(com.minecolonies.api.colony.buildings.registry.BuildingEntry) java.util(java.util) Item(net.minecraft.item.Item) Function(java.util.function.Function) Supplier(java.util.function.Supplier) Collectors(java.util.stream.Collectors) LootTableManager(net.minecraft.loot.LootTableManager) Unpooled(io.netty.buffer.Unpooled) StandardFactoryController(com.minecolonies.api.colony.requestsystem.StandardFactoryController) ItemStack(net.minecraft.item.ItemStack) Nullable(org.jetbrains.annotations.Nullable) MinecraftForge(net.minecraftforge.common.MinecraftForge) IMinecoloniesAPI(com.minecolonies.api.IMinecoloniesAPI) ResourceLocation(net.minecraft.util.ResourceLocation) Network(com.minecolonies.coremod.Network) ItemStorage(com.minecolonies.api.crafting.ItemStorage) NotNull(org.jetbrains.annotations.NotNull) PacketBuffer(net.minecraft.network.PacketBuffer) ModLootTables(com.minecolonies.api.loot.ModLootTables) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) BuildingEntry(com.minecolonies.api.colony.buildings.registry.BuildingEntry) ResourceLocation(net.minecraft.util.ResourceLocation) AnimalHerdingModule(com.minecolonies.coremod.colony.buildings.modules.AnimalHerdingModule)

Example 4 with AnimalHerdingModule

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

the class JEIPlugin method registerCategories.

@Override
public void registerCategories(@NotNull final IRecipeCategoryRegistration registration) {
    final IJeiHelpers jeiHelpers = registration.getJeiHelpers();
    final IGuiHelper guiHelper = jeiHelpers.getGuiHelper();
    registration.addRecipeCategories(new CompostRecipeCategory(guiHelper));
    registration.addRecipeCategories(new FishermanRecipeCategory(guiHelper));
    categories.clear();
    for (final BuildingEntry building : IMinecoloniesAPI.getInstance().getBuildingRegistry()) {
        for (final Supplier<IBuildingModule> producer : building.getModuleProducers()) {
            final IBuildingModule module = producer.get();
            if (module instanceof ICraftingBuildingModule) {
                final ICraftingBuildingModule crafting = (ICraftingBuildingModule) module;
                final IJob<?> job = crafting.getCraftingJob();
                if (job != null) {
                    registerCategory(registration, new GenericRecipeCategory(building, job, crafting, guiHelper));
                }
            }
            if (module instanceof AnimalHerdingModule) {
                final AnimalHerdingModule herding = (AnimalHerdingModule) module;
                registerCategory(registration, new HerderRecipeCategory(building, herding.getHerdingJob(), herding, guiHelper));
            }
        }
    }
}
Also used : IGuiHelper(mezz.jei.api.helpers.IGuiHelper) BuildingEntry(com.minecolonies.api.colony.buildings.registry.BuildingEntry) IBuildingModule(com.minecolonies.api.colony.buildings.modules.IBuildingModule) AnimalHerdingModule(com.minecolonies.coremod.colony.buildings.modules.AnimalHerdingModule) ICraftingBuildingModule(com.minecolonies.api.colony.buildings.modules.ICraftingBuildingModule) IJeiHelpers(mezz.jei.api.helpers.IJeiHelpers)

Aggregations

BuildingEntry (com.minecolonies.api.colony.buildings.registry.BuildingEntry)4 AnimalHerdingModule (com.minecolonies.coremod.colony.buildings.modules.AnimalHerdingModule)4 IMinecoloniesAPI (com.minecolonies.api.IMinecoloniesAPI)2 IBuildingModule (com.minecolonies.api.colony.buildings.modules.IBuildingModule)2 ICraftingBuildingModule (com.minecolonies.api.colony.buildings.modules.ICraftingBuildingModule)2 StandardFactoryController (com.minecolonies.api.colony.requestsystem.StandardFactoryController)2 ItemStorage (com.minecolonies.api.crafting.ItemStorage)2 ModLootTables (com.minecolonies.api.loot.ModLootTables)2 Network (com.minecolonies.coremod.Network)2 Unpooled (io.netty.buffer.Unpooled)2 java.util (java.util)2 Function (java.util.function.Function)2 Supplier (java.util.function.Supplier)2 Collectors (java.util.stream.Collectors)2 IGuiHelper (mezz.jei.api.helpers.IGuiHelper)2 IJeiHelpers (mezz.jei.api.helpers.IJeiHelpers)2 ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)2 Item (net.minecraft.item.Item)2 ItemStack (net.minecraft.item.ItemStack)2 LootTableManager (net.minecraft.loot.LootTableManager)2