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

50 lines
1.7 KiB
Java
Raw Normal View History

2019-01-01 15:20:12 +01:00
package de.ellpeck.naturesaura.compat.patchouli;
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
2020-04-29 16:38:50 +02:00
import de.ellpeck.naturesaura.recipes.AnimalSpawnerRecipe;
2019-01-01 15:20:12 +01:00
import net.minecraft.item.ItemStack;
2020-01-21 21:04:44 +01:00
import net.minecraft.item.SpawnEggItem;
2019-01-01 15:20:12 +01:00
import vazkii.patchouli.api.IComponentProcessor;
import vazkii.patchouli.api.IVariableProvider;
import vazkii.patchouli.api.PatchouliAPI;
public class ProcessorAnimalSpawner implements IComponentProcessor {
private AnimalSpawnerRecipe recipe;
@Override
public void setup(IVariableProvider<String> provider) {
2020-04-29 16:38:50 +02:00
this.recipe = PatchouliCompat.getRecipe("animal_spawner", provider.get("recipe"));
2019-01-01 15:20:12 +01:00
}
@Override
public String process(String key) {
if (this.recipe == null)
return null;
2019-01-01 15:20:12 +01:00
if (key.startsWith("input")) {
int id = Integer.parseInt(key.substring(5)) - 1;
if (this.recipe.ingredients.length > id)
return PatchouliAPI.instance.serializeIngredient(this.recipe.ingredients[id]);
else
return null;
} else {
switch (key) {
case "name":
2020-01-25 16:56:04 +01:00
return this.recipe.entity.getName().getFormattedText();
2019-01-01 15:20:12 +01:00
case "entity":
2020-01-25 16:56:04 +01:00
return this.recipe.entity.getRegistryName().toString();
2019-01-01 15:20:12 +01:00
case "egg":
2020-01-25 16:56:04 +01:00
ItemStack egg = new ItemStack(SpawnEggItem.getEgg(this.recipe.entity));
2019-01-01 15:20:12 +01:00
return PatchouliAPI.instance.serializeItemStack(egg);
default:
return null;
}
}
}
@Override
public boolean allowRender(String group) {
return !"seekrit".equals(group);
}
}