NaturesAura/src/main/java/de/ellpeck/naturesaura/compat/patchouli/ProcessorTreeRitual.java

34 lines
1.2 KiB
Java
Raw Normal View History

package de.ellpeck.naturesaura.compat.patchouli;
2020-04-29 16:38:50 +02:00
import de.ellpeck.naturesaura.recipes.TreeRitualRecipe;
import vazkii.patchouli.api.IComponentProcessor;
2020-09-22 03:17:02 +02:00
import vazkii.patchouli.api.IVariable;
import vazkii.patchouli.api.IVariableProvider;
public class ProcessorTreeRitual implements IComponentProcessor {
private TreeRitualRecipe recipe;
@Override
2020-09-22 03:17:02 +02:00
public void setup(IVariableProvider provider) {
this.recipe = PatchouliCompat.getRecipe("tree_ritual", provider.get("recipe").asString());
}
@Override
2020-09-22 03:17:02 +02:00
public IVariable process(String key) {
if (this.recipe == null)
2020-09-22 15:01:16 +02:00
return null;
if (key.startsWith("input")) {
2021-12-16 21:56:27 +01:00
var id = Integer.parseInt(key.substring(5)) - 1;
return this.recipe.ingredients.length > id ? PatchouliCompat.ingredientVariable(this.recipe.ingredients[id]) : null;
} else {
2021-12-16 21:56:27 +01:00
return switch (key) {
case "output" -> IVariable.from(this.recipe.result);
case "sapling" -> PatchouliCompat.ingredientVariable(this.recipe.saplingType);
2021-12-28 11:53:10 +01:00
case "name" -> IVariable.wrap(this.recipe.result.getHoverName().getString());
2021-12-16 21:56:27 +01:00
default -> null;
};
}
}
}