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))));
}
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));
}
}
}
}
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))));
}
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));
}
}
}
}
Aggregations