Search in sources :

Example 1 with IVariableProvider

use of vazkii.patchouli.api.IVariableProvider in project bewitchment by MoriyaShiine.

the class OilCraftingProcessor method setup.

@Override
public void setup(IVariableProvider variables) {
    String recipeId = variables.get("recipe").asString();
    RecipeManager manager = MinecraftClient.getInstance().world.getRecipeManager();
    recipe = (OilRecipe) manager.get(new Identifier(recipeId)).filter(recipe -> recipe.getType().equals(BWRecipeTypes.OIL_RECIPE_TYPE)).orElseThrow(IllegalArgumentException::new);
}
Also used : BWRecipeTypes(moriyashiine.bewitchment.common.registry.BWRecipeTypes) IVariableProvider(vazkii.patchouli.api.IVariableProvider) ItemStack(net.minecraft.item.ItemStack) IVariable(vazkii.patchouli.api.IVariable) Identifier(net.minecraft.util.Identifier) IComponentProcessor(vazkii.patchouli.api.IComponentProcessor) MinecraftClient(net.minecraft.client.MinecraftClient) RecipeManager(net.minecraft.recipe.RecipeManager) OilRecipe(moriyashiine.bewitchment.common.recipe.OilRecipe) Identifier(net.minecraft.util.Identifier) RecipeManager(net.minecraft.recipe.RecipeManager)

Example 2 with IVariableProvider

use of vazkii.patchouli.api.IVariableProvider in project bewitchment by MoriyaShiine.

the class RitualProcessor method setup.

@Override
public void setup(IVariableProvider variables) {
    String recipeId = variables.get("recipe").asString();
    RecipeManager manager = MinecraftClient.getInstance().world.getRecipeManager();
    recipe = (RitualRecipe) manager.get(new Identifier(recipeId)).filter(recipe -> recipe.getType().equals(BWRecipeTypes.RITUAL_RECIPE_TYPE)).orElseThrow(IllegalArgumentException::new);
}
Also used : BWRecipeTypes(moriyashiine.bewitchment.common.registry.BWRecipeTypes) IVariableProvider(vazkii.patchouli.api.IVariableProvider) ItemStack(net.minecraft.item.ItemStack) IVariable(vazkii.patchouli.api.IVariable) I18n(net.minecraft.client.resource.language.I18n) TranslatableText(net.minecraft.text.TranslatableText) RitualRecipe(moriyashiine.bewitchment.common.recipe.RitualRecipe) Identifier(net.minecraft.util.Identifier) IComponentProcessor(vazkii.patchouli.api.IComponentProcessor) MinecraftClient(net.minecraft.client.MinecraftClient) RecipeManager(net.minecraft.recipe.RecipeManager) Identifier(net.minecraft.util.Identifier) RecipeManager(net.minecraft.recipe.RecipeManager)

Example 3 with IVariableProvider

use of vazkii.patchouli.api.IVariableProvider in project Miskatonic-Mysteries-Fabric by cybercat5555.

the class ChemistryProcessor method setup.

@Override
public void setup(IVariableProvider variables) {
    String recipeId = variables.get("recipe").asString();
    RecipeManager manager = MinecraftClient.getInstance().world.getRecipeManager();
    recipe = (ChemistryRecipe) manager.get(new Identifier(recipeId)).filter(recipe -> recipe.getType().equals(MMRecipes.CHEMISTRY_RECIPE)).orElseThrow(IllegalArgumentException::new);
}
Also used : IVariableProvider(vazkii.patchouli.api.IVariableProvider) ItemStack(net.minecraft.item.ItemStack) IVariable(vazkii.patchouli.api.IVariable) Identifier(net.minecraft.util.Identifier) IComponentProcessor(vazkii.patchouli.api.IComponentProcessor) MinecraftClient(net.minecraft.client.MinecraftClient) RecipeManager(net.minecraft.recipe.RecipeManager) MMRecipes(com.miskatonicmysteries.common.registry.MMRecipes) ChemistryRecipe(com.miskatonicmysteries.common.feature.recipe.ChemistryRecipe) Identifier(net.minecraft.util.Identifier) RecipeManager(net.minecraft.recipe.RecipeManager)

