NaturesAura/src/main/java/de/ellpeck/naturesaura/compat/jei/JEINaturesAuraPlugin.java

78 lines
3.8 KiB
Java
Raw Normal View History

2018-10-22 00:14:52 +02:00
package de.ellpeck.naturesaura.compat.jei;
2018-10-16 21:10:38 +02:00
import de.ellpeck.naturesaura.NaturesAura;
2018-11-11 13:26:19 +01:00
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
2018-10-16 21:10:38 +02:00
import de.ellpeck.naturesaura.blocks.ModBlocks;
2020-01-26 01:41:49 +01:00
import de.ellpeck.naturesaura.items.ItemAuraBottle;
import de.ellpeck.naturesaura.items.ItemEffectPowder;
2020-01-23 19:20:47 +01:00
import de.ellpeck.naturesaura.items.ModItems;
2020-04-29 16:38:50 +02:00
import de.ellpeck.naturesaura.recipes.ModRecipes;
2018-10-16 21:10:38 +02:00
import mezz.jei.api.IModPlugin;
2020-01-21 21:04:44 +01:00
import mezz.jei.api.JeiPlugin;
2021-12-19 17:14:56 +01:00
import mezz.jei.api.ingredients.subtypes.IIngredientSubtypeInterpreter;
2020-01-21 21:04:44 +01:00
import mezz.jei.api.registration.IRecipeCatalystRegistration;
import mezz.jei.api.registration.IRecipeCategoryRegistration;
import mezz.jei.api.registration.IRecipeRegistration;
2020-01-23 19:20:47 +01:00
import mezz.jei.api.registration.ISubtypeRegistration;
2020-04-29 16:38:50 +02:00
import net.minecraft.client.Minecraft;
2021-12-19 17:14:56 +01:00
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
2018-10-16 21:10:38 +02:00
2020-01-21 21:04:44 +01:00
@JeiPlugin
2018-10-16 21:10:38 +02:00
public class JEINaturesAuraPlugin implements IModPlugin {
2020-01-21 21:04:44 +01:00
public static final ResourceLocation TREE_RITUAL = new ResourceLocation(NaturesAura.MOD_ID, "tree_ritual");
public static final ResourceLocation ALTAR = new ResourceLocation(NaturesAura.MOD_ID, "altar");
public static final ResourceLocation OFFERING = new ResourceLocation(NaturesAura.MOD_ID, "offering");
public static final ResourceLocation SPAWNER = new ResourceLocation(NaturesAura.MOD_ID, "animal_spawner");
@Override
public ResourceLocation getPluginUid() {
return new ResourceLocation(NaturesAura.MOD_ID, "jei_plugin");
}
2018-10-16 21:10:38 +02:00
@Override
public void registerCategories(IRecipeCategoryRegistration registry) {
2021-12-19 17:14:56 +01:00
var helper = registry.getJeiHelpers().getGuiHelper();
2018-10-16 21:10:38 +02:00
registry.addRecipeCategories(
2018-10-18 18:00:21 +02:00
new TreeRitualCategory(helper),
2018-11-21 01:05:50 +01:00
new AltarCategory(helper),
new OfferingCategory(helper),
new AnimalSpawnerCategory(helper)
2018-10-16 21:10:38 +02:00
);
}
2020-01-23 19:20:47 +01:00
@Override
public void registerItemSubtypes(ISubtypeRegistration registration) {
2021-12-19 17:14:56 +01:00
registration.registerSubtypeInterpreter(ModItems.EFFECT_POWDER, (stack, context) -> ItemEffectPowder.getEffect(stack).toString());
registration.registerSubtypeInterpreter(ModItems.AURA_BOTTLE, (stack, context) -> ItemAuraBottle.getType(stack).getName().toString());
2020-01-23 19:20:47 +01:00
2021-12-19 17:14:56 +01:00
var auraInterpreter = (IIngredientSubtypeInterpreter<ItemStack>) (stack, context) -> {
2021-12-23 13:27:52 +01:00
var container = stack.getCapability(NaturesAuraAPI.CAP_AURA_CONTAINER).orElse(null);
2020-01-23 19:20:47 +01:00
if (container != null)
return String.valueOf(container.getStoredAura());
2021-12-19 17:14:56 +01:00
return IIngredientSubtypeInterpreter.NONE;
2020-01-23 19:20:47 +01:00
};
registration.registerSubtypeInterpreter(ModItems.AURA_CACHE, auraInterpreter);
registration.registerSubtypeInterpreter(ModItems.AURA_TROVE, auraInterpreter);
}
2018-10-16 21:10:38 +02:00
@Override
2020-01-21 21:04:44 +01:00
public void registerRecipeCatalysts(IRecipeCatalystRegistration registration) {
registration.addRecipeCatalyst(new ItemStack(ModBlocks.GOLD_POWDER), TREE_RITUAL);
registration.addRecipeCatalyst(new ItemStack(ModBlocks.WOOD_STAND), TREE_RITUAL);
registration.addRecipeCatalyst(new ItemStack(ModBlocks.NATURE_ALTAR), ALTAR);
registration.addRecipeCatalyst(new ItemStack(ModBlocks.OFFERING_TABLE), OFFERING);
registration.addRecipeCatalyst(new ItemStack(ModBlocks.ANIMAL_SPAWNER), SPAWNER);
}
2018-10-16 21:10:38 +02:00
2020-01-21 21:04:44 +01:00
@Override
public void registerRecipes(IRecipeRegistration registration) {
2021-12-19 17:14:56 +01:00
var manager = Minecraft.getInstance().level.getRecipeManager();
registration.addRecipes(manager.getAllRecipesFor(ModRecipes.TREE_RITUAL_TYPE), TREE_RITUAL);
registration.addRecipes(manager.getAllRecipesFor(ModRecipes.ALTAR_TYPE), ALTAR);
registration.addRecipes(manager.getAllRecipesFor(ModRecipes.OFFERING_TYPE), OFFERING);
registration.addRecipes(manager.getAllRecipesFor(ModRecipes.ANIMAL_SPAWNER_TYPE), SPAWNER);
2018-10-16 21:10:38 +02:00
}
}