Refactor setting recipe items for JEI

This commit is contained in:
mezz 2015-12-31 02:10:57 -08:00
parent 3fde850448
commit 123042a069
12 changed files with 145 additions and 188 deletions

View file

@ -56,6 +56,6 @@ public abstract class BaseRecipeWrapper<T extends BaseRecipe> extends BlankRecip
@Override
public void drawInfo(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight) {
// TODO: make right location for each recipe
// RecipeInfoUtil.drawInfo(minecraft, 0, 0, baseRecipe.euPerTick(), baseRecipe.tickTime());
// RecipeUtil.drawInfo(minecraft, 0, 0, baseRecipe.euPerTick(), baseRecipe.tickTime());
}
}

View file

@ -1,46 +0,0 @@
package techreborn.compat.jei;
import javax.annotation.Nonnull;
import java.awt.Color;
import java.text.NumberFormat;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.util.StatCollector;
public class RecipeInfoUtil {
private static final int color = Color.darkGray.getRGB();
private RecipeInfoUtil() {
}
public static void drawInfo(@Nonnull Minecraft minecraft, int x, int y, final double startCost, final double euPerTick, final int tickTime) {
FontRenderer fontRendererObj = minecraft.fontRendererObj;
int lineSpacing = fontRendererObj.FONT_HEIGHT + 1;
NumberFormat formatter = NumberFormat.getInstance();
String startCostEU = formatter.format(startCost);
String startCostString = StatCollector.translateToLocalFormatted("techreborn.jei.recipe.start.cost", startCostEU);
fontRendererObj.drawString(startCostString, x, y, color);
y += lineSpacing;
drawInfo(minecraft, x, y, euPerTick, tickTime);
}
public static void drawInfo(@Nonnull Minecraft minecraft, int x, int y, final double euPerTick, final int tickTime) {
FontRenderer fontRendererObj = minecraft.fontRendererObj;
int lineSpacing = fontRendererObj.FONT_HEIGHT + 1;
String runningCostString = StatCollector.translateToLocalFormatted("techreborn.jei.recipe.running.cost", euPerTick);
fontRendererObj.drawString(runningCostString, x, y, color);
y += lineSpacing;
String processingTimeString1 = StatCollector.translateToLocalFormatted("techreborn.jei.recipe.processing.time.1", tickTime);
fontRendererObj.drawString(processingTimeString1, x, y, color);
y += lineSpacing;
int seconds = tickTime / 20;
String processingTimeString2 = StatCollector.translateToLocalFormatted("techreborn.jei.recipe.processing.time.2", seconds);
fontRendererObj.drawString(processingTimeString2, x + 10, y, color);
}
}

View file

