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

80 lines
4.3 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;
2022-06-27 15:24:04 +02:00
import de.ellpeck.naturesaura.recipes.*;
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;
2022-06-27 15:24:04 +02:00
import mezz.jei.api.constants.VanillaTypes;
2021-12-19 17:14:56 +01:00
import mezz.jei.api.ingredients.subtypes.IIngredientSubtypeInterpreter;
2022-06-27 15:24:04 +02:00
import mezz.jei.api.recipe.RecipeType;
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 {
2022-06-27 15:24:04 +02:00
public static final RecipeType<TreeRitualRecipe> TREE_RITUAL = RecipeType.create(NaturesAura.MOD_ID, "tree_ritual", TreeRitualRecipe.class);
public static final RecipeType<AltarRecipe> ALTAR = RecipeType.create(NaturesAura.MOD_ID, "altar", AltarRecipe.class);
public static final RecipeType<OfferingRecipe> OFFERING = RecipeType.create(NaturesAura.MOD_ID, "offering", OfferingRecipe.class);
public static final RecipeType<AnimalSpawnerRecipe> SPAWNER = RecipeType.create(NaturesAura.MOD_ID, "animal_spawner", AnimalSpawnerRecipe.class);
2020-01-21 21:04:44 +01:00
@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) {
2022-06-27 15:24:04 +02:00
registration.registerSubtypeInterpreter(VanillaTypes.ITEM_STACK, ModItems.EFFECT_POWDER, (stack, context) -> ItemEffectPowder.getEffect(stack).toString());
registration.registerSubtypeInterpreter(VanillaTypes.ITEM_STACK, 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
};
2022-06-27 15:24:04 +02:00
registration.registerSubtypeInterpreter(VanillaTypes.ITEM_STACK, ModItems.AURA_CACHE, auraInterpreter);
registration.registerSubtypeInterpreter(VanillaTypes.ITEM_STACK, ModItems.AURA_TROVE, auraInterpreter);
2020-01-23 19:20:47 +01:00
}
2018-10-16 21:10:38 +02:00
@Override
2020-01-21 21:04:44 +01:00
public void registerRecipeCatalysts(IRecipeCatalystRegistration registration) {
2022-06-27 15:24:04 +02:00
registration.addRecipeCatalyst(new ItemStack(ModBlocks.GOLD_POWDER), JEINaturesAuraPlugin.TREE_RITUAL);
registration.addRecipeCatalyst(new ItemStack(ModBlocks.WOOD_STAND), JEINaturesAuraPlugin.TREE_RITUAL);
registration.addRecipeCatalyst(new ItemStack(ModBlocks.NATURE_ALTAR), JEINaturesAuraPlugin.ALTAR);
registration.addRecipeCatalyst(new ItemStack(ModBlocks.OFFERING_TABLE), JEINaturesAuraPlugin.OFFERING);
registration.addRecipeCatalyst(new ItemStack(ModBlocks.ANIMAL_SPAWNER), JEINaturesAuraPlugin.SPAWNER);
2020-01-21 21:04:44 +01:00
}
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();
2022-06-27 15:24:04 +02:00
registration.addRecipes(JEINaturesAuraPlugin.TREE_RITUAL, manager.getAllRecipesFor(ModRecipes.TREE_RITUAL_TYPE));
registration.addRecipes(JEINaturesAuraPlugin.ALTAR, manager.getAllRecipesFor(ModRecipes.ALTAR_TYPE));
registration.addRecipes(JEINaturesAuraPlugin.OFFERING, manager.getAllRecipesFor(ModRecipes.OFFERING_TYPE));
registration.addRecipes(JEINaturesAuraPlugin.SPAWNER, manager.getAllRecipesFor(ModRecipes.ANIMAL_SPAWNER_TYPE));
2018-10-16 21:10:38 +02:00
}
}