Skip to content

Commit

Permalink
Added JEI compat for Custom Compacting Recipes
Browse files Browse the repository at this point in the history
  • Loading branch information
Buuz135 committed Nov 18, 2023
1 parent 24b7ad7 commit 8c76332
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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<CustomCompactingRecipe> {

public static RecipeType<CustomCompactingRecipe> TYPE = RecipeType.create(FunctionalStorage.MOD_ID, "dissolution", CustomCompactingRecipe.class);

private final IGuiHelper guiHelper;

public CompactingRecipeCategory(IGuiHelper guiHelper) {
this.guiHelper = guiHelper;
}

@Override
public RecipeType<CustomCompactingRecipe> 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);
}
}
Original file line number Diff line number Diff line change
@@ -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<CustomCompactingRecipe>) 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;
}
}

0 comments on commit 8c76332

Please sign in to comment.