2019-01-01 15:20:12 +01:00
|
|
|
package de.ellpeck.naturesaura.compat.patchouli;
|
|
|
|
|
2020-04-29 16:38:50 +02:00
|
|
|
import de.ellpeck.naturesaura.recipes.AnimalSpawnerRecipe;
|
2021-12-16 21:56:27 +01:00
|
|
|
import net.minecraft.world.item.ItemStack;
|
|
|
|
import net.minecraftforge.common.ForgeSpawnEggItem;
|
2019-01-01 15:20:12 +01:00
|
|
|
import vazkii.patchouli.api.IComponentProcessor;
|
2020-09-22 03:17:02 +02:00
|
|
|
import vazkii.patchouli.api.IVariable;
|
2019-01-01 15:20:12 +01:00
|
|
|
import vazkii.patchouli.api.IVariableProvider;
|
|
|
|
|
|
|
|
public class ProcessorAnimalSpawner implements IComponentProcessor {
|
|
|
|
|
|
|
|
private AnimalSpawnerRecipe recipe;
|
|
|
|
|
|
|
|
@Override
|
2020-09-22 03:17:02 +02:00
|
|
|
public void setup(IVariableProvider provider) {
|
|
|
|
this.recipe = PatchouliCompat.getRecipe("animal_spawner", provider.get("recipe").asString());
|
2019-01-01 15:20:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2020-09-22 03:17:02 +02:00
|
|
|
public IVariable process(String key) {
|
2019-03-31 10:21:59 +02:00
|
|
|
if (this.recipe == null)
|
2020-09-22 15:01:16 +02:00
|
|
|
return null;
|
2019-01-01 15:20:12 +01:00
|
|
|
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;
|
2019-01-01 15:20:12 +01:00
|
|
|
} else {
|
2021-12-16 21:56:27 +01:00
|
|
|
return switch (key) {
|
|
|
|
case "name" -> IVariable.wrap(this.recipe.entity.getDescription().getString());
|
|
|
|
case "entity" -> IVariable.wrap(this.recipe.entity.getRegistryName().toString());
|
|
|
|
case "egg" -> IVariable.from(new ItemStack(ForgeSpawnEggItem.fromEntityType(this.recipe.entity)));
|
|
|
|
default -> null;
|
|
|
|
};
|
2019-01-01 15:20:12 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean allowRender(String group) {
|
|
|
|
return !"seekrit".equals(group);
|
|
|
|
}
|
|
|
|
}
|