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

72 lines
2.4 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;
2020-04-29 16:38:50 +02:00
import de.ellpeck.naturesaura.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;
2021-12-19 17:14:56 +01:00
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
2018-11-21 01:05:50 +01:00
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
2021-12-19 17:14:56 +01:00
public Component getTitle() {
return new TranslatableComponent("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()
2021-12-19 17:14:56 +01:00
.add(offeringRecipe.input.getItems())
.add(offeringRecipe.startItem.getItems()).build());
2020-01-23 20:57:56 +01:00
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);
2021-12-19 17:14:56 +01:00
group.set(0, Arrays.asList(recipe.input.getItems()));
2018-11-21 01:05:50 +01:00
group.init(1, false, 65, 14);
group.set(1, recipe.output);
group.init(2, true, 27, 0);
2021-12-19 17:14:56 +01:00
group.set(2, Arrays.asList(recipe.startItem.getItems()));
2018-11-21 01:05:50 +01:00
}
}