From f8c2f53b6ad26c72ea48a2dde5bfcb751d95182d Mon Sep 17 00:00:00 2001 From: Mrbysco Date: Sun, 3 Mar 2024 19:02:05 +0100 Subject: [PATCH] Re-add JEI support --- .../mod/jei/EmpowererRecipeCategory.java | 174 ++++++++---------- .../mod/jei/FermentingCategory.java | 170 ++++++++--------- .../mod/jei/JEIActuallyAdditionsPlugin.java | 28 ++- .../mod/jei/LaserRecipeCategory.java | 155 ++++++++-------- 4 files changed, 255 insertions(+), 272 deletions(-) diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/EmpowererRecipeCategory.java b/src/main/java/de/ellpeck/actuallyadditions/mod/jei/EmpowererRecipeCategory.java index c7a3f9d8d..00dfe62dd 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/EmpowererRecipeCategory.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/jei/EmpowererRecipeCategory.java @@ -1,97 +1,77 @@ -///* -// * This file ("EmpowererRecipeCategory.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; -// -//import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -//import de.ellpeck.actuallyadditions.mod.crafting.EmpowererRecipe; -//import de.ellpeck.actuallyadditions.mod.util.AssetUtil; -//import mezz.jei.api.constants.VanillaTypes; -//import mezz.jei.api.gui.IRecipeLayout; -//import mezz.jei.api.gui.drawable.IDrawable; -//import mezz.jei.api.gui.drawable.IDrawableStatic; -//import mezz.jei.api.helpers.IGuiHelper; -//import mezz.jei.api.ingredients.IIngredients; -//import mezz.jei.api.recipe.category.IRecipeCategory; -//import net.minecraft.client.resources.language.I18n; -//import net.minecraft.resources.ResourceLocation; -//import net.minecraft.world.item.ItemStack; -// -//import java.util.ArrayList; -//import java.util.Arrays; -// -//public class EmpowererRecipeCategory implements IRecipeCategory { -// -// public static final ResourceLocation ID = new ResourceLocation(ActuallyAdditions.MODID, "empowerer_jei"); -// -// private final IDrawableStatic background; -// -// public EmpowererRecipeCategory(IGuiHelper helper) { -// this.background = helper.drawableBuilder(AssetUtil.getGuiLocation("gui_nei_empowerer"), 0, 0, 135, 80).setTextureSize(256,256).build(); -// } -// -// @Override -// public ResourceLocation getUid() { -// return ID; -// } -// -// @Override -// public Class getRecipeClass() { -// return EmpowererRecipe.class; -// } -// -// @Override -// public String getTitle() { -// return I18n.get("container.actuallyadditions.empowerer"); -// } -// -// @Override -// public IDrawable getBackground() { -// return background; -// } -// -// @Override -// public IDrawable getIcon() { -// return null; -// } -// -// @Override -// public void setIngredients(EmpowererRecipe empowererRecipe, IIngredients ingredients) { -// ArrayList input = new ArrayList<>(); -// input.addAll(Arrays.asList(empowererRecipe.getInput().getItems())); -// input.addAll(Arrays.asList(empowererRecipe.getStandOne().getItems())); -// input.addAll(Arrays.asList(empowererRecipe.getStandTwo().getItems())); -// input.addAll(Arrays.asList(empowererRecipe.getStandThree().getItems())); -// input.addAll(Arrays.asList(empowererRecipe.getStandFour().getItems())); -// ingredients.setInputs(VanillaTypes.ITEM, input); -// ingredients.setOutput(VanillaTypes.ITEM, empowererRecipe.getOutput()); -// } -// -// @Override -// public void setRecipe(IRecipeLayout recipeLayout, EmpowererRecipe recipe, IIngredients ingredients) { -// recipeLayout.getItemStacks().init(0, true, 31, 31); -// recipeLayout.getItemStacks().set(0, Arrays.asList(recipe.getInput().getItems())); -// -// recipeLayout.getItemStacks().init(1, true, 1, 31); -// recipeLayout.getItemStacks().set(1, Arrays.asList(recipe.getStandOne().getItems())); -// -// recipeLayout.getItemStacks().init(2, true, 31, 1); -// recipeLayout.getItemStacks().set(2, Arrays.asList(recipe.getStandTwo().getItems())); -// -// recipeLayout.getItemStacks().init(3, true, 61, 31); -// recipeLayout.getItemStacks().set(3, Arrays.asList(recipe.getStandThree().getItems())); -// -// recipeLayout.getItemStacks().init(4, true, 31, 61); -// recipeLayout.getItemStacks().set(4, Arrays.asList(recipe.getStandFour().getItems())); -// -// recipeLayout.getItemStacks().init(5, false, 112, 31); -// recipeLayout.getItemStacks().set(5, recipe.getResultItem()); -// } -//} +/* + * This file ("EmpowererRecipeCategory.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; + +import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; +import de.ellpeck.actuallyadditions.mod.crafting.EmpowererRecipe; +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.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.multiplayer.ClientLevel; +import net.minecraft.core.RegistryAccess; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; + +public class EmpowererRecipeCategory implements IRecipeCategory { + + public static final ResourceLocation ID = new ResourceLocation(ActuallyAdditions.MODID, "empowerer_jei"); + + private final IDrawableStatic background; + + public EmpowererRecipeCategory(IGuiHelper helper) { + this.background = helper.drawableBuilder(AssetUtil.getGuiLocation("gui_nei_empowerer"), 0, 0, 135, 80).setTextureSize(256,256).build(); + } + + @Override + public RecipeType getRecipeType() { + return JEIActuallyAdditionsPlugin.EMPOWERER; + } + + @Override + public Component getTitle() { + return Component.translatable("container.actuallyadditions.empowerer"); + } + + @Override + public IDrawable getBackground() { + return background; + } + + @Override + public IDrawable getIcon() { + return null; + } + + @Override + public void setRecipe(IRecipeLayoutBuilder builder, EmpowererRecipe 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, 32, 32).addIngredients(recipe.getInput()); + builder.addSlot(RecipeIngredientRole.INPUT, 2, 32).addIngredients(recipe.getStandOne()); + builder.addSlot(RecipeIngredientRole.INPUT, 32, 2).addIngredients(recipe.getStandTwo()); + builder.addSlot(RecipeIngredientRole.INPUT, 62, 32).addIngredients(recipe.getStandThree()); + builder.addSlot(RecipeIngredientRole.INPUT, 32, 62).addIngredients(recipe.getStandFour()); + + builder.addSlot(RecipeIngredientRole.OUTPUT, 113, 32).addItemStack(recipe.getResultItem(registryAccess)); + } +} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/FermentingCategory.java b/src/main/java/de/ellpeck/actuallyadditions/mod/jei/FermentingCategory.java index 8f5629763..0c590febd 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/FermentingCategory.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/jei/FermentingCategory.java @@ -1,84 +1,88 @@ -//package de.ellpeck.actuallyadditions.mod.jei; +package de.ellpeck.actuallyadditions.mod.jei; + +import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; +import de.ellpeck.actuallyadditions.mod.crafting.FermentingRecipe; +import de.ellpeck.actuallyadditions.mod.inventory.gui.FluidDisplay; +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.gui.GuiGraphics; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidType; + +public class FermentingCategory implements IRecipeCategory { + private final IDrawableStatic background; + private final IDrawableStatic fluidBackground; + + public FermentingCategory(IGuiHelper guiHelper) { + background = guiHelper.drawableBuilder(new ResourceLocation(ActuallyAdditions.MODID, "textures/gui/gui_fermenting_barrel.png"), 41, 4, 94, 86).setTextureSize(256,256).build(); + fluidBackground = guiHelper.drawableBuilder(AssetUtil.GUI_INVENTORY_LOCATION, 0, 171, 18, 85).build(); + } + + @Override + public RecipeType getRecipeType() { + return JEIActuallyAdditionsPlugin.FERMENTING; + } + + @Override + public Component getTitle() { + return Component.literal("Fermenting Recipe"); + } + + @Override + public IDrawable getBackground() { + return background; + } + + @Override + public IDrawable getIcon() { + return null; + } + + @Override + public void setRecipe(IRecipeLayoutBuilder builder, FermentingRecipe recipe, IFocusGroup focuses) { +// int maxFluid = Math.max(FluidType.BUCKET_VOLUME, Math.max(recipe.getInput().getAmount(), recipe.getOutput().getAmount())); +// recipe.setInputDisplay(new FluidDisplay(19, 1, recipe.getInput(), maxFluid, false)); +// recipe.setOutputDisplay(new FluidDisplay(19+38, 1, recipe.getOutput(), maxFluid, false)); + + FluidStack input = recipe.getInput(); + int height = (int)(83D / 1000 * input.getAmount()); + int offset = 83 - height; + builder.addSlot(RecipeIngredientRole.INPUT, 20, 1 + offset) + .addFluidStack(input.getFluid(), input.getAmount()) + .setFluidRenderer(input.getAmount(), false, 16, height) + .setBackground(fluidBackground, -1, -1 - offset); + + FluidStack output = recipe.getOutput(); + height = (int)(83D / 1000 * input.getAmount()); + offset = 83 - height;; + builder.addSlot(RecipeIngredientRole.OUTPUT, 20+38, 1 + offset) + .addFluidStack(output.getFluid(), output.getAmount()) + .setFluidRenderer(output.getAmount(), false, 16, height) + .setBackground(fluidBackground, -1, -1 - offset); + } + + @Override + public void draw(FermentingRecipe recipe, IRecipeSlotsView recipeSlotsView, GuiGraphics guiGraphics, double mouseX, double mouseY) { +// IRecipeCategory.super.draw(recipe, recipeSlotsView, guiGraphics, mouseX, mouseY); +// recipe.getInputDisplay().ifPresent(display -> { +// display.draw(guiGraphics); +// display.render(guiGraphics, (int) mouseX, (int) mouseY); +// }); // -//import com.mojang.blaze3d.vertex.PoseStack; -//import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -//import de.ellpeck.actuallyadditions.mod.crafting.FermentingRecipe; -//import de.ellpeck.actuallyadditions.mod.inventory.gui.FluidDisplay; -//import mezz.jei.api.constants.VanillaTypes; -//import mezz.jei.api.gui.IRecipeLayout; -//import mezz.jei.api.gui.drawable.IDrawable; -//import mezz.jei.api.gui.drawable.IDrawableStatic; -//import mezz.jei.api.helpers.IGuiHelper; -//import mezz.jei.api.ingredients.IIngredients; -//import mezz.jei.api.recipe.category.IRecipeCategory; -//import net.minecraft.resources.ResourceLocation; -//import net.minecraftforge.fluids.FluidAttributes; -// -//import javax.annotation.Nonnull; -// -//public class FermentingCategory implements IRecipeCategory { -// public static final ResourceLocation ID = new ResourceLocation(ActuallyAdditions.MODID, "fermenting_jei"); -// -// private final IDrawableStatic background; -// -// public FermentingCategory(IGuiHelper guiHelper) { -// background = guiHelper.drawableBuilder(new ResourceLocation(ActuallyAdditions.MODID, "textures/gui/gui_fermenting_barrel.png"), 41, 4, 94, 86).setTextureSize(256,256).build(); -// } -// -// @Override -// public ResourceLocation getUid() { -// return ID; -// } -// -// @Override -// public Class getRecipeClass() { -// return FermentingRecipe.class; -// } -// -// @Override -// public String getTitle() { -// return "Fermenting Recipe"; -// } -// -// @Override -// public IDrawable getBackground() { -// return background; -// } -// -// @Override -// public IDrawable getIcon() { -// return null; -// } -// -// @Override -// public void setIngredients(@Nonnull FermentingRecipe fermentingRecipe, @Nonnull IIngredients ingredients) { -// ingredients.setInput(VanillaTypes.FLUID, fermentingRecipe.getInput()); -// ingredients.setOutput(VanillaTypes.FLUID, fermentingRecipe.getOutput()); -// } -// -// @Override -// public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull FermentingRecipe fermentingRecipe, @Nonnull IIngredients ingredients) { -// int maxFluid = Math.max(FluidType.BUCKET_VOLUME, Math.max(fermentingRecipe.getInput().getAmount(), fermentingRecipe.getOutput().getAmount())); -// -// fermentingRecipe.setInputDisplay(new FluidDisplay(19, 1, fermentingRecipe.getInput(), maxFluid, false)); -// fermentingRecipe.setOutputDisplay(new FluidDisplay(19+38, 1, fermentingRecipe.getOutput(), maxFluid, false)); -// } -// -// @Override -// public void draw(FermentingRecipe recipe, PoseStack matrixStack, double mouseX, double mouseY) { -// IRecipeCategory.super.draw(recipe, matrixStack, mouseX, mouseY); -// -// recipe.getInputDisplay().ifPresent(display -> { -// display.draw(matrixStack); -// display.render(matrixStack, (int) mouseX, (int) mouseY); -// }); -// -// recipe.getOutputDisplay().ifPresent(display -> { -// display.draw(matrixStack); -// display.render(matrixStack, (int) mouseX, (int) mouseY); -// }); -// -// -// //TODO draw the progress indicator, scaled to the recipe duration. -// } -//} +// recipe.getOutputDisplay().ifPresent(display -> { +// display.draw(guiGraphics); +// display.render(guiGraphics, (int) mouseX, (int) mouseY); +// }); + //TODO draw the progress indicator, scaled to the recipe duration. + } +} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/JEIActuallyAdditionsPlugin.java b/src/main/java/de/ellpeck/actuallyadditions/mod/jei/JEIActuallyAdditionsPlugin.java index 15da7d1cc..29053df08 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/JEIActuallyAdditionsPlugin.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/jei/JEIActuallyAdditionsPlugin.java @@ -11,11 +11,17 @@ package de.ellpeck.actuallyadditions.mod.jei; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; +import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks; +import de.ellpeck.actuallyadditions.mod.crafting.ActuallyRecipes; +import de.ellpeck.actuallyadditions.mod.crafting.EmpowererRecipe; +import de.ellpeck.actuallyadditions.mod.crafting.FermentingRecipe; +import de.ellpeck.actuallyadditions.mod.crafting.LaserRecipe; import de.ellpeck.actuallyadditions.mod.items.ActuallyItems; import mezz.jei.api.IModPlugin; import mezz.jei.api.JeiPlugin; import mezz.jei.api.constants.RecipeTypes; import mezz.jei.api.helpers.IJeiHelpers; +import mezz.jei.api.recipe.RecipeType; import mezz.jei.api.registration.IRecipeCatalystRegistration; import mezz.jei.api.registration.IRecipeCategoryRegistration; import mezz.jei.api.registration.IRecipeRegistration; @@ -32,13 +38,17 @@ public class JEIActuallyAdditionsPlugin implements IModPlugin { return ID; } + public static final RecipeType FERMENTING = RecipeType.create(ActuallyAdditions.MODID, "fermenting", FermentingRecipe.class); + public static final RecipeType LASER = RecipeType.create(ActuallyAdditions.MODID, "laser", LaserRecipe.class); + public static final RecipeType EMPOWERER = RecipeType.create(ActuallyAdditions.MODID, "empowerer", EmpowererRecipe.class); + @Override public void registerCategories(IRecipeCategoryRegistration registry) { IJeiHelpers helpers = registry.getJeiHelpers(); -// registry.addRecipeCategories(new FermentingCategory(helpers.getGuiHelper())); //TODO: re-enable after refactor jei compat -// registry.addRecipeCategories(new LaserRecipeCategory(helpers.getGuiHelper())); //TODO: re-enable after refactor jei compat -// registry.addRecipeCategories(new EmpowererRecipeCategory(helpers.getGuiHelper())); //TODO: re-enable after refactor jei compat + registry.addRecipeCategories(new FermentingCategory(helpers.getGuiHelper())); //TODO: re-enable after refactor jei compat + registry.addRecipeCategories(new LaserRecipeCategory(helpers.getGuiHelper())); //TODO: re-enable after refactor jei compat + registry.addRecipeCategories(new EmpowererRecipeCategory(helpers.getGuiHelper())); //TODO: re-enable after refactor jei compat //registry.addRecipeCategories(new CoffeeMachineRecipeCategory(helpers.getGuiHelper()), new CompostRecipeCategory(helpers.getGuiHelper()), new CrusherRecipeCategory(helpers.getGuiHelper()), new ReconstructorRecipeCategory(helpers.getGuiHelper()), new EmpowererRecipeCategory(helpers.getGuiHelper()), new BookletRecipeCategory(helpers.getGuiHelper())); } @@ -46,9 +56,9 @@ public class JEIActuallyAdditionsPlugin implements IModPlugin { @Override public void registerRecipeCatalysts(IRecipeCatalystRegistration registry) { registry.addRecipeCatalyst(new ItemStack(ActuallyItems.CRAFTER_ON_A_STICK.get()), RecipeTypes.CRAFTING); -// registry.addRecipeCatalyst(new ItemStack(ActuallyBlocks.FERMENTING_BARREL.getItem()), FermentingCategory.ID); //TODO: re-enable after refactor jei compat -// registry.addRecipeCatalyst(new ItemStack(ActuallyBlocks.ATOMIC_RECONSTRUCTOR.getItem()), LaserRecipeCategory.ID); //TODO: re-enable after refactor jei compat -// registry.addRecipeCatalyst(new ItemStack(ActuallyBlocks.EMPOWERER.getItem()), EmpowererRecipeCategory.ID); //TODO: re-enable after refactor jei compat + registry.addRecipeCatalyst(new ItemStack(ActuallyBlocks.FERMENTING_BARREL.getItem()), FERMENTING); //TODO: re-enable after refactor jei compat + registry.addRecipeCatalyst(new ItemStack(ActuallyBlocks.ATOMIC_RECONSTRUCTOR.getItem()), LASER); //TODO: re-enable after refactor jei compat + registry.addRecipeCatalyst(new ItemStack(ActuallyBlocks.EMPOWERER.getItem()), EMPOWERER); //TODO: re-enable after refactor jei compat // registry.addRecipeCatalyst(new ItemStack(ActuallyBlocks.blockFurnaceDouble.get()), VanillaRecipeCategoryUid.SMELTING); // registry.addRecipeCatalyst(new ItemStack(ActuallyBlocks.blockGrinder.get()), CrusherRecipeCategory.NAME); @@ -64,9 +74,9 @@ public class JEIActuallyAdditionsPlugin implements IModPlugin { public void registerRecipes(IRecipeRegistration registry) { Level level = Minecraft.getInstance().level; -// registry.addRecipes(level.getRecipeManager().getAllRecipesFor(ActuallyRecipes.Types.FERMENTING), FermentingCategory.ID); //TODO: re-enable after refactor jei compat -// registry.addRecipes(level.getRecipeManager().getAllRecipesFor(ActuallyRecipes.Types.LASER), LaserRecipeCategory.ID); //TODO: re-enable after refactor jei compat -// registry.addRecipes(level.getRecipeManager().getAllRecipesFor(ActuallyRecipes.Types.EMPOWERING), EmpowererRecipeCategory.ID); //TODO: re-enable after refactor jei compat + registry.addRecipes(FERMENTING, level.getRecipeManager().getAllRecipesFor(ActuallyRecipes.Types.FERMENTING.get())); //TODO: re-enable after refactor jei compat + registry.addRecipes(LASER, level.getRecipeManager().getAllRecipesFor(ActuallyRecipes.Types.LASER.get())); //TODO: re-enable after refactor jei compat + registry.addRecipes(EMPOWERER, level.getRecipeManager().getAllRecipesFor(ActuallyRecipes.Types.EMPOWERING.get())); //TODO: re-enable after refactor jei compat //registry.addRecipes(ActuallyAdditionsAPI.BOOKLET_PAGES_WITH_ITEM_OR_FLUID_DATA, BookletRecipeCategory.NAME); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/LaserRecipeCategory.java b/src/main/java/de/ellpeck/actuallyadditions/mod/jei/LaserRecipeCategory.java index 596cc2263..32d3e75aa 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/LaserRecipeCategory.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/jei/LaserRecipeCategory.java @@ -1,83 +1,72 @@ -///* -// * 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; -// -//import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -//import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks; -//import de.ellpeck.actuallyadditions.mod.crafting.LaserRecipe; -//import de.ellpeck.actuallyadditions.mod.util.AssetUtil; -//import mezz.jei.api.constants.VanillaTypes; -//import mezz.jei.api.gui.IRecipeLayout; -//import mezz.jei.api.gui.drawable.IDrawable; -//import mezz.jei.api.gui.drawable.IDrawableStatic; -//import mezz.jei.api.helpers.IGuiHelper; -//import mezz.jei.api.ingredients.IIngredients; -//import mezz.jei.api.recipe.category.IRecipeCategory; -//import net.minecraft.network.chat.TranslatableComponent; -//import net.minecraft.resources.ResourceLocation; -//import net.minecraft.world.item.ItemStack; -// -//import javax.annotation.Nonnull; -//import java.util.Arrays; -// -//public class LaserRecipeCategory implements IRecipeCategory { -// -// public static final ResourceLocation ID = new ResourceLocation(ActuallyAdditions.MODID, "laser_jei"); -// private final IDrawableStatic background; -// private final ItemStack RECONSTRUCTOR = new ItemStack(ActuallyBlocks.ATOMIC_RECONSTRUCTOR.getItem()); -// -// public LaserRecipeCategory(IGuiHelper helper) { -// this.background = helper.drawableBuilder(AssetUtil.getGuiLocation("gui_nei_atomic_reconstructor"), 0, 0, 96, 60).setTextureSize(256,256).build(); -// } -// -// @Override -// public ResourceLocation getUid() { -// return ID; -// } -// -// @Override -// public Class getRecipeClass() { -// return LaserRecipe.class; -// } -// -// @Override -// public String getTitle() { -// return Component.translatable("container.actuallyadditions.reconstructor").getString(); -// } -// -// @Override -// public IDrawable getBackground() { -// return this.background; -// } -// -// @Override -// public IDrawable getIcon() { -// return null; -// } -// -// @Override -// public void setIngredients(LaserRecipe laserRecipe, IIngredients ingredients) { -// ingredients.setInputs(VanillaTypes.ITEM, Arrays.asList(laserRecipe.getInput().getItems())); -// ingredients.setOutput(VanillaTypes.ITEM, laserRecipe.getResultItem()); -// } -// -// @Override -// public void setRecipe(@Nonnull IRecipeLayout layout, @Nonnull LaserRecipe laserRecipe, @Nonnull IIngredients iIngredients) { -// layout.getItemStacks().init(0, true, 4, 18); -// layout.getItemStacks().set(0, iIngredients.getInputs(VanillaTypes.ITEM).get(0)); -// -// layout.getItemStacks().init(1, false, 34, 19); -// layout.getItemStacks().set(1, RECONSTRUCTOR); -// -// layout.getItemStacks().init(2, false, 66, 18); -// layout.getItemStacks().set(2, iIngredients.getOutputs(VanillaTypes.ITEM).get(0)); -// } -//} +/* + * 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; + +import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks; +import de.ellpeck.actuallyadditions.mod.crafting.LaserRecipe; +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.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.multiplayer.ClientLevel; +import net.minecraft.core.RegistryAccess; +import net.minecraft.network.chat.Component; +import net.minecraft.world.item.ItemStack; + +public class LaserRecipeCategory implements IRecipeCategory { + private final IDrawableStatic background; + private final ItemStack RECONSTRUCTOR = new ItemStack(ActuallyBlocks.ATOMIC_RECONSTRUCTOR.getItem()); + + public LaserRecipeCategory(IGuiHelper helper) { + this.background = helper.drawableBuilder(AssetUtil.getGuiLocation("gui_nei_atomic_reconstructor"), 0, 0, 96, 60).setTextureSize(256,256).build(); + } + + @Override + public RecipeType getRecipeType() { + return JEIActuallyAdditionsPlugin.LASER; + } + + @Override + public Component getTitle() { + return Component.translatable("container.actuallyadditions.reconstructor"); + } + + @Override + public IDrawable getBackground() { + return this.background; + } + + @Override + public IDrawable getIcon() { + return null; + } + + @Override + public void setRecipe(IRecipeLayoutBuilder builder, LaserRecipe 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, 35, 20).addItemStack(RECONSTRUCTOR); + + builder.addSlot(RecipeIngredientRole.OUTPUT, 66, 19).addItemStack(recipe.getResultItem(registryAccess)); + } +}