2020-09-09 16:48:43 +02:00
|
|
|
package de.ellpeck.actuallyadditions.common.jei.reconstructor;
|
2016-01-17 22:57:32 +01:00
|
|
|
|
2018-06-24 02:44:47 +02:00
|
|
|
import java.util.Arrays;
|
|
|
|
|
2016-11-10 19:50:01 +01:00
|
|
|
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
|
2016-05-14 13:51:18 +02:00
|
|
|
import de.ellpeck.actuallyadditions.api.recipe.LensConversionRecipe;
|
2020-09-09 16:48:43 +02:00
|
|
|
import de.ellpeck.actuallyadditions.common.blocks.InitBlocks;
|
2020-09-09 16:49:01 +02:00
|
|
|
import de.ellpeck.actuallyadditions.booklet.misc.BookletUtils;
|
2020-09-09 16:48:43 +02:00
|
|
|
import de.ellpeck.actuallyadditions.common.jei.RecipeWrapperWithButton;
|
|
|
|
import de.ellpeck.actuallyadditions.common.recipe.EnchBookConversion;
|
2016-10-29 10:47:33 +02:00
|
|
|
import mezz.jei.api.ingredients.IIngredients;
|
2018-12-11 07:18:31 +01:00
|
|
|
import mezz.jei.api.ingredients.VanillaTypes;
|
2017-12-12 07:54:12 +01:00
|
|
|
import mezz.jei.api.recipe.IRecipeWrapperFactory;
|
2016-01-17 22:57:32 +01:00
|
|
|
import net.minecraft.client.Minecraft;
|
2019-02-27 20:51:41 +01:00
|
|
|
import net.minecraft.client.resources.I18n;
|
2017-12-12 07:54:12 +01:00
|
|
|
import net.minecraft.init.Items;
|
2016-01-17 22:57:32 +01:00
|
|
|
import net.minecraft.item.ItemStack;
|
2017-12-12 07:54:12 +01:00
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
|
|
import net.minecraft.nbt.NBTTagList;
|
|
|
|
import net.minecraft.nbt.NBTTagString;
|
2016-01-17 22:57:32 +01:00
|
|
|
|
2018-06-24 02:44:47 +02:00
|
|
|
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);
|
|
|
|
};
|
2016-01-17 22:57:32 +01:00
|
|
|
|
2016-05-19 20:05:12 +02:00
|
|
|
public final LensConversionRecipe theRecipe;
|
2016-01-17 22:57:32 +01:00
|
|
|
|
2018-06-24 02:44:47 +02:00
|
|
|
public ReconstructorRecipeWrapper(LensConversionRecipe recipe) {
|
2016-01-17 22:57:32 +01:00
|
|
|
this.theRecipe = recipe;
|
|
|
|
}
|
|
|
|
|
2016-10-29 10:47:33 +02:00
|
|
|
@Override
|
2018-06-24 02:44:47 +02:00
|
|
|
public void getIngredients(IIngredients ingredients) {
|
2018-12-11 07:18:31 +01:00
|
|
|
ingredients.setInputs(VanillaTypes.ITEM, Arrays.asList(this.theRecipe.getInput().getMatchingStacks()));
|
|
|
|
ingredients.setOutput(VanillaTypes.ITEM, this.theRecipe.getOutput());
|
2016-01-17 22:57:32 +01:00
|
|
|
}
|
|
|
|
|
2016-11-02 20:55:47 +01:00
|
|
|
@Override
|
2018-06-24 02:44:47 +02:00
|
|
|
public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) {
|
2019-05-02 09:10:29 +02:00
|
|
|
minecraft.fontRenderer.drawString(this.theRecipe.getEnergyUsed() + " " + I18n.format("actuallyadditions.cf"), 55, 0, 0xFFFFFF, true);
|
2016-11-02 20:55:47 +01:00
|
|
|
super.drawInfo(minecraft, recipeWidth, recipeHeight, mouseX, mouseY);
|
|
|
|
}
|
|
|
|
|
2016-01-17 22:57:32 +01:00
|
|
|
@Override
|
2018-06-24 02:44:47 +02:00
|
|
|
public int getButtonX() {
|
2016-01-17 22:57:32 +01:00
|
|
|
return 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2018-06-24 02:44:47 +02:00
|
|
|
public int getButtonY() {
|
2016-01-17 22:57:32 +01:00
|
|
|
return 40;
|
|
|
|
}
|
2016-02-01 17:49:55 +01:00
|
|
|
|
|
|
|
@Override
|
2018-06-24 02:44:47 +02:00
|
|
|
public IBookletPage getPage() {
|
2016-11-10 19:50:01 +01:00
|
|
|
return BookletUtils.findFirstPageForStack(new ItemStack(InitBlocks.blockAtomicReconstructor));
|
2016-02-01 17:49:55 +01:00
|
|
|
}
|
2018-06-24 02:44:47 +02:00
|
|
|
|
2017-12-12 07:54:12 +01:00
|
|
|
public static class EnchBookWrapper extends ReconstructorRecipeWrapper {
|
|
|
|
|
2018-06-24 02:44:47 +02:00
|
|
|
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");
|
|
|
|
NBTTagCompound t = OUT.getTagCompound().getCompoundTag("display");
|
|
|
|
NBTTagList l = new NBTTagList();
|
|
|
|
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) {
|
2018-12-11 07:18:31 +01:00
|
|
|
ingredients.setInput(VanillaTypes.ITEM, BOOK);
|
2020-09-09 16:49:01 +02:00
|
|
|
ingredients.setOutput(VanillaTypes.ITEM, OUT);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|