diff --git a/src/main/java/com/buuz135/functionalstorage/compat/jei/CompactingRecipeCategory.java b/src/main/java/com/buuz135/functionalstorage/compat/jei/CompactingRecipeCategory.java new file mode 100644 index 00000000..97065d30 --- /dev/null +++ b/src/main/java/com/buuz135/functionalstorage/compat/jei/CompactingRecipeCategory.java @@ -0,0 +1,59 @@ +package com.buuz135.functionalstorage.compat.jei; + +import com.buuz135.functionalstorage.FunctionalStorage; +import com.buuz135.functionalstorage.recipe.CustomCompactingRecipe; +import mezz.jei.api.gui.builder.IRecipeLayoutBuilder; +import mezz.jei.api.gui.drawable.IDrawable; +import mezz.jei.api.gui.ingredient.IRecipeSlotsView; +import mezz.jei.api.helpers.IGuiHelper; +import mezz.jei.api.recipe.IFocusGroup; +import mezz.jei.api.recipe.RecipeIngredientRole; +import mezz.jei.api.recipe.RecipeType; +import mezz.jei.api.recipe.category.IRecipeCategory; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.crafting.Ingredient; + +public class CompactingRecipeCategory implements IRecipeCategory { + + public static RecipeType TYPE = RecipeType.create(FunctionalStorage.MOD_ID, "dissolution", CustomCompactingRecipe.class); + + private final IGuiHelper guiHelper; + + public CompactingRecipeCategory(IGuiHelper guiHelper) { + this.guiHelper = guiHelper; + } + + @Override + public RecipeType getRecipeType() { + return TYPE; + } + + @Override + public Component getTitle() { + return Component.literal("Custom Compacting"); + } + + @Override + public IDrawable getBackground() { + return guiHelper.createBlankDrawable(64,64); + } + + @Override + public IDrawable getIcon() { + return null; + } + + @Override + public void setRecipe(IRecipeLayoutBuilder builder, CustomCompactingRecipe recipe, IFocusGroup focuses) { + builder.addSlot(RecipeIngredientRole.INPUT, 8, 40).addIngredients(Ingredient.of(recipe.lower_input)); + builder.addSlot(RecipeIngredientRole.OUTPUT, 24, 8).addIngredients(Ingredient.of(recipe.higher_input)); + } + + @Override + public void draw(CustomCompactingRecipe recipe, IRecipeSlotsView recipeSlotsView, GuiGraphics guiGraphics, double mouseX, double mouseY) { + //new ResourceLocation(FunctionalStorage.MOD_ID, "textures/block/compacting_drawer_front.png") + guiGraphics.blit(new ResourceLocation(FunctionalStorage.MOD_ID, "textures/block/compacting_drawer_front.png"), 0,0, 64,64, 64, 64, 64,64); + } +} diff --git a/src/main/java/com/buuz135/functionalstorage/compat/jei/JEIPlugin.java b/src/main/java/com/buuz135/functionalstorage/compat/jei/JEIPlugin.java new file mode 100644 index 00000000..e457b7b2 --- /dev/null +++ b/src/main/java/com/buuz135/functionalstorage/compat/jei/JEIPlugin.java @@ -0,0 +1,47 @@ +package com.buuz135.functionalstorage.compat.jei; + +import com.buuz135.functionalstorage.FunctionalStorage; +import com.buuz135.functionalstorage.recipe.CustomCompactingRecipe; +import com.hrznstudio.titanium.util.RecipeUtil; +import mezz.jei.api.IModPlugin; +import mezz.jei.api.JeiPlugin; +import mezz.jei.api.registration.IRecipeCatalystRegistration; +import mezz.jei.api.registration.IRecipeCategoryRegistration; +import mezz.jei.api.registration.IRecipeRegistration; +import net.minecraft.client.Minecraft; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.RecipeType; + +@JeiPlugin +public class JEIPlugin implements IModPlugin { + + public static ResourceLocation PLUGIN_ID = new ResourceLocation(FunctionalStorage.MOD_ID, "main"); + + private CompactingRecipeCategory compactingRecipeCategory; + + @Override + public void registerCategories(IRecipeCategoryRegistration registration) { + IModPlugin.super.registerCategories(registration); + registration.addRecipeCategories(compactingRecipeCategory = new CompactingRecipeCategory(registration.getJeiHelpers().getGuiHelper())); + } + + @Override + public void registerRecipes(IRecipeRegistration registration) { + registration.addRecipes(CompactingRecipeCategory.TYPE, RecipeUtil.getRecipes(Minecraft.getInstance().level, (RecipeType) FunctionalStorage.CUSTOM_COMPACTING_RECIPE_TYPE.get())); + } + + @Override + public void registerRecipeCatalysts(IRecipeCatalystRegistration registration) { + IModPlugin.super.registerRecipeCatalysts(registration); + registration.addRecipeCatalyst(new ItemStack(FunctionalStorage.COMPACTING_DRAWER.getKey().get()), CompactingRecipeCategory.TYPE); + registration.addRecipeCatalyst(new ItemStack(FunctionalStorage.FRAMED_COMPACTING_DRAWER.getKey().get()), CompactingRecipeCategory.TYPE); + registration.addRecipeCatalyst(new ItemStack(FunctionalStorage.SIMPLE_COMPACTING_DRAWER.getKey().get()), CompactingRecipeCategory.TYPE); + registration.addRecipeCatalyst(new ItemStack(FunctionalStorage.FRAMED_SIMPLE_COMPACTING_DRAWER.getKey().get()), CompactingRecipeCategory.TYPE); + } + + @Override + public ResourceLocation getPluginUid() { + return PLUGIN_ID; + } +}