NaturesAura/src/main/java/de/ellpeck/naturesaura/compat/jei/AltarCategory.java

83 lines
2.9 KiB
Java
Raw Normal View History

2020-01-21 21:04:44 +01:00
package de.ellpeck.naturesaura.compat.jei;
2018-10-18 18:00:21 +02:00
2020-01-23 20:57:56 +01:00
import com.google.common.collect.ImmutableList;
2018-10-18 18:00:21 +02:00
import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.blocks.ModBlocks;
2021-01-14 23:15:02 +01:00
import de.ellpeck.naturesaura.recipes.AltarRecipe;
2020-01-23 20:57:56 +01:00
import mezz.jei.api.constants.VanillaTypes;
2018-10-18 18:00:21 +02:00
import mezz.jei.api.gui.IRecipeLayout;
2020-01-21 21:04:44 +01:00
import mezz.jei.api.gui.drawable.IDrawable;
import mezz.jei.api.gui.ingredient.IGuiItemStackGroup;
import mezz.jei.api.helpers.IGuiHelper;
2018-10-18 18:00:21 +02:00
import mezz.jei.api.ingredients.IIngredients;
2020-01-21 21:04:44 +01:00
import mezz.jei.api.recipe.category.IRecipeCategory;
2018-10-18 18:00:21 +02:00
import net.minecraft.client.resources.I18n;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
2018-10-18 18:00:21 +02:00
import net.minecraft.util.ResourceLocation;
import java.util.Arrays;
import java.util.Collections;
2020-01-21 21:04:44 +01:00
public class AltarCategory implements IRecipeCategory<AltarRecipe> {
2018-10-18 18:00:21 +02:00
private final IDrawable background;
private final ItemStack altar = new ItemStack(ModBlocks.NATURE_ALTAR);
public AltarCategory(IGuiHelper helper) {
2020-02-25 22:57:10 +01:00
this.background = helper.createDrawable(new ResourceLocation(NaturesAura.MOD_ID, "textures/gui/jei/altar.png"), 0, 0, 103, 57);
2018-10-18 18:00:21 +02:00
}
@Override
2020-01-21 21:04:44 +01:00
public ResourceLocation getUid() {
2018-10-18 18:00:21 +02:00
return JEINaturesAuraPlugin.ALTAR;
}
@Override
2020-01-21 21:04:44 +01:00
public Class<? extends AltarRecipe> getRecipeClass() {
return AltarRecipe.class;
2018-10-18 18:00:21 +02:00
}
@Override
2020-01-21 21:04:44 +01:00
public String getTitle() {
return I18n.format("container." + JEINaturesAuraPlugin.ALTAR + ".name");
2018-10-18 18:00:21 +02:00
}
@Override
public IDrawable getBackground() {
return this.background;
}
@Override
2020-01-21 21:04:44 +01:00
public IDrawable getIcon() {
return null;
}
@Override
public void setIngredients(AltarRecipe altarRecipe, IIngredients iIngredients) {
2020-01-23 20:57:56 +01:00
ImmutableList.Builder<ItemStack> builder = ImmutableList.builder();
builder.add(altarRecipe.input.getMatchingStacks());
if (altarRecipe.catalyst != Ingredient.EMPTY)
builder.add(altarRecipe.catalyst.getMatchingStacks());
2020-02-25 22:57:10 +01:00
if (altarRecipe.requiredType != null)
builder.add(altarRecipe.getDimensionBottle());
2020-01-23 20:57:56 +01:00
iIngredients.setInputs(VanillaTypes.ITEM, builder.build());
iIngredients.setOutput(VanillaTypes.ITEM, altarRecipe.output);
2020-01-21 21:04:44 +01:00
}
@Override
public void setRecipe(IRecipeLayout iRecipeLayout, AltarRecipe recipe, IIngredients iIngredients) {
IGuiItemStackGroup group = iRecipeLayout.getItemStacks();
2018-10-18 18:00:21 +02:00
group.init(0, true, 0, 18);
group.set(0, Arrays.asList(recipe.input.getMatchingStacks()));
2020-02-25 22:57:10 +01:00
group.init(1, false, 80, 18);
2018-10-18 18:00:21 +02:00
group.set(1, recipe.output);
2018-10-31 01:17:58 +01:00
group.init(2, true, 26, 18);
group.set(2, recipe.catalyst == Ingredient.EMPTY ?
Collections.singletonList(this.altar) : Arrays.asList(recipe.catalyst.getMatchingStacks()));
2020-02-25 22:57:10 +01:00
group.init(3, true, 51, 18);
if (recipe.requiredType != null)
group.set(3, recipe.getDimensionBottle());
2018-10-18 18:00:21 +02:00
}
}