Search in sources :

Example 1 with EnumTier

use of com.codetaylor.mc.artisanworktables.api.internal.reference.EnumTier in project artisan-worktables by codetaylor.

the class PluginJEI method register.

@Override
public void register(IModRegistry registry) {
    for (EnumTier tier : EnumTier.values()) {
        if (!ModuleWorktablesConfig.isTierEnabled(tier)) {
            continue;
        }
        for (String name : ArtisanAPI.getWorktableNames()) {
            registry.addRecipeCatalyst(this.getWorktableAsItemStack(name, tier), PluginJEI.createUID(name, tier));
        }
        for (String name : ArtisanAPI.getWorktableNames()) {
            registry.handleRecipes(ArtisanRecipe.class, JEIRecipeWrapper::new, PluginJEI.createUID(name, tier));
        }
        IRecipeTransferRegistry transferRegistry = registry.getRecipeTransferRegistry();
        for (String name : ArtisanAPI.getWorktableNames()) {
            transferRegistry.addRecipeTransferHandler(new JEIRecipeTransferInfoWorktable(name, PluginJEI.createUID(name, tier), tier));
        }
        for (String name : ArtisanAPI.getWorktableNames()) {
            List<IArtisanRecipe> recipeList = new ArrayList<>();
            RecipeRegistry recipeRegistry = ArtisanAPI.getWorktableRecipeRegistry(name);
            recipeList = recipeRegistry.getRecipeListByTier(recipeList, tier);
            registry.addRecipes(recipeList, PluginJEI.createUID(name, tier));
        }
    }
}
Also used : IArtisanRecipe(com.codetaylor.mc.artisanworktables.api.recipe.IArtisanRecipe) ArrayList(java.util.ArrayList) EnumTier(com.codetaylor.mc.artisanworktables.api.internal.reference.EnumTier) IRecipeTransferRegistry(mezz.jei.api.recipe.transfer.IRecipeTransferRegistry) IRecipeRegistry(mezz.jei.api.IRecipeRegistry) RecipeRegistry(com.codetaylor.mc.artisanworktables.api.internal.recipe.RecipeRegistry)

Example 2 with EnumTier

use of com.codetaylor.mc.artisanworktables.api.internal.reference.EnumTier in project artisan-worktables by codetaylor.

the class RecipeBuilderInternal method validate.

public void validate() throws RecipeBuilderException {
    if (this.invalid) {
        throw new RecipeBuilderException("Invalid recipe");
    }
    if (this.recipeCopyStrategy != null) {
        if (!this.recipeCopyStrategy.isValid()) {
            this.setInvalid("Invalid recipe copy strategy");
        } else if (!this.inputSet && this.recipeCopyStrategy.isExcludeInput()) {
            this.setInvalid("Recipe missing input");
        } else if (!this.outputSet && this.recipeCopyStrategy.isExcludeOutput()) {
            this.setInvalid("Recipe missing output");
        }
    } else {
        // Recipe must have a minimum of one output
        this.isTrue(this.outputSet, "No outputs defined for recipe");
        // Recipe must have ingredients
        this.isTrue(this.inputSet, "No ingredients defined for recipe");
    }
    // Must be able to calculate recipe tier
    EnumTier tier = RecipeTierCalculator.calculateTier(this.width, this.height, this.tools.size(), this.secondaryIngredients.size());
    if (tier == null) {
        this.setInvalid("Unable to calculate recipe tier");
    } else {
        this.minimumTier = Math.max(this.minimumTier, tier.getId());
    }
    this.validateRun = true;
}
Also used : EnumTier(com.codetaylor.mc.artisanworktables.api.internal.reference.EnumTier)

Example 3 with EnumTier

use of com.codetaylor.mc.artisanworktables.api.internal.reference.EnumTier in project artisan-worktables by codetaylor.

the class PluginGameStages method processStagedRecipes.

@SideOnly(Side.CLIENT)
private void processStagedRecipes() {
    if (!FMLCommonHandler.instance().getEffectiveSide().isClient()) {
        return;
    }
    if (PluginJEI.RECIPE_REGISTRY == null) {
        return;
    }
    EntityPlayerSP player = Minecraft.getMinecraft().player;
    Collection<String> unlockedStages = GameStagesHelper.getUnlockedStages(player);
    GameStagesRequirementContext context = (GameStagesRequirementContext) ArtisanAPI.getRequirementContext(new ResourceLocation(ModArtisanWorktables.MOD_ID, "gamestages"));
    context.setUnlockedStages(unlockedStages);
    for (String name : ArtisanAPI.getWorktableNames()) {
        RecipeRegistry registry = ArtisanAPI.getWorktableRecipeRegistry(name);
        if (registry != null) {
            for (EnumTier tier : EnumTier.values()) {
                List<IArtisanRecipe> recipeList = registry.getRecipeListByTier(new ArrayList<>(), tier);
                String uid = PluginJEI.createUID(name, tier);
                for (IArtisanRecipe recipe : recipeList) {
                    IRecipeWrapper recipeWrapper = PluginJEI.RECIPE_REGISTRY.getRecipeWrapper(recipe, uid);
                    if (recipeWrapper == null) {
                        continue;
                    }
                    IRequirement requirement = recipe.getRequirement(GameStagesRequirement.LOCATION);
                    // noinspection unchecked
                    if (requirement == null || requirement.match(context)) {
                        PluginJEI.RECIPE_REGISTRY.unhideRecipe(recipeWrapper);
                    } else {
                        PluginJEI.RECIPE_REGISTRY.hideRecipe(recipeWrapper);
                    }
                }
            }
        }
    }
}
Also used : IRequirement(com.codetaylor.mc.artisanworktables.api.recipe.requirement.IRequirement) GameStagesRequirementContext(com.codetaylor.mc.artisanworktables.modules.requirement.gamestages.requirement.GameStagesRequirementContext) ResourceLocation(net.minecraft.util.ResourceLocation) IArtisanRecipe(com.codetaylor.mc.artisanworktables.api.recipe.IArtisanRecipe) IRecipeWrapper(mezz.jei.api.recipe.IRecipeWrapper) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) EnumTier(com.codetaylor.mc.artisanworktables.api.internal.reference.EnumTier) RecipeRegistry(com.codetaylor.mc.artisanworktables.api.internal.recipe.RecipeRegistry) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

EnumTier (com.codetaylor.mc.artisanworktables.api.internal.reference.EnumTier)3 RecipeRegistry (com.codetaylor.mc.artisanworktables.api.internal.recipe.RecipeRegistry)2 IArtisanRecipe (com.codetaylor.mc.artisanworktables.api.recipe.IArtisanRecipe)2 IRequirement (com.codetaylor.mc.artisanworktables.api.recipe.requirement.IRequirement)1 GameStagesRequirementContext (com.codetaylor.mc.artisanworktables.modules.requirement.gamestages.requirement.GameStagesRequirementContext)1 ArrayList (java.util.ArrayList)1 IRecipeRegistry (mezz.jei.api.IRecipeRegistry)1 IRecipeWrapper (mezz.jei.api.recipe.IRecipeWrapper)1 IRecipeTransferRegistry (mezz.jei.api.recipe.transfer.IRecipeTransferRegistry)1 EntityPlayerSP (net.minecraft.client.entity.EntityPlayerSP)1 ResourceLocation (net.minecraft.util.ResourceLocation)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1