Add Mining Lens category

This commit is contained in:
Mrbysco 2024-03-12 22:21:17 +01:00
parent 87b4e29534
commit b866f50e8f
3 changed files with 96 additions and 1 deletions

View file

@ -22,6 +22,7 @@ import de.ellpeck.actuallyadditions.mod.jei.crusher.CrusherCategory;
import de.ellpeck.actuallyadditions.mod.jei.empowerer.EmpowererRecipeCategory;
import de.ellpeck.actuallyadditions.mod.jei.fermenting.FermentingCategory;
import de.ellpeck.actuallyadditions.mod.jei.laser.LaserRecipeCategory;
import de.ellpeck.actuallyadditions.mod.jei.lens.MiningLensRecipeCategory;
import de.ellpeck.actuallyadditions.mod.jei.pressing.PressingCategory;
import mezz.jei.api.IModPlugin;
import mezz.jei.api.JeiPlugin;
@ -52,6 +53,7 @@ public class JEIActuallyAdditionsPlugin implements IModPlugin {
public static final RecipeType<EmpowererRecipe> EMPOWERER = RecipeType.create(ActuallyAdditions.MODID, "empowerer", EmpowererRecipe.class);
public static final RecipeType<CoffeeIngredientRecipe> COFFEE_MACHINE = RecipeType.create(ActuallyAdditions.MODID, "coffee_machine", CoffeeIngredientRecipe.class);
public static final RecipeType<CrushingRecipe> CRUSHING = RecipeType.create(ActuallyAdditions.MODID, "crushing", CrushingRecipe.class);
public static final RecipeType<MiningLensRecipe> MINING_LENS = RecipeType.create(ActuallyAdditions.MODID, "mining_lens", MiningLensRecipe.class);
@Override
public void registerCategories(IRecipeCategoryRegistration registry) {
@ -63,6 +65,7 @@ public class JEIActuallyAdditionsPlugin implements IModPlugin {
registry.addRecipeCategories(new CoffeeMachineCategory(helpers.getGuiHelper()));
registry.addRecipeCategories(new PressingCategory(helpers.getGuiHelper()));
registry.addRecipeCategories(new CrusherCategory(helpers.getGuiHelper()));
registry.addRecipeCategories(new MiningLensRecipeCategory(helpers.getGuiHelper()));
}
@Override
@ -76,6 +79,7 @@ public class JEIActuallyAdditionsPlugin implements IModPlugin {
registry.addRecipeCatalyst(new ItemStack(ActuallyBlocks.CANOLA_PRESS.getItem()), PRESSING);
registry.addRecipeCatalyst(new ItemStack(ActuallyBlocks.CRUSHER.getItem()), CRUSHING);
registry.addRecipeCatalyst(new ItemStack(ActuallyBlocks.CRUSHER_DOUBLE.getItem()), CRUSHING);
registry.addRecipeCatalyst(new ItemStack(ActuallyItems.LENS_OF_THE_MINER.get()), MINING_LENS);
// registry.addRecipeCatalyst(new ItemStack(ActuallyItems.itemBooklet.get()), BookletRecipeCategory.NAME);
// registry.addRecipeCatalyst(new ItemStack(InitBlocks.blockCompost.get()), CompostRecipeCategory.NAME);
@ -91,6 +95,7 @@ public class JEIActuallyAdditionsPlugin implements IModPlugin {
registry.addRecipes(COFFEE_MACHINE, level.getRecipeManager().getAllRecipesFor(ActuallyRecipes.Types.COFFEE_INGREDIENT.get()).stream().map(RecipeHolder::value).toList());
registry.addRecipes(PRESSING, level.getRecipeManager().getAllRecipesFor(ActuallyRecipes.Types.PRESSING.get()).stream().map(RecipeHolder::value).toList());
registry.addRecipes(CRUSHING, level.getRecipeManager().getAllRecipesFor(ActuallyRecipes.Types.CRUSHING.get()).stream().map(RecipeHolder::value).toList());
registry.addRecipes(MINING_LENS, level.getRecipeManager().getAllRecipesFor(ActuallyRecipes.Types.MINING_LENS.get()).stream().map(RecipeHolder::value).toList());
//registry.addRecipes(ActuallyAdditionsAPI.BOOKLET_PAGES_WITH_ITEM_OR_FLUID_DATA, BookletRecipeCategory.NAME);
}

View file

@ -0,0 +1,88 @@
/*
* This file ("ReconstructorRecipeCategory.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015-2017 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.jei.lens;
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
import de.ellpeck.actuallyadditions.mod.crafting.MiningLensRecipe;
import de.ellpeck.actuallyadditions.mod.items.ActuallyItems;
import de.ellpeck.actuallyadditions.mod.jei.JEIActuallyAdditionsPlugin;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
import mezz.jei.api.gui.builder.IRecipeLayoutBuilder;
import mezz.jei.api.gui.drawable.IDrawable;
import mezz.jei.api.gui.drawable.IDrawableStatic;
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.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.core.RegistryAccess;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.ItemStack;
public class MiningLensRecipeCategory implements IRecipeCategory<MiningLensRecipe> {
private final IDrawableStatic background;
private final ItemStack RECONSTRUCTOR = new ItemStack(ActuallyBlocks.ATOMIC_RECONSTRUCTOR.getItem());
public MiningLensRecipeCategory(IGuiHelper helper) {
this.background = helper.drawableBuilder(AssetUtil.getGuiLocation("gui_nei_atomic_reconstructor"), 0, 0, 96, 60).setTextureSize(256,256).build();
}
@Override
public RecipeType<MiningLensRecipe> getRecipeType() {
return JEIActuallyAdditionsPlugin.MINING_LENS;
}
@Override
public Component getTitle() {
return Component.translatable("jei.actuallyadditions.mining_lens");
}
@Override
public IDrawable getBackground() {
return this.background;
}
@Override
public IDrawable getIcon() {
return null;
}
@Override
public void setRecipe(IRecipeLayoutBuilder builder, MiningLensRecipe recipe, IFocusGroup focuses) {
Minecraft minecraft = Minecraft.getInstance();
ClientLevel level = minecraft.level;
if (level == null) {
throw new NullPointerException("level must not be null.");
}
RegistryAccess registryAccess = level.registryAccess();
builder.addSlot(RecipeIngredientRole.INPUT, 5, 19).addIngredients(recipe.getInput());
builder.addSlot(RecipeIngredientRole.INPUT, 27, 20).addItemStack(RECONSTRUCTOR);
builder.addSlot(RecipeIngredientRole.INPUT, 43, 20).addItemStack(new ItemStack(ActuallyItems.LENS_OF_THE_MINER.get()));
builder.addSlot(RecipeIngredientRole.OUTPUT, 66, 19).addItemStack(recipe.getResultItem(registryAccess));
}
@Override
public void draw(MiningLensRecipe recipe, IRecipeSlotsView recipeSlotsView, GuiGraphics guiGraphics, double mouseX, double mouseY) {
Minecraft mc = Minecraft.getInstance();
Component component = Component.translatable("jei.actuallyadditions.mining_lens.weight");
guiGraphics.drawString(mc.font, component, 2, 42, 0, false);
String weight = String.valueOf(recipe.getWeight());
guiGraphics.drawString(mc.font, weight, 16 - mc.font.width(weight) / 2, 52, 0, false);
}
}

View file

@ -980,5 +980,7 @@
"_comment": "JEI",
"jei.actuallyadditions.coffee.special": "Special Feature",
"jei.actuallyadditions.coffee.maxAmount": "Max Amount",
"jei.actuallyadditions.coffee.extra.milk": "+01:00, -1 Level"
"jei.actuallyadditions.coffee.extra.milk": "+01:00, -1 Level",
"jei.actuallyadditions.mining_lens": "Lens of the Miner",
"jei.actuallyadditions.mining_lens.weight": "Weight:"
}