@ -0,0 +1,92 @@
package techreborn.compat.jei;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.awt.Color;
import java.text.NumberFormat;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
import net.minecraftforge.fluids.FluidStack;
import mezz.jei.api.gui.IGuiFluidStackGroup;
import mezz.jei.api.gui.IGuiItemStackGroup;
import mezz.jei.api.gui.IRecipeLayout;
public class RecipeUtil {
private static final int color = Color.darkGray.getRGB();
private RecipeUtil() {
}
public static void drawInfo(@Nonnull Minecraft minecraft, int x, int y, final double startCost, final double euPerTick, final int tickTime) {
FontRenderer fontRendererObj = minecraft.fontRendererObj;
int lineSpacing = fontRendererObj.FONT_HEIGHT + 1;
NumberFormat formatter = NumberFormat.getInstance();
String startCostEU = formatter.format(startCost);
String startCostString = StatCollector.translateToLocalFormatted("techreborn.jei.recipe.start.cost", startCostEU);
fontRendererObj.drawString(startCostString, x, y, color);
y += lineSpacing;
drawInfo(minecraft, x, y, euPerTick, tickTime);
}
public static void drawInfo(@Nonnull Minecraft minecraft, int x, int y, final double euPerTick, final int tickTime) {
FontRenderer fontRendererObj = minecraft.fontRendererObj;
int lineSpacing = fontRendererObj.FONT_HEIGHT + 1;
String runningCostString = StatCollector.translateToLocalFormatted("techreborn.jei.recipe.running.cost", euPerTick);
fontRendererObj.drawString(runningCostString, x, y, color);
y += lineSpacing;
String processingTimeString1 = StatCollector.translateToLocalFormatted("techreborn.jei.recipe.processing.time.1", tickTime);
fontRendererObj.drawString(processingTimeString1, x, y, color);
y += lineSpacing;
int seconds = tickTime / 20;
String processingTimeString2 = StatCollector.translateToLocalFormatted("techreborn.jei.recipe.processing.time.2", seconds);
fontRendererObj.drawString(processingTimeString2, x + 10, y, color);
}
public static void setRecipeItems(@Nonnull IRecipeLayout recipeLayout, @Nonnull BaseRecipeWrapper<?> recipe, @Nullable int[] itemInputSlots, @Nullable int[] itemOutputSlots, @Nullable int[] fluidInputSlots, @Nullable int[] fluidOutputSlots) {
IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks();
IGuiFluidStackGroup guiFluidStacks = recipeLayout.getFluidStacks();
if (itemInputSlots != null) {
List<List<ItemStack>> inputs = recipe.getInputs();
for (int i = 0; i < inputs.size() && i < itemInputSlots.length; i++) {
int inputSlot = itemInputSlots[i];
guiItemStacks.set(inputSlot, inputs.get(i));
}
}
if (itemOutputSlots != null) {
List<ItemStack> outputs = recipe.getOutputs();
for (int i = 0; i < outputs.size() && i < itemOutputSlots.length; i++) {
int outputSlot = itemOutputSlots[i];
guiItemStacks.set(outputSlot, outputs.get(i));
}
}
if (fluidInputSlots != null) {
List<FluidStack> fluidInputs = recipe.getFluidInputs();
for (int i = 0; i < fluidInputs.size() && i < fluidInputSlots.length; i++) {
int inputTank = fluidInputSlots[i];
guiFluidStacks.set(inputTank, fluidInputs.get(i));
}
}
if (fluidOutputSlots != null) {
List<FluidStack> fluidOutputs = recipe.getFluidOutputs();
for (int i = 0; i < fluidOutputs.size() && i < fluidOutputSlots.length; i++) {
int outputTank = fluidOutputSlots[i];
guiFluidStacks.set(outputTank, fluidOutputs.get(i));
}
}
}
}

View file

@ -15,11 +15,11 @@ import mezz.jei.api.recipe.IRecipeCategory;
import mezz.jei.api.recipe.IRecipeWrapper;
import techreborn.client.gui.GuiAlloySmelter;
import techreborn.compat.jei.RecipeCategoryUids;
import techreborn.compat.jei.RecipeUtil;
public class AlloySmelterRecipeCategory implements IRecipeCategory {
private static final int INPUT_SLOT_0 = 0;
private static final int INPUT_SLOT_1 = 1;
private static final int OUTPUT_SLOT = 2;
private static final int[] INPUT_SLOTS = {0, 1};
private static final int[] OUTPUT_SLOTS = {2};
private final IDrawable background;
private final IDrawableAnimated electricity;
@ -63,15 +63,13 @@ public class AlloySmelterRecipeCategory implements IRecipeCategory {
@Override
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IRecipeWrapper recipeWrapper) {
IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks();
guiItemStacks.init(INPUT_SLOT_0, true, 0, 0);
guiItemStacks.init(INPUT_SLOT_1, true, 18, 0);
guiItemStacks.init(OUTPUT_SLOT, false, 69, 18);
guiItemStacks.init(INPUT_SLOTS[0], true, 0, 0);
guiItemStacks.init(INPUT_SLOTS[1], true, 18, 0);
guiItemStacks.init(OUTPUT_SLOTS[0], false, 69, 18);
if (recipeWrapper instanceof AlloySmelterRecipeWrapper) {
AlloySmelterRecipeWrapper alloySmelterRecipe = (AlloySmelterRecipeWrapper) recipeWrapper;
guiItemStacks.set(INPUT_SLOT_0, alloySmelterRecipe.getInputs().get(0));
guiItemStacks.set(INPUT_SLOT_1, alloySmelterRecipe.getInputs().get(1));
guiItemStacks.set(OUTPUT_SLOT, alloySmelterRecipe.getOutputs());
AlloySmelterRecipeWrapper recipe = (AlloySmelterRecipeWrapper) recipeWrapper;
RecipeUtil.setRecipeItems(recipeLayout, recipe, INPUT_SLOTS, OUTPUT_SLOTS, null, null);
}
}
}

View file

@ -15,11 +15,11 @@ import mezz.jei.api.recipe.IRecipeCategory;
import mezz.jei.api.recipe.IRecipeWrapper;
import techreborn.client.gui.GuiAssemblingMachine;
import techreborn.compat.jei.RecipeCategoryUids;
import techreborn.compat.jei.RecipeUtil;
public class AssemblingMachineRecipeCategory implements IRecipeCategory {
private static final int INPUT_SLOT_0 = 0;
private static final int INPUT_SLOT_1 = 1;
private static final int OUTPUT_SLOT = 2;
private static final int[] INPUT_SLOTS = {0, 1};
private static final int[] OUTPUT_SLOTS = {2};
private final IDrawable background;
private final IDrawableAnimated electricity;
@ -63,15 +63,13 @@ public class AssemblingMachineRecipeCategory implements IRecipeCategory {
@Override
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IRecipeWrapper recipeWrapper) {
IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks();
guiItemStacks.init(INPUT_SLOT_0, true, 0, 0);
guiItemStacks.init(INPUT_SLOT_1, true, 18, 0);
guiItemStacks.init(OUTPUT_SLOT, false, 69, 18);
guiItemStacks.init(INPUT_SLOTS[0], true, 0, 0);
guiItemStacks.init(INPUT_SLOTS[1], true, 18, 0);
guiItemStacks.init(OUTPUT_SLOTS[0], false, 69, 18);
if (recipeWrapper instanceof AssemblingMachineRecipeWrapper) {
AssemblingMachineRecipeWrapper recipe = (AssemblingMachineRecipeWrapper) recipeWrapper;
guiItemStacks.set(INPUT_SLOT_0, recipe.getInputs().get(0));
guiItemStacks.set(INPUT_SLOT_1, recipe.getInputs().get(1));
guiItemStacks.set(OUTPUT_SLOT, recipe.getOutputs());
RecipeUtil.setRecipeItems(recipeLayout, recipe, INPUT_SLOTS, OUTPUT_SLOTS, null, null);
}
}
}

View file

@ -1,28 +1,23 @@
package techreborn.compat.jei.blastFurnace;
import javax.annotation.Nonnull;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
import mezz.jei.api.IGuiHelper;
import mezz.jei.api.gui.IDrawable;
import mezz.jei.api.gui.IDrawableAnimated;
import mezz.jei.api.gui.IDrawableStatic;
import mezz.jei.api.gui.IGuiItemStackGroup;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.recipe.IRecipeCategory;
import mezz.jei.api.recipe.IRecipeWrapper;
import techreborn.client.gui.GuiBlastFurnace;
import techreborn.compat.jei.RecipeCategoryUids;
import techreborn.compat.jei.RecipeUtil;
public class BlastFurnaceRecipeCategory implements IRecipeCategory {
private static final int INPUT_SLOT_0 = 0;
private static final int INPUT_SLOT_1 = 1;
private static final int OUTPUT_SLOT_0 = 2;
private static final int OUTPUT_SLOT_1 = 3;
private static final int[] INPUT_SLOTS = {0, 1};
private static final int[] OUTPUT_SLOTS = {2, 3};
private final IDrawable background;
private final String title;
@ -63,25 +58,14 @@ public class BlastFurnaceRecipeCategory implements IRecipeCategory {
@Override
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IRecipeWrapper recipeWrapper) {
IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks();
guiItemStacks.init(INPUT_SLOT_0, true, 0, 0);
guiItemStacks.init(INPUT_SLOT_1, true, 0, 18);
guiItemStacks.init(OUTPUT_SLOT_0, false, 60, 10);
guiItemStacks.init(OUTPUT_SLOT_1, false, 78, 10);
guiItemStacks.init(INPUT_SLOTS[0], true, 0, 0);
guiItemStacks.init(INPUT_SLOTS[1], true, 0, 18);
guiItemStacks.init(OUTPUT_SLOTS[0], false, 60, 10);
guiItemStacks.init(OUTPUT_SLOTS[1], false, 78, 10);
if (recipeWrapper instanceof BlastFurnaceRecipeWrapper) {
BlastFurnaceRecipeWrapper recipe = (BlastFurnaceRecipeWrapper) recipeWrapper;
List<List<ItemStack>> inputs = recipe.getInputs();
guiItemStacks.set(INPUT_SLOT_0, inputs.get(0));
if (inputs.size() > 1) {
guiItemStacks.set(INPUT_SLOT_1, inputs.get(1));
}
List<ItemStack> outputs = recipe.getOutputs();
guiItemStacks.set(OUTPUT_SLOT_0, outputs.get(0));
if (outputs.size() > 1) {
guiItemStacks.set(OUTPUT_SLOT_1, outputs.get(1));
}
RecipeUtil.setRecipeItems(recipeLayout, recipe, INPUT_SLOTS, OUTPUT_SLOTS, null, null);
}
}
}

