ActuallyAdditions/src/main/java/de/ellpeck/actuallyadditions/mod/jei/reconstructor/ReconstructorRecipeWrapper.java

99 lines
3.5 KiB
Java

/*
* This file ("ReconstructorRecipeWrapper.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015-2017 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.jei.reconstructor;
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
import de.ellpeck.actuallyadditions.api.recipe.LensConversionRecipe;
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
import de.ellpeck.actuallyadditions.mod.booklet.misc.BookletUtils;
import de.ellpeck.actuallyadditions.mod.jei.RecipeWrapperWithButton;
import de.ellpeck.actuallyadditions.mod.recipe.EnchBookConversion;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.ingredients.VanillaTypes;
import mezz.jei.api.recipe.IRecipeWrapperFactory;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.I18n;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.ListNBT;
import net.minecraft.nbt.NBTTagString;
import java.util.Arrays;
public class ReconstructorRecipeWrapper extends RecipeWrapperWithButton {
public static final IRecipeWrapperFactory<LensConversionRecipe> FACTORY = (recipe) -> {
if (recipe instanceof EnchBookConversion) {
return new EnchBookWrapper((EnchBookConversion) recipe);
}
return new ReconstructorRecipeWrapper(recipe);
};
public final LensConversionRecipe theRecipe;
public ReconstructorRecipeWrapper(LensConversionRecipe recipe) {
this.theRecipe = recipe;
}
@Override
public void getIngredients(IIngredients ingredients) {
ingredients.setInputs(VanillaTypes.ITEM, Arrays.asList(this.theRecipe.getInput().getMatchingStacks()));
ingredients.setOutput(VanillaTypes.ITEM, this.theRecipe.getOutput());
}
@Override
public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) {
minecraft.fontRenderer.drawString(this.theRecipe.getEnergyUsed() + " " + I18n.format("actuallyadditions.cf"), 55, 0, 0xFFFFFF, true);
super.drawInfo(minecraft, recipeWidth, recipeHeight, mouseX, mouseY);
}
@Override
public int getButtonX() {
return 3;
}
@Override
public int getButtonY() {
return 40;
}
@Override
public IBookletPage getPage() {
return BookletUtils.findFirstPageForStack(new ItemStack(ActuallyBlocks.blockAtomicReconstructor));
}
public static class EnchBookWrapper extends ReconstructorRecipeWrapper {
private static final ItemStack BOOK = new ItemStack(Items.ENCHANTED_BOOK);
private static final ItemStack OUT = new ItemStack(Items.ENCHANTED_BOOK);
static {
OUT.setStackDisplayName("Split Book");
CompoundNBT t = OUT.getTagCompound().getCompoundTag("display");
ListNBT l = new ListNBT();
l.appendTag(new NBTTagString("Book will be split based on enchantments!"));
t.setTag("Lore", l);
}
public EnchBookWrapper(EnchBookConversion recipe) {
super(recipe);
}
@Override
public void getIngredients(IIngredients ingredients) {
ingredients.setInput(VanillaTypes.ITEM, BOOK);
ingredients.setOutput(VanillaTypes.ITEM, OUT);
}
}
}