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

35 lines
1.3 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;
2023-07-08 12:32:27 +02:00
import net.minecraft.world.level.Level;
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
2023-07-08 12:32:27 +02:00
public void setup(Level level, IVariableProvider provider) {
2020-09-22 03:17:02 +02:00
this.recipe = PatchouliCompat.getRecipe("tree_ritual", provider.get("recipe").asString());
}
@Override
2023-07-08 12:32:27 +02:00
public IVariable process(Level level, 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;
2024-03-10 15:54:58 +01:00
return this.recipe.ingredients.size() > id ? PatchouliCompat.ingredientVariable(this.recipe.ingredients.get(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;
};
}
}
}