Example 4 with IVariableProvider

use of vazkii.patchouli.api.IVariableProvider in project Patchouli by VazkiiMods.

the class BookTemplate method compile.

public void compile(BookContentsBuilder builder, IVariableProvider variables) {
    if (compiled) {
        return;
    }
    createProcessor();
    components.removeIf(Objects::isNull);
    if (processor != null) {
        IVariableProvider processorVars = variables;
        if (encapsulation != null) {
            processorVars = encapsulation.wrapProvider(variables);
        }
        try {
            processor.setup(processorVars);
        } catch (Exception e) {
            throw new RuntimeException("Error setting up template processor", e);
        }
    }
    for (TemplateInclusion include : inclusions) {
        if (include.template == null || include.template.isEmpty() || include.as == null || include.as.isEmpty()) {
            throw new IllegalArgumentException("Template inclusion must define both \"template\" and \"as\" fields.");
        }
        include.upperMerge(encapsulation);
        include.process(processor);
        BookTemplate template = createTemplate(book, builder, include.template, include);
        template.compile(builder, variables);
        components.addAll(template.components);
    }
    for (TemplateComponent c : components) {
        c.compile(variables, processor, encapsulation);
    }
    compiled = true;
}
Also used : Objects(java.util.Objects) IVariableProvider(vazkii.patchouli.api.IVariableProvider)

Example 5 with IVariableProvider

use of vazkii.patchouli.api.IVariableProvider in project bewitchment by MoriyaShiine.

the class CurseProcessor method setup.

@Override
public void setup(IVariableProvider variables) {
    String recipeId = variables.get("recipe").asString();
    RecipeManager manager = MinecraftClient.getInstance().world.getRecipeManager();
    recipe = (CurseRecipe) manager.get(new Identifier(recipeId)).filter(recipe -> recipe.getType().equals(BWRecipeTypes.CURSE_RECIPE_TYPE)).orElseThrow(IllegalArgumentException::new);
}
Also used : BWRecipeTypes(moriyashiine.bewitchment.common.registry.BWRecipeTypes) BWRegistries(moriyashiine.bewitchment.common.registry.BWRegistries) IVariableProvider(vazkii.patchouli.api.IVariableProvider) ItemStack(net.minecraft.item.ItemStack) IVariable(vazkii.patchouli.api.IVariable) TranslatableText(net.minecraft.text.TranslatableText) Identifier(net.minecraft.util.Identifier) IComponentProcessor(vazkii.patchouli.api.IComponentProcessor) MinecraftClient(net.minecraft.client.MinecraftClient) RecipeManager(net.minecraft.recipe.RecipeManager) CurseRecipe(moriyashiine.bewitchment.common.recipe.CurseRecipe) Identifier(net.minecraft.util.Identifier) RecipeManager(net.minecraft.recipe.RecipeManager)

Aggregations

IVariableProvider (vazkii.patchouli.api.IVariableProvider)6 MinecraftClient (net.minecraft.client.MinecraftClient)5 ItemStack (net.minecraft.item.ItemStack)5 RecipeManager (net.minecraft.recipe.RecipeManager)5 Identifier (net.minecraft.util.Identifier)5 IComponentProcessor (vazkii.patchouli.api.IComponentProcessor)5 IVariable (vazkii.patchouli.api.IVariable)5 BWRecipeTypes (moriyashiine.bewitchment.common.registry.BWRecipeTypes)4 TranslatableText (net.minecraft.text.TranslatableText)2 ChemistryRecipe (com.miskatonicmysteries.common.feature.recipe.ChemistryRecipe)1 MMRecipes (com.miskatonicmysteries.common.registry.MMRecipes)1 Objects (java.util.Objects)1 CurseRecipe (moriyashiine.bewitchment.common.recipe.CurseRecipe)1 IncenseRecipe (moriyashiine.bewitchment.common.recipe.IncenseRecipe)1 OilRecipe (moriyashiine.bewitchment.common.recipe.OilRecipe)1 RitualRecipe (moriyashiine.bewitchment.common.recipe.RitualRecipe)1 BWRegistries (moriyashiine.bewitchment.common.registry.BWRegistries)1 I18n (net.minecraft.client.resource.language.I18n)1