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

49 lines
1.6 KiB
Java
Raw Normal View History

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;
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;
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) {
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")) {
int id = Integer.parseInt(key.substring(5)) - 1;
if (this.recipe.ingredients.length > id)
2020-09-22 18:03:56 +02:00
return PatchouliCompat.ingredientVariable(this.recipe.ingredients[id]);
2019-01-01 15:20:12 +01:00
else
2020-09-22 15:01:16 +02:00
return null;
2019-01-01 15:20:12 +01:00
} else {
switch (key) {
case "name":
2020-09-22 03:17:02 +02:00
return IVariable.wrap(this.recipe.entity.getName().getString());
2019-01-01 15:20:12 +01:00
case "entity":
2020-09-22 03:17:02 +02:00
return IVariable.wrap(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));
2020-09-22 03:17:02 +02:00
return IVariable.from(egg);
2019-01-01 15:20:12 +01:00
default:
2020-09-22 15:01:16 +02:00
return null;
2019-01-01 15:20:12 +01:00
}
}
}
@Override
public boolean allowRender(String group) {
return !"seekrit".equals(group);
}
}