-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added JEI compat for Custom Compacting Recipes
- Loading branch information
Showing
2 changed files
with
106 additions
and
0 deletions.
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
src/main/java/com/buuz135/functionalstorage/compat/jei/CompactingRecipeCategory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
src/main/java/com/buuz135/functionalstorage/compat/jei/JEIPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |