TechReborn/1.11/jei/rollingMachine/RollingMachineRecipeCategory.java

101 lines
2.9 KiB
Java
Raw Normal View History

2016-03-13 17:08:30 +01:00
package techreborn.compat.jei.rollingMachine;
import mezz.jei.api.IGuiHelper;
2016-10-08 21:46:16 +02:00
import mezz.jei.api.gui.*;
2016-09-27 18:03:57 +02:00
import mezz.jei.api.ingredients.IIngredients;
2016-03-13 17:08:30 +01:00
import mezz.jei.api.recipe.BlankRecipeCategory;
import net.minecraft.client.Minecraft;
2016-09-27 18:03:57 +02:00
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.translation.I18n;
2016-03-13 17:08:30 +01:00
import techreborn.client.gui.GuiRollingMachine;
import techreborn.compat.jei.RecipeCategoryUids;
2016-10-08 21:46:16 +02:00
import javax.annotation.Nonnull;
public class RollingMachineRecipeCategory extends BlankRecipeCategory<RollingMachineRecipeWrapper> {
2016-03-25 10:47:34 +01:00
private static final int[] INPUT_SLOTS = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
private static final int[] OUTPUT_SLOTS = { 10 };
2016-03-13 17:08:30 +01:00
private final IDrawable background;
private final IDrawableAnimated progress;
private final ICraftingGridHelper craftingGridHelper;
private final String title;
2016-10-08 21:46:16 +02:00
public RollingMachineRecipeCategory(IGuiHelper guiHelper) {
2016-03-13 17:08:30 +01:00
background = guiHelper.createDrawable(GuiRollingMachine.texture, 29, 16, 116, 54);
title = I18n.translateToLocal("tile.techreborn.rollingmachine.name");
2016-03-13 17:08:30 +01:00
IDrawableStatic progressStatic = guiHelper.createDrawable(GuiRollingMachine.texture, 176, 14, 20, 18);
progress = guiHelper.createAnimatedDrawable(progressStatic, 250, IDrawableAnimated.StartDirection.LEFT, false);
craftingGridHelper = guiHelper.createCraftingGridHelper(INPUT_SLOTS[0], OUTPUT_SLOTS[0]);
}
@Nonnull
@Override
2016-10-08 21:46:16 +02:00
public String getUid() {
2016-03-13 17:08:30 +01:00
return RecipeCategoryUids.ROLLING_MACHINE;
}
@Nonnull
@Override
2016-10-08 21:46:16 +02:00
public String getTitle() {
2016-03-13 17:08:30 +01:00
return title;
}
@Nonnull
@Override
2016-10-08 21:46:16 +02:00
public IDrawable getBackground() {
2016-03-13 17:08:30 +01:00
return background;
}
@Override
2016-10-08 21:46:16 +02:00
public void drawAnimations(
@Nonnull
Minecraft minecraft) {
2016-03-13 17:08:30 +01:00
progress.draw(minecraft, 62, 18);
}
@Override
2016-10-08 21:46:16 +02:00
public void setRecipe(
@Nonnull
IRecipeLayout recipeLayout,
@Nonnull
RollingMachineRecipeWrapper recipeWrapper) {
2016-03-13 17:08:30 +01:00
IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks();
2016-10-08 21:46:16 +02:00
for (int l = 0; l < 3; l++) {
for (int k1 = 0; k1 < 3; k1++) {
2016-03-13 17:08:30 +01:00
int i = k1 + l * 3;
guiItemStacks.init(INPUT_SLOTS[i], true, k1 * 18, l * 18);
}
}
guiItemStacks.init(OUTPUT_SLOTS[0], false, 94, 18);
2016-09-27 18:03:57 +02:00
craftingGridHelper.setInput(guiItemStacks, recipeWrapper.getInputs());
craftingGridHelper.setOutput(guiItemStacks, recipeWrapper.getOutputs());
}
@Override
2016-10-08 21:46:16 +02:00
public void setRecipe(
@Nonnull
IRecipeLayout recipeLayout,
@Nonnull
RollingMachineRecipeWrapper recipeWrapper,
@Nonnull
IIngredients ingredients) {
2016-09-27 18:03:57 +02:00
IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks();
2016-10-08 21:46:16 +02:00
for (int l = 0; l < 3; l++) {
for (int k1 = 0; k1 < 3; k1++) {
2016-09-27 18:03:57 +02:00
int i = k1 + l * 3;
guiItemStacks.init(INPUT_SLOTS[i], true, k1 * 18, l * 18);
}
2016-03-13 17:08:30 +01:00
}
2016-09-27 18:03:57 +02:00
guiItemStacks.init(OUTPUT_SLOTS[0], false, 94, 18);
craftingGridHelper.setInputStacks(guiItemStacks, ingredients.getInputs(ItemStack.class));
craftingGridHelper.setOutput(guiItemStacks, ingredients.getOutputs(ItemStack.class));
2016-03-13 17:08:30 +01:00
}
}