View file

@ -1,10 +1,8 @@
package techreborn.compat.jei.centrifuge;
import javax.annotation.Nonnull;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
import mezz.jei.api.IGuiHelper;
@ -15,10 +13,10 @@ import mezz.jei.api.recipe.IRecipeCategory;
import mezz.jei.api.recipe.IRecipeWrapper;
import techreborn.client.gui.GuiCentrifuge;
import techreborn.compat.jei.RecipeCategoryUids;
import techreborn.compat.jei.RecipeUtil;
public class CentrifugeRecipeCategory implements IRecipeCategory {
private static final int INPUT_SLOT = 0;
private static final int EMPTY_CELL_SLOT = 1;
private static final int[] INPUT_SLOTS = {0, 1};
private static final int[] OUTPUT_SLOTS = {2, 3, 4, 5};
private final IDrawable background;
@ -60,8 +58,8 @@ public class CentrifugeRecipeCategory implements IRecipeCategory {
@Override
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IRecipeWrapper recipeWrapper) {
IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks();
guiItemStacks.init(INPUT_SLOT, true, 30, 30);
guiItemStacks.init(EMPTY_CELL_SLOT, true, 0, 0);
guiItemStacks.init(INPUT_SLOTS[0], true, 30, 30);
guiItemStacks.init(INPUT_SLOTS[1], true, 0, 0);
guiItemStacks.init(OUTPUT_SLOTS[0], false, 30, 0);
guiItemStacks.init(OUTPUT_SLOTS[1], false, 60, 30);
@ -70,19 +68,7 @@ public class CentrifugeRecipeCategory implements IRecipeCategory {
if (recipeWrapper instanceof CentrifugeRecipeWrapper) {
CentrifugeRecipeWrapper recipe = (CentrifugeRecipeWrapper) recipeWrapper;
List<List<ItemStack>> inputs = recipe.getInputs();
guiItemStacks.set(INPUT_SLOT, inputs.get(0));
if (inputs.size() > 1) {
guiItemStacks.set(EMPTY_CELL_SLOT, inputs.get(1));
}
List<ItemStack> outputs = recipe.getOutputs();
for (int i = 0; i < outputs.size() && i < OUTPUT_SLOTS.length; i++) {
int outputSlot = OUTPUT_SLOTS[i];
ItemStack output = outputs.get(i);
guiItemStacks.set(outputSlot, output);
}
RecipeUtil.setRecipeItems(recipeLayout, recipe, INPUT_SLOTS, OUTPUT_SLOTS, null, null);
}
}
}

View file

@ -1,10 +1,8 @@
package techreborn.compat.jei.chemicalReactor;
import javax.annotation.Nonnull;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
import mezz.jei.api.IGuiHelper;
@ -15,11 +13,11 @@ import mezz.jei.api.recipe.IRecipeCategory;
import mezz.jei.api.recipe.IRecipeWrapper;
import techreborn.client.gui.GuiChemicalReactor;
import techreborn.compat.jei.RecipeCategoryUids;
import techreborn.compat.jei.RecipeUtil;
public class ChemicalReactorRecipeCategory implements IRecipeCategory {
private static final int INPUT_SLOT_0 = 0;
private static final int INPUT_SLOT_1 = 1;
private static final int OUTPUT_SLOT = 2;
private static final int[] INPUT_SLOTS = {0, 1};
private static final int[] OUTPUT_SLOTS = {2};
private final IDrawable background;
private final String title;
@ -60,21 +58,14 @@ public class ChemicalReactorRecipeCategory implements IRecipeCategory {
@Override
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IRecipeWrapper recipeWrapper) {
IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks();
guiItemStacks.init(INPUT_SLOT_0, true, 0, 0);
guiItemStacks.init(INPUT_SLOT_1, true, 20, 0);
guiItemStacks.init(INPUT_SLOTS[0], true, 0, 0);
guiItemStacks.init(INPUT_SLOTS[1], true, 20, 0);
guiItemStacks.init(OUTPUT_SLOT, false, 10, 30);
guiItemStacks.init(OUTPUT_SLOTS[0], false, 10, 30);
if (recipeWrapper instanceof ChemicalReactorRecipeWrapper) {
ChemicalReactorRecipeWrapper recipe = (ChemicalReactorRecipeWrapper) recipeWrapper;
List<List<ItemStack>> inputs = recipe.getInputs();
guiItemStacks.set(INPUT_SLOT_0, inputs.get(0));
if (inputs.size() > 1) {
guiItemStacks.set(INPUT_SLOT_1, inputs.get(1));
}
guiItemStacks.set(OUTPUT_SLOT, recipe.getOutputs());
RecipeUtil.setRecipeItems(recipeLayout, recipe, INPUT_SLOTS, OUTPUT_SLOTS, null, null);
}
}
}

View file

@ -10,7 +10,7 @@ import net.minecraft.item.ItemStack;
import mezz.jei.api.recipe.BlankRecipeWrapper;
import techreborn.api.reactor.FusionReactorRecipe;
import techreborn.compat.jei.RecipeInfoUtil;
import techreborn.compat.jei.RecipeUtil;
public class FusionReactorRecipeWrapper extends BlankRecipeWrapper {
private FusionReactorRecipe baseRecipe;
@ -39,6 +39,6 @@ public class FusionReactorRecipeWrapper extends BlankRecipeWrapper {
@Override
public void drawInfo(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight) {
RecipeInfoUtil.drawInfo(minecraft, 0, 67, baseRecipe.getStartEU(), baseRecipe.getEuTick(), baseRecipe.getTickTime());
RecipeUtil.drawInfo(minecraft, 0, 67, baseRecipe.getStartEU(), baseRecipe.getEuTick(), baseRecipe.getTickTime());
}
}

View file

@ -1,14 +1,10 @@
package techreborn.compat.jei.grinder;
import javax.annotation.Nonnull;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
import net.minecraftforge.fluids.FluidStack;
import mezz.jei.api.IGuiHelper;
import mezz.jei.api.gui.IDrawable;
import mezz.jei.api.gui.IGuiFluidStackGroup;
@ -18,12 +14,13 @@ import mezz.jei.api.recipe.IRecipeCategory;
import mezz.jei.api.recipe.IRecipeWrapper;
import techreborn.client.gui.GuiGrinder;
import techreborn.compat.jei.RecipeCategoryUids;
import techreborn.compat.jei.RecipeUtil;
import techreborn.tiles.TileGrinder;
public class GrinderRecipeCategory implements IRecipeCategory {
private static final int[] INPUT_SLOTS = {0, 1};
private static final int[] OUTPUT_SLOTS = {2, 3, 4, 5};
private static final int INPUT_TANK = 0;
private static final int[] INPUT_TANKS = {0};
private final IDrawable background;
private final IDrawable blankArea; // for covering the lightning power symbol
@ -77,28 +74,11 @@ public class GrinderRecipeCategory implements IRecipeCategory {
guiItemStacks.init(OUTPUT_SLOTS[3], false, 123, 19);
IGuiFluidStackGroup guiFluidStacks = recipeLayout.getFluidStacks();
guiFluidStacks.init(INPUT_TANK, true, 4, 4, 12, 47, TileGrinder.TANK_CAPACITY, tankOverlay);
guiFluidStacks.init(INPUT_TANKS[0], true, 4, 4, 12, 47, TileGrinder.TANK_CAPACITY, tankOverlay);
if (recipeWrapper instanceof GrinderRecipeWrapper) {
GrinderRecipeWrapper recipe = (GrinderRecipeWrapper) recipeWrapper;
List<List<ItemStack>> inputs = recipe.getInputs();
for (int i = 0; i < inputs.size() && i < INPUT_SLOTS.length; i++) {
int inputSlot = INPUT_SLOTS[i];
guiItemStacks.set(inputSlot, inputs.get(i));
}
List<ItemStack> outputs = recipe.getOutputs();
for (int i = 0; i < outputs.size() && i < OUTPUT_SLOTS.length; i++) {
int outputSlot = OUTPUT_SLOTS[i];
ItemStack output = outputs.get(i);
guiItemStacks.set(outputSlot, output);
}
List<FluidStack> fluidInputs = recipe.getFluidInputs();
if (fluidInputs.size() > 0) {
guiFluidStacks.set(INPUT_TANK, fluidInputs.get(0));
}
RecipeUtil.setRecipeItems(recipeLayout, recipe, INPUT_SLOTS, OUTPUT_SLOTS, INPUT_TANKS, null);
}
}
}

View file

@ -1,10 +1,8 @@
package techreborn.compat.jei.implosionCompressor;
import javax.annotation.Nonnull;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
import mezz.jei.api.IGuiHelper;
@ -17,12 +15,11 @@ import mezz.jei.api.recipe.IRecipeCategory;
import mezz.jei.api.recipe.IRecipeWrapper;
import techreborn.client.gui.GuiImplosionCompressor;
import techreborn.compat.jei.RecipeCategoryUids;
import techreborn.compat.jei.RecipeUtil;
public class ImplosionCompressorRecipeCategory implements IRecipeCategory {
private static final int INPUT_SLOT_0 = 0;
private static final int INPUT_SLOT_1 = 1;
private static final int OUTPUT_SLOT_0 = 2;
private static final int OUTPUT_SLOT_1 = 3;
private static final int[] INPUT_SLOTS = {0, 1};
private static final int[] OUTPUT_SLOTS = {2, 3};
private final IDrawable background;
private final IDrawable electricity;
@ -66,25 +63,15 @@ public class ImplosionCompressorRecipeCategory implements IRecipeCategory {
@Override
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IRecipeWrapper recipeWrapper) {
IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks();
guiItemStacks.init(INPUT_SLOT_0, true, 20, 0);
guiItemStacks.init(INPUT_SLOT_1, true, 20, 18);
guiItemStacks.init(OUTPUT_SLOT_0, false, 76, 9);
guiItemStacks.init(OUTPUT_SLOT_1, false, 94, 9);
guiItemStacks.init(INPUT_SLOTS[0], true, 20, 0);
guiItemStacks.init(INPUT_SLOTS[1], true, 20, 18);
guiItemStacks.init(OUTPUT_SLOTS[0], false, 76, 9);
guiItemStacks.init(OUTPUT_SLOTS[1], false, 94, 9);
if (recipeWrapper instanceof ImplosionCompressorRecipeWrapper) {
ImplosionCompressorRecipeWrapper recipe = (ImplosionCompressorRecipeWrapper) recipeWrapper;
List<List<ItemStack>> inputs = recipe.getInputs();
guiItemStacks.set(INPUT_SLOT_0, inputs.get(0));
if (inputs.size() > 1) {
guiItemStacks.set(INPUT_SLOT_1, inputs.get(1));
}
List<ItemStack> outputs = recipe.getOutputs();
guiItemStacks.set(OUTPUT_SLOT_0, outputs.get(0));
if (outputs.size() > 1) {
guiItemStacks.set(OUTPUT_SLOT_1, outputs.get(1));
}
RecipeUtil.setRecipeItems(recipeLayout, recipe, INPUT_SLOTS, OUTPUT_SLOTS, null, null);
}
}
}

View file

@ -1,10 +1,8 @@
package techreborn.compat.jei.industrialElectrolyzer;
import javax.annotation.Nonnull;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
import mezz.jei.api.IGuiHelper;
@ -15,6 +13,7 @@ import mezz.jei.api.recipe.IRecipeCategory;
import mezz.jei.api.recipe.IRecipeWrapper;
import techreborn.client.gui.GuiIndustrialElectrolyzer;
import techreborn.compat.jei.RecipeCategoryUids;
import techreborn.compat.jei.RecipeUtil;
public class IndustrialElectrolyzerRecipeCategory implements IRecipeCategory {
private static final int[] INPUT_SLOTS = {0, 1};
@ -68,19 +67,7 @@ public class IndustrialElectrolyzerRecipeCategory implements IRecipeCategory {
if (recipeWrapper instanceof IndustrialElectrolyzerRecipeWrapper) {
IndustrialElectrolyzerRecipeWrapper recipe = (IndustrialElectrolyzerRecipeWrapper) recipeWrapper;
List<List<ItemStack>> inputs = recipe.getInputs();
for (int i = 0; i < inputs.size() && i < INPUT_SLOTS.length; i++) {
int inputSlot = INPUT_SLOTS[i];
guiItemStacks.set(inputSlot, inputs.get(i));
}
List<ItemStack> outputs = recipe.getOutputs();
for (int i = 0; i < outputs.size() && i < OUTPUT_SLOTS.length; i++) {
int outputSlot = OUTPUT_SLOTS[i];
ItemStack output = outputs.get(i);
guiItemStacks.set(outputSlot, output);
}
RecipeUtil.setRecipeItems(recipeLayout, recipe, INPUT_SLOTS, OUTPUT_SLOTS, null, null);
}
}
}