Search in sources :

Example 1 with CraftingModuleView

use of com.minecolonies.coremod.colony.buildings.moduleviews.CraftingModuleView in project minecolonies by ldtteam.

the class AbstractTeachingGuiHandler method getRecipeCategory.

@Nullable
protected JobBasedRecipeCategory<?> getRecipeCategory(@NotNull final AbstractBuildingView view) {
    for (final CraftingModuleView moduleView : view.getModuleViews(CraftingModuleView.class)) {
        if (!isSupportedCraftingModule(moduleView))
            continue;
        final JobEntry jobEntry = moduleView.getJobEntry();
        if (jobEntry != null) {
            final ResourceLocation uid = ICraftingBuildingModule.getUid(jobEntry, moduleView.getId());
            final JobBasedRecipeCategory<?> category = this.categories.get(uid);
            if (category != null) {
                return category;
            }
        }
    }
    return null;
}
Also used : JobEntry(com.minecolonies.api.colony.jobs.registry.JobEntry) ResourceLocation(net.minecraft.util.ResourceLocation) CraftingModuleView(com.minecolonies.coremod.colony.buildings.moduleviews.CraftingModuleView) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with CraftingModuleView

use of com.minecolonies.coremod.colony.buildings.moduleviews.CraftingModuleView in project minecolonies by Minecolonies.

the class AbstractTeachingGuiHandler method getRecipeCategory.

@Nullable
protected JobBasedRecipeCategory<?> getRecipeCategory(@NotNull final AbstractBuildingView view) {
    for (final CraftingModuleView moduleView : view.getModuleViews(CraftingModuleView.class)) {
        if (!isSupportedCraftingModule(moduleView))
            continue;
        final JobEntry jobEntry = moduleView.getJobEntry();
        if (jobEntry != null) {
            final ResourceLocation uid = ICraftingBuildingModule.getUid(jobEntry, moduleView.getId());
            final JobBasedRecipeCategory<?> category = this.categories.get(uid);
            if (category != null) {
                return category;
            }
        }
    }
    return null;
}
Also used : JobEntry(com.minecolonies.api.colony.jobs.registry.JobEntry) ResourceLocation(net.minecraft.util.ResourceLocation) CraftingModuleView(com.minecolonies.coremod.colony.buildings.moduleviews.CraftingModuleView) Nullable(org.jetbrains.annotations.Nullable)

Example 3 with CraftingModuleView

use of com.minecolonies.coremod.colony.buildings.moduleviews.CraftingModuleView in project minecolonies by Minecolonies.

the class RecipeSetting method getValue.

@Override
public IRecipeStorage getValue(final IBuildingView building) {
    final CraftingModuleView craftingModule = building.getModuleViewMatching(CraftingModuleView.class, m -> m.getId().equals(craftingModuleId));
    for (final IRecipeStorage recipe : craftingModule.getRecipes()) {
        if (recipe.getToken().equals(currentIndex)) {
            return recipe;
        }
    }
    currentIndex = craftingModule.getRecipes().get(0).getToken();
    return craftingModule.getRecipes().get(0);
}
Also used : IRecipeStorage(com.minecolonies.api.crafting.IRecipeStorage) CraftingModuleView(com.minecolonies.coremod.colony.buildings.moduleviews.CraftingModuleView)

Aggregations

CraftingModuleView (com.minecolonies.coremod.colony.buildings.moduleviews.CraftingModuleView)3 JobEntry (com.minecolonies.api.colony.jobs.registry.JobEntry)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 Nullable (org.jetbrains.annotations.Nullable)2 IRecipeStorage (com.minecolonies.api.crafting.IRecipeStorage)1