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

71 lines
2.3 KiB
Java
Raw Normal View History

2020-01-21 21:04:44 +01:00
package de.ellpeck.naturesaura.compat.jei;
2018-11-21 01:05:50 +01:00
2020-01-23 20:57:56 +01:00
import com.google.common.collect.ImmutableList;
2018-11-21 01:05:50 +01:00
import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.api.recipes.OfferingRecipe;
2020-01-23 20:57:56 +01:00
import mezz.jei.api.constants.VanillaTypes;
2018-11-21 01:05:50 +01: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-11-21 01:05:50 +01:00
import mezz.jei.api.ingredients.IIngredients;
2020-01-21 21:04:44 +01:00
import mezz.jei.api.recipe.category.IRecipeCategory;
2018-11-21 01:05:50 +01:00
import net.minecraft.client.resources.I18n;
2020-01-23 20:57:56 +01:00
import net.minecraft.item.ItemStack;
2018-11-21 01:05:50 +01:00
import net.minecraft.util.ResourceLocation;
import java.util.Arrays;
2020-01-21 21:04:44 +01:00
public class OfferingCategory implements IRecipeCategory<OfferingRecipe> {
2018-11-21 01:05:50 +01:00
private final IDrawable background;
public OfferingCategory(IGuiHelper helper) {
this.background = helper.createDrawable(new ResourceLocation(NaturesAura.MOD_ID, "textures/gui/jei/offering.png"), 0, 0, 87, 36);
}
@Override
2020-01-21 21:04:44 +01:00
public ResourceLocation getUid() {
2018-11-21 01:05:50 +01:00
return JEINaturesAuraPlugin.OFFERING;
}
@Override
2020-01-21 21:04:44 +01:00
public Class<? extends OfferingRecipe> getRecipeClass() {
return OfferingRecipe.class;
2018-11-21 01:05:50 +01:00
}
@Override
2020-01-21 21:04:44 +01:00
public String getTitle() {
return I18n.format("container." + JEINaturesAuraPlugin.OFFERING + ".name");
2018-11-21 01:05:50 +01: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(OfferingRecipe offeringRecipe, IIngredients iIngredients) {
2020-01-23 20:57:56 +01:00
iIngredients.setInputs(VanillaTypes.ITEM, ImmutableList.<ItemStack>builder()
.add(offeringRecipe.input.getMatchingStacks())
.add(offeringRecipe.startItem.getMatchingStacks()).build());
iIngredients.setOutput(VanillaTypes.ITEM, offeringRecipe.output);
2020-01-21 21:04:44 +01:00
}
@Override
public void setRecipe(IRecipeLayout recipeLayout, OfferingRecipe recipe, IIngredients ingredients) {
2018-11-21 01:05:50 +01:00
IGuiItemStackGroup group = recipeLayout.getItemStacks();
group.init(0, true, 0, 14);
group.set(0, Arrays.asList(recipe.input.getMatchingStacks()));
group.init(1, false, 65, 14);
group.set(1, recipe.output);
group.init(2, true, 27, 0);
group.set(2, Arrays.asList(recipe.startItem.getMatchingStacks()));
}
}